From d0c14d7564ff03a877cbb7bcc2bdd3d27da3cf7a Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 16 Oct 2023 09:32:05 -0400 Subject: [PATCH] Fix NFS detection on the BSDs - on the BSDs, look at the f_fstypename field to determine file system type, as this is the documented way to do that. The sqlite codebase also does so for macOS notably. - removed dead code in the Windows case --- .../seacas/libraries/ioss/src/Ioss_FileInfo.C | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/seacas/libraries/ioss/src/Ioss_FileInfo.C b/packages/seacas/libraries/ioss/src/Ioss_FileInfo.C index a8959a10ef..e8a1dfdc59 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_FileInfo.C +++ b/packages/seacas/libraries/ioss/src/Ioss_FileInfo.C @@ -172,19 +172,16 @@ namespace Ioss { //: Return TRUE if file is on an NFS filesystem... bool FileInfo::is_nfs() const { -#if !defined(__IOSS_WINDOWS__) -#define NFS_FS 0x6969 /* statfs defines that 0x6969 is NFS filesystem */ +#if defined(__IOSS_WINDOWS__) + return false; +#else auto tmp_path = pathname(); if (tmp_path.empty()) { char *current_cwd = getcwd(nullptr, 0); tmp_path = std::string(current_cwd); free(current_cwd); } -#if defined(__IOSS_WINDOWS__) - char *path = _fullpath(nullptr, tmp_path.c_str(), _MAX_PATH); -#else char *path = ::realpath(tmp_path.c_str(), nullptr); -#endif if (path != nullptr) { struct statfs stat_fs; @@ -196,10 +193,15 @@ namespace Ioss { IOSS_ERROR(errmsg); } free(path); - return (stat_fs.f_type == NFS_FS); + +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) + return (0 == ::strcmp("nfs", stat_fs.f_fstypename)); +#else + /* linux statfs defines that 0x6969 is NFS filesystem */ + return (stat_fs.f_type == 0x6969); +#endif } #endif - return false; } //: Time of last data modification. See 'man stat(2)'