Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NFS detection on the BSDs #411

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer that the #define NFS_FS be used here. Many static analyzers complain about magic numbers. I realize that the define would be used in exactly one place and that there are many other magic numbers throughout the code base, but ...

#endif
}
#endif
return false;
}

//: Time of last data modification. See 'man stat(2)'
Expand Down
Loading