Revision 0c866a7e linux-user/syscall.c
b/linux-user/syscall.c | ||
---|---|---|
328 | 328 |
return (fchmodat(dirfd, pathname, mode, 0)); |
329 | 329 |
} |
330 | 330 |
#endif |
331 |
#if defined(TARGET_NR_fchownat) && defined(USE_UID16)
|
|
331 |
#if defined(TARGET_NR_fchownat) |
|
332 | 332 |
static int sys_fchownat(int dirfd, const char *pathname, uid_t owner, |
333 | 333 |
gid_t group, int flags) |
334 | 334 |
{ |
... | ... | |
437 | 437 |
#if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat) |
438 | 438 |
_syscall3(int,sys_fchmodat,int,dirfd,const char *,pathname, mode_t,mode) |
439 | 439 |
#endif |
440 |
#if defined(TARGET_NR_fchownat) && defined(__NR_fchownat) && defined(USE_UID16)
|
|
440 |
#if defined(TARGET_NR_fchownat) && defined(__NR_fchownat) |
|
441 | 441 |
_syscall5(int,sys_fchownat,int,dirfd,const char *,pathname, |
442 | 442 |
uid_t,owner,gid_t,group,int,flags) |
443 | 443 |
#endif |
... | ... | |
4164 | 4164 |
else |
4165 | 4165 |
return gid; |
4166 | 4166 |
} |
4167 |
|
|
4167 |
static inline int tswapid(int id) |
|
4168 |
{ |
|
4169 |
return tswap16(id); |
|
4170 |
} |
|
4171 |
#else /* !USE_UID16 */ |
|
4172 |
static inline int high2lowuid(int uid) |
|
4173 |
{ |
|
4174 |
return uid; |
|
4175 |
} |
|
4176 |
static inline int high2lowgid(int gid) |
|
4177 |
{ |
|
4178 |
return gid; |
|
4179 |
} |
|
4180 |
static inline int low2highuid(int uid) |
|
4181 |
{ |
|
4182 |
return uid; |
|
4183 |
} |
|
4184 |
static inline int low2highgid(int gid) |
|
4185 |
{ |
|
4186 |
return gid; |
|
4187 |
} |
|
4188 |
static inline int tswapid(int id) |
|
4189 |
{ |
|
4190 |
return tswap32(id); |
|
4191 |
} |
|
4168 | 4192 |
#endif /* USE_UID16 */ |
4169 | 4193 |
|
4170 | 4194 |
void syscall_init(void) |
... | ... | |
6765 | 6789 |
ret = host_to_target_stat64(cpu_env, arg3, &st); |
6766 | 6790 |
break; |
6767 | 6791 |
#endif |
6768 |
#ifdef USE_UID16 |
|
6769 | 6792 |
case TARGET_NR_lchown: |
6770 | 6793 |
if (!(p = lock_user_string(arg1))) |
6771 | 6794 |
goto efault; |
6772 | 6795 |
ret = get_errno(lchown(p, low2highuid(arg2), low2highgid(arg3))); |
6773 | 6796 |
unlock_user(p, arg1, 0); |
6774 | 6797 |
break; |
6798 |
#ifdef TARGET_NR_getuid |
|
6775 | 6799 |
case TARGET_NR_getuid: |
6776 | 6800 |
ret = get_errno(high2lowuid(getuid())); |
6777 | 6801 |
break; |
6802 |
#endif |
|
6803 |
#ifdef TARGET_NR_getgid |
|
6778 | 6804 |
case TARGET_NR_getgid: |
6779 | 6805 |
ret = get_errno(high2lowgid(getgid())); |
6780 | 6806 |
break; |
6807 |
#endif |
|
6808 |
#ifdef TARGET_NR_geteuid |
|
6781 | 6809 |
case TARGET_NR_geteuid: |
6782 | 6810 |
ret = get_errno(high2lowuid(geteuid())); |
6783 | 6811 |
break; |
6812 |
#endif |
|
6813 |
#ifdef TARGET_NR_getegid |
|
6784 | 6814 |
case TARGET_NR_getegid: |
6785 | 6815 |
ret = get_errno(high2lowgid(getegid())); |
6786 | 6816 |
break; |
6817 |
#endif |
|
6787 | 6818 |
case TARGET_NR_setreuid: |
6788 | 6819 |
ret = get_errno(setreuid(low2highuid(arg1), low2highuid(arg2))); |
6789 | 6820 |
break; |
... | ... | |
6793 | 6824 |
case TARGET_NR_getgroups: |
6794 | 6825 |
{ |
6795 | 6826 |
int gidsetsize = arg1; |
6796 |
uint16_t *target_grouplist;
|
|
6827 |
target_id *target_grouplist;
|
|
6797 | 6828 |
gid_t *grouplist; |
6798 | 6829 |
int i; |
6799 | 6830 |
|
... | ... | |
6806 | 6837 |
if (!target_grouplist) |
6807 | 6838 |
goto efault; |
6808 | 6839 |
for(i = 0;i < ret; i++) |
6809 |
target_grouplist[i] = tswap16(grouplist[i]);
|
|
6840 |
target_grouplist[i] = tswapid(high2lowgid(grouplist[i]));
|
|
6810 | 6841 |
unlock_user(target_grouplist, arg2, gidsetsize * 2); |
6811 | 6842 |
} |
6812 | 6843 |
} |
... | ... | |
6814 | 6845 |
case TARGET_NR_setgroups: |
6815 | 6846 |
{ |
6816 | 6847 |
int gidsetsize = arg1; |
6817 |
uint16_t *target_grouplist;
|
|
6848 |
target_id *target_grouplist;
|
|
6818 | 6849 |
gid_t *grouplist; |
6819 | 6850 |
int i; |
6820 | 6851 |
|
... | ... | |
6825 | 6856 |
goto fail; |
6826 | 6857 |
} |
6827 | 6858 |
for(i = 0;i < gidsetsize; i++) |
6828 |
grouplist[i] = tswap16(target_grouplist[i]);
|
|
6859 |
grouplist[i] = low2highgid(tswapid(target_grouplist[i]));
|
|
6829 | 6860 |
unlock_user(target_grouplist, arg2, 0); |
6830 | 6861 |
ret = get_errno(setgroups(gidsetsize, grouplist)); |
6831 | 6862 |
} |
... | ... | |
6901 | 6932 |
case TARGET_NR_setfsgid: |
6902 | 6933 |
ret = get_errno(setfsgid(arg1)); |
6903 | 6934 |
break; |
6904 |
#endif /* USE_UID16 */ |
|
6905 | 6935 |
|
6906 | 6936 |
#ifdef TARGET_NR_lchown32 |
6907 | 6937 |
case TARGET_NR_lchown32: |
Also available in: Unified diff