diff options
author | Brooks Davis <[email protected]> | 2022-10-27 22:45:44 +0100 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2022-11-07 15:55:26 -0800 |
commit | 20b867f5f716fedab675f5eac395e7e1ea54572d (patch) | |
tree | a3d54a1e59c29651ae77ca71b93fb9b81e455f32 /module/os/freebsd | |
parent | 6c89cffc2cccbca82314bf276d31512f9dc4f6ec (diff) |
freebsd: add ifdefs around legacy ioctl support
Require that ZFS_LEGACY_SUPPORT be defined for legacy ioctl support to
be built. For now, define it in zfs_ioctl_compat.h so support is always
built. This will allow systems that need never support pre-openzfs
tools a mechanism to remove support at build time. This code should
be removed once the need for tool compatability is gone.
No functional change at this time.
Reviewed-by: Ryan Moeller <[email protected]>
Reviewed-by: Richard Yao <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Brooks Davis <[email protected]>
Closes #14127
Diffstat (limited to 'module/os/freebsd')
-rw-r--r-- | module/os/freebsd/zfs/kmod_core.c | 16 | ||||
-rw-r--r-- | module/os/freebsd/zfs/zfs_ioctl_compat.c | 2 |
2 files changed, 16 insertions, 2 deletions
diff --git a/module/os/freebsd/zfs/kmod_core.c b/module/os/freebsd/zfs/kmod_core.c index 020ef6a39..6885d565e 100644 --- a/module/os/freebsd/zfs/kmod_core.c +++ b/module/os/freebsd/zfs/kmod_core.c @@ -124,7 +124,9 @@ zfsdev_ioctl(struct cdev *dev, ulong_t zcmd, caddr_t arg, int flag, int vecnum; zfs_iocparm_t *zp; zfs_cmd_t *zc; +#ifdef ZFS_LEGACY_SUPPORT zfs_cmd_legacy_t *zcl; +#endif int rc, error; void *uaddr; @@ -133,7 +135,9 @@ zfsdev_ioctl(struct cdev *dev, ulong_t zcmd, caddr_t arg, int flag, zp = (void *)arg; uaddr = (void *)zp->zfs_cmd; error = 0; +#ifdef ZFS_LEGACY_SUPPORT zcl = NULL; +#endif if (len != sizeof (zfs_iocparm_t)) { printf("len %d vecnum: %d sizeof (zfs_cmd_t) %ju\n", @@ -142,6 +146,7 @@ zfsdev_ioctl(struct cdev *dev, ulong_t zcmd, caddr_t arg, int flag, } zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP); +#ifdef ZFS_LEGACY_SUPPORT /* * Remap ioctl code for legacy user binaries */ @@ -157,22 +162,29 @@ zfsdev_ioctl(struct cdev *dev, ulong_t zcmd, caddr_t arg, int flag, goto out; } zfs_cmd_legacy_to_ozfs(zcl, zc); - } else if (copyin(uaddr, zc, sizeof (zfs_cmd_t))) { + } else +#endif + if (copyin(uaddr, zc, sizeof (zfs_cmd_t))) { error = SET_ERROR(EFAULT); goto out; } error = zfsdev_ioctl_common(vecnum, zc, 0); +#ifdef ZFS_LEGACY_SUPPORT if (zcl) { zfs_cmd_ozfs_to_legacy(zc, zcl); rc = copyout(zcl, uaddr, sizeof (*zcl)); - } else { + } else +#endif + { rc = copyout(zc, uaddr, sizeof (*zc)); } if (error == 0 && rc != 0) error = SET_ERROR(EFAULT); out: +#ifdef ZFS_LEGACY_SUPPORT if (zcl) kmem_free(zcl, sizeof (zfs_cmd_legacy_t)); +#endif kmem_free(zc, sizeof (zfs_cmd_t)); MPASS(tsd_get(rrw_tsd_key) == NULL); return (error); diff --git a/module/os/freebsd/zfs/zfs_ioctl_compat.c b/module/os/freebsd/zfs/zfs_ioctl_compat.c index 08913ab05..3ddffec91 100644 --- a/module/os/freebsd/zfs/zfs_ioctl_compat.c +++ b/module/os/freebsd/zfs/zfs_ioctl_compat.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include <sys/cmn_err.h> #include <sys/zfs_ioctl_compat.h> +#ifdef ZFS_LEGACY_SUPPORT enum zfs_ioc_legacy { ZFS_IOC_LEGACY_NONE = -1, ZFS_IOC_LEGACY_FIRST = 0, @@ -361,3 +362,4 @@ zfs_cmd_ozfs_to_legacy(zfs_cmd_t *src, zfs_cmd_legacy_t *dst) sizeof (zfs_cmd_t) - 8 - offsetof(zfs_cmd_t, zc_sendobj)); dst->zc_jailid = src->zc_zoneid; } +#endif /* ZFS_LEGACY_SUPPORT */ |