Skip to content

Commit 8d09807

Browse files
committed
gfs2: add compat_ioctl support
Out of the four ioctl commands supported on gfs2, only FITRIM works in compat mode. Add a proper handler based on the ext4 implementation. Fixes: 6ddc5c3 ("gfs2: getlabel support") Reviewed-by: Bob Peterson <rpeterso@redhat.com> Cc: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent 0581f18 commit 8d09807

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

‎fs/gfs2/file.c‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <linux/slab.h>
88
#include <linux/spinlock.h>
9+
#include <linux/compat.h>
910
#include <linux/completion.h>
1011
#include <linux/buffer_head.h>
1112
#include <linux/pagemap.h>
@@ -354,6 +355,31 @@ static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
354355
return -ENOTTY;
355356
}
356357

358+
#ifdef CONFIG_COMPAT
359+
static long gfs2_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
360+
{
361+
switch(cmd) {
362+
/* These are just misnamed, they actually get/put from/to user an int */
363+
case FS_IOC32_GETFLAGS:
364+
cmd = FS_IOC_GETFLAGS;
365+
break;
366+
case FS_IOC32_SETFLAGS:
367+
cmd = FS_IOC_SETFLAGS;
368+
break;
369+
/* Keep this list in sync with gfs2_ioctl */
370+
case FITRIM:
371+
case FS_IOC_GETFSLABEL:
372+
break;
373+
default:
374+
return -ENOIOCTLCMD;
375+
}
376+
377+
return gfs2_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
378+
}
379+
#else
380+
#define gfs2_compat_ioctl NULL
381+
#endif
382+
357383
/**
358384
* gfs2_size_hint - Give a hint to the size of a write request
359385
* @filep: The struct file
@@ -1293,6 +1319,7 @@ const struct file_operations gfs2_file_fops = {
12931319
.write_iter = gfs2_file_write_iter,
12941320
.iopoll = iomap_dio_iopoll,
12951321
.unlocked_ioctl = gfs2_ioctl,
1322+
.compat_ioctl = gfs2_compat_ioctl,
12961323
.mmap = gfs2_mmap,
12971324
.open = gfs2_open,
12981325
.release = gfs2_release,
@@ -1308,6 +1335,7 @@ const struct file_operations gfs2_file_fops = {
13081335
const struct file_operations gfs2_dir_fops = {
13091336
.iterate_shared = gfs2_readdir,
13101337
.unlocked_ioctl = gfs2_ioctl,
1338+
.compat_ioctl = gfs2_compat_ioctl,
13111339
.open = gfs2_open,
13121340
.release = gfs2_release,
13131341
.fsync = gfs2_fsync,
@@ -1324,6 +1352,7 @@ const struct file_operations gfs2_file_fops_nolock = {
13241352
.write_iter = gfs2_file_write_iter,
13251353
.iopoll = iomap_dio_iopoll,
13261354
.unlocked_ioctl = gfs2_ioctl,
1355+
.compat_ioctl = gfs2_compat_ioctl,
13271356
.mmap = gfs2_mmap,
13281357
.open = gfs2_open,
13291358
.release = gfs2_release,
@@ -1337,6 +1366,7 @@ const struct file_operations gfs2_file_fops_nolock = {
13371366
const struct file_operations gfs2_dir_fops_nolock = {
13381367
.iterate_shared = gfs2_readdir,
13391368
.unlocked_ioctl = gfs2_ioctl,
1369+
.compat_ioctl = gfs2_compat_ioctl,
13401370
.open = gfs2_open,
13411371
.release = gfs2_release,
13421372
.fsync = gfs2_fsync,

0 commit comments

Comments
 (0)