Skip to content

Commit

Permalink
Merge pull request #411 from seanm/statfs-improvements
Browse files Browse the repository at this point in the history
Fix NFS detection on the BSDs
  • Loading branch information
gsjaardema authored Oct 16, 2023
2 parents e17fcee + d0c14d7 commit 0369822
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/seacas/libraries/ioss/src/Ioss_FileInfo.C
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)'
Expand Down

0 comments on commit 0369822

Please sign in to comment.