Commit 828b1c50 authored by Ryusuke Konishi's avatar Ryusuke Konishi

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: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
parent cde98f0f
...@@ -681,7 +681,7 @@ const struct file_operations nilfs_dir_operations = { ...@@ -681,7 +681,7 @@ const struct file_operations nilfs_dir_operations = {
.readdir = nilfs_readdir, .readdir = nilfs_readdir,
.unlocked_ioctl = nilfs_ioctl, .unlocked_ioctl = nilfs_ioctl,
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
.compat_ioctl = nilfs_ioctl, .compat_ioctl = nilfs_compat_ioctl,
#endif /* CONFIG_COMPAT */ #endif /* CONFIG_COMPAT */
.fsync = nilfs_sync_file, .fsync = nilfs_sync_file,
......
...@@ -142,7 +142,7 @@ const struct file_operations nilfs_file_operations = { ...@@ -142,7 +142,7 @@ const struct file_operations nilfs_file_operations = {
.aio_write = generic_file_aio_write, .aio_write = generic_file_aio_write,
.unlocked_ioctl = nilfs_ioctl, .unlocked_ioctl = nilfs_ioctl,
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
.compat_ioctl = nilfs_ioctl, .compat_ioctl = nilfs_compat_ioctl,
#endif /* CONFIG_COMPAT */ #endif /* CONFIG_COMPAT */
.mmap = nilfs_file_mmap, .mmap = nilfs_file_mmap,
.open = generic_file_open, .open = generic_file_open,
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/capability.h> /* capable() */ #include <linux/capability.h> /* capable() */
#include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */ #include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/compat.h> /* compat_ptr() */
#include <linux/mount.h> /* mnt_want_write(), mnt_drop_write() */ #include <linux/mount.h> /* mnt_want_write(), mnt_drop_write() */
#include <linux/nilfs2_fs.h> #include <linux/nilfs2_fs.h>
#include "nilfs.h" #include "nilfs.h"
...@@ -766,3 +767,23 @@ long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -766,3 +767,23 @@ long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
return -ENOTTY; 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
...@@ -246,6 +246,7 @@ extern int nilfs_sync_file(struct file *, int); ...@@ -246,6 +246,7 @@ extern int nilfs_sync_file(struct file *, int);
/* ioctl.c */ /* ioctl.c */
long nilfs_ioctl(struct file *, unsigned int, unsigned long); 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 *, int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, struct nilfs_argv *,
void **); void **);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment