Commit 8170f56baf6b146653246b8cbf7298fd228cbc75
1 parent
ccfa72b7
linux-user unlinkat() syscall, by Thayne Harbaugh.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3221 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
19 additions
and
0 deletions
linux-user/syscall.c
| ... | ... | @@ -150,6 +150,7 @@ type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \ |
| 150 | 150 | #define __NR_sys_syslog __NR_syslog |
| 151 | 151 | #define __NR_sys_tgkill __NR_tgkill |
| 152 | 152 | #define __NR_sys_tkill __NR_tkill |
| 153 | +#define __NR_sys_unlinkat __NR_unlinkat | |
| 153 | 154 | |
| 154 | 155 | #if defined(__alpha__) || defined (__ia64__) || defined(__x86_64__) |
| 155 | 156 | #define __NR__llseek __NR_lseek |
| ... | ... | @@ -198,6 +199,9 @@ _syscall1(int,exit_group,int,error_code) |
| 198 | 199 | #if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address) |
| 199 | 200 | _syscall1(int,set_tid_address,int *,tidptr) |
| 200 | 201 | #endif |
| 202 | +#if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat) | |
| 203 | +_syscall3(int,sys_unlinkat,int,dirfd,const char *,pathname,int,flags) | |
| 204 | +#endif | |
| 201 | 205 | |
| 202 | 206 | extern int personality(int); |
| 203 | 207 | extern int flock(int, int); |
| ... | ... | @@ -2577,6 +2581,21 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, |
| 2577 | 2581 | ret = get_errno(unlink(p)); |
| 2578 | 2582 | unlock_user(p, arg1, 0); |
| 2579 | 2583 | break; |
| 2584 | +#if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat) | |
| 2585 | + case TARGET_NR_unlinkat: | |
| 2586 | + if (!arg2) { | |
| 2587 | + ret = -EFAULT; | |
| 2588 | + goto fail; | |
| 2589 | + } | |
| 2590 | + p = lock_user_string(arg2); | |
| 2591 | + if (!access_ok(VERIFY_READ, p, 1)) | |
| 2592 | + ret = -EFAULT; | |
| 2593 | + else | |
| 2594 | + ret = get_errno(sys_unlinkat(arg1, p, arg3)); | |
| 2595 | + if (p) | |
| 2596 | + unlock_user(p, arg2, 0); | |
| 2597 | + break; | |
| 2598 | +#endif | |
| 2580 | 2599 | case TARGET_NR_execve: |
| 2581 | 2600 | { |
| 2582 | 2601 | char **argp, **envp; | ... | ... |