From 529246df96e2838b18592ed18628d2a122828be8 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Mon, 8 Jun 2020 13:57:22 -0700 Subject: [PATCH] Restore support for in-kernel ZFS ioctls In Illumos it is possible to call ioctl functions from within the kernel by passing the FKIOCTL flag. Neither FreeBSD nor Linux support that, but it doesn't hurt to keep it around, as all the code is there. Before this commit it was a dead code and zc_iflags was always zero. Restore this functionality by allowing to pass a flag to the zfsdev_ioctl_common() function. Reviewed-by: Ryan Moeller Reviewed-by: Brian Behlendorf Signed-off-by: Pawel Jakub Dawidek Closes #10417 --- include/sys/zfs_ioctl_impl.h | 2 +- module/os/freebsd/zfs/kmod_core.c | 2 +- module/os/linux/zfs/zfs_ioctl_os.c | 2 +- module/zfs/zfs_ioctl.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/sys/zfs_ioctl_impl.h b/include/sys/zfs_ioctl_impl.h index 6a0b188ea6..2da6dde877 100644 --- a/include/sys/zfs_ioctl_impl.h +++ b/include/sys/zfs_ioctl_impl.h @@ -86,7 +86,7 @@ boolean_t zfs_vfs_held(zfsvfs_t *); int zfs_vfs_ref(zfsvfs_t **); void zfs_vfs_rele(zfsvfs_t *); -long zfsdev_ioctl_common(uint_t, zfs_cmd_t *); +long zfsdev_ioctl_common(uint_t, zfs_cmd_t *, int); int zfsdev_attach(void); void zfsdev_detach(void); int zfs_kmod_init(void); diff --git a/module/os/freebsd/zfs/kmod_core.c b/module/os/freebsd/zfs/kmod_core.c index 10807afa3d..2e16cf1231 100644 --- a/module/os/freebsd/zfs/kmod_core.c +++ b/module/os/freebsd/zfs/kmod_core.c @@ -196,7 +196,7 @@ zfsdev_ioctl(struct cdev *dev, ulong_t zcmd, caddr_t arg, int flag, error = SET_ERROR(EFAULT); goto out; } - error = zfsdev_ioctl_common(vecnum, zc); + error = zfsdev_ioctl_common(vecnum, zc, 0); if (zcl) { zfs_cmd_zof_to_bsd12(zc, zcl); rc = copyout(zcl, uaddr, sizeof (*zcl)); diff --git a/module/os/linux/zfs/zfs_ioctl_os.c b/module/os/linux/zfs/zfs_ioctl_os.c index acaead68fa..0689747997 100644 --- a/module/os/linux/zfs/zfs_ioctl_os.c +++ b/module/os/linux/zfs/zfs_ioctl_os.c @@ -191,7 +191,7 @@ zfsdev_ioctl(struct file *filp, unsigned cmd, unsigned long arg) error = -SET_ERROR(EFAULT); goto out; } - error = -zfsdev_ioctl_common(vecnum, zc); + error = -zfsdev_ioctl_common(vecnum, zc, 0); rc = ddi_copyout(zc, (void *)(uintptr_t)arg, sizeof (zfs_cmd_t), 0); if (error == 0 && rc != 0) error = -SET_ERROR(EFAULT); diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index 6e7e9b9f09..8b6dca18c1 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -7375,9 +7375,9 @@ zfsdev_minor_alloc(void) } long -zfsdev_ioctl_common(uint_t vecnum, zfs_cmd_t *zc) +zfsdev_ioctl_common(uint_t vecnum, zfs_cmd_t *zc, int flag) { - int error, cmd, flag = 0; + int error, cmd; const zfs_ioc_vec_t *vec; char *saved_poolname = NULL; nvlist_t *innvl = NULL;