USB: fix u132-hcd code/data warning
[safe/jmp/linux-2.6] / fs / fuse / file.c
index ab627b4..a9f5e13 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
+#include <linux/module.h>
 
 static const struct file_operations fuse_direct_io_file_operations;
 
@@ -100,8 +101,8 @@ static void fuse_file_put(struct fuse_file *ff)
        }
 }
 
-static int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file,
-                       bool isdir)
+int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file,
+                bool isdir)
 {
        struct fuse_open_out outarg;
        struct fuse_file *ff;
@@ -128,6 +129,7 @@ static int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file,
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(fuse_do_open);
 
 void fuse_finish_open(struct inode *inode, struct file *file)
 {
@@ -232,6 +234,7 @@ void fuse_sync_release(struct fuse_file *ff, int flags)
        fuse_put_request(ff->fc, ff->reserved_req);
        kfree(ff);
 }
+EXPORT_SYMBOL_GPL(fuse_sync_release);
 
 /*
  * Scramble the ID space with XTEA, so that the value of the files_struct
@@ -825,6 +828,9 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
                if (!page)
                        break;
 
+               if (mapping_writably_mapped(mapping))
+                       flush_dcache_page(page);
+
                pagefault_disable();
                tmp = iov_iter_copy_from_user_atomic(page, ii, offset, bytes);
                pagefault_enable();
@@ -1009,8 +1015,8 @@ static int fuse_get_user_pages(struct fuse_req *req, const char __user *buf,
        return 0;
 }
 
-static ssize_t fuse_direct_io(struct file *file, const char __user *buf,
-                             size_t count, loff_t *ppos, int write)
+ssize_t fuse_direct_io(struct file *file, const char __user *buf,
+                      size_t count, loff_t *ppos, int write)
 {
        struct fuse_file *ff = file->private_data;
        struct fuse_conn *fc = ff->fc;
@@ -1060,12 +1066,14 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf,
                                break;
                }
        }
-       fuse_put_request(fc, req);
+       if (!IS_ERR(req))
+               fuse_put_request(fc, req);
        if (res > 0)
                *ppos = pos;
 
        return res;
 }
+EXPORT_SYMBOL_GPL(fuse_direct_io);
 
 static ssize_t fuse_direct_read(struct file *file, char __user *buf,
                                     size_t count, loff_t *ppos)
@@ -1309,7 +1317,7 @@ static int fuse_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
        return 0;
 }
 
-static struct vm_operations_struct fuse_file_vm_ops = {
+static const struct vm_operations_struct fuse_file_vm_ops = {
        .close          = fuse_vma_close,
        .fault          = filemap_fault,
        .page_mkwrite   = fuse_page_mkwrite,
@@ -1595,7 +1603,7 @@ static int fuse_ioctl_copy_user(struct page **pages, struct iovec *iov,
                        kaddr += copy;
                }
 
-               kunmap(map);
+               kunmap(page);
        }
 
        return 0;
@@ -1647,12 +1655,11 @@ static int fuse_ioctl_copy_user(struct page **pages, struct iovec *iov,
  * limits ioctl data transfers to well-formed ioctls and is the forced
  * behavior for all FUSE servers.
  */
-static long fuse_file_do_ioctl(struct file *file, unsigned int cmd,
-                              unsigned long arg, unsigned int flags)
+long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
+                  unsigned int flags)
 {
-       struct inode *inode = file->f_dentry->d_inode;
        struct fuse_file *ff = file->private_data;
-       struct fuse_conn *fc = get_fuse_conn(inode);
+       struct fuse_conn *fc = ff->fc;
        struct fuse_ioctl_in inarg = {
                .fh = ff->fh,
                .cmd = cmd,
@@ -1671,13 +1678,6 @@ static long fuse_file_do_ioctl(struct file *file, unsigned int cmd,
        /* assume all the iovs returned by client always fits in a page */
        BUILD_BUG_ON(sizeof(struct iovec) * FUSE_IOCTL_MAX_IOV > PAGE_SIZE);
 
-       if (!fuse_allow_task(fc, current))
-               return -EACCES;
-
-       err = -EIO;
-       if (is_bad_inode(inode))
-               goto out;
-
        err = -ENOMEM;
        pages = kzalloc(sizeof(pages[0]) * FUSE_MAX_PAGES_PER_REQ, GFP_KERNEL);
        iov_page = alloc_page(GFP_KERNEL);
@@ -1738,7 +1738,7 @@ static long fuse_file_do_ioctl(struct file *file, unsigned int cmd,
 
        /* okay, let's send it to the client */
        req->in.h.opcode = FUSE_IOCTL;
-       req->in.h.nodeid = get_node_id(inode);
+       req->in.h.nodeid = ff->nodeid;
        req->in.numargs = 1;
        req->in.args[0].size = sizeof(inarg);
        req->in.args[0].value = &inarg;
@@ -1821,17 +1821,33 @@ static long fuse_file_do_ioctl(struct file *file, unsigned int cmd,
 
        return err ? err : outarg.result;
 }
+EXPORT_SYMBOL_GPL(fuse_do_ioctl);
+
+static long fuse_file_ioctl_common(struct file *file, unsigned int cmd,
+                                  unsigned long arg, unsigned int flags)
+{
+       struct inode *inode = file->f_dentry->d_inode;
+       struct fuse_conn *fc = get_fuse_conn(inode);
+
+       if (!fuse_allow_task(fc, current))
+               return -EACCES;
+
+       if (is_bad_inode(inode))
+               return -EIO;
+
+       return fuse_do_ioctl(file, cmd, arg, flags);
+}
 
 static long fuse_file_ioctl(struct file *file, unsigned int cmd,
                            unsigned long arg)
 {
-       return fuse_file_do_ioctl(file, cmd, arg, 0);
+       return fuse_file_ioctl_common(file, cmd, arg, 0);
 }
 
 static long fuse_file_compat_ioctl(struct file *file, unsigned int cmd,
                                   unsigned long arg)
 {
-       return fuse_file_do_ioctl(file, cmd, arg, FUSE_IOCTL_COMPAT);
+       return fuse_file_ioctl_common(file, cmd, arg, FUSE_IOCTL_COMPAT);
 }
 
 /*
@@ -1885,11 +1901,10 @@ static void fuse_register_polled_file(struct fuse_conn *fc,
        spin_unlock(&fc->lock);
 }
 
-static unsigned fuse_file_poll(struct file *file, poll_table *wait)
+unsigned fuse_file_poll(struct file *file, poll_table *wait)
 {
-       struct inode *inode = file->f_dentry->d_inode;
        struct fuse_file *ff = file->private_data;
-       struct fuse_conn *fc = get_fuse_conn(inode);
+       struct fuse_conn *fc = ff->fc;
        struct fuse_poll_in inarg = { .fh = ff->fh, .kh = ff->kh };
        struct fuse_poll_out outarg;
        struct fuse_req *req;
@@ -1911,10 +1926,10 @@ static unsigned fuse_file_poll(struct file *file, poll_table *wait)
 
        req = fuse_get_req(fc);
        if (IS_ERR(req))
-               return PTR_ERR(req);
+               return POLLERR;
 
        req->in.h.opcode = FUSE_POLL;
-       req->in.h.nodeid = get_node_id(inode);
+       req->in.h.nodeid = ff->nodeid;
        req->in.numargs = 1;
        req->in.args[0].size = sizeof(inarg);
        req->in.args[0].value = &inarg;
@@ -1933,6 +1948,7 @@ static unsigned fuse_file_poll(struct file *file, poll_table *wait)
        }
        return POLLERR;
 }
+EXPORT_SYMBOL_GPL(fuse_file_poll);
 
 /*
  * This is called from fuse_handle_notify() on FUSE_NOTIFY_POLL and