Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 6ddc5c3ddf25 ("gfs2: getlabel support")
Reviewed-by: Bob Peterson <rpeterso@redhat.com>
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+30
+30
fs/gfs2/file.c
··· 6 6 7 7 #include <linux/slab.h> 8 8 #include <linux/spinlock.h> 9 + #include <linux/compat.h> 9 10 #include <linux/completion.h> 10 11 #include <linux/buffer_head.h> 11 12 #include <linux/pagemap.h> ··· 354 353 355 354 return -ENOTTY; 356 355 } 356 + 357 + #ifdef CONFIG_COMPAT 358 + static long gfs2_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 359 + { 360 + switch(cmd) { 361 + /* These are just misnamed, they actually get/put from/to user an int */ 362 + case FS_IOC32_GETFLAGS: 363 + cmd = FS_IOC_GETFLAGS; 364 + break; 365 + case FS_IOC32_SETFLAGS: 366 + cmd = FS_IOC_SETFLAGS; 367 + break; 368 + /* Keep this list in sync with gfs2_ioctl */ 369 + case FITRIM: 370 + case FS_IOC_GETFSLABEL: 371 + break; 372 + default: 373 + return -ENOIOCTLCMD; 374 + } 375 + 376 + return gfs2_ioctl(filp, cmd, (unsigned long)compat_ptr(arg)); 377 + } 378 + #else 379 + #define gfs2_compat_ioctl NULL 380 + #endif 357 381 358 382 /** 359 383 * gfs2_size_hint - Give a hint to the size of a write request ··· 1319 1293 .write_iter = gfs2_file_write_iter, 1320 1294 .iopoll = iomap_dio_iopoll, 1321 1295 .unlocked_ioctl = gfs2_ioctl, 1296 + .compat_ioctl = gfs2_compat_ioctl, 1322 1297 .mmap = gfs2_mmap, 1323 1298 .open = gfs2_open, 1324 1299 .release = gfs2_release, ··· 1335 1308 const struct file_operations gfs2_dir_fops = { 1336 1309 .iterate_shared = gfs2_readdir, 1337 1310 .unlocked_ioctl = gfs2_ioctl, 1311 + .compat_ioctl = gfs2_compat_ioctl, 1338 1312 .open = gfs2_open, 1339 1313 .release = gfs2_release, 1340 1314 .fsync = gfs2_fsync, ··· 1352 1324 .write_iter = gfs2_file_write_iter, 1353 1325 .iopoll = iomap_dio_iopoll, 1354 1326 .unlocked_ioctl = gfs2_ioctl, 1327 + .compat_ioctl = gfs2_compat_ioctl, 1355 1328 .mmap = gfs2_mmap, 1356 1329 .open = gfs2_open, 1357 1330 .release = gfs2_release, ··· 1366 1337 const struct file_operations gfs2_dir_fops_nolock = { 1367 1338 .iterate_shared = gfs2_readdir, 1368 1339 .unlocked_ioctl = gfs2_ioctl, 1340 + .compat_ioctl = gfs2_compat_ioctl, 1369 1341 .open = gfs2_open, 1370 1342 .release = gfs2_release, 1371 1343 .fsync = gfs2_fsync,