]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] compat_sys_fcntl{,64} x86_64 part
authorStephen Rothwell <sfr@canb.auug.org.au>
Tue, 11 Mar 2003 01:34:10 +0000 (17:34 -0800)
committerChristoph Hellwig <hch@lst.de>
Tue, 11 Mar 2003 01:34:10 +0000 (17:34 -0800)
Here is the x86_64 part of the patch with Andi's blessing.

arch/x86_64/ia32/ia32entry.S
arch/x86_64/ia32/sys_ia32.c
include/asm-x86_64/compat.h
include/asm-x86_64/fcntl.h
include/asm-x86_64/ia32.h

index 37f1bdbec65517298d98268a069ac709f3c57245..18d762b1abc06e4cfe30cb78d0cca1e830a43487 100644 (file)
@@ -255,7 +255,7 @@ ia32_sys_call_table:
        .quad sys_umount                        /* new_umount */
        .quad ni_syscall                        /* old lock syscall holder */
        .quad sys32_ioctl
-       .quad sys32_fcntl64             /* 55 */
+       .quad compat_sys_fcntl64                /* 55 */
        .quad ni_syscall                        /* old mpx syscall holder */
        .quad sys_setpgid
        .quad ni_syscall                        /* old ulimit syscall holder */
@@ -421,7 +421,7 @@ ia32_sys_call_table:
        .quad sys_mincore
        .quad sys_madvise
        .quad sys_getdents64    /* 220 getdents64 */ 
-       .quad sys32_fcntl64     
+       .quad compat_sys_fcntl64        
        .quad sys_ni_syscall    /* tux */
        .quad sys_ni_syscall    /* security */
        .quad sys_gettid        
index 266dc29a49dad5054232920d6fb9f88e8d8f9b61..ad99f443c35bdb09a9e632fb9b67b2f5065f731e 100644 (file)
@@ -1016,102 +1016,6 @@ sys32_getrusage(int who, struct rusage32 *ru)
        return ret;
 }
 
-extern asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg);
-asmlinkage long sys32_fcntl64(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_compat_flock(&f, (struct compat_flock *)arg))
-                               return -EFAULT;
-                       old_fs = get_fs(); set_fs (KERNEL_DS);
-                       ret = sys_fcntl(fd, cmd, (unsigned long)&f);
-                       set_fs (old_fs);
-                       if (ret) return ret;
-                       if (put_compat_flock(&f, (struct compat_flock *)arg))
-                               return -EFAULT;
-                       return 0;
-               }
-       case F_GETLK64: 
-       case F_SETLK64: 
-       case F_SETLKW64: 
-               return sys32_fcntl64(fd,cmd,arg); 
-
-       default:
-               return sys_fcntl(fd, cmd, (unsigned long)arg);
-       }
-}
-
-static inline int get_flock64(struct ia32_flock64 *fl32, struct flock *fl64)
-{
-       if (access_ok(fl32, sizeof(struct ia32_flock64), VERIFY_WRITE)) {
-               int ret = __get_user(fl64->l_type, &fl32->l_type); 
-               ret |= __get_user(fl64->l_whence, &fl32->l_whence);
-               ret |= __get_user(fl64->l_start, &fl32->l_start); 
-               ret |= __get_user(fl64->l_len, &fl32->l_len); 
-               ret |= __get_user(fl64->l_pid, &fl32->l_pid); 
-               return ret; 
-               }
-       return -EFAULT; 
-}
-
-static inline int put_flock64(struct ia32_flock64 *fl32, struct flock *fl64)
-{
-       if (access_ok(fl32, sizeof(struct ia32_flock64), VERIFY_WRITE)) {
-               int ret = __put_user(fl64->l_type, &fl32->l_type); 
-               ret |= __put_user(fl64->l_whence, &fl32->l_whence);
-               ret |= __put_user(fl64->l_start, &fl32->l_start); 
-               ret |= __put_user(fl64->l_len, &fl32->l_len); 
-               ret |= __put_user(fl64->l_pid, &fl32->l_pid); 
-               return ret; 
-       }
-       return -EFAULT; 
-}
-
-asmlinkage long sys32_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
-       struct flock fl64;  
-       mm_segment_t oldfs = get_fs(); 
-       int ret = 0; 
-       int oldcmd = cmd;
-       unsigned long oldarg = arg;
-
-       switch (cmd) {
-       case F_GETLK64: 
-               cmd = F_GETLK; 
-               goto cnv;
-       case F_SETLK64: 
-               cmd = F_SETLK; 
-               goto cnv; 
-       case F_SETLKW64:
-               cmd = F_SETLKW; 
-       cnv:
-               ret = get_flock64((struct ia32_flock64 *)arg, &fl64); 
-               arg = (unsigned long)&fl64; 
-               set_fs(KERNEL_DS); 
-               break; 
-       case F_GETLK:
-       case F_SETLK:
-       case F_SETLKW:
-               return sys32_fcntl(fd,cmd,arg); 
-       }
-       if (!ret)
-               ret = sys_fcntl(fd, cmd, arg);
-       set_fs(oldfs); 
-       if (oldcmd == F_GETLK64 && !ret)
-               ret = put_flock64((struct ia32_flock64 *)oldarg, &fl64); 
-       return ret; 
-}
-
 int sys32_ni_syscall(int call)
 { 
        printk(KERN_INFO "IA32 syscall %d from %s not implemented\n", call,
index 0763ad9d8db843867c60bbc2ec109420f9c93f9b..36be83b589697954fc3d62cde9cdc6ccc1b59f29 100644 (file)
@@ -68,6 +68,22 @@ struct compat_flock {
        compat_pid_t    l_pid;
 };
 
+#define F_GETLK64      12      /*  using 'struct flock64' */
+#define F_SETLK64      13
+#define F_SETLKW64     14
+
+/*
+ * IA32 uses 4 byte alignment for 64 bit quantities,
+ * so we need to pack this structure.
+ */
+struct compat_flock64 {
+       short           l_type;
+       short           l_whence;
+       compat_loff_t   l_start;
+       compat_loff_t   l_len;
+       compat_pid_t    l_pid;
+} __attribute__((packed));
+
 struct compat_statfs {
        int             f_type;
        int             f_bsize;
@@ -88,4 +104,7 @@ typedef u32          compat_old_sigset_t;    /* at least 32 bits */
 
 typedef u32               compat_sigset_word;
 
+#define COMPAT_OFF_T_MAX       0x7fffffff
+#define COMPAT_LOFF_T_MAX      0x7fffffffffffffff
+
 #endif /* _ASM_X86_64_COMPAT_H */
index 33363eaf5a7ff7a807d173d91c56a6ab6b021350..aabf1a30a3b971cd821b0a28cd58c1c9badfcf90 100644 (file)
@@ -72,8 +72,4 @@ struct flock {
 
 #define F_LINUX_SPECIFIC_BASE  1024
 
-#ifdef __KERNEL__
-#define flock64        flock
-#endif
-
 #endif /* !_X86_64_FCNTL_H */
index cf902eaaa647dbe19bb3ed54fba2b083920a9668..a102c0ed785d752c80ef3e3d5236ac51b00fa92d 100644 (file)
  * 32 bit structures for IA32 support.
  */
 
-struct ia32_flock64 {
-       short  l_type;
-       short  l_whence;
-       loff_t l_start;  /* unnatural alignment */
-       loff_t l_len;
-       pid_t  l_pid;
-} __attribute__((packed));
-
-#define F_GETLK64      12      /*  using 'struct flock64' */
-#define F_SETLK64      13
-#define F_SETLKW64     14
-
 #include <asm/sigcontext32.h>
 
 /* signal.h */