Commit 722183f69b1dc6c1c9f5f5c250622ca5a71cdb3e

Authored by ths
1 parent 8170f56b

linux-user renameat() syscall, by Thayne Harbaugh.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3222 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 27 additions and 0 deletions
linux-user/syscall.c
... ... @@ -146,6 +146,7 @@ type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
146 146 #define __NR_sys_mkdirat __NR_mkdirat
147 147 #define __NR_sys_mknodat __NR_mknodat
148 148 #define __NR_sys_openat __NR_openat
  149 +#define __NR_sys_renameat __NR_renameat
149 150 #define __NR_sys_rt_sigqueueinfo __NR_rt_sigqueueinfo
150 151 #define __NR_sys_syslog __NR_syslog
151 152 #define __NR_sys_tgkill __NR_tgkill
... ... @@ -185,6 +186,10 @@ _syscall4(int,sys_mknodat,int,dirfd,const char *,pathname,
185 186 #if defined(TARGET_NR_openat) && defined(__NR_openat)
186 187 _syscall4(int,sys_openat,int,dirfd,const char *,pathname,int,flags,mode_t,mode)
187 188 #endif
  189 +#if defined(TARGET_NR_renameat) && defined(__NR_renameat)
  190 +_syscall4(int,sys_renameat,int,olddirfd,const char *,oldpath,
  191 + int,newdirfd,const char *,newpath)
  192 +#endif
188 193 _syscall3(int,sys_rt_sigqueueinfo,int,pid,int,sig,siginfo_t *,uinfo)
189 194 _syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
190 195 #if defined(TARGET_NR_tgkill) && defined(__NR_tgkill)
... ... @@ -2830,6 +2835,28 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
2830 2835 unlock_user(p, arg1, 0);
2831 2836 }
2832 2837 break;
  2838 +#if defined(TARGET_NR_renameat) && defined(__NR_renameat)
  2839 + case TARGET_NR_renameat:
  2840 + if (!arg2 || !arg4) {
  2841 + ret = -EFAULT;
  2842 + goto fail;
  2843 + }
  2844 + {
  2845 + void *p2 = NULL;
  2846 + p = lock_user_string(arg2);
  2847 + p2 = lock_user_string(arg4);
  2848 + if (!access_ok(VERIFY_READ, p, 1)
  2849 + || !access_ok(VERIFY_READ, p2, 1))
  2850 + ret = -EFAULT;
  2851 + else
  2852 + ret = get_errno(sys_renameat(arg1, p, arg3, p2));
  2853 + if (p2)
  2854 + unlock_user(p2, arg4, 0);
  2855 + if (p)
  2856 + unlock_user(p, arg2, 0);
  2857 + }
  2858 + break;
  2859 +#endif
2833 2860 case TARGET_NR_mkdir:
2834 2861 p = lock_user_string(arg1);
2835 2862 ret = get_errno(mkdir(p, arg2));
... ...