]> err.no Git - linux-2.6/commitdiff
[PATCH] remove duplicated sys_open32() code from 64bit archs
authorMiklos Szeredi <miklos@szeredi.hu>
Tue, 6 Sep 2005 22:18:25 +0000 (15:18 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 7 Sep 2005 23:57:43 +0000 (16:57 -0700)
64 bit architectures all implement their own compatibility sys_open(),
when in fact the difference is simply not forcing the O_LARGEFILE
flag.  So use the a common function instead.

Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Cc: <viro@parcelfarce.linux.theplanet.co.uk>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/ia64/ia32/ia32_entry.S
arch/ia64/ia32/sys_ia32.c
arch/ppc64/kernel/misc.S
arch/ppc64/kernel/sys_ppc32.c
arch/sparc64/kernel/sys_sparc32.c
arch/x86_64/ia32/ia32entry.S
arch/x86_64/ia32/sys_ia32.c
fs/compat.c
fs/open.c
include/linux/fs.h

index 829a6d80711c13827ecd5fe74d19f0ce4732a1dc..0708edb06cc4da8190f76eb4e16e1bafcb2e6833 100644 (file)
@@ -215,7 +215,7 @@ ia32_syscall_table:
        data8 sys32_fork
        data8 sys_read
        data8 sys_write
        data8 sys32_fork
        data8 sys_read
        data8 sys_write
-       data8 sys32_open          /* 5 */
+       data8 compat_sys_open     /* 5 */
        data8 sys_close
        data8 sys32_waitpid
        data8 sys_creat
        data8 sys_close
        data8 sys32_waitpid
        data8 sys_creat
index c1e20d65dd6cb4688391f928f43445aea644b66b..e29a8a55486a5e35fdc8eac3a2bb0acefc5cb062 100644 (file)
@@ -2359,37 +2359,6 @@ sys32_brk (unsigned int brk)
        return ret;
 }
 
        return ret;
 }
 
-/*
- * Exactly like fs/open.c:sys_open(), except that it doesn't set the O_LARGEFILE flag.
- */
-asmlinkage long
-sys32_open (const char __user * filename, int flags, int mode)
-{
-       char * tmp;
-       int fd, error;
-
-       tmp = getname(filename);
-       fd = PTR_ERR(tmp);
-       if (!IS_ERR(tmp)) {
-               fd = get_unused_fd();
-               if (fd >= 0) {
-                       struct file *f = filp_open(tmp, flags, mode);
-                       error = PTR_ERR(f);
-                       if (IS_ERR(f))
-                               goto out_error;
-                       fd_install(fd, f);
-               }
-out:
-               putname(tmp);
-       }
-       return fd;
-
-out_error:
-       put_unused_fd(fd);
-       fd = error;
-       goto out;
-}
-
 /* Structure for ia32 emulation on ia64 */
 struct epoll_event32
 {
 /* Structure for ia32 emulation on ia64 */
 struct epoll_event32
 {
index 474df0a862bfac60094e0e50c6ba0890f87e03c7..2164bd7b4ef61073723878922eaee94bbd2b48dd 100644 (file)
@@ -957,7 +957,7 @@ _GLOBAL(sys_call_table32)
        .llong .ppc_fork
        .llong .sys_read
        .llong .sys_write
        .llong .ppc_fork
        .llong .sys_read
        .llong .sys_write
-       .llong .sys32_open              /* 5 */
+       .llong .compat_sys_open         /* 5 */
        .llong .sys_close
        .llong .sys32_waitpid
        .llong .sys32_creat
        .llong .sys_close
        .llong .sys32_waitpid
        .llong .sys32_creat
index 206619080e669b42cfdb3003dc85e715bf6e8221..214914a95a504e546a48837995bebfa9571a7eb1 100644 (file)
@@ -867,37 +867,6 @@ off_t ppc32_lseek(unsigned int fd, u32 offset, unsigned int origin)
        return sys_lseek(fd, (int)offset, origin);
 }
 
        return sys_lseek(fd, (int)offset, origin);
 }
 
-/*
- * This is just a version for 32-bit applications which does
- * not force O_LARGEFILE on.
- */
-asmlinkage long sys32_open(const char __user * filename, int flags, int mode)
-{
-       char * tmp;
-       int fd, error;
-
-       tmp = getname(filename);
-       fd = PTR_ERR(tmp);
-       if (!IS_ERR(tmp)) {
-               fd = get_unused_fd();
-               if (fd >= 0) {
-                       struct file * f = filp_open(tmp, flags, mode);
-                       error = PTR_ERR(f);
-                       if (IS_ERR(f))
-                               goto out_error;
-                       fd_install(fd, f);
-               }
-out:
-               putname(tmp);
-       }
-       return fd;
-
-out_error:
-       put_unused_fd(fd);
-       fd = error;
-       goto out;
-}
-
 /* Note: it is necessary to treat bufsiz as an unsigned int,
  * with the corresponding cast to a signed int to insure that the 
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
 /* Note: it is necessary to treat bufsiz as an unsigned int,
  * with the corresponding cast to a signed int to insure that the 
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
index 1d3aa588df8a5a8466113947ae3d3102c021c1e1..7f6239ed252142e52c45f2921de58b339d770086 100644 (file)
@@ -1002,29 +1002,7 @@ asmlinkage long sys32_adjtimex(struct timex32 __user *utp)
 asmlinkage long sparc32_open(const char __user *filename,
                             int flags, int mode)
 {
 asmlinkage long sparc32_open(const char __user *filename,
                             int flags, int mode)
 {
-       char * tmp;
-       int fd, error;
-
-       tmp = getname(filename);
-       fd = PTR_ERR(tmp);
-       if (!IS_ERR(tmp)) {
-               fd = get_unused_fd();
-               if (fd >= 0) {
-                       struct file * f = filp_open(tmp, flags, mode);
-                       error = PTR_ERR(f);
-                       if (IS_ERR(f))
-                               goto out_error;
-                       fd_install(fd, f);
-               }
-out:
-               putname(tmp);
-       }
-       return fd;
-
-out_error:
-       put_unused_fd(fd);
-       fd = error;
-       goto out;
+       return do_sys_open(filename, flags, mode);
 }
 
 extern unsigned long do_mremap(unsigned long addr,
 }
 
 extern unsigned long do_mremap(unsigned long addr,
index c45d6a05b984f6d1e43e863e6da10b2b5f96d074..f174083d55672335bdbc0a442ae5c8fc4c2a697e 100644 (file)
@@ -307,7 +307,7 @@ ia32_sys_call_table:
        .quad stub32_fork
        .quad sys_read
        .quad sys_write
        .quad stub32_fork
        .quad sys_read
        .quad sys_write
-       .quad sys32_open                /* 5 */
+       .quad compat_sys_open           /* 5 */
        .quad sys_close
        .quad sys32_waitpid
        .quad sys_creat
        .quad sys_close
        .quad sys32_waitpid
        .quad sys_creat
index be996d1b691e19e0061391794706484f2dac18a4..04d80406ce4fed4c1a6ce646253675c65b074269 100644 (file)
@@ -969,32 +969,6 @@ long sys32_kill(int pid, int sig)
        return sys_kill(pid, sig);
 }
  
        return sys_kill(pid, sig);
 }
  
-asmlinkage long sys32_open(const char __user * filename, int flags, int mode)
-{
-       char * tmp;
-       int fd, error;
-
-       /* don't force O_LARGEFILE */
-       tmp = getname(filename);
-       fd = PTR_ERR(tmp);
-       if (!IS_ERR(tmp)) {
-               fd = get_unused_fd();
-               if (fd >= 0) {
-                       struct file *f = filp_open(tmp, flags, mode);
-                       error = PTR_ERR(f);
-                       if (IS_ERR(f)) {
-                               put_unused_fd(fd); 
-                               fd = error;
-                       } else {
-                               fsnotify_open(f->f_dentry);
-                               fd_install(fd, f);
-                       }
-               }
-               putname(tmp);
-       }
-       return fd;
-}
-
 extern asmlinkage long
 sys_timer_create(clockid_t which_clock,
                 struct sigevent __user *timer_event_spec,
 extern asmlinkage long
 sys_timer_create(clockid_t which_clock,
                 struct sigevent __user *timer_event_spec,
index 2eb03c49b07ce226cda102c5c25b0dd8884b1afd..8c665705c6a07beea9a4ead55a2184524f7ed41f 100644 (file)
@@ -1274,6 +1274,16 @@ out:
        return ret;
 }
 
        return ret;
 }
 
+/*
+ * Exactly like fs/open.c:sys_open(), except that it doesn't set the
+ * O_LARGEFILE flag.
+ */
+asmlinkage long
+compat_sys_open(const char __user *filename, int flags, int mode)
+{
+       return do_sys_open(filename, flags, mode);
+}
+
 /*
  * compat_count() counts the number of arguments/envelopes. It is basically
  * a copy of count() from fs/exec.c, except that it works with 32 bit argv
 /*
  * compat_count() counts the number of arguments/envelopes. It is basically
  * a copy of count() from fs/exec.c, except that it works with 32 bit argv
index 32bf05e2996d8054b8ced182c41471d7c3e133e6..4ee2dcc31c285dc57c6922b21e1bad80e740b6c3 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -933,16 +933,11 @@ void fastcall fd_install(unsigned int fd, struct file * file)
 
 EXPORT_SYMBOL(fd_install);
 
 
 EXPORT_SYMBOL(fd_install);
 
-asmlinkage long sys_open(const char __user * filename, int flags, int mode)
+long do_sys_open(const char __user *filename, int flags, int mode)
 {
 {
-       char * tmp;
-       int fd;
+       char *tmp = getname(filename);
+       int fd = PTR_ERR(tmp);
 
 
-       if (force_o_largefile())
-               flags |= O_LARGEFILE;
-
-       tmp = getname(filename);
-       fd = PTR_ERR(tmp);
        if (!IS_ERR(tmp)) {
                fd = get_unused_fd();
                if (fd >= 0) {
        if (!IS_ERR(tmp)) {
                fd = get_unused_fd();
                if (fd >= 0) {
@@ -959,6 +954,14 @@ asmlinkage long sys_open(const char __user * filename, int flags, int mode)
        }
        return fd;
 }
        }
        return fd;
 }
+
+asmlinkage long sys_open(const char __user *filename, int flags, int mode)
+{
+       if (force_o_largefile())
+               flags |= O_LARGEFILE;
+
+       return do_sys_open(filename, flags, mode);
+}
 EXPORT_SYMBOL_GPL(sys_open);
 
 #ifndef __alpha__
 EXPORT_SYMBOL_GPL(sys_open);
 
 #ifndef __alpha__
index 57e294bf83f441d07342b999153a68089dacb99c..7e1b589842afa2e54ac0aaee3f3dc7bd7583c979 100644 (file)
@@ -1280,6 +1280,7 @@ static inline int break_lease(struct inode *inode, unsigned int mode)
 /* fs/open.c */
 
 extern int do_truncate(struct dentry *, loff_t start);
 /* fs/open.c */
 
 extern int do_truncate(struct dentry *, loff_t start);
+extern long do_sys_open(const char __user *filename, int flags, int mode);
 extern struct file *filp_open(const char *, int, int);
 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
 extern int filp_close(struct file *, fl_owner_t id);
 extern struct file *filp_open(const char *, int, int);
 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
 extern int filp_close(struct file *, fl_owner_t id);