Skip to content

Commit 828b1c5

Browse files
committed
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 <[email protected]>
1 parent cde98f0 commit 828b1c5

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

fs/nilfs2/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ const struct file_operations nilfs_dir_operations = {
681681
.readdir = nilfs_readdir,
682682
.unlocked_ioctl = nilfs_ioctl,
683683
#ifdef CONFIG_COMPAT
684-
.compat_ioctl = nilfs_ioctl,
684+
.compat_ioctl = nilfs_compat_ioctl,
685685
#endif /* CONFIG_COMPAT */
686686
.fsync = nilfs_sync_file,
687687

fs/nilfs2/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ const struct file_operations nilfs_file_operations = {
142142
.aio_write = generic_file_aio_write,
143143
.unlocked_ioctl = nilfs_ioctl,
144144
#ifdef CONFIG_COMPAT
145-
.compat_ioctl = nilfs_ioctl,
145+
.compat_ioctl = nilfs_compat_ioctl,
146146
#endif /* CONFIG_COMPAT */
147147
.mmap = nilfs_file_mmap,
148148
.open = generic_file_open,

fs/nilfs2/ioctl.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/capability.h> /* capable() */
2727
#include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */
2828
#include <linux/vmalloc.h>
29+
#include <linux/compat.h> /* compat_ptr() */
2930
#include <linux/mount.h> /* mnt_want_write(), mnt_drop_write() */
3031
#include <linux/nilfs2_fs.h>
3132
#include "nilfs.h"
@@ -766,3 +767,23 @@ long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
766767
return -ENOTTY;
767768
}
768769
}
770+
771+
#ifdef CONFIG_COMPAT
772+
long 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

fs/nilfs2/nilfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ extern int nilfs_sync_file(struct file *, int);
246246

247247
/* ioctl.c */
248248
long nilfs_ioctl(struct file *, unsigned int, unsigned long);
249+
long nilfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
249250
int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, struct nilfs_argv *,
250251
void **);
251252

0 commit comments

Comments
 (0)