Add a function to compare the huge page size displayed in /proc/meminfo (which is the kernel's default size) with the size used by a given mount point. This will be used by the quota test to determine if a special mount option must be used.
Signed-off-by: Adam Litke <[EMAIL PROTECTED]> --- tests/hugetests.h | 2 ++ tests/testutils.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 0 deletions(-) diff --git a/tests/hugetests.h b/tests/hugetests.h index f43cfd2..0afc00d 100644 --- a/tests/hugetests.h +++ b/tests/hugetests.h @@ -145,6 +145,8 @@ long get_pool_counter(unsigned int counter, unsigned long pagesize_kb); int set_pool_counter(unsigned int counter, unsigned long val, unsigned long pagesize_kb); +int using_system_hpage_size(const char *mount); + /* WARNING: Racy -- use for test cases only! */ int kernel_has_private_reservations(int fd); diff --git a/tests/testutils.c b/tests/testutils.c index 9aa6c3d..76ce860 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -467,3 +467,27 @@ int kernel_has_private_reservations(int fd) } return -1; } + +int using_system_hpage_size(const char *mount) +{ + struct statfs64 sb; + int err; + long meminfo_size, mount_size; + + if (!mount) + FAIL("using_system_hpage_size: hugetlbfs is not mounted\n"); + + err = statfs64(mount, &sb); + if (err) + FAIL("statfs64: %s\n", strerror(errno)); + + meminfo_size = file_read_ulong("/proc/meminfo", "Hugepagesize:"); + if (meminfo_size < 0) + FAIL("using_system_hpage_size: Failed to read /proc/meminfo\n"); + + mount_size = sb.f_bsize / 1024; /* Compare to meminfo in kB */ + if (mount_size == meminfo_size) + return 1; + else + return 0; +} ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Libhugetlbfs-devel mailing list Libhugetlbfs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel