Commit 56c8f68f1d2e45ad740de8c01780c7a4830d2098
1 parent
c960bde1
statfs fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1680 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
99 additions
and
19 deletions
linux-user/syscall.c
| ... | ... | @@ -42,6 +42,7 @@ |
| 42 | 42 | #include <sys/poll.h> |
| 43 | 43 | #include <sys/times.h> |
| 44 | 44 | #include <sys/shm.h> |
| 45 | +#include <sys/statfs.h> | |
| 45 | 46 | #include <utime.h> |
| 46 | 47 | #include <sys/sysinfo.h> |
| 47 | 48 | //#include <sys/user.h> |
| ... | ... | @@ -202,8 +203,6 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ |
| 202 | 203 | |
| 203 | 204 | #define __NR_sys_uname __NR_uname |
| 204 | 205 | #define __NR_sys_getcwd1 __NR_getcwd |
| 205 | -#define __NR_sys_statfs __NR_statfs | |
| 206 | -#define __NR_sys_fstatfs __NR_fstatfs | |
| 207 | 206 | #define __NR_sys_getdents __NR_getdents |
| 208 | 207 | #define __NR_sys_getdents64 __NR_getdents64 |
| 209 | 208 | #define __NR_sys_rt_sigqueueinfo __NR_rt_sigqueueinfo |
| ... | ... | @@ -225,8 +224,6 @@ _syscall3(int, sys_getdents, uint, fd, struct dirent *, dirp, uint, count); |
| 225 | 224 | _syscall3(int, sys_getdents64, uint, fd, struct dirent64 *, dirp, uint, count); |
| 226 | 225 | _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, |
| 227 | 226 | loff_t *, res, uint, wh); |
| 228 | -_syscall2(int,sys_statfs,const char *,path,struct kernel_statfs *,buf) | |
| 229 | -_syscall2(int,sys_fstatfs,int,fd,struct kernel_statfs *,buf) | |
| 230 | 227 | _syscall3(int,sys_rt_sigqueueinfo,int,pid,int,sig,siginfo_t *,uinfo) |
| 231 | 228 | #ifdef __NR_exit_group |
| 232 | 229 | _syscall1(int,exit_group,int,error_code) |
| ... | ... | @@ -1659,7 +1656,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, |
| 1659 | 1656 | { |
| 1660 | 1657 | long ret; |
| 1661 | 1658 | struct stat st; |
| 1662 | - struct kernel_statfs *stfs; | |
| 1659 | + struct statfs stfs; | |
| 1663 | 1660 | |
| 1664 | 1661 | #ifdef DEBUG |
| 1665 | 1662 | gemu_log("syscall %d", num); |
| ... | ... | @@ -2298,26 +2295,47 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, |
| 2298 | 2295 | goto unimplemented; |
| 2299 | 2296 | #endif |
| 2300 | 2297 | case TARGET_NR_statfs: |
| 2301 | - stfs = (void *)arg2; | |
| 2302 | - ret = get_errno(sys_statfs(path((const char *)arg1), stfs)); | |
| 2298 | + ret = get_errno(statfs(path((const char *)arg1), &stfs)); | |
| 2303 | 2299 | convert_statfs: |
| 2304 | 2300 | if (!is_error(ret)) { |
| 2305 | - tswap32s(&stfs->f_type); | |
| 2306 | - tswap32s(&stfs->f_bsize); | |
| 2307 | - tswap32s(&stfs->f_blocks); | |
| 2308 | - tswap32s(&stfs->f_bfree); | |
| 2309 | - tswap32s(&stfs->f_bavail); | |
| 2310 | - tswap32s(&stfs->f_files); | |
| 2311 | - tswap32s(&stfs->f_ffree); | |
| 2312 | - tswap32s(&stfs->f_fsid.val[0]); | |
| 2313 | - tswap32s(&stfs->f_fsid.val[1]); | |
| 2314 | - tswap32s(&stfs->f_namelen); | |
| 2301 | + struct target_statfs *target_stfs = (void *)arg2; | |
| 2302 | + | |
| 2303 | + put_user(stfs.f_type, &target_stfs->f_type); | |
| 2304 | + put_user(stfs.f_bsize, &target_stfs->f_bsize); | |
| 2305 | + put_user(stfs.f_blocks, &target_stfs->f_blocks); | |
| 2306 | + put_user(stfs.f_bfree, &target_stfs->f_bfree); | |
| 2307 | + put_user(stfs.f_bavail, &target_stfs->f_bavail); | |
| 2308 | + put_user(stfs.f_files, &target_stfs->f_files); | |
| 2309 | + put_user(stfs.f_ffree, &target_stfs->f_ffree); | |
| 2310 | + put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid); | |
| 2311 | + put_user(stfs.f_namelen, &target_stfs->f_namelen); | |
| 2315 | 2312 | } |
| 2316 | 2313 | break; |
| 2317 | 2314 | case TARGET_NR_fstatfs: |
| 2318 | - stfs = (void *)arg2; | |
| 2319 | - ret = get_errno(sys_fstatfs(arg1, stfs)); | |
| 2315 | + ret = get_errno(fstatfs(arg1, &stfs)); | |
| 2320 | 2316 | goto convert_statfs; |
| 2317 | +#ifdef TARGET_NR_statfs64 | |
| 2318 | + case TARGET_NR_statfs64: | |
| 2319 | + ret = get_errno(statfs(path((const char *)arg1), &stfs)); | |
| 2320 | + convert_statfs64: | |
| 2321 | + if (!is_error(ret)) { | |
| 2322 | + struct target_statfs64 *target_stfs = (void *)arg3; | |
| 2323 | + | |
| 2324 | + put_user(stfs.f_type, &target_stfs->f_type); | |
| 2325 | + put_user(stfs.f_bsize, &target_stfs->f_bsize); | |
| 2326 | + put_user(stfs.f_blocks, &target_stfs->f_blocks); | |
| 2327 | + put_user(stfs.f_bfree, &target_stfs->f_bfree); | |
| 2328 | + put_user(stfs.f_bavail, &target_stfs->f_bavail); | |
| 2329 | + put_user(stfs.f_files, &target_stfs->f_files); | |
| 2330 | + put_user(stfs.f_ffree, &target_stfs->f_ffree); | |
| 2331 | + put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid); | |
| 2332 | + put_user(stfs.f_namelen, &target_stfs->f_namelen); | |
| 2333 | + } | |
| 2334 | + break; | |
| 2335 | + case TARGET_NR_fstatfs64: | |
| 2336 | + ret = get_errno(fstatfs(arg1, &stfs)); | |
| 2337 | + goto convert_statfs64; | |
| 2338 | +#endif | |
| 2321 | 2339 | #ifdef TARGET_NR_ioperm |
| 2322 | 2340 | case TARGET_NR_ioperm: |
| 2323 | 2341 | goto unimplemented; | ... | ... |
linux-user/syscall_defs.h
| ... | ... | @@ -1102,6 +1102,68 @@ struct target_stat64 { |
| 1102 | 1102 | #error unsupported CPU |
| 1103 | 1103 | #endif |
| 1104 | 1104 | |
| 1105 | +#ifdef TARGET_MIPS | |
| 1106 | +struct target_statfs { | |
| 1107 | + target_long f_type; | |
| 1108 | + target_long f_bsize; | |
| 1109 | + target_long f_frsize; /* Fragment size - unsupported */ | |
| 1110 | + target_long f_blocks; | |
| 1111 | + target_long f_bfree; | |
| 1112 | + target_long f_files; | |
| 1113 | + target_long f_ffree; | |
| 1114 | + target_long f_bavail; | |
| 1115 | + | |
| 1116 | + /* Linux specials */ | |
| 1117 | + int f_fsid; | |
| 1118 | + target_long f_namelen; | |
| 1119 | + target_long f_spare[6]; | |
| 1120 | +}; | |
| 1121 | + | |
| 1122 | +struct target_statfs64 { | |
| 1123 | + uint32_t f_type; | |
| 1124 | + uint32_t f_bsize; | |
| 1125 | + uint32_t f_frsize; /* Fragment size - unsupported */ | |
| 1126 | + uint32_t __pad; | |
| 1127 | + uint64_t f_blocks; | |
| 1128 | + uint64_t f_bfree; | |
| 1129 | + uint64_t f_files; | |
| 1130 | + uint64_t f_ffree; | |
| 1131 | + uint64_t f_bavail; | |
| 1132 | + int f_fsid; | |
| 1133 | + uint32_t f_namelen; | |
| 1134 | + uint32_t f_spare[6]; | |
| 1135 | +}; | |
| 1136 | +#else | |
| 1137 | +struct target_statfs { | |
| 1138 | + uint32_t f_type; | |
| 1139 | + uint32_t f_bsize; | |
| 1140 | + uint32_t f_blocks; | |
| 1141 | + uint32_t f_bfree; | |
| 1142 | + uint32_t f_bavail; | |
| 1143 | + uint32_t f_files; | |
| 1144 | + uint32_t f_ffree; | |
| 1145 | + int f_fsid; | |
| 1146 | + uint32_t f_namelen; | |
| 1147 | + uint32_t f_frsize; | |
| 1148 | + uint32_t f_spare[5]; | |
| 1149 | +}; | |
| 1150 | + | |
| 1151 | +struct target_statfs64 { | |
| 1152 | + uint32_t f_type; | |
| 1153 | + uint32_t f_bsize; | |
| 1154 | + uint64_t f_blocks; | |
| 1155 | + uint64_t f_bfree; | |
| 1156 | + uint64_t f_bavail; | |
| 1157 | + uint64_t f_files; | |
| 1158 | + uint64_t f_ffree; | |
| 1159 | + int f_fsid; | |
| 1160 | + uint32_t f_namelen; | |
| 1161 | + uint32_t f_frsize; | |
| 1162 | + uint32_t f_spare[5]; | |
| 1163 | +}; | |
| 1164 | +#endif | |
| 1165 | + | |
| 1166 | + | |
| 1105 | 1167 | #define TARGET_F_DUPFD 0 /* dup */ |
| 1106 | 1168 | #define TARGET_F_GETFD 1 /* get close_on_exec */ |
| 1107 | 1169 | #define TARGET_F_SETFD 2 /* set/clear close_on_exec */ | ... | ... |