Skip to content

Commit 19b84f3

Browse files
author
bellard
committed
added setgroups and getgroups syscalls
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@131 c046a42c-6fe2-441c-8c8c-71466251a162
1 parent 08fc608 commit 19b84f3

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

linux-user/syscall.c

+28-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#include <linux/hdreg.h>
5959
#include <linux/soundcard.h>
6060
#include <linux/dirent.h>
61+
#include <linux/kd.h>
6162

6263
#include "qemu.h"
6364

@@ -117,6 +118,7 @@ extern int setresuid(uid_t, uid_t, uid_t);
117118
extern int getresuid(uid_t *, uid_t *, uid_t *);
118119
extern int setresgid(gid_t, gid_t, gid_t);
119120
extern int getresgid(gid_t *, gid_t *, gid_t *);
121+
extern int setgroups(int, gid_t *);
120122

121123
static inline long get_errno(long ret)
122124
{
@@ -1722,9 +1724,33 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
17221724
}
17231725
break;
17241726
case TARGET_NR_getgroups:
1725-
goto unimplemented;
1727+
{
1728+
int gidsetsize = arg1;
1729+
uint16_t *target_grouplist = (void *)arg2;
1730+
gid_t *grouplist;
1731+
int i;
1732+
1733+
grouplist = alloca(gidsetsize * sizeof(gid_t));
1734+
ret = get_errno(getgroups(gidsetsize, grouplist));
1735+
if (!is_error(ret)) {
1736+
for(i = 0;i < gidsetsize; i++)
1737+
target_grouplist[i] = tswap16(grouplist[i]);
1738+
}
1739+
}
1740+
break;
17261741
case TARGET_NR_setgroups:
1727-
goto unimplemented;
1742+
{
1743+
int gidsetsize = arg1;
1744+
uint16_t *target_grouplist = (void *)arg2;
1745+
gid_t *grouplist;
1746+
int i;
1747+
1748+
grouplist = alloca(gidsetsize * sizeof(gid_t));
1749+
for(i = 0;i < gidsetsize; i++)
1750+
grouplist[i] = tswap16(target_grouplist[i]);
1751+
ret = get_errno(setgroups(gidsetsize, grouplist));
1752+
}
1753+
break;
17281754
case TARGET_NR_select:
17291755
goto unimplemented;
17301756
case TARGET_NR_symlink:

0 commit comments

Comments
 (0)