diff options
author | Ankit Jain <me@ankitjain.org> | 2009-06-19 14:28:07 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-06-24 08:15:27 -0400 |
commit | 3e63cbb1efca7dd3137de1bb475e2e068e38ef23 (patch) | |
tree | 5a7964068266e778e94c1348192d3c85eba4ac48 /fs/compat_ioctl.c | |
parent | 01c031945f2755c7afaaf456088543312f2b72ea (diff) |
fs: Add new pre-allocation ioctls to vfs for compatibility with legacy xfs ioctls
This patch adds ioctls to vfs for compatibility with legacy XFS
pre-allocation ioctls (XFS_IOC_*RESVP*). The implementation
effectively invokes sys_fallocate for the new ioctls.
Also handles the compat_ioctl case.
Note: These legacy ioctls are also implemented by OCFS2.
[AV: folded fixes from hch]
Signed-off-by: Ankit Jain <me@ankitjain.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/compat_ioctl.c')
-rw-r--r-- | fs/compat_ioctl.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index c135202c38b3..626c7483b4de 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/skbuff.h> | 31 | #include <linux/skbuff.h> |
32 | #include <linux/netlink.h> | 32 | #include <linux/netlink.h> |
33 | #include <linux/vt.h> | 33 | #include <linux/vt.h> |
34 | #include <linux/falloc.h> | ||
34 | #include <linux/fs.h> | 35 | #include <linux/fs.h> |
35 | #include <linux/file.h> | 36 | #include <linux/file.h> |
36 | #include <linux/ppp_defs.h> | 37 | #include <linux/ppp_defs.h> |
@@ -1779,6 +1780,41 @@ lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
1779 | return sys_ioctl(fd, cmd, (unsigned long)tn); | 1780 | return sys_ioctl(fd, cmd, (unsigned long)tn); |
1780 | } | 1781 | } |
1781 | 1782 | ||
1783 | /* on ia32 l_start is on a 32-bit boundary */ | ||
1784 | #if defined(CONFIG_IA64) || defined(CONFIG_X86_64) | ||
1785 | struct space_resv_32 { | ||
1786 | __s16 l_type; | ||
1787 | __s16 l_whence; | ||
1788 | __s64 l_start __attribute__((packed)); | ||
1789 | /* len == 0 means until end of file */ | ||
1790 | __s64 l_len __attribute__((packed)); | ||
1791 | __s32 l_sysid; | ||
1792 | __u32 l_pid; | ||
1793 | __s32 l_pad[4]; /* reserve area */ | ||
1794 | }; | ||
1795 | |||
1796 | #define FS_IOC_RESVSP_32 _IOW ('X', 40, struct space_resv_32) | ||
1797 | #define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32) | ||
1798 | |||
1799 | /* just account for different alignment */ | ||
1800 | static int compat_ioctl_preallocate(struct file *file, unsigned long arg) | ||
1801 | { | ||
1802 | struct space_resv_32 __user *p32 = (void __user *)arg; | ||
1803 | struct space_resv __user *p = compat_alloc_user_space(sizeof(*p)); | ||
1804 | |||
1805 | if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) || | ||
1806 | copy_in_user(&p->l_whence, &p32->l_whence, sizeof(s16)) || | ||
1807 | copy_in_user(&p->l_start, &p32->l_start, sizeof(s64)) || | ||
1808 | copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) || | ||
1809 | copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) || | ||
1810 | copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) || | ||
1811 | copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32))) | ||
1812 | return -EFAULT; | ||
1813 | |||
1814 | return ioctl_preallocate(file, p); | ||
1815 | } | ||
1816 | #endif | ||
1817 | |||
1782 | 1818 | ||
1783 | typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int, | 1819 | typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int, |
1784 | unsigned long, struct file *); | 1820 | unsigned long, struct file *); |
@@ -2756,6 +2792,18 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | |||
2756 | case FIOQSIZE: | 2792 | case FIOQSIZE: |
2757 | break; | 2793 | break; |
2758 | 2794 | ||
2795 | #if defined(CONFIG_IA64) || defined(CONFIG_X86_64) | ||
2796 | case FS_IOC_RESVSP_32: | ||
2797 | case FS_IOC_RESVSP64_32: | ||
2798 | error = compat_ioctl_preallocate(filp, arg); | ||
2799 | goto out_fput; | ||
2800 | #else | ||
2801 | case FS_IOC_RESVSP: | ||
2802 | case FS_IOC_RESVSP64: | ||
2803 | error = ioctl_preallocate(filp, (void __user *)arg); | ||
2804 | goto out_fput; | ||
2805 | #endif | ||
2806 | |||
2759 | case FIBMAP: | 2807 | case FIBMAP: |
2760 | case FIGETBSZ: | 2808 | case FIGETBSZ: |
2761 | case FIONREAD: | 2809 | case FIONREAD: |