aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Macy <[email protected]>2019-12-05 13:06:51 -0800
committerBrian Behlendorf <[email protected]>2019-12-05 13:06:51 -0800
commit054a049841879bfa4d7a8c91fbe5c7d51864e23d (patch)
treec7f63cdf70d90e07e40272b06705ed64f4a31712
parente64e84eca57966cff1314d61f5b9557876e856e3 (diff)
Add ZFS_IOC offsets for FreeBSD
FreeBSD requires three additional ioctls, they are ZFS_IOC_NEXTBOOT, ZFS_IOC_JAIL, and ZFS_IOC_UNJAIL. These have been added after the Linux-specific ioctls. The range 0x80-0xFF has been reserved for future optional platform-specific ioctls. Any platform may choose to implement these as appropriate. None of the existing ioctl numbers have been changed to maintain compatibility. For Linux no vectors have been registered for the new ioctls and they are reported as unsupported. Reviewed-by: Jorgen Lundman <[email protected]> Reviewed-by: Allan Jude <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Matt Macy <[email protected]> Closes #9667
-rw-r--r--include/sys/fs/zfs.h25
-rw-r--r--tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c27
2 files changed, 31 insertions, 21 deletions
diff --git a/include/sys/fs/zfs.h b/include/sys/fs/zfs.h
index eeb457903..1474e1f04 100644
--- a/include/sys/fs/zfs.h
+++ b/include/sys/fs/zfs.h
@@ -1190,9 +1190,13 @@ typedef enum {
*/
typedef enum zfs_ioc {
/*
- * illumos - 81/128 numbers reserved.
+ * Core features - 81/128 numbers reserved.
*/
+#ifdef __FreeBSD__
+ ZFS_IOC_FIRST = 0,
+#else
ZFS_IOC_FIRST = ('Z' << 8),
+#endif
ZFS_IOC = ZFS_IOC_FIRST,
ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST, /* 0x5a00 */
ZFS_IOC_POOL_DESTROY, /* 0x5a01 */
@@ -1280,18 +1284,15 @@ typedef enum zfs_ioc {
ZFS_IOC_WAIT, /* 0x5a53 */
/*
- * Linux - 3/64 numbers reserved.
+ * Per-platform (Optional) - 6/128 numbers reserved.
*/
- ZFS_IOC_LINUX = ('Z' << 8) + 0x80,
- ZFS_IOC_EVENTS_NEXT, /* 0x5a81 */
- ZFS_IOC_EVENTS_CLEAR, /* 0x5a82 */
- ZFS_IOC_EVENTS_SEEK, /* 0x5a83 */
-
- /*
- * FreeBSD - 1/64 numbers reserved.
- */
- ZFS_IOC_FREEBSD = ('Z' << 8) + 0xC0,
-
+ ZFS_IOC_PLATFORM = ZFS_IOC_FIRST + 0x80,
+ ZFS_IOC_EVENTS_NEXT, /* 0x81 (Linux) */
+ ZFS_IOC_EVENTS_CLEAR, /* 0x82 (Linux) */
+ ZFS_IOC_EVENTS_SEEK, /* 0x83 (Linux) */
+ ZFS_IOC_NEXTBOOT, /* 0x84 (FreeBSD) */
+ ZFS_IOC_JAIL, /* 0x85 (FreeBSD) */
+ ZFS_IOC_UNJAIL, /* 0x86 (FreeBSD) */
ZFS_IOC_LAST
} zfs_ioc_t;
diff --git a/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c b/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c
index f3392dc17..294c055f2 100644
--- a/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c
+++ b/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c
@@ -22,6 +22,7 @@
#include <string.h>
#include <strings.h>
#include <libzfs_core.h>
+#include <libzutil.h>
#include <sys/nvpair.h>
#include <sys/zfs_ioctl.h>
@@ -99,10 +100,12 @@ static unsigned ioc_skip[] = {
ZFS_IOC_SPACE_WRITTEN,
ZFS_IOC_POOL_REGUID,
ZFS_IOC_SEND_PROGRESS,
-
ZFS_IOC_EVENTS_NEXT,
ZFS_IOC_EVENTS_CLEAR,
ZFS_IOC_EVENTS_SEEK,
+ ZFS_IOC_NEXTBOOT,
+ ZFS_IOC_JAIL,
+ ZFS_IOC_UNJAIL,
};
@@ -154,7 +157,7 @@ lzc_ioctl_run(zfs_ioc_t ioc, const char *name, nvlist_t *innvl, int expected)
zc.zc_nvlist_dst_size = MAX(size * 2, 128 * 1024);
zc.zc_nvlist_dst = (uint64_t)(uintptr_t)malloc(zc.zc_nvlist_dst_size);
- if (ioctl(zfs_fd, ioc, &zc) != 0)
+ if (zfs_ioctl_fd(zfs_fd, ioc, &zc) != 0)
error = errno;
if (error != expected) {
@@ -685,7 +688,7 @@ zfs_destroy(const char *dataset)
(void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name));
zc.zc_name[sizeof (zc.zc_name) - 1] = '\0';
- err = ioctl(zfs_fd, ZFS_IOC_DESTROY, &zc);
+ err = zfs_ioctl_fd(zfs_fd, ZFS_IOC_DESTROY, &zc);
return (err == 0 ? 0 : errno);
}
@@ -858,7 +861,7 @@ zfs_ioc_input_tests(const char *pool)
if (ioc_tested[cmd])
continue;
- if (ioctl(zfs_fd, ioc, &zc) != 0 &&
+ if (zfs_ioctl_fd(zfs_fd, ioc, &zc) != 0 &&
errno != ZFS_ERR_IOC_CMD_UNAVAIL) {
(void) fprintf(stderr, "cmd %d is missing a test case "
"(%d)\n", cmd, errno);
@@ -867,9 +870,12 @@ zfs_ioc_input_tests(const char *pool)
}
enum zfs_ioc_ref {
+#ifdef __FreeBSD__
+ ZFS_IOC_BASE = 0,
+#else
ZFS_IOC_BASE = ('Z' << 8),
- LINUX_IOC_BASE = ZFS_IOC_BASE + 0x80,
- FREEBSD_IOC_BASE = ZFS_IOC_BASE + 0xC0,
+#endif
+ ZFS_IOC_PLATFORM_BASE = ZFS_IOC_BASE + 0x80,
};
/*
@@ -972,9 +978,12 @@ validate_ioc_values(void)
CHECK(ZFS_IOC_BASE + 81 == ZFS_IOC_REDACT);
CHECK(ZFS_IOC_BASE + 82 == ZFS_IOC_GET_BOOKMARK_PROPS);
CHECK(ZFS_IOC_BASE + 83 == ZFS_IOC_WAIT);
- CHECK(LINUX_IOC_BASE + 1 == ZFS_IOC_EVENTS_NEXT);
- CHECK(LINUX_IOC_BASE + 2 == ZFS_IOC_EVENTS_CLEAR);
- CHECK(LINUX_IOC_BASE + 3 == ZFS_IOC_EVENTS_SEEK);
+ CHECK(ZFS_IOC_PLATFORM_BASE + 1 == ZFS_IOC_EVENTS_NEXT);
+ CHECK(ZFS_IOC_PLATFORM_BASE + 2 == ZFS_IOC_EVENTS_CLEAR);
+ CHECK(ZFS_IOC_PLATFORM_BASE + 3 == ZFS_IOC_EVENTS_SEEK);
+ CHECK(ZFS_IOC_PLATFORM_BASE + 4 == ZFS_IOC_NEXTBOOT);
+ CHECK(ZFS_IOC_PLATFORM_BASE + 5 == ZFS_IOC_JAIL);
+ CHECK(ZFS_IOC_PLATFORM_BASE + 6 == ZFS_IOC_UNJAIL);
#undef CHECK