fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / fs / reiserfs / ioctl.c
index e2dbca0..fa5dbac 100644 (file)
@@ -10,6 +10,7 @@
 #include <asm/uaccess.h>
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
+#include <linux/compat.h>
 
 static int reiserfs_unpack(struct inode *inode, struct file *filp);
 
@@ -103,6 +104,40 @@ int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
        }
 }
 
+#ifdef CONFIG_COMPAT
+long reiserfs_compat_ioctl(struct file *file, unsigned int cmd,
+                               unsigned long arg)
+{
+       struct inode *inode = file->f_path.dentry->d_inode;
+       int ret;
+
+       /* These are just misnamed, they actually get/put from/to user an int */
+       switch (cmd) {
+       case REISERFS_IOC32_UNPACK:
+               cmd = REISERFS_IOC_UNPACK;
+               break;
+       case REISERFS_IOC32_GETFLAGS:
+               cmd = REISERFS_IOC_GETFLAGS;
+               break;
+       case REISERFS_IOC32_SETFLAGS:
+               cmd = REISERFS_IOC_SETFLAGS;
+               break;
+       case REISERFS_IOC32_GETVERSION:
+               cmd = REISERFS_IOC_GETVERSION;
+               break;
+       case REISERFS_IOC32_SETVERSION:
+               cmd = REISERFS_IOC_SETVERSION;
+               break;
+       default:
+               return -ENOIOCTLCMD;
+       }
+       lock_kernel();
+       ret = reiserfs_ioctl(inode, file, cmd, (unsigned long) compat_ptr(arg));
+       unlock_kernel();
+       return ret;
+}
+#endif
+
 /*
 ** reiserfs_unpack
 ** Function try to convert tail from direct item into indirect.
@@ -125,12 +160,12 @@ static int reiserfs_unpack(struct inode *inode, struct file *filp)
        if (REISERFS_I(inode)->i_flags & i_nopack_mask) {
                return 0;
        }
-       reiserfs_write_lock(inode->i_sb);
 
        /* we need to make sure nobody is changing the file size beneath
         ** us
         */
        mutex_lock(&inode->i_mutex);
+       reiserfs_write_lock(inode->i_sb);
 
        write_from = inode->i_size & (blocksize - 1);
        /* if we are on a block boundary, we are already unpacked.  */