fat: convert to unlocked_ioctl
[pandora-kernel.git] / fs / fat / file.c
index b28ea64..a14c2f6 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/capability.h>
 #include <linux/module.h>
+#include <linux/compat.h>
 #include <linux/mount.h>
 #include <linux/time.h>
 #include <linux/buffer_head.h>
@@ -114,9 +115,9 @@ out:
        return err;
 }
 
-int fat_generic_ioctl(struct inode *inode, struct file *filp,
-                     unsigned int cmd, unsigned long arg)
+long fat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
+       struct inode *inode = filp->f_path.dentry->d_inode;
        u32 __user *user_attr = (u32 __user *)arg;
 
        switch (cmd) {
@@ -129,12 +130,21 @@ int fat_generic_ioctl(struct inode *inode, struct file *filp,
        }
 }
 
+#ifdef CONFIG_COMPAT
+static long fat_generic_compat_ioctl(struct file *filp, unsigned int cmd,
+                                     unsigned long arg)
+
+{
+       return fat_generic_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
+}
+#endif
+
 static int fat_file_release(struct inode *inode, struct file *filp)
 {
        if ((filp->f_mode & FMODE_WRITE) &&
             MSDOS_SB(inode->i_sb)->options.flush) {
                fat_flush_inodes(inode->i_sb, inode, NULL);
-               congestion_wait(WRITE, HZ/10);
+               congestion_wait(BLK_RW_ASYNC, HZ/10);
        }
        return 0;
 }
@@ -159,7 +169,10 @@ const struct file_operations fat_file_operations = {
        .aio_write      = generic_file_aio_write,
        .mmap           = generic_file_mmap,
        .release        = fat_file_release,
-       .ioctl          = fat_generic_ioctl,
+       .unlocked_ioctl = fat_generic_ioctl,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl   = fat_generic_compat_ioctl,
+#endif
        .fsync          = fat_file_fsync,
        .splice_read    = generic_file_splice_read,
 };
@@ -176,8 +189,26 @@ static int fat_cont_expand(struct inode *inode, loff_t size)
 
        inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
        mark_inode_dirty(inode);
-       if (IS_SYNC(inode))
-               err = sync_page_range_nolock(inode, mapping, start, count);
+       if (IS_SYNC(inode)) {
+               int err2;
+
+               /*
+                * Opencode syncing since we don't have a file open to use
+                * standard fsync path.
+                */
+               err = filemap_fdatawrite_range(mapping, start,
+                                              start + count - 1);
+               err2 = sync_mapping_buffers(mapping);
+               if (!err)
+                       err = err2;
+               err2 = write_inode_now(inode, 1);
+               if (!err)
+                       err = err2;
+               if (!err) {
+                       err =  filemap_fdatawait_range(mapping, start,
+                                                      start + count - 1);
+               }
+       }
 out:
        return err;
 }