Commit 2fd628fe authored by Atsushi Nemoto's avatar Atsushi Nemoto Committed by Ralf Baechle

[MIPS] Use generic compat routines for readdir, getdents

    
Not just cleanup but also fixes O32 readdir(2) emulation.
Signed-off-by: default avatarAtsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 92f22c18
......@@ -161,60 +161,6 @@ asmlinkage int sys32_execve(nabi_no_regargs struct pt_regs regs)
return error;
}
struct dirent32 {
unsigned int d_ino;
unsigned int d_off;
unsigned short d_reclen;
char d_name[NAME_MAX + 1];
};
static void
xlate_dirent(void *dirent64, void *dirent32, long n)
{
long off;
struct dirent *dirp;
struct dirent32 *dirp32;
off = 0;
while (off < n) {
dirp = (struct dirent *)(dirent64 + off);
dirp32 = (struct dirent32 *)(dirent32 + off);
off += dirp->d_reclen;
dirp32->d_ino = dirp->d_ino;
dirp32->d_off = (unsigned int)dirp->d_off;
dirp32->d_reclen = dirp->d_reclen;
strncpy(dirp32->d_name, dirp->d_name, dirp->d_reclen - ((3 * 4) + 2));
}
return;
}
asmlinkage long
sys32_getdents(unsigned int fd, void * dirent32, unsigned int count)
{
long n;
void *dirent64;
dirent64 = (void *)((unsigned long)(dirent32 + (sizeof(long) - 1)) & ~(sizeof(long) - 1));
if ((n = sys_getdents(fd, dirent64, count - (dirent64 - dirent32))) < 0)
return(n);
xlate_dirent(dirent64, dirent32, n);
return(n);
}
asmlinkage int old_readdir(unsigned int fd, void * dirent, unsigned int count);
asmlinkage int
sys32_readdir(unsigned int fd, void * dirent32, unsigned int count)
{
int n;
struct dirent dirent64;
if ((n = old_readdir(fd, &dirent64, count)) < 0)
return(n);
xlate_dirent(&dirent64, dirent32, dirent64.d_reclen);
return(n);
}
asmlinkage int
sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr, int options)
{
......
......@@ -195,7 +195,7 @@ EXPORT(sysn32_call_table)
PTR sys_fdatasync
PTR sys_truncate
PTR sys_ftruncate /* 6075 */
PTR sys32_getdents
PTR compat_sys_getdents
PTR sys_getcwd
PTR sys_chdir
PTR sys_fchdir
......
......@@ -293,7 +293,7 @@ sys_call_table:
PTR sys_uselib
PTR sys_swapon
PTR sys_reboot
PTR sys32_readdir
PTR compat_sys_old_readdir
PTR old_mmap /* 4090 */
PTR sys_munmap
PTR sys_truncate
......@@ -345,7 +345,7 @@ sys_call_table:
PTR sys_setfsuid
PTR sys_setfsgid
PTR sys32_llseek /* 4140 */
PTR sys32_getdents
PTR compat_sys_getdents
PTR compat_sys_select
PTR sys_flock
PTR sys_msync
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment