[PATCH] sparc64: Fix stat

Like Alpha, sparc64's struct stat was defined before we had the
nanosecond et al. fields added. So like Alpha I have to cons up a
struct stat64 to get this stuff. I'll work on the glibc bits soon.

Also, we were forgetting to fill in the nanosecond fields in the sparc
compat stat64 syscalls.

Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by David S. Miller and committed by Linus Torvalds 0ba4da03 0b2cad2f

+129 -48
+65 -3
arch/sparc64/kernel/sys_sparc32.c
··· 352 352 err |= put_user(old_encode_dev(stat->rdev), &statbuf->st_rdev); 353 353 err |= put_user(stat->size, &statbuf->st_size); 354 354 err |= put_user(stat->atime.tv_sec, &statbuf->st_atime); 355 - err |= put_user(0, &statbuf->__unused1); 355 + err |= put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec); 356 356 err |= put_user(stat->mtime.tv_sec, &statbuf->st_mtime); 357 - err |= put_user(0, &statbuf->__unused2); 357 + err |= put_user(stat->mtime.tv_nsec, &statbuf->st_mtime_nsec); 358 358 err |= put_user(stat->ctime.tv_sec, &statbuf->st_ctime); 359 - err |= put_user(0, &statbuf->__unused3); 359 + err |= put_user(stat->ctime.tv_nsec, &statbuf->st_ctime_nsec); 360 360 err |= put_user(stat->blksize, &statbuf->st_blksize); 361 361 err |= put_user(stat->blocks, &statbuf->st_blocks); 362 362 err |= put_user(0, &statbuf->__unused4[0]); 363 363 err |= put_user(0, &statbuf->__unused4[1]); 364 364 365 365 return err; 366 + } 367 + 368 + int cp_compat_stat64(struct kstat *stat, struct compat_stat64 __user *statbuf) 369 + { 370 + int err; 371 + 372 + err = put_user(huge_encode_dev(stat->dev), &statbuf->st_dev); 373 + err |= put_user(stat->ino, &statbuf->st_ino); 374 + err |= put_user(stat->mode, &statbuf->st_mode); 375 + err |= put_user(stat->nlink, &statbuf->st_nlink); 376 + err |= put_user(stat->uid, &statbuf->st_uid); 377 + err |= put_user(stat->gid, &statbuf->st_gid); 378 + err |= put_user(huge_encode_dev(stat->rdev), &statbuf->st_rdev); 379 + err |= put_user(0, (unsigned long __user *) &statbuf->__pad3[0]); 380 + err |= put_user(stat->size, &statbuf->st_size); 381 + err |= put_user(stat->blksize, &statbuf->st_blksize); 382 + err |= put_user(0, (unsigned int __user *) &statbuf->__pad4[0]); 383 + err |= put_user(0, (unsigned int __user *) &statbuf->__pad4[4]); 384 + err |= put_user(stat->blocks, &statbuf->st_blocks); 385 + err |= put_user(stat->atime.tv_sec, &statbuf->st_atime); 386 + err |= put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec); 387 + err |= put_user(stat->mtime.tv_sec, &statbuf->st_mtime); 388 + err |= put_user(stat->mtime.tv_nsec, &statbuf->st_mtime_nsec); 389 + err |= put_user(stat->ctime.tv_sec, &statbuf->st_ctime); 390 + err |= put_user(stat->ctime.tv_nsec, &statbuf->st_ctime_nsec); 391 + err |= put_user(0, &statbuf->__unused4); 392 + err |= put_user(0, &statbuf->__unused5); 393 + 394 + return err; 395 + } 396 + 397 + asmlinkage long compat_sys_stat64(char __user * filename, 398 + struct compat_stat64 __user *statbuf) 399 + { 400 + struct kstat stat; 401 + int error = vfs_stat(filename, &stat); 402 + 403 + if (!error) 404 + error = cp_compat_stat64(&stat, statbuf); 405 + return error; 406 + } 407 + 408 + asmlinkage long compat_sys_lstat64(char __user * filename, 409 + struct compat_stat64 __user *statbuf) 410 + { 411 + struct kstat stat; 412 + int error = vfs_lstat(filename, &stat); 413 + 414 + if (!error) 415 + error = cp_compat_stat64(&stat, statbuf); 416 + return error; 417 + } 418 + 419 + asmlinkage long compat_sys_fstat64(unsigned int fd, 420 + struct compat_stat64 __user * statbuf) 421 + { 422 + struct kstat stat; 423 + int error = vfs_fstat(fd, &stat); 424 + 425 + if (!error) 426 + error = cp_compat_stat64(&stat, statbuf); 427 + return error; 366 428 } 367 429 368 430 asmlinkage long compat_sys_sysfs(int option, u32 arg1, u32 arg2)
+6 -6
arch/sparc64/kernel/systbls.S
··· 32 32 .word sys32_umount, sys32_setgid16, sys32_getgid16, sys32_signal, sys32_geteuid16 33 33 /*50*/ .word sys32_getegid16, sys_acct, sys_nis_syscall, sys_getgid, compat_sys_ioctl 34 34 .word sys32_reboot, sys32_mmap2, sys_symlink, sys32_readlink, sys32_execve 35 - /*60*/ .word sys32_umask, sys_chroot, compat_sys_newfstat, sys_fstat64, sys_getpagesize 35 + /*60*/ .word sys32_umask, sys_chroot, compat_sys_newfstat, compat_sys_fstat64, sys_getpagesize 36 36 .word sys32_msync, sys_vfork, sys32_pread64, sys32_pwrite64, sys_geteuid 37 37 /*70*/ .word sys_getegid, sys_mmap, sys_setreuid, sys_munmap, sys_mprotect 38 38 .word sys_madvise, sys_vhangup, sys32_truncate64, sys_mincore, sys32_getgroups16 ··· 46 46 .word sys32_getgroups, sys32_gettimeofday, sys32_getrusage, sys_nis_syscall, sys_getcwd 47 47 /*120*/ .word compat_sys_readv, compat_sys_writev, sys32_settimeofday, sys32_fchown16, sys_fchmod 48 48 .word sys_nis_syscall, sys32_setreuid16, sys32_setregid16, sys_rename, sys_truncate 49 - /*130*/ .word sys_ftruncate, sys_flock, sys_lstat64, sys_nis_syscall, sys_nis_syscall 50 - .word sys_nis_syscall, sys32_mkdir, sys_rmdir, sys32_utimes, sys_stat64 49 + /*130*/ .word sys_ftruncate, sys_flock, compat_sys_lstat64, sys_nis_syscall, sys_nis_syscall 50 + .word sys_nis_syscall, sys32_mkdir, sys_rmdir, sys32_utimes, compat_sys_stat64 51 51 /*140*/ .word sys32_sendfile64, sys_nis_syscall, sys32_futex, sys_gettid, compat_sys_getrlimit 52 52 .word compat_sys_setrlimit, sys_pivot_root, sys32_prctl, sys_pciconfig_read, sys_pciconfig_write 53 53 /*150*/ .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_getdents64 ··· 98 98 .word sys_umount, sys_setgid, sys_getgid, sys_signal, sys_geteuid 99 99 /*50*/ .word sys_getegid, sys_acct, sys_memory_ordering, sys_nis_syscall, sys_ioctl 100 100 .word sys_reboot, sys_nis_syscall, sys_symlink, sys_readlink, sys_execve 101 - /*60*/ .word sys_umask, sys_chroot, sys_newfstat, sys_nis_syscall, sys_getpagesize 101 + /*60*/ .word sys_umask, sys_chroot, sys_newfstat, sys_stat64, sys_getpagesize 102 102 .word sys_msync, sys_vfork, sys_pread64, sys_pwrite64, sys_nis_syscall 103 103 /*70*/ .word sys_nis_syscall, sys_mmap, sys_nis_syscall, sys64_munmap, sys_mprotect 104 104 .word sys_madvise, sys_vhangup, sys_nis_syscall, sys_mincore, sys_getgroups ··· 112 112 .word sys_nis_syscall, sys_gettimeofday, sys_getrusage, sys_getsockopt, sys_getcwd 113 113 /*120*/ .word sys_readv, sys_writev, sys_settimeofday, sys_fchown, sys_fchmod 114 114 .word sys_recvfrom, sys_setreuid, sys_setregid, sys_rename, sys_truncate 115 - /*130*/ .word sys_ftruncate, sys_flock, sys_nis_syscall, sys_sendto, sys_shutdown 116 - .word sys_socketpair, sys_mkdir, sys_rmdir, sys_utimes, sys_nis_syscall 115 + /*130*/ .word sys_ftruncate, sys_flock, sys_lstat64, sys_sendto, sys_shutdown 116 + .word sys_socketpair, sys_mkdir, sys_rmdir, sys_utimes, sys_stat64 117 117 /*140*/ .word sys_sendfile64, sys_getpeername, sys_futex, sys_gettid, sys_getrlimit 118 118 .word sys_setrlimit, sys_pivot_root, sys_prctl, sys_pciconfig_read, sys_pciconfig_write 119 119 /*150*/ .word sys_getsockname, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_getdents64
+3 -3
include/asm-sparc/unistd.h
··· 79 79 #define __NR_umask 60 /* Common */ 80 80 #define __NR_chroot 61 /* Common */ 81 81 #define __NR_fstat 62 /* Common */ 82 - #define __NR_fstat64 63 /* Linux sparc32 Specific */ 82 + #define __NR_fstat64 63 /* Linux Specific */ 83 83 #define __NR_getpagesize 64 /* Common */ 84 84 #define __NR_msync 65 /* Common in newer 1.3.x revs... */ 85 85 #define __NR_vfork 66 /* Common */ ··· 148 148 #define __NR_truncate 129 /* Common */ 149 149 #define __NR_ftruncate 130 /* Common */ 150 150 #define __NR_flock 131 /* Common */ 151 - #define __NR_lstat64 132 /* Linux sparc32 Specific */ 151 + #define __NR_lstat64 132 /* Linux Specific */ 152 152 #define __NR_sendto 133 /* Common */ 153 153 #define __NR_shutdown 134 /* Common */ 154 154 #define __NR_socketpair 135 /* Common */ 155 155 #define __NR_mkdir 136 /* Common */ 156 156 #define __NR_rmdir 137 /* Common */ 157 157 #define __NR_utimes 138 /* SunOS Specific */ 158 - #define __NR_stat64 139 /* Linux sparc32 Specific */ 158 + #define __NR_stat64 139 /* Linux Specific */ 159 159 #define __NR_sendfile64 140 /* adjtime under SunOS */ 160 160 #define __NR_getpeername 141 /* Common */ 161 161 #define __NR_futex 142 /* gethostid under SunOS */
+37 -3
include/asm-sparc64/compat.h
··· 51 51 compat_dev_t st_rdev; 52 52 compat_off_t st_size; 53 53 compat_time_t st_atime; 54 - u32 __unused1; 54 + compat_ulong_t st_atime_nsec; 55 55 compat_time_t st_mtime; 56 - u32 __unused2; 56 + compat_ulong_t st_mtime_nsec; 57 57 compat_time_t st_ctime; 58 - u32 __unused3; 58 + compat_ulong_t st_ctime_nsec; 59 59 compat_off_t st_blksize; 60 60 compat_off_t st_blocks; 61 61 u32 __unused4[2]; 62 + }; 63 + 64 + struct compat_stat64 { 65 + unsigned long long st_dev; 66 + 67 + unsigned long long st_ino; 68 + 69 + unsigned int st_mode; 70 + unsigned int st_nlink; 71 + 72 + unsigned int st_uid; 73 + unsigned int st_gid; 74 + 75 + unsigned long long st_rdev; 76 + 77 + unsigned char __pad3[8]; 78 + 79 + long long st_size; 80 + unsigned int st_blksize; 81 + 82 + unsigned char __pad4[8]; 83 + unsigned int st_blocks; 84 + 85 + unsigned int st_atime; 86 + unsigned int st_atime_nsec; 87 + 88 + unsigned int st_mtime; 89 + unsigned int st_mtime_nsec; 90 + 91 + unsigned int st_ctime; 92 + unsigned int st_ctime_nsec; 93 + 94 + unsigned int __unused4; 95 + unsigned int __unused5; 62 96 }; 63 97 64 98 struct compat_flock {
+15 -30
include/asm-sparc64/stat.h
··· 21 21 unsigned long __unused4[2]; 22 22 }; 23 23 24 - #ifdef __KERNEL__ 25 - /* This is sparc32 stat64 structure. */ 26 - 27 24 struct stat64 { 28 - unsigned long long st_dev; 29 - 30 - unsigned long long st_ino; 25 + unsigned long st_dev; 26 + unsigned long st_ino; 27 + unsigned long st_nlink; 31 28 32 29 unsigned int st_mode; 33 - unsigned int st_nlink; 34 - 35 30 unsigned int st_uid; 36 31 unsigned int st_gid; 32 + unsigned int __pad0; 37 33 38 - unsigned long long st_rdev; 34 + unsigned long st_rdev; 35 + long st_size; 36 + long st_blksize; 37 + long st_blocks; 39 38 40 - unsigned char __pad3[8]; 41 - 42 - long long st_size; 43 - unsigned int st_blksize; 44 - 45 - unsigned char __pad4[8]; 46 - unsigned int st_blocks; 47 - 48 - unsigned int st_atime; 49 - unsigned int st_atime_nsec; 50 - 51 - unsigned int st_mtime; 52 - unsigned int st_mtime_nsec; 53 - 54 - unsigned int st_ctime; 55 - unsigned int st_ctime_nsec; 56 - 57 - unsigned int __unused4; 58 - unsigned int __unused5; 39 + unsigned long st_atime; 40 + unsigned long st_atime_nsec; 41 + unsigned long st_mtime; 42 + unsigned long st_mtime_nsec; 43 + unsigned long st_ctime; 44 + unsigned long st_ctime_nsec; 45 + long __unused[3]; 59 46 }; 60 - 61 - #endif 62 47 63 48 #endif
+3 -3
include/asm-sparc64/unistd.h
··· 79 79 #define __NR_umask 60 /* Common */ 80 80 #define __NR_chroot 61 /* Common */ 81 81 #define __NR_fstat 62 /* Common */ 82 - /* #define __NR_fstat64 63 Linux sparc32 Specific */ 82 + #define __NR_fstat64 63 /* Linux Specific */ 83 83 #define __NR_getpagesize 64 /* Common */ 84 84 #define __NR_msync 65 /* Common in newer 1.3.x revs... */ 85 85 #define __NR_vfork 66 /* Common */ ··· 148 148 #define __NR_truncate 129 /* Common */ 149 149 #define __NR_ftruncate 130 /* Common */ 150 150 #define __NR_flock 131 /* Common */ 151 - /* #define __NR_lstat64 132 Linux sparc32 Specific */ 151 + #define __NR_lstat64 132 /* Linux Specific */ 152 152 #define __NR_sendto 133 /* Common */ 153 153 #define __NR_shutdown 134 /* Common */ 154 154 #define __NR_socketpair 135 /* Common */ 155 155 #define __NR_mkdir 136 /* Common */ 156 156 #define __NR_rmdir 137 /* Common */ 157 157 #define __NR_utimes 138 /* SunOS Specific */ 158 - /* #define __NR_stat64 139 Linux sparc32 Specific */ 158 + #define __NR_stat64 139 /* Linux Specific */ 159 159 #define __NR_sendfile64 140 /* adjtime under SunOS */ 160 160 #define __NR_getpeername 141 /* Common */ 161 161 #define __NR_futex 142 /* gethostid under SunOS */