Skip to content

Commit 4ab6c8a

Browse files
committed
mpool/hugepage: use statvfs() instead of statfs() when needed.
Thanks Siegmar Gross for the report.
1 parent 4135cdf commit 4ab6c8a

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

opal/mca/mpool/hugepage/mpool_hugepage_component.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* Copyright (c) 2012-2016 Los Alamos National Security, LLC. All rights
1616
* reserved.
1717
* Copyright (c) 2016 Intel, Inc. All rights reserved.
18+
* Copyright (c) 2016 Research Organization for Information Science
19+
* and Technology (RIST). All rights reserved.
1820
*
1921
* $COPYRIGHT$
2022
*
@@ -56,6 +58,17 @@
5658

5759
#include <fcntl.h>
5860

61+
/*
62+
* Note that some OS's (e.g., NetBSD and Solaris) have statfs(), but
63+
* no struct statfs (!). So check to make sure we have struct statfs
64+
* before allowing the use of statfs().
65+
*/
66+
#if defined(HAVE_STATFS) && (defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) || \
67+
defined(HAVE_STRUCT_STATFS_F_TYPE))
68+
#define USE_STATFS 1
69+
#endif
70+
71+
5972
/*
6073
* Local functions
6174
*/
@@ -220,12 +233,15 @@ static void mca_mpool_hugepage_find_hugepages (void) {
220233
} while (tok);
221234

222235
if (!tok) {
223-
#if HAVE_STATFS
236+
#if defined(USE_STATFS)
224237
struct statfs info;
225238

226239
statfs (path, &info);
227-
page_size = info.f_bsize;
240+
#elif defined(HAVE_STATVFS)
241+
struct statvfs info;
242+
statvfs (path, &info);
228243
#endif
244+
page_size = info.f_bsize;
229245
} else {
230246
(void) sscanf (tok, "pagesize=%lu", &page_size);
231247
}

0 commit comments

Comments
 (0)