aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2011-02-03 07:26:17 -0500
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2011-03-08 00:58:30 -0500
commit828b1c50ae11e6dda68f8dfefe43b74c7182b157 (patch)
tree9c258f65382865edb71e06bf11007071fb058806 /fs/nilfs2
parentcde98f0f84ccff78e87235cb7b551747d6ad00de (diff)
nilfs2: add compat ioctl
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>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r--fs/nilfs2/dir.c2
-rw-r--r--fs/nilfs2/file.c2
-rw-r--r--fs/nilfs2/ioctl.c21
-rw-r--r--fs/nilfs2/nilfs.h1
4 files changed, 24 insertions, 2 deletions
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index b72833a2cc1c..3a1923943b14 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -681,7 +681,7 @@ const struct file_operations nilfs_dir_operations = {
681 .readdir = nilfs_readdir, 681 .readdir = nilfs_readdir,
682 .unlocked_ioctl = nilfs_ioctl, 682 .unlocked_ioctl = nilfs_ioctl,
683#ifdef CONFIG_COMPAT 683#ifdef CONFIG_COMPAT
684 .compat_ioctl = nilfs_ioctl, 684 .compat_ioctl = nilfs_compat_ioctl,
685#endif /* CONFIG_COMPAT */ 685#endif /* CONFIG_COMPAT */
686 .fsync = nilfs_sync_file, 686 .fsync = nilfs_sync_file,
687 687
diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c
index 2f560c9fb808..7a5e4ab15c6e 100644
--- a/fs/nilfs2/file.c
+++ b/fs/nilfs2/file.c
@@ -142,7 +142,7 @@ const struct file_operations nilfs_file_operations = {
142 .aio_write = generic_file_aio_write, 142 .aio_write = generic_file_aio_write,
143 .unlocked_ioctl = nilfs_ioctl, 143 .unlocked_ioctl = nilfs_ioctl,
144#ifdef CONFIG_COMPAT 144#ifdef CONFIG_COMPAT
145 .compat_ioctl = nilfs_ioctl, 145 .compat_ioctl = nilfs_compat_ioctl,
146#endif /* CONFIG_COMPAT */ 146#endif /* CONFIG_COMPAT */
147 .mmap = nilfs_file_mmap, 147 .mmap = nilfs_file_mmap,
148 .open = generic_file_open, 148 .open = generic_file_open,
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index 3aad6413aba4..d89173edd7fe 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -26,6 +26,7 @@
26#include <linux/capability.h> /* capable() */ 26#include <linux/capability.h> /* capable() */
27#include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */ 27#include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */
28#include <linux/vmalloc.h> 28#include <linux/vmalloc.h>
29#include <linux/compat.h> /* compat_ptr() */
29#include <linux/mount.h> /* mnt_want_write(), mnt_drop_write() */ 30#include <linux/mount.h> /* mnt_want_write(), mnt_drop_write() */
30#include <linux/nilfs2_fs.h> 31#include <linux/nilfs2_fs.h>
31#include "nilfs.h" 32#include "nilfs.h"
@@ -766,3 +767,23 @@ long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
766 return -ENOTTY; 767 return -ENOTTY;
767 } 768 }
768} 769}
770
771#ifdef CONFIG_COMPAT
772long nilfs_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
773{
774 switch (cmd) {
775 case FS_IOC32_GETFLAGS:
776 cmd = FS_IOC_GETFLAGS;
777 break;
778 case FS_IOC32_SETFLAGS:
779 cmd = FS_IOC_SETFLAGS;
780 break;
781 case FS_IOC32_GETVERSION:
782 cmd = FS_IOC_GETVERSION;
783 break;
784 default:
785 return -ENOIOCTLCMD;
786 }
787 return nilfs_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
788}
789#endif
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 3e3acb1fdd2f..45b1fd1d0245 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -246,6 +246,7 @@ extern int nilfs_sync_file(struct file *, int);
246 246
247/* ioctl.c */ 247/* ioctl.c */
248long nilfs_ioctl(struct file *, unsigned int, unsigned long); 248long nilfs_ioctl(struct file *, unsigned int, unsigned long);
249long nilfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
249int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, struct nilfs_argv *, 250int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, struct nilfs_argv *,
250 void **); 251 void **);
251 252