aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2009-04-28 10:56:39 -0400
committerMiklos Szeredi <mszeredi@suse.cz>2009-04-28 10:56:39 -0400
commitd36f248710c05714f37d921258b630bd1456b99f (patch)
tree025c84f7db1e139a08564611a1534f5bc2b8fd7a
parent8b0797a4984de4406de25808e1a424344de543e4 (diff)
fuse: don't use inode in fuse_do_ioctl() helper
Create a helper for sending an IOCTL request that doesn't use a struct inode. This prepares this function for use by CUSE, where the inode is not owned by a fuse filesystem. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
-rw-r--r--fs/fuse/file.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index ab627b40c3ea..9f0ade0b4ce8 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1647,12 +1647,11 @@ static int fuse_ioctl_copy_user(struct page **pages, struct iovec *iov,
1647 * limits ioctl data transfers to well-formed ioctls and is the forced 1647 * limits ioctl data transfers to well-formed ioctls and is the forced
1648 * behavior for all FUSE servers. 1648 * behavior for all FUSE servers.
1649 */ 1649 */
1650static long fuse_file_do_ioctl(struct file *file, unsigned int cmd, 1650static long fuse_do_ioctl(struct file *file, unsigned int cmd,
1651 unsigned long arg, unsigned int flags) 1651 unsigned long arg, unsigned int flags)
1652{ 1652{
1653 struct inode *inode = file->f_dentry->d_inode;
1654 struct fuse_file *ff = file->private_data; 1653 struct fuse_file *ff = file->private_data;
1655 struct fuse_conn *fc = get_fuse_conn(inode); 1654 struct fuse_conn *fc = ff->fc;
1656 struct fuse_ioctl_in inarg = { 1655 struct fuse_ioctl_in inarg = {
1657 .fh = ff->fh, 1656 .fh = ff->fh,
1658 .cmd = cmd, 1657 .cmd = cmd,
@@ -1671,13 +1670,6 @@ static long fuse_file_do_ioctl(struct file *file, unsigned int cmd,
1671 /* assume all the iovs returned by client always fits in a page */ 1670 /* assume all the iovs returned by client always fits in a page */
1672 BUILD_BUG_ON(sizeof(struct iovec) * FUSE_IOCTL_MAX_IOV > PAGE_SIZE); 1671 BUILD_BUG_ON(sizeof(struct iovec) * FUSE_IOCTL_MAX_IOV > PAGE_SIZE);
1673 1672
1674 if (!fuse_allow_task(fc, current))
1675 return -EACCES;
1676
1677 err = -EIO;
1678 if (is_bad_inode(inode))
1679 goto out;
1680
1681 err = -ENOMEM; 1673 err = -ENOMEM;
1682 pages = kzalloc(sizeof(pages[0]) * FUSE_MAX_PAGES_PER_REQ, GFP_KERNEL); 1674 pages = kzalloc(sizeof(pages[0]) * FUSE_MAX_PAGES_PER_REQ, GFP_KERNEL);
1683 iov_page = alloc_page(GFP_KERNEL); 1675 iov_page = alloc_page(GFP_KERNEL);
@@ -1738,7 +1730,7 @@ static long fuse_file_do_ioctl(struct file *file, unsigned int cmd,
1738 1730
1739 /* okay, let's send it to the client */ 1731 /* okay, let's send it to the client */
1740 req->in.h.opcode = FUSE_IOCTL; 1732 req->in.h.opcode = FUSE_IOCTL;
1741 req->in.h.nodeid = get_node_id(inode); 1733 req->in.h.nodeid = ff->nodeid;
1742 req->in.numargs = 1; 1734 req->in.numargs = 1;
1743 req->in.args[0].size = sizeof(inarg); 1735 req->in.args[0].size = sizeof(inarg);
1744 req->in.args[0].value = &inarg; 1736 req->in.args[0].value = &inarg;
@@ -1822,16 +1814,31 @@ static long fuse_file_do_ioctl(struct file *file, unsigned int cmd,
1822 return err ? err : outarg.result; 1814 return err ? err : outarg.result;
1823} 1815}
1824 1816
1817static long fuse_file_ioctl_common(struct file *file, unsigned int cmd,
1818 unsigned long arg, unsigned int flags)
1819{
1820 struct inode *inode = file->f_dentry->d_inode;
1821 struct fuse_conn *fc = get_fuse_conn(inode);
1822
1823 if (!fuse_allow_task(fc, current))
1824 return -EACCES;
1825
1826 if (is_bad_inode(inode))
1827 return -EIO;
1828
1829 return fuse_do_ioctl(file, cmd, arg, flags);
1830}
1831
1825static long fuse_file_ioctl(struct file *file, unsigned int cmd, 1832static long fuse_file_ioctl(struct file *file, unsigned int cmd,
1826 unsigned long arg) 1833 unsigned long arg)
1827{ 1834{
1828 return fuse_file_do_ioctl(file, cmd, arg, 0); 1835 return fuse_file_ioctl_common(file, cmd, arg, 0);
1829} 1836}
1830 1837
1831static long fuse_file_compat_ioctl(struct file *file, unsigned int cmd, 1838static long fuse_file_compat_ioctl(struct file *file, unsigned int cmd,
1832 unsigned long arg) 1839 unsigned long arg)
1833{ 1840{
1834 return fuse_file_do_ioctl(file, cmd, arg, FUSE_IOCTL_COMPAT); 1841 return fuse_file_ioctl_common(file, cmd, arg, FUSE_IOCTL_COMPAT);
1835} 1842}
1836 1843
1837/* 1844/*