arget_fl; - int l_type; - - if (!lock_user_struct(VERIFY_READ, target_fl, target_flock_addr, 1)) { - return -TARGET_EFAULT; - } - - __get_user(l_type, &target_fl->l_type); - l_type = target_to_host_flock(l_type); - if (l_type < 0) { - return l_type; - } - fl->l_type = l_type; - __get_user(fl->l_whence, &target_fl->l_whence); - __get_user(fl->l_start, &target_fl->l_start); - __get_user(fl->l_len, &target_fl->l_len); - __get_user(fl->l_pid, &target_fl->l_pid); - unlock_user_struct(target_fl, target_flock_addr, 0); - return 0; -} - -static inline abi_long copy_to_user_flock(abi_ulong target_flock_addr, - const struct flock64 *fl) -{ - struct target_flock *target_fl; - short l_type; - - if (!lock_user_struct(VERIFY_WRITE, target_fl, target_flock_addr, 0)) { - return -TARGET_EFAULT; - } - - l_type = host_to_target_flock(fl->l_type); - __put_user(l_type, &target_fl->l_type); - __put_user(fl->l_whence, &target_fl->l_whence); - __put_user(fl->l_start, &target_fl->l_start); - __put_user(fl->l_len, &target_fl->l_len); - __put_user(fl->l_pid, &target_fl->l_pid); - unlock_user_struct(target_fl, target_flock_addr, 1); - return 0; -} - -typedef abi_long from_flock64_fn(struct flock64 *fl, abi_ulong target_addr); -typedef abi_long to_flock64_fn(abi_ulong target_addr, const struct flock64 *fl); +typedef abi_long from_flock_fn(struct flock *fl, abi_ulong target_addr); +typedef abi_long to_flock_fn(abi_ulong target_addr, const struct flock *fl); #if defined(TARGET_ARM) && TARGET_ABI_BITS == 32 -struct target_oabi_flock64 { +struct target_oabi_flock { abi_short l_type; abi_short l_whence; abi_llong l_start; @@ -6911,10 +6856,10 @@ struct target_oabi_flock64 { abi_int l_pid; } QEMU_PACKED; -static inline abi_long copy_from_user_oabi_flock64(struct flock64 *fl, +static inline abi_long copy_from_user_oabi_flock(struct flock *fl, abi_ulong target_flock_addr) { - struct target_oabi_flock64 *target_fl; + struct target_oabi_flock *target_fl; int l_type; if (!lock_user_struct(VERIFY_READ, target_fl, target_flock_addr, 1)) { @@ -6935,10 +6880,10 @@ static inline abi_long copy_from_user_oabi_flock64(struct flock64 *fl, return 0; } -static inline abi_long copy_to_user_oabi_flock64(abi_ulong target_flock_addr, - const struct flock64 *fl) +static inline abi_long copy_to_user_oabi_flock(abi_ulong target_flock_addr, + const struct flock *fl) { - struct target_oabi_flock64 *target_fl; + struct target_oabi_flock *target_fl; short l_type; if (!lock_user_struct(VERIFY_WRITE, target_fl, target_flock_addr, 0)) { @@ -6956,10 +6901,10 @@ static inline abi_long copy_to_user_oabi_flock64(abi_ulong target_flock_addr, } #endif -static inline abi_long copy_from_user_flock64(struct flock64 *fl, +static inline abi_long copy_from_user_flock(struct flock *fl, abi_ulong target_flock_addr) { - struct target_flock64 *target_fl; + struct target_flock *target_fl; int l_type; if (!lock_user_struct(VERIFY_READ, target_fl, target_flock_addr, 1)) { @@ -6980,10 +6925,10 @@ static inline abi_long copy_from_user_flock64(struct flock64 *fl, return 0; } -static inline abi_long copy_to_user_flock64(abi_ulong target_flock_addr, - const struct flock64 *fl) +static inline abi_long copy_to_user_flock(abi_ulong target_flock_addr, + const struct flock *fl) { - struct target_flock64 *target_fl; + struct target_flock *target_fl; short l_type; if (!lock_user_struct(VERIFY_WRITE, target_fl, target_flock_addr, 0)) { @@ -7002,7 +6947,7 @@ static inline abi_long copy_to_user_flock64(abi_ulong target_flock_addr, static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) { - struct flock64 fl64; + struct flock fl64; #ifdef F_GETOWN_EX struct f_owner_ex fox; struct target_f_owner_ex *target_fox; @@ -7015,6 +6960,7 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) switch(cmd) { case TARGET_F_GETLK: + case TARGET_F_OFD_GETLK: ret = copy_from_user_flock(&fl64, arg); if (ret) { return ret; @@ -7024,32 +6970,11 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) ret = copy_to_user_flock(arg, &fl64); } break; - case TARGET_F_SETLK: case TARGET_F_SETLKW: - ret = copy_from_user_flock(&fl64, arg); - if (ret) { - return ret; - } - ret = get_errno(safe_fcntl(fd, host_cmd, &fl64)); - break; - - case TARGET_F_GETLK64: - case TARGET_F_OFD_GETLK: - ret = copy_from_user_flock64(&fl64, arg); - if (ret) { - return ret; - } - ret = get_errno(safe_fcntl(fd, host_cmd, &fl64)); - if (ret == 0) { - ret = copy_to_user_flock64(arg, &fl64); - } - break; - case TARGET_F_SETLK64: - case TARGET_F_SETLKW64: case TARGET_F_OFD_SETLK: case TARGET_F_OFD_SETLKW: - ret = copy_from_user_flock64(&fl64, arg); + ret = copy_from_user_flock(&fl64, arg); if (ret) { return ret; } @@ -7278,7 +7203,7 @@ static inline abi_long target_truncate64(CPUArchState *cpu_env, const char *arg1 arg2 = arg3; arg3 = arg4; } - return get_errno(truncate64(arg1, target_offset64(arg2, arg3))); + return get_errno(truncate(arg1, target_offset64(arg2, arg3))); } #endif @@ -7292,7 +7217,7 @@ static inline abi_long target_ftruncate64(CPUArchState *cpu_env, abi_long arg1, arg2 = arg3; arg3 = arg4; } - return get_errno(ftruncate64(arg1, target_offset64(arg2, arg3))); + return get_errno(ftruncate(arg1, target_offset64(arg2, arg3))); } #endif @@ -8667,7 +8592,7 @@ static int do_getdents(abi_long dirfd, abi_long arg2, abi_long count) void *tdirp; int hlen, hoff, toff; int hreclen, treclen; - off64_t prev_diroff = 0; + off_t prev_diroff = 0; hdirp = g_try_malloc(count); if (!hdirp) { @@ -8720,7 +8645,7 @@ static int do_getdents(abi_long dirfd, abi_long arg2, abi_long count) * Return what we have, resetting the file pointer to the * location of the first record not returned. */ - lseek64(dirfd, prev_diroff, SEEK_SET); + lseek(dirfd, prev_diroff, SEEK_SET); break; } @@ -8754,7 +8679,7 @@ static int do_getdents64(abi_long dirfd, abi_long arg2, abi_long count) void *tdirp; int hlen, hoff, toff; int hreclen, treclen; - off64_t prev_diroff = 0; + off_t prev_diroff = 0; hdirp = g_try_malloc(count); if (!hdirp) { @@ -8796,7 +8721,7 @@ static int do_getdents64(abi_long dirfd, abi_long arg2, abi_long count) * Return what we have, resetting the file pointer to the * location of the first record not returned. */ - lseek64(dirfd, prev_diroff, SEEK_SET); + lseek(dirfd, prev_diroff, SEEK_SET); break; } @@ -11527,7 +11452,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, return -TARGET_EFAULT; } } - ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5))); + ret = get_errno(pread(arg1, p, arg3, target_offset64(arg4, arg5))); unlock_user(p, arg2, ret); return ret; case TARGET_NR_pwrite64: @@ -11544,7 +11469,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, return -TARGET_EFAULT; } } - ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5))); + ret = get_errno(pwrite(arg1, p, arg3, target_offset64(arg4, arg5))); unlock_user(p, arg2, 0); return ret; #endif @@ -12404,14 +12329,14 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, case TARGET_NR_fcntl64: { int cmd; - struct flock64 fl; - from_flock64_fn *copyfrom = copy_from_user_flock64; - to_flock64_fn *copyto = copy_to_user_flock64; + struct flock fl; + from_flock_fn *copyfrom = copy_from_user_flock; + to_flock_fn *copyto = copy_to_user_flock; #ifdef TARGET_ARM if (!cpu_env->eabi) { - copyfrom = copy_from_user_oabi_flock64; - copyto = copy_to_user_oabi_flock64; + copyfrom = copy_from_user_oabi_flock; + copyto = copy_to_user_oabi_flock; } #endif @@ -12421,7 +12346,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, } switch(arg2) { - case TARGET_F_GETLK64: + case TARGET_F_GETLK: ret = copyfrom(&fl, arg3); if (ret) { break; @@ -12432,8 +12357,8 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, } break; - case TARGET_F_SETLK64: - case TARGET_F_SETLKW64: + case TARGET_F_SETLK: + case TARGET_F_SETLKW: ret = copyfrom(&fl, arg3); if (ret) { break; -- 2.44.0