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 <[EMAIL PROTECTED]>

---

 tests/testutils.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff -upNr libhugetlbfs-1.3-pre1.orig/tests/testutils.c 
libhugetlbfs-1.3-pre1/tests/testutils.c
--- libhugetlbfs-1.3-pre1.orig/tests/testutils.c        2008-04-11 
22:38:50.000000000 -0500
+++ libhugetlbfs-1.3-pre1/tests/testutils.c     2008-04-11 22:42:33.000000000 
-0500
@@ -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");

Attachment: signature.asc
Description: This is a digitally signed message part

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to