nilfs2: add compat ioctl
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Thu, 3 Feb 2011 12:26:17 +0000 (21:26 +0900)
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Tue, 8 Mar 2011 05:58:30 +0000 (14:58 +0900)
The current FS_IOC_GETFLAGS/SETFLAGS/GETVERSION will fail if
application is 32 bit and kernel is 64 bit.

This issue is avoidable by adding compat_ioctl method.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
fs/nilfs2/dir.c
fs/nilfs2/file.c
fs/nilfs2/ioctl.c
fs/nilfs2/nilfs.h

index b72833a2cc1c34b1b77efd1a70cf9279ace69c83..3a1923943b14c9300bd8af952451efa86177c09c 100644 (file)
@@ -681,7 +681,7 @@ const struct file_operations nilfs_dir_operations = {
        .readdir        = nilfs_readdir,
        .unlocked_ioctl = nilfs_ioctl,
 #ifdef CONFIG_COMPAT
-       .compat_ioctl   = nilfs_ioctl,
+       .compat_ioctl   = nilfs_compat_ioctl,
 #endif /* CONFIG_COMPAT */
        .fsync          = nilfs_sync_file,
 
index 2f560c9fb808192cdddad3277c345e04440b1fb6..7a5e4ab15c6ee869c815c878df1b098b686915b4 100644 (file)
@@ -142,7 +142,7 @@ const struct file_operations nilfs_file_operations = {
        .aio_write      = generic_file_aio_write,
        .unlocked_ioctl = nilfs_ioctl,
 #ifdef CONFIG_COMPAT
-       .compat_ioctl   = nilfs_ioctl,
+       .compat_ioctl   = nilfs_compat_ioctl,
 #endif /* CONFIG_COMPAT */
        .mmap           = nilfs_file_mmap,
        .open           = generic_file_open,
index 3aad6413aba440b45c81272be741fb44550d6d8e..d89173edd7fed24f1e37ddac61cba678705b25b9 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/capability.h>  /* capable() */
 #include <linux/uaccess.h>     /* copy_from_user(), copy_to_user() */
 #include <linux/vmalloc.h>
+#include <linux/compat.h>      /* compat_ptr() */
 #include <linux/mount.h>       /* mnt_want_write(), mnt_drop_write() */
 #include <linux/nilfs2_fs.h>
 #include "nilfs.h"
@@ -766,3 +767,23 @@ long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
                return -ENOTTY;
        }
 }
+
+#ifdef CONFIG_COMPAT
+long nilfs_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+       switch (cmd) {
+       case FS_IOC32_GETFLAGS:
+               cmd = FS_IOC_GETFLAGS;
+               break;
+       case FS_IOC32_SETFLAGS:
+               cmd = FS_IOC_SETFLAGS;
+               break;
+       case FS_IOC32_GETVERSION:
+               cmd = FS_IOC_GETVERSION;
+               break;
+       default:
+               return -ENOIOCTLCMD;
+       }
+       return nilfs_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
+}
+#endif
index 3e3acb1fdd2ff2ff71f0bd30b8cd4d6b8a7967e5..45b1fd1d02450ee3608193ac3560c2d49233e9fd 100644 (file)
@@ -246,6 +246,7 @@ extern int nilfs_sync_file(struct file *, int);
 
 /* ioctl.c */
 long nilfs_ioctl(struct file *, unsigned int, unsigned long);
+long nilfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, struct nilfs_argv *,
                                       void **);