diff options
author | Kanoj Sarcar <kanoj@engr.sgi.com> | 2000-06-23 22:31:58 +0000 |
---|---|---|
committer | Kanoj Sarcar <kanoj@engr.sgi.com> | 2000-06-23 22:31:58 +0000 |
commit | 1556b78dba02843a0aeb2b7565db3e7ed4fddaf3 (patch) | |
tree | 5c141040df585d3da9d38b03d31b7194d30c2422 /arch/mips64 | |
parent | 7f0666a4296fd7d581ee9e21f550157f24c39998 (diff) |
Sys32_fcntl from sparc to prevent procmail from confusing the kernel.
Diffstat (limited to 'arch/mips64')
-rw-r--r-- | arch/mips64/kernel/linux32.c | 61 | ||||
-rw-r--r-- | arch/mips64/kernel/scall_o32.S | 2 |
2 files changed, 62 insertions, 1 deletions
diff --git a/arch/mips64/kernel/linux32.c b/arch/mips64/kernel/linux32.c index 97a5aa051..28b3be98a 100644 --- a/arch/mips64/kernel/linux32.c +++ b/arch/mips64/kernel/linux32.c @@ -1358,3 +1358,64 @@ asmlinkage int sys32_setsockopt(int fd, int level, int optname, } return sys_setsockopt(fd, level, optname, optval, optlen); } + +struct flock32 { + short l_type; + short l_whence; + __kernel_off_t32 l_start; + __kernel_off_t32 l_len; + __kernel_pid_t32 l_pid; + short __unused; +}; + +static inline int get_flock(struct flock *kfl, struct flock32 *ufl) +{ + int err; + + err = get_user(kfl->l_type, &ufl->l_type); + err |= __get_user(kfl->l_whence, &ufl->l_whence); + err |= __get_user(kfl->l_start, &ufl->l_start); + err |= __get_user(kfl->l_len, &ufl->l_len); + err |= __get_user(kfl->l_pid, &ufl->l_pid); + return err; +} + +static inline int put_flock(struct flock *kfl, struct flock32 *ufl) +{ + int err; + + err = __put_user(kfl->l_type, &ufl->l_type); + err |= __put_user(kfl->l_whence, &ufl->l_whence); + err |= __put_user(kfl->l_start, &ufl->l_start); + err |= __put_user(kfl->l_len, &ufl->l_len); + err |= __put_user(kfl->l_pid, &ufl->l_pid); + return err; +} + +extern asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg); + +asmlinkage long sys32_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg) +{ + switch (cmd) { + case F_GETLK: + case F_SETLK: + case F_SETLKW: + { + struct flock f; + mm_segment_t old_fs; + long ret; + + if(get_flock(&f, (struct flock32 *)arg)) + return -EFAULT; + old_fs = get_fs(); set_fs (KERNEL_DS); + ret = sys_fcntl(fd, cmd, (unsigned long)&f); + set_fs (old_fs); + if(put_flock(&f, (struct flock32 *)arg)) + return -EFAULT; + return ret; + } + default: + return sys_fcntl(fd, cmd, (unsigned long)arg); + } +} + diff --git a/arch/mips64/kernel/scall_o32.S b/arch/mips64/kernel/scall_o32.S index 927a1ac2f..a6f7266eb 100644 --- a/arch/mips64/kernel/scall_o32.S +++ b/arch/mips64/kernel/scall_o32.S @@ -256,7 +256,7 @@ illegal_syscall: sys sys_umount 2 sys sys_ni_syscall 0 sys sys32_ioctl 3 - sys sys_fcntl 3 /* 4055 */ + sys sys32_fcntl 3 /* 4055 */ sys sys_ni_syscall 2 sys sys_setpgid 2 sys sys_ni_syscall, 0 |