Lines 230-236
static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \
Link Here
|
230 |
return syscall(__NR_##name, arg1, arg2, arg3, arg4, arg5, arg6); \ |
230 |
return syscall(__NR_##name, arg1, arg2, arg3, arg4, arg5, arg6); \ |
231 |
} |
231 |
} |
232 |
|
232 |
|
233 |
|
|
|
234 |
#define __NR_sys_uname __NR_uname |
233 |
#define __NR_sys_uname __NR_uname |
235 |
#define __NR_sys_getcwd1 __NR_getcwd |
234 |
#define __NR_sys_getcwd1 __NR_getcwd |
236 |
#define __NR_sys_getdents __NR_getdents |
235 |
#define __NR_sys_getdents __NR_getdents |
Lines 245-250
static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \
Link Here
|
245 |
#define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch |
244 |
#define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch |
246 |
#define __NR_sys_statx __NR_statx |
245 |
#define __NR_sys_statx __NR_statx |
247 |
|
246 |
|
|
|
247 |
#define __X32_SYSCALL_BIT 0x40000000UL |
248 |
#define __NR_getdents64_x32 (__X32_SYSCALL_BIT + 217) |
249 |
#define __NR_sys_getdents64_x32 __NR_getdents64_x32 |
250 |
|
248 |
#if defined(__alpha__) || defined(__x86_64__) || defined(__s390x__) |
251 |
#if defined(__alpha__) || defined(__x86_64__) || defined(__s390x__) |
249 |
#define __NR__llseek __NR_lseek |
252 |
#define __NR__llseek __NR_lseek |
250 |
#endif |
253 |
#endif |
Lines 275-280
_syscall3(int, sys_getdents, uint, fd, struct linux_dirent *, dirp, uint, count)
Link Here
|
275 |
(defined(TARGET_NR_getdents64) && defined(__NR_getdents64)) |
278 |
(defined(TARGET_NR_getdents64) && defined(__NR_getdents64)) |
276 |
_syscall3(int, sys_getdents64, uint, fd, struct linux_dirent64 *, dirp, uint, count); |
279 |
_syscall3(int, sys_getdents64, uint, fd, struct linux_dirent64 *, dirp, uint, count); |
277 |
#endif |
280 |
#endif |
|
|
281 |
#if (defined(TARGET_NR_getdents) && \ |
282 |
!defined(EMULATE_GETDENTS_WITH_GETDENTS)) || \ |
283 |
(defined(TARGET_NR_getdents64_x32) && defined(__NR_getdents64_x32)) |
284 |
_syscall3(int, sys_getdents64_x32, uint, fd, struct linux_dirent64 *, dirp, uint, count); |
285 |
#endif |
278 |
#if defined(TARGET_NR__llseek) && defined(__NR_llseek) |
286 |
#if defined(TARGET_NR__llseek) && defined(__NR_llseek) |
279 |
_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, |
287 |
_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, |
280 |
loff_t *, res, uint, wh); |
288 |
loff_t *, res, uint, wh); |
Lines 1062-1068
static inline rlim_t target_to_host_rlim(abi_ulong target_rlim)
Link Here
|
1062 |
{ |
1070 |
{ |
1063 |
abi_ulong target_rlim_swap; |
1071 |
abi_ulong target_rlim_swap; |
1064 |
rlim_t result; |
1072 |
rlim_t result; |
1065 |
|
1073 |
|
1066 |
target_rlim_swap = tswapal(target_rlim); |
1074 |
target_rlim_swap = tswapal(target_rlim); |
1067 |
if (target_rlim_swap == TARGET_RLIM_INFINITY) |
1075 |
if (target_rlim_swap == TARGET_RLIM_INFINITY) |
1068 |
return RLIM_INFINITY; |
1076 |
return RLIM_INFINITY; |
Lines 1070-1076
static inline rlim_t target_to_host_rlim(abi_ulong target_rlim)
Link Here
|
1070 |
result = target_rlim_swap; |
1078 |
result = target_rlim_swap; |
1071 |
if (target_rlim_swap != (rlim_t)result) |
1079 |
if (target_rlim_swap != (rlim_t)result) |
1072 |
return RLIM_INFINITY; |
1080 |
return RLIM_INFINITY; |
1073 |
|
1081 |
|
1074 |
return result; |
1082 |
return result; |
1075 |
} |
1083 |
} |
1076 |
|
1084 |
|
Lines 1078-1090
static inline abi_ulong host_to_target_rlim(rlim_t rlim)
Link Here
|
1078 |
{ |
1086 |
{ |
1079 |
abi_ulong target_rlim_swap; |
1087 |
abi_ulong target_rlim_swap; |
1080 |
abi_ulong result; |
1088 |
abi_ulong result; |
1081 |
|
1089 |
|
1082 |
if (rlim == RLIM_INFINITY || rlim != (abi_long)rlim) |
1090 |
if (rlim == RLIM_INFINITY || rlim != (abi_long)rlim) |
1083 |
target_rlim_swap = TARGET_RLIM_INFINITY; |
1091 |
target_rlim_swap = TARGET_RLIM_INFINITY; |
1084 |
else |
1092 |
else |
1085 |
target_rlim_swap = rlim; |
1093 |
target_rlim_swap = rlim; |
1086 |
result = tswapal(target_rlim_swap); |
1094 |
result = tswapal(target_rlim_swap); |
1087 |
|
1095 |
|
1088 |
return result; |
1096 |
return result; |
1089 |
} |
1097 |
} |
1090 |
|
1098 |
|
Lines 1526-1534
static inline abi_long target_to_host_cmsg(struct msghdr *msgh,
Link Here
|
1526 |
abi_ulong target_cmsg_addr; |
1534 |
abi_ulong target_cmsg_addr; |
1527 |
struct target_cmsghdr *target_cmsg, *target_cmsg_start; |
1535 |
struct target_cmsghdr *target_cmsg, *target_cmsg_start; |
1528 |
socklen_t space = 0; |
1536 |
socklen_t space = 0; |
1529 |
|
1537 |
|
1530 |
msg_controllen = tswapal(target_msgh->msg_controllen); |
1538 |
msg_controllen = tswapal(target_msgh->msg_controllen); |
1531 |
if (msg_controllen < sizeof (struct target_cmsghdr)) |
1539 |
if (msg_controllen < sizeof (struct target_cmsghdr)) |
1532 |
goto the_end; |
1540 |
goto the_end; |
1533 |
target_cmsg_addr = tswapal(target_msgh->msg_control); |
1541 |
target_cmsg_addr = tswapal(target_msgh->msg_control); |
1534 |
target_cmsg = lock_user(VERIFY_READ, target_cmsg_addr, msg_controllen, 1); |
1542 |
target_cmsg = lock_user(VERIFY_READ, target_cmsg_addr, msg_controllen, 1); |
Lines 1610-1616
static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
Link Here
|
1610 |
socklen_t space = 0; |
1618 |
socklen_t space = 0; |
1611 |
|
1619 |
|
1612 |
msg_controllen = tswapal(target_msgh->msg_controllen); |
1620 |
msg_controllen = tswapal(target_msgh->msg_controllen); |
1613 |
if (msg_controllen < sizeof (struct target_cmsghdr)) |
1621 |
if (msg_controllen < sizeof (struct target_cmsghdr)) |
1614 |
goto the_end; |
1622 |
goto the_end; |
1615 |
target_cmsg_addr = tswapal(target_msgh->msg_control); |
1623 |
target_cmsg_addr = tswapal(target_msgh->msg_control); |
1616 |
target_cmsg = lock_user(VERIFY_WRITE, target_cmsg_addr, msg_controllen, 0); |
1624 |
target_cmsg = lock_user(VERIFY_WRITE, target_cmsg_addr, msg_controllen, 0); |
Lines 5592-5598
abi_long do_set_thread_area(CPUX86State *env, abi_ulong ptr)
Link Here
|
5592 |
} |
5600 |
} |
5593 |
unlock_user_struct(target_ldt_info, ptr, 1); |
5601 |
unlock_user_struct(target_ldt_info, ptr, 1); |
5594 |
|
5602 |
|
5595 |
if (ldt_info.entry_number < TARGET_GDT_ENTRY_TLS_MIN || |
5603 |
if (ldt_info.entry_number < TARGET_GDT_ENTRY_TLS_MIN || |
5596 |
ldt_info.entry_number > TARGET_GDT_ENTRY_TLS_MAX) |
5604 |
ldt_info.entry_number > TARGET_GDT_ENTRY_TLS_MAX) |
5597 |
return -TARGET_EINVAL; |
5605 |
return -TARGET_EINVAL; |
5598 |
seg_32bit = ldt_info.flags & 1; |
5606 |
seg_32bit = ldt_info.flags & 1; |
Lines 5670-5676
static abi_long do_get_thread_area(CPUX86State *env, abi_ulong ptr)
Link Here
|
5670 |
lp = (uint32_t *)(gdt_table + idx); |
5678 |
lp = (uint32_t *)(gdt_table + idx); |
5671 |
entry_1 = tswap32(lp[0]); |
5679 |
entry_1 = tswap32(lp[0]); |
5672 |
entry_2 = tswap32(lp[1]); |
5680 |
entry_2 = tswap32(lp[1]); |
5673 |
|
5681 |
|
5674 |
read_exec_only = ((entry_2 >> 9) & 1) ^ 1; |
5682 |
read_exec_only = ((entry_2 >> 9) & 1) ^ 1; |
5675 |
contents = (entry_2 >> 10) & 3; |
5683 |
contents = (entry_2 >> 10) & 3; |
5676 |
seg_not_present = ((entry_2 >> 15) & 1) ^ 1; |
5684 |
seg_not_present = ((entry_2 >> 15) & 1) ^ 1; |
Lines 5686-5693
static abi_long do_get_thread_area(CPUX86State *env, abi_ulong ptr)
Link Here
|
5686 |
(read_exec_only << 3) | (limit_in_pages << 4) | |
5694 |
(read_exec_only << 3) | (limit_in_pages << 4) | |
5687 |
(seg_not_present << 5) | (useable << 6) | (lm << 7); |
5695 |
(seg_not_present << 5) | (useable << 6) | (lm << 7); |
5688 |
limit = (entry_1 & 0xffff) | (entry_2 & 0xf0000); |
5696 |
limit = (entry_1 & 0xffff) | (entry_2 & 0xf0000); |
5689 |
base_addr = (entry_1 >> 16) | |
5697 |
base_addr = (entry_1 >> 16) | |
5690 |
(entry_2 & 0xff000000) | |
5698 |
(entry_2 & 0xff000000) | |
5691 |
((entry_2 & 0xff) << 16); |
5699 |
((entry_2 & 0xff) << 16); |
5692 |
target_ldt_info->base_addr = tswapal(base_addr); |
5700 |
target_ldt_info->base_addr = tswapal(base_addr); |
5693 |
target_ldt_info->limit = tswap32(limit); |
5701 |
target_ldt_info->limit = tswap32(limit); |
Lines 9535-9541
static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
Link Here
|
9535 |
} |
9543 |
} |
9536 |
#endif |
9544 |
#endif |
9537 |
#else |
9545 |
#else |
9538 |
/* Implement getdents in terms of getdents64 */ |
9546 |
/* Implement getdents in terms of getdents64_x32 */ |
9539 |
{ |
9547 |
{ |
9540 |
struct linux_dirent64 *dirp; |
9548 |
struct linux_dirent64 *dirp; |
9541 |
abi_long count = arg3; |
9549 |
abi_long count = arg3; |
Lines 9544-9550
static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
Link Here
|
9544 |
if (!dirp) { |
9552 |
if (!dirp) { |
9545 |
return -TARGET_EFAULT; |
9553 |
return -TARGET_EFAULT; |
9546 |
} |
9554 |
} |
9547 |
ret = get_errno(sys_getdents64(arg1, dirp, count)); |
9555 |
ret = get_errno(sys_getdents64_x32(arg1, dirp, count)); |
9548 |
if (!is_error(ret)) { |
9556 |
if (!is_error(ret)) { |
9549 |
/* Convert the dirent64 structs to target dirent. We do this |
9557 |
/* Convert the dirent64 structs to target dirent. We do this |
9550 |
* in-place, since we can guarantee that a target_dirent is no |
9558 |
* in-place, since we can guarantee that a target_dirent is no |
Lines 9619-9624
static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
Link Here
|
9619 |
} |
9627 |
} |
9620 |
return ret; |
9628 |
return ret; |
9621 |
#endif /* TARGET_NR_getdents64 */ |
9629 |
#endif /* TARGET_NR_getdents64 */ |
|
|
9630 |
#if defined(TARGET_NR_getdents64_x32) && defined(__NR_getdents64_x32) |
9631 |
case TARGET_NR_getdents64_x32: |
9632 |
{ |
9633 |
struct linux_dirent64 *dirp; |
9634 |
abi_long count = arg3; |
9635 |
if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0))) |
9636 |
return -TARGET_EFAULT; |
9637 |
ret = get_errno(sys_getdents64_x32(arg1, dirp, count)); |
9638 |
if (!is_error(ret)) { |
9639 |
struct linux_dirent64 *de; |
9640 |
int len = ret; |
9641 |
int reclen; |
9642 |
de = dirp; |
9643 |
while (len > 0) { |
9644 |
reclen = de->d_reclen; |
9645 |
if (reclen > len) |
9646 |
break; |
9647 |
de->d_reclen = tswap16(reclen); |
9648 |
tswap64s((uint64_t *)&de->d_ino); |
9649 |
tswap64s((uint64_t *)&de->d_off); |
9650 |
de = (struct linux_dirent64 *)((char *)de + reclen); |
9651 |
len -= reclen; |
9652 |
} |
9653 |
} |
9654 |
unlock_user(dirp, arg2, ret); |
9655 |
} |
9656 |
return ret; |
9657 |
#endif /* TARGET_NR_getdents64_x32 */ |
9622 |
#if defined(TARGET_NR__newselect) |
9658 |
#if defined(TARGET_NR__newselect) |
9623 |
case TARGET_NR__newselect: |
9659 |
case TARGET_NR__newselect: |
9624 |
return do_select(arg1, arg2, arg3, arg4, arg5); |
9660 |
return do_select(arg1, arg2, arg3, arg4, arg5); |
Lines 10554-10560
static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
Link Here
|
10554 |
return get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3))); |
10590 |
return get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3))); |
10555 |
#if defined(TARGET_NR_fchownat) |
10591 |
#if defined(TARGET_NR_fchownat) |
10556 |
case TARGET_NR_fchownat: |
10592 |
case TARGET_NR_fchownat: |
10557 |
if (!(p = lock_user_string(arg2))) |
10593 |
if (!(p = lock_user_string(arg2))) |
10558 |
return -TARGET_EFAULT; |
10594 |
return -TARGET_EFAULT; |
10559 |
ret = get_errno(fchownat(arg1, p, low2highuid(arg3), |
10595 |
ret = get_errno(fchownat(arg1, p, low2highuid(arg3), |
10560 |
low2highgid(arg4), arg5)); |
10596 |
low2highgid(arg4), arg5)); |