Skip to contentSkip to conversation

{get,set}groups32 syscalls

Qemu-devel Paul Brook 1 participant 1 message Jan 31, 2005

lore
Share & tools
lore

Paul Brook

author
#0 lore raw

The attached patch implements the getgroups32 and setgroups32 syscalls.

Paul

Index: linux-user/syscall.c
===================================================================
RCS file: /cvsroot/qemu/qemu/linux-user/syscall.c,v retrieving revision 1.55

syscall.c +26 -2
diff -u -p -r1.55 syscall.c
@@ -2916,9 +2916,33 @@ long do_syscall(void *cpu_env, int num, 
         ret = get_errno(setregid(arg1, arg2));
         break;
     case TARGET_NR_getgroups32:
-        goto unimplemented;
+        {
+            int gidsetsize = arg1;
+            uint32_t *target_grouplist = (void *)arg2;
+            gid_t *grouplist;
+            int i;
+
+            grouplist = alloca(gidsetsize * sizeof(gid_t));
+            ret = get_errno(getgroups(gidsetsize, grouplist));
+            if (!is_error(ret)) {
+                for(i = 0;i < gidsetsize; i++)
+                    target_grouplist[i] = tswap32(grouplist[i]);
+            }
+        }
+        break;
     case TARGET_NR_setgroups32:
-        goto unimplemented;
+        {
+            int gidsetsize = arg1;
+            uint32_t *target_grouplist = (void *)arg2;
+            gid_t *grouplist;
+            int i;
+
+            grouplist = alloca(gidsetsize * sizeof(gid_t));
+            for(i = 0;i < gidsetsize; i++)
+                grouplist[i] = tswap32(target_grouplist[i]);
+            ret = get_errno(setgroups(gidsetsize, grouplist));
+        }
+        break;
     case TARGET_NR_fchown32:
         ret = get_errno(fchown(arg1, arg2, arg3));
         break;