aboutsummaryrefslogtreecommitdiffstats
path: root/module/os/linux
diff options
context:
space:
mode:
authorMatthew Macy <[email protected]>2019-12-02 10:08:27 -0800
committerBrian Behlendorf <[email protected]>2019-12-02 10:08:27 -0800
commit51420321068e905445e625def28fadc7c3625e13 (patch)
treee45349eef2df831b142fa97d5e21d86aea8cda4d /module/os/linux
parent42a826eed32cd428a3f7c796c619a854c1f8f9dd (diff)
Move zfs_cmd_t copyin/copyout to platform code
FreeBSD needs to cope with multiple version of the zfs_cmd_t structure. Allowing the platform code to pre and post process the cmd structure makes it possible to work with legacy tooling. Reviewed-by: Jorgen Lundman <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Matt Macy <[email protected]> Closes #9624
Diffstat (limited to 'module/os/linux')
-rw-r--r--module/os/linux/zfs/zfs_ioctl_os.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/module/os/linux/zfs/zfs_ioctl_os.c b/module/os/linux/zfs/zfs_ioctl_os.c
index fa47c30ea..2960832a5 100644
--- a/module/os/linux/zfs/zfs_ioctl_os.c
+++ b/module/os/linux/zfs/zfs_ioctl_os.c
@@ -168,9 +168,25 @@ static long
zfsdev_ioctl(struct file *filp, unsigned cmd, unsigned long arg)
{
uint_t vecnum;
+ zfs_cmd_t *zc;
+ int error, rc;
vecnum = cmd - ZFS_IOC_FIRST;
- return (zfsdev_ioctl_common(vecnum, arg));
+
+ zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
+
+ if (ddi_copyin((void *)(uintptr_t)arg, zc, sizeof (zfs_cmd_t), 0)) {
+ error = -SET_ERROR(EFAULT);
+ goto out;
+ }
+ error = -zfsdev_ioctl_common(vecnum, zc);
+ rc = ddi_copyout(zc, (void *)(uintptr_t)arg, sizeof (zfs_cmd_t), 0);
+ if (error == 0 && rc != 0)
+ error = -SET_ERROR(EFAULT);
+out:
+ kmem_free(zc, sizeof (zfs_cmd_t));
+ return (error);
+
}
int