aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2006-02-21 01:59:00 -0500
committerRalf Baechle <ralf@linux-mips.org>2006-02-27 12:30:37 -0500
commit2fd628fe25e1f3d07996b0dab728ea0702f81306 (patch)
treef57882e33f96141ba59f8f188e8797adb40e42b0 /arch/mips
parent92f22c183cd669c8575767fede8fe43bb4f7bce9 (diff)
[MIPS] Use generic compat routines for readdir, getdents
Not just cleanup but also fixes O32 readdir(2) emulation. Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/kernel/linux32.c54
-rw-r--r--arch/mips/kernel/scall64-n32.S2
-rw-r--r--arch/mips/kernel/scall64-o32.S4
3 files changed, 3 insertions, 57 deletions
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index 5f68b220c26d..e00e5f6e7fdd 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -161,60 +161,6 @@ out:
161 return error; 161 return error;
162} 162}
163 163
164struct dirent32 {
165 unsigned int d_ino;
166 unsigned int d_off;
167 unsigned short d_reclen;
168 char d_name[NAME_MAX + 1];
169};
170
171static void
172xlate_dirent(void *dirent64, void *dirent32, long n)
173{
174 long off;
175 struct dirent *dirp;
176 struct dirent32 *dirp32;
177
178 off = 0;
179 while (off < n) {
180 dirp = (struct dirent *)(dirent64 + off);
181 dirp32 = (struct dirent32 *)(dirent32 + off);
182 off += dirp->d_reclen;
183 dirp32->d_ino = dirp->d_ino;
184 dirp32->d_off = (unsigned int)dirp->d_off;
185 dirp32->d_reclen = dirp->d_reclen;
186 strncpy(dirp32->d_name, dirp->d_name, dirp->d_reclen - ((3 * 4) + 2));
187 }
188 return;
189}
190
191asmlinkage long
192sys32_getdents(unsigned int fd, void * dirent32, unsigned int count)
193{
194 long n;
195 void *dirent64;
196
197 dirent64 = (void *)((unsigned long)(dirent32 + (sizeof(long) - 1)) & ~(sizeof(long) - 1));
198 if ((n = sys_getdents(fd, dirent64, count - (dirent64 - dirent32))) < 0)
199 return(n);
200 xlate_dirent(dirent64, dirent32, n);
201 return(n);
202}
203
204asmlinkage int old_readdir(unsigned int fd, void * dirent, unsigned int count);
205
206asmlinkage int
207sys32_readdir(unsigned int fd, void * dirent32, unsigned int count)
208{
209 int n;
210 struct dirent dirent64;
211
212 if ((n = old_readdir(fd, &dirent64, count)) < 0)
213 return(n);
214 xlate_dirent(&dirent64, dirent32, dirent64.d_reclen);
215 return(n);
216}
217
218asmlinkage int 164asmlinkage int
219sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr, int options) 165sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr, int options)
220{ 166{
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index d87b5446fa13..02c8267e45e7 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -195,7 +195,7 @@ EXPORT(sysn32_call_table)
195 PTR sys_fdatasync 195 PTR sys_fdatasync
196 PTR sys_truncate 196 PTR sys_truncate
197 PTR sys_ftruncate /* 6075 */ 197 PTR sys_ftruncate /* 6075 */
198 PTR sys32_getdents 198 PTR compat_sys_getdents
199 PTR sys_getcwd 199 PTR sys_getcwd
200 PTR sys_chdir 200 PTR sys_chdir
201 PTR sys_fchdir 201 PTR sys_fchdir
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 5b0414018c9a..797e0d874889 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -293,7 +293,7 @@ sys_call_table:
293 PTR sys_uselib 293 PTR sys_uselib
294 PTR sys_swapon 294 PTR sys_swapon
295 PTR sys_reboot 295 PTR sys_reboot
296 PTR sys32_readdir 296 PTR compat_sys_old_readdir
297 PTR old_mmap /* 4090 */ 297 PTR old_mmap /* 4090 */
298 PTR sys_munmap 298 PTR sys_munmap
299 PTR sys_truncate 299 PTR sys_truncate
@@ -345,7 +345,7 @@ sys_call_table:
345 PTR sys_setfsuid 345 PTR sys_setfsuid
346 PTR sys_setfsgid 346 PTR sys_setfsgid
347 PTR sys32_llseek /* 4140 */ 347 PTR sys32_llseek /* 4140 */
348 PTR sys32_getdents 348 PTR compat_sys_getdents
349 PTR compat_sys_select 349 PTR compat_sys_select
350 PTR sys_flock 350 PTR sys_flock
351 PTR sys_msync 351 PTR sys_msync