Commit f7719648 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] compat ioctl consolidation

From: Arun Sharma <arun.sharma@intel.com>, kevin.tian@intel.com

Move a whole bunch of filesystem ioctl conversion functions out of per-arch
files and into fs/compat_ioctl.c

It moves linux32_dirent to compat.h and renames it as compat_dirent. 
linux32_dirent has been eliminated from ia64.  Other archs should do the
same.

We'll leave old_linux_dirent32 as is, since it seems to be arch specific
(ia64 doesn't use it for example).
parent ca887863
......@@ -26,43 +26,11 @@
_ret; \
})
#define P(i) ((void *)(unsigned long)(i))
asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
#define CODE
#include "compat_ioctl.c"
#define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct linux32_dirent[2])
#define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct linux32_dirent[2])
static long
put_dirent32 (struct dirent *d, struct linux32_dirent *d32)
{
size_t namelen = strlen(d->d_name);
return (put_user(d->d_ino, &d32->d_ino)
|| put_user(d->d_off, &d32->d_off)
|| put_user(d->d_reclen, &d32->d_reclen)
|| copy_to_user(d32->d_name, d->d_name, namelen + 1));
}
static int vfat_ioctl32(unsigned fd, unsigned cmd, void *ptr)
{
int ret;
mm_segment_t oldfs = get_fs();
struct dirent d[2];
set_fs(KERNEL_DS);
ret = sys_ioctl(fd,cmd,(unsigned long)&d);
set_fs(oldfs);
if (!ret) {
ret |= put_dirent32(&d[0], (struct linux32_dirent *)ptr);
ret |= put_dirent32(&d[1], ((struct linux32_dirent *)ptr) + 1);
}
return ret;
}
typedef int (* ioctl32_handler_t)(unsigned int, unsigned int, unsigned long, struct file *);
#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL((cmd),sys_ioctl)
......@@ -73,8 +41,6 @@ typedef int (* ioctl32_handler_t)(unsigned int, unsigned int, unsigned long, str
};
IOCTL_TABLE_START
HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32)
HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32, vfat_ioctl32)
#define DECLARES
#include "compat_ioctl.c"
#include <linux/compat_ioctl.h>
......
......@@ -249,13 +249,6 @@ typedef struct siginfo32 {
} _sifields;
} siginfo_t32;
struct linux32_dirent {
u32 d_ino;
u32 d_off;
u16 d_reclen;
char d_name[256];
};
struct old_linux32_dirent {
u32 d_ino;
u32 d_offset;
......
......@@ -707,8 +707,8 @@ sys32_settimeofday (struct compat_timeval *tv, struct timezone *tz)
}
struct getdents32_callback {
struct linux32_dirent * current_dir;
struct linux32_dirent * previous;
struct compat_dirent * current_dir;
struct compat_dirent * previous;
int count;
int error;
};
......@@ -722,7 +722,7 @@ static int
filldir32 (void *__buf, const char *name, int namlen, loff_t offset, ino_t ino,
unsigned int d_type)
{
struct linux32_dirent * dirent;
struct compat_dirent * dirent;
struct getdents32_callback * buf = (struct getdents32_callback *) __buf;
int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1, 4);
......@@ -748,10 +748,10 @@ filldir32 (void *__buf, const char *name, int namlen, loff_t offset, ino_t ino,
}
asmlinkage long
sys32_getdents (unsigned int fd, struct linux32_dirent *dirent, unsigned int count)
sys32_getdents (unsigned int fd, struct compat_dirent *dirent, unsigned int count)
{
struct file * file;
struct linux32_dirent * lastdirent;
struct compat_dirent * lastdirent;
struct getdents32_callback buf;
int error;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -90,5 +90,12 @@ struct compat_statfs64 {
__u32 f_spare[5];
};
struct compat_dirent {
u32 d_ino;
compat_off_t d_off;
u16 d_reclen;
char d_name[256];
};
#endif /* CONFIG_COMPAT */
#endif /* _LINUX_COMPAT_H */
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