Commit 9d33b76b205194857f17ca35a7581b1f500f0462
1 parent
f1afe02a
linux-user: fix fstatat64()/newfstatat() syscall implementation
There are two different syscall names for the same goal. On systems with sizeof(long) == 64 it calls newfstatat. On systems with sizeof(long) == 32 it calls fstatat64. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name> Signed-off-by: Riku Voipio <riku.voipio@iki.fi> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7050 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
25 additions
and
4 deletions
linux-user/syscall.c
| ... | ... | @@ -169,6 +169,7 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ |
| 169 | 169 | #define __NR_sys_linkat __NR_linkat |
| 170 | 170 | #define __NR_sys_mkdirat __NR_mkdirat |
| 171 | 171 | #define __NR_sys_mknodat __NR_mknodat |
| 172 | +#define __NR_sys_newfstatat __NR_newfstatat | |
| 172 | 173 | #define __NR_sys_openat __NR_openat |
| 173 | 174 | #define __NR_sys_readlinkat __NR_readlinkat |
| 174 | 175 | #define __NR_sys_renameat __NR_renameat |
| ... | ... | @@ -209,7 +210,8 @@ _syscall4(int,sys_fchmodat,int,dirfd,const char *,pathname, |
| 209 | 210 | _syscall5(int,sys_fchownat,int,dirfd,const char *,pathname, |
| 210 | 211 | uid_t,owner,gid_t,group,int,flags) |
| 211 | 212 | #endif |
| 212 | -#if defined(TARGET_NR_fstatat64) && defined(__NR_fstatat64) | |
| 213 | +#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \ | |
| 214 | + defined(__NR_fstatat64) | |
| 213 | 215 | _syscall4(int,sys_fstatat64,int,dirfd,const char *,pathname, |
| 214 | 216 | struct stat *,buf,int,flags) |
| 215 | 217 | #endif |
| ... | ... | @@ -240,6 +242,11 @@ _syscall3(int,sys_mkdirat,int,dirfd,const char *,pathname,mode_t,mode) |
| 240 | 242 | _syscall4(int,sys_mknodat,int,dirfd,const char *,pathname, |
| 241 | 243 | mode_t,mode,dev_t,dev) |
| 242 | 244 | #endif |
| 245 | +#if (defined(TARGET_NR_newfstatat) || defined(TARGET_NR_fstatat64) ) && \ | |
| 246 | + defined(__NR_newfstatat) | |
| 247 | +_syscall4(int,sys_newfstatat,int,dirfd,const char *,pathname, | |
| 248 | + struct stat *,buf,int,flags) | |
| 249 | +#endif | |
| 243 | 250 | #if defined(TARGET_NR_openat) && defined(__NR_openat) |
| 244 | 251 | _syscall4(int,sys_openat,int,dirfd,const char *,pathname,int,flags,mode_t,mode) |
| 245 | 252 | #endif |
| ... | ... | @@ -3280,7 +3287,7 @@ static inline abi_long host_to_target_timespec(abi_ulong target_addr, |
| 3280 | 3287 | return 0; |
| 3281 | 3288 | } |
| 3282 | 3289 | |
| 3283 | -#ifdef TARGET_NR_stat64 | |
| 3290 | +#if defined(TARGET_NR_stat64) || defined(TARGET_NR_newfstatat) | |
| 3284 | 3291 | static inline abi_long host_to_target_stat64(void *cpu_env, |
| 3285 | 3292 | abi_ulong target_addr, |
| 3286 | 3293 | struct stat *host_st) |
| ... | ... | @@ -3312,11 +3319,15 @@ static inline abi_long host_to_target_stat64(void *cpu_env, |
| 3312 | 3319 | } else |
| 3313 | 3320 | #endif |
| 3314 | 3321 | { |
| 3322 | +#if TARGET_LONG_BITS == 64 | |
| 3323 | + struct target_stat *target_st; | |
| 3324 | +#else | |
| 3315 | 3325 | struct target_stat64 *target_st; |
| 3326 | +#endif | |
| 3316 | 3327 | |
| 3317 | 3328 | if (!lock_user_struct(VERIFY_WRITE, target_st, target_addr, 0)) |
| 3318 | 3329 | return -TARGET_EFAULT; |
| 3319 | - memset(target_st, 0, sizeof(struct target_stat64)); | |
| 3330 | + memset(target_st, 0, sizeof(*target_st)); | |
| 3320 | 3331 | __put_user(host_st->st_dev, &target_st->st_dev); |
| 3321 | 3332 | __put_user(host_st->st_ino, &target_st->st_ino); |
| 3322 | 3333 | #ifdef TARGET_STAT64_HAS_BROKEN_ST_INO |
| ... | ... | @@ -5459,11 +5470,21 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, |
| 5459 | 5470 | ret = host_to_target_stat64(cpu_env, arg2, &st); |
| 5460 | 5471 | break; |
| 5461 | 5472 | #endif |
| 5462 | -#if defined(TARGET_NR_fstatat64) && defined(__NR_fstatat64) | |
| 5473 | +#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \ | |
| 5474 | + (defined(__NR_fstatat64) || defined(__NR_newfstatat)) | |
| 5475 | +#ifdef TARGET_NR_fstatat64 | |
| 5463 | 5476 | case TARGET_NR_fstatat64: |
| 5477 | +#endif | |
| 5478 | +#ifdef TARGET_NR_newfstatat | |
| 5479 | + case TARGET_NR_newfstatat: | |
| 5480 | +#endif | |
| 5464 | 5481 | if (!(p = lock_user_string(arg2))) |
| 5465 | 5482 | goto efault; |
| 5483 | +#ifdef __NR_fstatat64 | |
| 5466 | 5484 | ret = get_errno(sys_fstatat64(arg1, path(p), &st, arg4)); |
| 5485 | +#else | |
| 5486 | + ret = get_errno(sys_newfstatat(arg1, path(p), &st, arg4)); | |
| 5487 | +#endif | |
| 5467 | 5488 | if (!is_error(ret)) |
| 5468 | 5489 | ret = host_to_target_stat64(cpu_env, arg3, &st); |
| 5469 | 5490 | break; | ... | ... |