syscall.c (ae9108f8f0746ce64d02afb1a216153a50926132) | syscall.c (efa921845c03ef4df6b9d4b3b1ee1a103e7d4b46) |
---|---|
1/* 2 * Linux syscalls 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or --- 224 unchanged lines hidden (view full) --- 233#define __NR_sys_getpriority __NR_getpriority 234#define __NR_sys_rt_sigqueueinfo __NR_rt_sigqueueinfo 235#define __NR_sys_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo 236#define __NR_sys_syslog __NR_syslog 237#define __NR_sys_futex __NR_futex 238#define __NR_sys_inotify_init __NR_inotify_init 239#define __NR_sys_inotify_add_watch __NR_inotify_add_watch 240#define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch | 1/* 2 * Linux syscalls 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or --- 224 unchanged lines hidden (view full) --- 233#define __NR_sys_getpriority __NR_getpriority 234#define __NR_sys_rt_sigqueueinfo __NR_rt_sigqueueinfo 235#define __NR_sys_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo 236#define __NR_sys_syslog __NR_syslog 237#define __NR_sys_futex __NR_futex 238#define __NR_sys_inotify_init __NR_inotify_init 239#define __NR_sys_inotify_add_watch __NR_inotify_add_watch 240#define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch |
241#define __NR_sys_statx __NR_statx |
|
241 242#if defined(__alpha__) || defined(__x86_64__) || defined(__s390x__) 243#define __NR__llseek __NR_lseek 244#endif 245 246/* Newer kernel ports have llseek() instead of _llseek() */ 247#if defined(TARGET_NR_llseek) && !defined(TARGET_NR__llseek) 248#define TARGET_NR__llseek TARGET_NR_llseek --- 62 unchanged lines hidden (view full) --- 311_syscall3(int, getrandom, void *, buf, size_t, buflen, unsigned int, flags) 312#endif 313 314#if defined(TARGET_NR_kcmp) && defined(__NR_kcmp) 315_syscall5(int, kcmp, pid_t, pid1, pid_t, pid2, int, type, 316 unsigned long, idx1, unsigned long, idx2) 317#endif 318 | 242 243#if defined(__alpha__) || defined(__x86_64__) || defined(__s390x__) 244#define __NR__llseek __NR_lseek 245#endif 246 247/* Newer kernel ports have llseek() instead of _llseek() */ 248#if defined(TARGET_NR_llseek) && !defined(TARGET_NR__llseek) 249#define TARGET_NR__llseek TARGET_NR_llseek --- 62 unchanged lines hidden (view full) --- 312_syscall3(int, getrandom, void *, buf, size_t, buflen, unsigned int, flags) 313#endif 314 315#if defined(TARGET_NR_kcmp) && defined(__NR_kcmp) 316_syscall5(int, kcmp, pid_t, pid1, pid_t, pid2, int, type, 317 unsigned long, idx1, unsigned long, idx2) 318#endif 319 |
320/* 321 * It is assumed that struct statx is architecture independent. 322 */ 323#if defined(TARGET_NR_statx) && defined(__NR_statx) 324_syscall5(int, sys_statx, int, dirfd, const char *, pathname, int, flags, 325 unsigned int, mask, struct target_statx *, statxbuf) 326#endif 327 |
|
319static bitmask_transtbl fcntl_flags_tbl[] = { 320 { TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, }, 321 { TARGET_O_ACCMODE, TARGET_O_RDWR, O_ACCMODE, O_RDWR, }, 322 { TARGET_O_CREAT, TARGET_O_CREAT, O_CREAT, O_CREAT, }, 323 { TARGET_O_EXCL, TARGET_O_EXCL, O_EXCL, O_EXCL, }, 324 { TARGET_O_NOCTTY, TARGET_O_NOCTTY, O_NOCTTY, O_NOCTTY, }, 325 { TARGET_O_TRUNC, TARGET_O_TRUNC, O_TRUNC, O_TRUNC, }, 326 { TARGET_O_APPEND, TARGET_O_APPEND, O_APPEND, O_APPEND, }, --- 6184 unchanged lines hidden (view full) --- 6511#endif 6512 unlock_user_struct(target_st, target_addr, 1); 6513 } 6514 6515 return 0; 6516} 6517#endif 6518 | 328static bitmask_transtbl fcntl_flags_tbl[] = { 329 { TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, }, 330 { TARGET_O_ACCMODE, TARGET_O_RDWR, O_ACCMODE, O_RDWR, }, 331 { TARGET_O_CREAT, TARGET_O_CREAT, O_CREAT, O_CREAT, }, 332 { TARGET_O_EXCL, TARGET_O_EXCL, O_EXCL, O_EXCL, }, 333 { TARGET_O_NOCTTY, TARGET_O_NOCTTY, O_NOCTTY, O_NOCTTY, }, 334 { TARGET_O_TRUNC, TARGET_O_TRUNC, O_TRUNC, O_TRUNC, }, 335 { TARGET_O_APPEND, TARGET_O_APPEND, O_APPEND, O_APPEND, }, --- 6184 unchanged lines hidden (view full) --- 6520#endif 6521 unlock_user_struct(target_st, target_addr, 1); 6522 } 6523 6524 return 0; 6525} 6526#endif 6527 |
6528#if defined(TARGET_NR_statx) && defined(__NR_statx) 6529static inline abi_long host_to_target_statx(struct target_statx *host_stx, 6530 abi_ulong target_addr) 6531{ 6532 struct target_statx *target_stx; 6533 6534 if (!lock_user_struct(VERIFY_WRITE, target_stx, target_addr, 0)) { 6535 return -TARGET_EFAULT; 6536 } 6537 memset(target_stx, 0, sizeof(*target_stx)); 6538 6539 __put_user(host_stx->stx_mask, &target_stx->stx_mask); 6540 __put_user(host_stx->stx_blksize, &target_stx->stx_blksize); 6541 __put_user(host_stx->stx_attributes, &target_stx->stx_attributes); 6542 __put_user(host_stx->stx_nlink, &target_stx->stx_nlink); 6543 __put_user(host_stx->stx_uid, &target_stx->stx_uid); 6544 __put_user(host_stx->stx_gid, &target_stx->stx_gid); 6545 __put_user(host_stx->stx_mode, &target_stx->stx_mode); 6546 __put_user(host_stx->stx_ino, &target_stx->stx_ino); 6547 __put_user(host_stx->stx_size, &target_stx->stx_size); 6548 __put_user(host_stx->stx_blocks, &target_stx->stx_blocks); 6549 __put_user(host_stx->stx_attributes_mask, &target_stx->stx_attributes_mask); 6550 __put_user(host_stx->stx_atime.tv_sec, &target_stx->stx_atime.tv_sec); 6551 __put_user(host_stx->stx_atime.tv_nsec, &target_stx->stx_atime.tv_nsec); 6552 __put_user(host_stx->stx_btime.tv_sec, &target_stx->stx_atime.tv_sec); 6553 __put_user(host_stx->stx_btime.tv_nsec, &target_stx->stx_atime.tv_nsec); 6554 __put_user(host_stx->stx_ctime.tv_sec, &target_stx->stx_atime.tv_sec); 6555 __put_user(host_stx->stx_ctime.tv_nsec, &target_stx->stx_atime.tv_nsec); 6556 __put_user(host_stx->stx_mtime.tv_sec, &target_stx->stx_atime.tv_sec); 6557 __put_user(host_stx->stx_mtime.tv_nsec, &target_stx->stx_atime.tv_nsec); 6558 __put_user(host_stx->stx_rdev_major, &target_stx->stx_rdev_major); 6559 __put_user(host_stx->stx_rdev_minor, &target_stx->stx_rdev_minor); 6560 __put_user(host_stx->stx_dev_major, &target_stx->stx_dev_major); 6561 __put_user(host_stx->stx_dev_minor, &target_stx->stx_dev_minor); 6562 6563 unlock_user_struct(target_stx, target_addr, 1); 6564 6565 return 0; 6566} 6567#endif 6568 6569 |
|
6519/* ??? Using host futex calls even when target atomic operations 6520 are not really atomic probably breaks things. However implementing 6521 futexes locally would make futexes shared between multiple processes 6522 tricky. However they're probably useless because guest atomic 6523 operations won't work either. */ 6524static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, 6525 target_ulong uaddr2, int val3) 6526{ --- 562 unchanged lines hidden (view full) --- 7089 abi_long arg2, abi_long arg3, abi_long arg4, 7090 abi_long arg5, abi_long arg6, abi_long arg7, 7091 abi_long arg8) 7092{ 7093 CPUState *cpu = env_cpu(cpu_env); 7094 abi_long ret; 7095#if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) \ 7096 || defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) \ | 6570/* ??? Using host futex calls even when target atomic operations 6571 are not really atomic probably breaks things. However implementing 6572 futexes locally would make futexes shared between multiple processes 6573 tricky. However they're probably useless because guest atomic 6574 operations won't work either. */ 6575static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, 6576 target_ulong uaddr2, int val3) 6577{ --- 562 unchanged lines hidden (view full) --- 7140 abi_long arg2, abi_long arg3, abi_long arg4, 7141 abi_long arg5, abi_long arg6, abi_long arg7, 7142 abi_long arg8) 7143{ 7144 CPUState *cpu = env_cpu(cpu_env); 7145 abi_long ret; 7146#if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) \ 7147 || defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) \ |
7097 || defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) | 7148 || defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) \ 7149 || defined(TARGET_NR_statx) |
7098 struct stat st; 7099#endif 7100#if defined(TARGET_NR_statfs) || defined(TARGET_NR_statfs64) \ 7101 || defined(TARGET_NR_fstatfs) 7102 struct statfs stfs; 7103#endif 7104 void *p; 7105 --- 3061 unchanged lines hidden (view full) --- 10167 return -TARGET_EFAULT; 10168 } 10169 ret = get_errno(fstatat(arg1, path(p), &st, arg4)); 10170 unlock_user(p, arg2, 0); 10171 if (!is_error(ret)) 10172 ret = host_to_target_stat64(cpu_env, arg3, &st); 10173 return ret; 10174#endif | 7150 struct stat st; 7151#endif 7152#if defined(TARGET_NR_statfs) || defined(TARGET_NR_statfs64) \ 7153 || defined(TARGET_NR_fstatfs) 7154 struct statfs stfs; 7155#endif 7156 void *p; 7157 --- 3061 unchanged lines hidden (view full) --- 10219 return -TARGET_EFAULT; 10220 } 10221 ret = get_errno(fstatat(arg1, path(p), &st, arg4)); 10222 unlock_user(p, arg2, 0); 10223 if (!is_error(ret)) 10224 ret = host_to_target_stat64(cpu_env, arg3, &st); 10225 return ret; 10226#endif |
10227#if defined(TARGET_NR_statx) 10228 case TARGET_NR_statx: 10229 { 10230 struct target_statx *target_stx; 10231 int dirfd = arg1; 10232 int flags = arg3; 10233 10234 p = lock_user_string(arg2); 10235 if (p == NULL) { 10236 return -TARGET_EFAULT; 10237 } 10238#if defined(__NR_statx) 10239 { 10240 /* 10241 * It is assumed that struct statx is architecture independent. 10242 */ 10243 struct target_statx host_stx; 10244 int mask = arg4; 10245 10246 ret = get_errno(sys_statx(dirfd, p, flags, mask, &host_stx)); 10247 if (!is_error(ret)) { 10248 if (host_to_target_statx(&host_stx, arg5) != 0) { 10249 unlock_user(p, arg2, 0); 10250 return -TARGET_EFAULT; 10251 } 10252 } 10253 10254 if (ret != -TARGET_ENOSYS) { 10255 unlock_user(p, arg2, 0); 10256 return ret; 10257 } 10258 } 10259#endif 10260 ret = get_errno(fstatat(dirfd, path(p), &st, flags)); 10261 unlock_user(p, arg2, 0); 10262 10263 if (!is_error(ret)) { 10264 if (!lock_user_struct(VERIFY_WRITE, target_stx, arg5, 0)) { 10265 return -TARGET_EFAULT; 10266 } 10267 memset(target_stx, 0, sizeof(*target_stx)); 10268 __put_user(major(st.st_dev), &target_stx->stx_dev_major); 10269 __put_user(minor(st.st_dev), &target_stx->stx_dev_minor); 10270 __put_user(st.st_ino, &target_stx->stx_ino); 10271 __put_user(st.st_mode, &target_stx->stx_mode); 10272 __put_user(st.st_uid, &target_stx->stx_uid); 10273 __put_user(st.st_gid, &target_stx->stx_gid); 10274 __put_user(st.st_nlink, &target_stx->stx_nlink); 10275 __put_user(major(st.st_rdev), &target_stx->stx_rdev_major); 10276 __put_user(minor(st.st_rdev), &target_stx->stx_rdev_minor); 10277 __put_user(st.st_size, &target_stx->stx_size); 10278 __put_user(st.st_blksize, &target_stx->stx_blksize); 10279 __put_user(st.st_blocks, &target_stx->stx_blocks); 10280 __put_user(st.st_atime, &target_stx->stx_atime.tv_sec); 10281 __put_user(st.st_mtime, &target_stx->stx_mtime.tv_sec); 10282 __put_user(st.st_ctime, &target_stx->stx_ctime.tv_sec); 10283 unlock_user_struct(target_stx, arg5, 1); 10284 } 10285 } 10286 return ret; 10287#endif |
|
10175#ifdef TARGET_NR_lchown 10176 case TARGET_NR_lchown: 10177 if (!(p = lock_user_string(arg1))) 10178 return -TARGET_EFAULT; 10179 ret = get_errno(lchown(p, low2highuid(arg2), low2highgid(arg3))); 10180 unlock_user(p, arg1, 0); 10181 return ret; 10182#endif --- 1607 unchanged lines hidden --- | 10288#ifdef TARGET_NR_lchown 10289 case TARGET_NR_lchown: 10290 if (!(p = lock_user_string(arg1))) 10291 return -TARGET_EFAULT; 10292 ret = get_errno(lchown(p, low2highuid(arg2), low2highgid(arg3))); 10293 unlock_user(p, arg1, 0); 10294 return ret; 10295#endif --- 1607 unchanged lines hidden --- |