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 <[EMAIL PROTECTED]>

Index: linux/include/linux/fs.h
===================================================================
--- linux.orig/include/linux/fs.h       2005-08-23 21:00:01.000000000 +0200
+++ linux/include/linux/fs.h    2005-08-23 21:00:18.000000000 +0200
@@ -1286,6 +1286,7 @@ static inline int break_lease(struct ino
 /* 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);
Index: linux/fs/open.c
===================================================================
--- linux.orig/fs/open.c        2005-08-23 20:25:54.000000000 +0200
+++ linux/fs/open.c     2005-08-23 21:00:18.000000000 +0200
@@ -938,16 +938,11 @@ void fastcall fd_install(unsigned int fd
 
 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) {
@@ -964,6 +959,14 @@ asmlinkage long sys_open(const char __us
        }
        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__
Index: linux/arch/x86_64/ia32/sys_ia32.c
===================================================================
--- linux.orig/arch/x86_64/ia32/sys_ia32.c      2005-08-23 20:22:33.000000000 
+0200
+++ linux/arch/x86_64/ia32/sys_ia32.c   2005-08-23 21:00:19.000000000 +0200
@@ -971,28 +971,7 @@ long sys32_kill(int pid, int 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;
+       return do_sys_open(filename, flags, mode);
 }
 
 extern asmlinkage long
Index: linux/arch/ppc64/kernel/sys_ppc32.c
===================================================================
--- linux.orig/arch/ppc64/kernel/sys_ppc32.c    2005-08-23 20:22:31.000000000 
+0200
+++ linux/arch/ppc64/kernel/sys_ppc32.c 2005-08-23 21:00:19.000000000 +0200
@@ -873,29 +873,7 @@ off_t ppc32_lseek(unsigned int fd, u32 o
  */
 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;
+       return do_sys_open(filename, flags, mode);
 }
 
 /* Note: it is necessary to treat bufsiz as an unsigned int,
Index: linux/arch/ia64/ia32/sys_ia32.c
===================================================================
--- linux.orig/arch/ia64/ia32/sys_ia32.c        2005-06-17 21:48:29.000000000 
+0200
+++ linux/arch/ia64/ia32/sys_ia32.c     2005-08-23 21:00:19.000000000 +0200
@@ -2365,29 +2365,7 @@ sys32_brk (unsigned int brk)
 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;
+       return do_sys_open(filename, flags, mode);
 }
 
 /* Structure for ia32 emulation on ia64 */
Index: linux/arch/sparc64/kernel/sys_sparc32.c
===================================================================
--- linux.orig/arch/sparc64/kernel/sys_sparc32.c        2005-06-17 
21:48:29.000000000 +0200
+++ linux/arch/sparc64/kernel/sys_sparc32.c     2005-08-23 21:00:19.000000000 
+0200
@@ -1002,29 +1002,7 @@ asmlinkage long sys32_adjtimex(struct ti
 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,
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to