diff options
author | Eric B Munson <ebmunson@us.ibm.com> | 2008-04-11 21:24:01 -0700 |
---|---|---|
committer | Nishanth Aravamudan <nacc@us.ibm.com> | 2008-04-15 09:24:04 -0700 |
commit | d641b32a3341bb62a0e6bd2b7fbb34962ca22bf7 (patch) | |
tree | 4f5b201a0ee5a7cdeca7d0c153902b06ffcb43d2 /tests/testutils.c | |
parent | fcbcd8d6681e5b62e526f980e20ad364d77d8744 (diff) | |
download | libhugetlbfs-d641b32a3341bb62a0e6bd2b7fbb34962ca22bf7.tar.gz |
Update check_hugetlb_shm_group to properly read gid from /proc
check_hugetlb_shm_get tries to read the value from
/proc/vm/sys/hugetlb_shm_group and use that value in a comparison
against users gid. This test will fail a majority of the time. This
patch ensures that the correct value is used in the comparison by
converting the value read from the file from an ascii string to an
integer value.
Signed-off-by: Eric Munson <ebmunson@us.ibm.com>
Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Diffstat (limited to 'tests/testutils.c')
-rw-r--r-- | tests/testutils.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/testutils.c b/tests/testutils.c index 5495785..79fb2c2 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -61,6 +61,7 @@ void check_hugetlb_shm_group(void) { int fd; ssize_t ret; + char gid_buffer[64] = {0}; gid_t hugetlb_shm_group; gid_t gid = getgid(); uid_t uid = getuid(); @@ -72,9 +73,10 @@ void check_hugetlb_shm_group(void) fd = open("/proc/sys/vm/hugetlb_shm_group", O_RDONLY); if (fd < 0) ERROR("Unable to open /proc/sys/vm/hugetlb_shm_group"); - ret = read(fd, &hugetlb_shm_group, sizeof(hugetlb_shm_group)); + ret = read(fd, &gid_buffer, sizeof(gid_buffer)); if (ret < 0) ERROR("Unable to read /proc/sys/vm/hugetlb_shm_group"); + hugetlb_shm_group = atoi(gid_buffer); close(fd); if (hugetlb_shm_group != gid) CONFIG("Do not have permission to use SHM_HUGETLB"); |