diff options
Diffstat (limited to 'arch/m68k/kernel/sys_m68k.c')
-rw-r--r-- | arch/m68k/kernel/sys_m68k.c | 83 |
1 files changed, 8 insertions, 75 deletions
diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c index 7deb402bfc75..218f441de667 100644 --- a/arch/m68k/kernel/sys_m68k.c +++ b/arch/m68k/kernel/sys_m68k.c | |||
@@ -29,37 +29,16 @@ | |||
29 | #include <asm/page.h> | 29 | #include <asm/page.h> |
30 | #include <asm/unistd.h> | 30 | #include <asm/unistd.h> |
31 | 31 | ||
32 | /* common code for old and new mmaps */ | ||
33 | static inline long do_mmap2( | ||
34 | unsigned long addr, unsigned long len, | ||
35 | unsigned long prot, unsigned long flags, | ||
36 | unsigned long fd, unsigned long pgoff) | ||
37 | { | ||
38 | int error = -EBADF; | ||
39 | struct file * file = NULL; | ||
40 | |||
41 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | ||
42 | if (!(flags & MAP_ANONYMOUS)) { | ||
43 | file = fget(fd); | ||
44 | if (!file) | ||
45 | goto out; | ||
46 | } | ||
47 | |||
48 | down_write(¤t->mm->mmap_sem); | ||
49 | error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); | ||
50 | up_write(¤t->mm->mmap_sem); | ||
51 | |||
52 | if (file) | ||
53 | fput(file); | ||
54 | out: | ||
55 | return error; | ||
56 | } | ||
57 | |||
58 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, | 32 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, |
59 | unsigned long prot, unsigned long flags, | 33 | unsigned long prot, unsigned long flags, |
60 | unsigned long fd, unsigned long pgoff) | 34 | unsigned long fd, unsigned long pgoff) |
61 | { | 35 | { |
62 | return do_mmap2(addr, len, prot, flags, fd, pgoff); | 36 | /* |
37 | * This is wrong for sun3 - there PAGE_SIZE is 8Kb, | ||
38 | * so we need to shift the argument down by 1; m68k mmap64(3) | ||
39 | * (in libc) expects the last argument of mmap2 in 4Kb units. | ||
40 | */ | ||
41 | return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff); | ||
63 | } | 42 | } |
64 | 43 | ||
65 | /* | 44 | /* |
@@ -90,57 +69,11 @@ asmlinkage int old_mmap(struct mmap_arg_struct __user *arg) | |||
90 | if (a.offset & ~PAGE_MASK) | 69 | if (a.offset & ~PAGE_MASK) |
91 | goto out; | 70 | goto out; |
92 | 71 | ||
93 | a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | 72 | error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, |
94 | 73 | a.offset >> PAGE_SHIFT); | |
95 | error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT); | ||
96 | out: | ||
97 | return error; | ||
98 | } | ||
99 | |||
100 | #if 0 | ||
101 | struct mmap_arg_struct64 { | ||
102 | __u32 addr; | ||
103 | __u32 len; | ||
104 | __u32 prot; | ||
105 | __u32 flags; | ||
106 | __u64 offset; /* 64 bits */ | ||
107 | __u32 fd; | ||
108 | }; | ||
109 | |||
110 | asmlinkage long sys_mmap64(struct mmap_arg_struct64 *arg) | ||
111 | { | ||
112 | int error = -EFAULT; | ||
113 | struct file * file = NULL; | ||
114 | struct mmap_arg_struct64 a; | ||
115 | unsigned long pgoff; | ||
116 | |||
117 | if (copy_from_user(&a, arg, sizeof(a))) | ||
118 | return -EFAULT; | ||
119 | |||
120 | if ((long)a.offset & ~PAGE_MASK) | ||
121 | return -EINVAL; | ||
122 | |||
123 | pgoff = a.offset >> PAGE_SHIFT; | ||
124 | if ((a.offset >> PAGE_SHIFT) != pgoff) | ||
125 | return -EINVAL; | ||
126 | |||
127 | if (!(a.flags & MAP_ANONYMOUS)) { | ||
128 | error = -EBADF; | ||
129 | file = fget(a.fd); | ||
130 | if (!file) | ||
131 | goto out; | ||
132 | } | ||
133 | a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | ||
134 | |||
135 | down_write(¤t->mm->mmap_sem); | ||
136 | error = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, pgoff); | ||
137 | up_write(¤t->mm->mmap_sem); | ||
138 | if (file) | ||
139 | fput(file); | ||
140 | out: | 74 | out: |
141 | return error; | 75 | return error; |
142 | } | 76 | } |
143 | #endif | ||
144 | 77 | ||
145 | struct sel_arg_struct { | 78 | struct sel_arg_struct { |
146 | unsigned long n; | 79 | unsigned long n; |