diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2005-09-06 18:18:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-07 19:57:43 -0400 |
commit | e922efc342d565a38eed3af377ff403f52148864 (patch) | |
tree | b9996a96ed1bbb6e387f7ba8216f8e43ca640398 | |
parent | ab8d11beb46f0bd0617e04205c01f5c1fe845b61 (diff) |
[PATCH] remove duplicated sys_open32() code from 64bit archs
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>
-rw-r--r-- | arch/ia64/ia32/ia32_entry.S | 2 | ||||
-rw-r--r-- | arch/ia64/ia32/sys_ia32.c | 31 | ||||
-rw-r--r-- | arch/ppc64/kernel/misc.S | 2 | ||||
-rw-r--r-- | arch/ppc64/kernel/sys_ppc32.c | 31 | ||||
-rw-r--r-- | arch/sparc64/kernel/sys_sparc32.c | 24 | ||||
-rw-r--r-- | arch/x86_64/ia32/ia32entry.S | 2 | ||||
-rw-r--r-- | arch/x86_64/ia32/sys_ia32.c | 26 | ||||
-rw-r--r-- | fs/compat.c | 10 | ||||
-rw-r--r-- | fs/open.c | 19 | ||||
-rw-r--r-- | include/linux/fs.h | 1 |
10 files changed, 26 insertions, 122 deletions
diff --git a/arch/ia64/ia32/ia32_entry.S b/arch/ia64/ia32/ia32_entry.S index 829a6d80711c..0708edb06cc4 100644 --- a/arch/ia64/ia32/ia32_entry.S +++ b/arch/ia64/ia32/ia32_entry.S | |||
@@ -215,7 +215,7 @@ ia32_syscall_table: | |||
215 | data8 sys32_fork | 215 | data8 sys32_fork |
216 | data8 sys_read | 216 | data8 sys_read |
217 | data8 sys_write | 217 | data8 sys_write |
218 | data8 sys32_open /* 5 */ | 218 | data8 compat_sys_open /* 5 */ |
219 | data8 sys_close | 219 | data8 sys_close |
220 | data8 sys32_waitpid | 220 | data8 sys32_waitpid |
221 | data8 sys_creat | 221 | data8 sys_creat |
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c index c1e20d65dd6c..e29a8a55486a 100644 --- a/arch/ia64/ia32/sys_ia32.c +++ b/arch/ia64/ia32/sys_ia32.c | |||
@@ -2359,37 +2359,6 @@ sys32_brk (unsigned int brk) | |||
2359 | return ret; | 2359 | return ret; |
2360 | } | 2360 | } |
2361 | 2361 | ||
2362 | /* | ||
2363 | * Exactly like fs/open.c:sys_open(), except that it doesn't set the O_LARGEFILE flag. | ||
2364 | */ | ||
2365 | asmlinkage long | ||
2366 | sys32_open (const char __user * filename, int flags, int mode) | ||
2367 | { | ||
2368 | char * tmp; | ||
2369 | int fd, error; | ||
2370 | |||
2371 | tmp = getname(filename); | ||
2372 | fd = PTR_ERR(tmp); | ||
2373 | if (!IS_ERR(tmp)) { | ||
2374 | fd = get_unused_fd(); | ||
2375 | if (fd >= 0) { | ||
2376 | struct file *f = filp_open(tmp, flags, mode); | ||
2377 | error = PTR_ERR(f); | ||
2378 | if (IS_ERR(f)) | ||
2379 | goto out_error; | ||
2380 | fd_install(fd, f); | ||
2381 | } | ||
2382 | out: | ||
2383 | putname(tmp); | ||
2384 | } | ||
2385 | return fd; | ||
2386 | |||
2387 | out_error: | ||
2388 | put_unused_fd(fd); | ||
2389 | fd = error; | ||
2390 | goto out; | ||
2391 | } | ||
2392 | |||
2393 | /* Structure for ia32 emulation on ia64 */ | 2362 | /* Structure for ia32 emulation on ia64 */ |
2394 | struct epoll_event32 | 2363 | struct epoll_event32 |
2395 | { | 2364 | { |
diff --git a/arch/ppc64/kernel/misc.S b/arch/ppc64/kernel/misc.S index 474df0a862bf..2164bd7b4ef6 100644 --- a/arch/ppc64/kernel/misc.S +++ b/arch/ppc64/kernel/misc.S | |||
@@ -957,7 +957,7 @@ _GLOBAL(sys_call_table32) | |||
957 | .llong .ppc_fork | 957 | .llong .ppc_fork |
958 | .llong .sys_read | 958 | .llong .sys_read |
959 | .llong .sys_write | 959 | .llong .sys_write |
960 | .llong .sys32_open /* 5 */ | 960 | .llong .compat_sys_open /* 5 */ |
961 | .llong .sys_close | 961 | .llong .sys_close |
962 | .llong .sys32_waitpid | 962 | .llong .sys32_waitpid |
963 | .llong .sys32_creat | 963 | .llong .sys32_creat |
diff --git a/arch/ppc64/kernel/sys_ppc32.c b/arch/ppc64/kernel/sys_ppc32.c index 206619080e66..214914a95a50 100644 --- a/arch/ppc64/kernel/sys_ppc32.c +++ b/arch/ppc64/kernel/sys_ppc32.c | |||
@@ -867,37 +867,6 @@ off_t ppc32_lseek(unsigned int fd, u32 offset, unsigned int origin) | |||
867 | return sys_lseek(fd, (int)offset, origin); | 867 | return sys_lseek(fd, (int)offset, origin); |
868 | } | 868 | } |
869 | 869 | ||
870 | /* | ||
871 | * This is just a version for 32-bit applications which does | ||
872 | * not force O_LARGEFILE on. | ||
873 | */ | ||
874 | asmlinkage long sys32_open(const char __user * filename, int flags, int mode) | ||
875 | { | ||
876 | char * tmp; | ||
877 | int fd, error; | ||
878 | |||
879 | tmp = getname(filename); | ||
880 | fd = PTR_ERR(tmp); | ||
881 | if (!IS_ERR(tmp)) { | ||
882 | fd = get_unused_fd(); | ||
883 | if (fd >= 0) { | ||
884 | struct file * f = filp_open(tmp, flags, mode); | ||
885 | error = PTR_ERR(f); | ||
886 | if (IS_ERR(f)) | ||
887 | goto out_error; | ||
888 | fd_install(fd, f); | ||
889 | } | ||
890 | out: | ||
891 | putname(tmp); | ||
892 | } | ||
893 | return fd; | ||
894 | |||
895 | out_error: | ||
896 | put_unused_fd(fd); | ||
897 | fd = error; | ||
898 | goto out; | ||
899 | } | ||
900 | |||
901 | /* Note: it is necessary to treat bufsiz as an unsigned int, | 870 | /* Note: it is necessary to treat bufsiz as an unsigned int, |
902 | * with the corresponding cast to a signed int to insure that the | 871 | * with the corresponding cast to a signed int to insure that the |
903 | * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) | 872 | * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) |
diff --git a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c index 1d3aa588df8a..7f6239ed2521 100644 --- a/arch/sparc64/kernel/sys_sparc32.c +++ b/arch/sparc64/kernel/sys_sparc32.c | |||
@@ -1002,29 +1002,7 @@ asmlinkage long sys32_adjtimex(struct timex32 __user *utp) | |||
1002 | asmlinkage long sparc32_open(const char __user *filename, | 1002 | asmlinkage long sparc32_open(const char __user *filename, |
1003 | int flags, int mode) | 1003 | int flags, int mode) |
1004 | { | 1004 | { |
1005 | char * tmp; | 1005 | return do_sys_open(filename, flags, mode); |
1006 | int fd, error; | ||
1007 | |||
1008 | tmp = getname(filename); | ||
1009 | fd = PTR_ERR(tmp); | ||
1010 | if (!IS_ERR(tmp)) { | ||
1011 | fd = get_unused_fd(); | ||
1012 | if (fd >= 0) { | ||
1013 | struct file * f = filp_open(tmp, flags, mode); | ||
1014 | error = PTR_ERR(f); | ||
1015 | if (IS_ERR(f)) | ||
1016 | goto out_error; | ||
1017 | fd_install(fd, f); | ||
1018 | } | ||
1019 | out: | ||
1020 | putname(tmp); | ||
1021 | } | ||
1022 | return fd; | ||
1023 | |||
1024 | out_error: | ||
1025 | put_unused_fd(fd); | ||
1026 | fd = error; | ||
1027 | goto out; | ||
1028 | } | 1006 | } |
1029 | 1007 | ||
1030 | extern unsigned long do_mremap(unsigned long addr, | 1008 | extern unsigned long do_mremap(unsigned long addr, |
diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S index c45d6a05b984..f174083d5567 100644 --- a/arch/x86_64/ia32/ia32entry.S +++ b/arch/x86_64/ia32/ia32entry.S | |||
@@ -307,7 +307,7 @@ ia32_sys_call_table: | |||
307 | .quad stub32_fork | 307 | .quad stub32_fork |
308 | .quad sys_read | 308 | .quad sys_read |
309 | .quad sys_write | 309 | .quad sys_write |
310 | .quad sys32_open /* 5 */ | 310 | .quad compat_sys_open /* 5 */ |
311 | .quad sys_close | 311 | .quad sys_close |
312 | .quad sys32_waitpid | 312 | .quad sys32_waitpid |
313 | .quad sys_creat | 313 | .quad sys_creat |
diff --git a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c index be996d1b691e..04d80406ce4f 100644 --- a/arch/x86_64/ia32/sys_ia32.c +++ b/arch/x86_64/ia32/sys_ia32.c | |||
@@ -969,32 +969,6 @@ long sys32_kill(int pid, int sig) | |||
969 | return sys_kill(pid, sig); | 969 | return sys_kill(pid, sig); |
970 | } | 970 | } |
971 | 971 | ||
972 | asmlinkage long sys32_open(const char __user * filename, int flags, int mode) | ||
973 | { | ||
974 | char * tmp; | ||
975 | int fd, error; | ||
976 | |||
977 | /* don't force O_LARGEFILE */ | ||
978 | tmp = getname(filename); | ||
979 | fd = PTR_ERR(tmp); | ||
980 | if (!IS_ERR(tmp)) { | ||
981 | fd = get_unused_fd(); | ||
982 | if (fd >= 0) { | ||
983 | struct file *f = filp_open(tmp, flags, mode); | ||
984 | error = PTR_ERR(f); | ||
985 | if (IS_ERR(f)) { | ||
986 | put_unused_fd(fd); | ||
987 | fd = error; | ||
988 | } else { | ||
989 | fsnotify_open(f->f_dentry); | ||
990 | fd_install(fd, f); | ||
991 | } | ||
992 | } | ||
993 | putname(tmp); | ||
994 | } | ||
995 | return fd; | ||
996 | } | ||
997 | |||
998 | extern asmlinkage long | 972 | extern asmlinkage long |
999 | sys_timer_create(clockid_t which_clock, | 973 | sys_timer_create(clockid_t which_clock, |
1000 | struct sigevent __user *timer_event_spec, | 974 | struct sigevent __user *timer_event_spec, |
diff --git a/fs/compat.c b/fs/compat.c index 2eb03c49b07c..8c665705c6a0 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -1275,6 +1275,16 @@ out: | |||
1275 | } | 1275 | } |
1276 | 1276 | ||
1277 | /* | 1277 | /* |
1278 | * Exactly like fs/open.c:sys_open(), except that it doesn't set the | ||
1279 | * O_LARGEFILE flag. | ||
1280 | */ | ||
1281 | asmlinkage long | ||
1282 | compat_sys_open(const char __user *filename, int flags, int mode) | ||
1283 | { | ||
1284 | return do_sys_open(filename, flags, mode); | ||
1285 | } | ||
1286 | |||
1287 | /* | ||
1278 | * compat_count() counts the number of arguments/envelopes. It is basically | 1288 | * compat_count() counts the number of arguments/envelopes. It is basically |
1279 | * a copy of count() from fs/exec.c, except that it works with 32 bit argv | 1289 | * a copy of count() from fs/exec.c, except that it works with 32 bit argv |
1280 | * and envp pointers. | 1290 | * and envp pointers. |
@@ -933,16 +933,11 @@ void fastcall fd_install(unsigned int fd, struct file * file) | |||
933 | 933 | ||
934 | EXPORT_SYMBOL(fd_install); | 934 | EXPORT_SYMBOL(fd_install); |
935 | 935 | ||
936 | asmlinkage long sys_open(const char __user * filename, int flags, int mode) | 936 | long do_sys_open(const char __user *filename, int flags, int mode) |
937 | { | 937 | { |
938 | char * tmp; | 938 | char *tmp = getname(filename); |
939 | int fd; | 939 | int fd = PTR_ERR(tmp); |
940 | 940 | ||
941 | if (force_o_largefile()) | ||
942 | flags |= O_LARGEFILE; | ||
943 | |||
944 | tmp = getname(filename); | ||
945 | fd = PTR_ERR(tmp); | ||
946 | if (!IS_ERR(tmp)) { | 941 | if (!IS_ERR(tmp)) { |
947 | fd = get_unused_fd(); | 942 | fd = get_unused_fd(); |
948 | if (fd >= 0) { | 943 | if (fd >= 0) { |
@@ -959,6 +954,14 @@ asmlinkage long sys_open(const char __user * filename, int flags, int mode) | |||
959 | } | 954 | } |
960 | return fd; | 955 | return fd; |
961 | } | 956 | } |
957 | |||
958 | asmlinkage long sys_open(const char __user *filename, int flags, int mode) | ||
959 | { | ||
960 | if (force_o_largefile()) | ||
961 | flags |= O_LARGEFILE; | ||
962 | |||
963 | return do_sys_open(filename, flags, mode); | ||
964 | } | ||
962 | EXPORT_SYMBOL_GPL(sys_open); | 965 | EXPORT_SYMBOL_GPL(sys_open); |
963 | 966 | ||
964 | #ifndef __alpha__ | 967 | #ifndef __alpha__ |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 57e294bf83f4..7e1b589842af 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1280,6 +1280,7 @@ static inline int break_lease(struct inode *inode, unsigned int mode) | |||
1280 | /* fs/open.c */ | 1280 | /* fs/open.c */ |
1281 | 1281 | ||
1282 | extern int do_truncate(struct dentry *, loff_t start); | 1282 | extern int do_truncate(struct dentry *, loff_t start); |
1283 | extern long do_sys_open(const char __user *filename, int flags, int mode); | ||
1283 | extern struct file *filp_open(const char *, int, int); | 1284 | extern struct file *filp_open(const char *, int, int); |
1284 | extern struct file * dentry_open(struct dentry *, struct vfsmount *, int); | 1285 | extern struct file * dentry_open(struct dentry *, struct vfsmount *, int); |
1285 | extern int filp_close(struct file *, fl_owner_t id); | 1286 | extern int filp_close(struct file *, fl_owner_t id); |