aboutsummaryrefslogtreecommitdiffstats
path: root/include/sys/fs/zfs.h
diff options
context:
space:
mode:
authorDon Brady <[email protected]>2018-09-02 15:14:01 -0400
committerBrian Behlendorf <[email protected]>2018-09-02 12:14:01 -0700
commitb83a0e2dc1b972e3ae5c0c17b714941b4604dfd6 (patch)
tree1165e7298a9ca33290ec1988da3acb4cd5065541 /include/sys/fs/zfs.h
parente8bcb693d6a19962291e4429f2dc4ce60693bef7 (diff)
Add basic zfs ioc input nvpair validation
We want newer versions of libzfs_core to run against an existing zfs kernel module (i.e. a deferred reboot or module reload after an update). Programmatically document, via a zfs_ioc_key_t, the valid arguments for the ioc commands that rely on nvpair input arguments (i.e. non legacy commands from libzfs_core). Automatically verify the expected pairs before dispatching a command. This initial phase focuses on the non-legacy ioctls. A follow-on change can address the legacy ioctl input from the zfs_cmd_t. The zfs_ioc_key_t for zfs_keys_channel_program looks like: static const zfs_ioc_key_t zfs_keys_channel_program[] = { {"program", DATA_TYPE_STRING, 0}, {"arg", DATA_TYPE_UNKNOWN, 0}, {"sync", DATA_TYPE_BOOLEAN_VALUE, ZK_OPTIONAL}, {"instrlimit", DATA_TYPE_UINT64, ZK_OPTIONAL}, {"memlimit", DATA_TYPE_UINT64, ZK_OPTIONAL}, }; Introduce four input errors to identify specific input failures (in addition to generic argument value errors like EINVAL, ERANGE, EBADF, and E2BIG). ZFS_ERR_IOC_CMD_UNAVAIL the ioctl number is not supported by kernel ZFS_ERR_IOC_ARG_UNAVAIL an input argument is not supported by kernel ZFS_ERR_IOC_ARG_REQUIRED a required input argument is missing ZFS_ERR_IOC_ARG_BADTYPE an input argument has an invalid type Reviewed-by: Matthew Ahrens <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Don Brady <[email protected]> Closes #7780
Diffstat (limited to 'include/sys/fs/zfs.h')
-rw-r--r--include/sys/fs/zfs.h176
1 files changed, 92 insertions, 84 deletions
diff --git a/include/sys/fs/zfs.h b/include/sys/fs/zfs.h
index 7daf72895..c8c7cebae 100644
--- a/include/sys/fs/zfs.h
+++ b/include/sys/fs/zfs.h
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2013, 2017 Joyent, Inc. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
@@ -1078,6 +1078,8 @@ typedef struct ddt_histogram {
/*
* /dev/zfs ioctl numbers.
+ *
+ * These numbers cannot change over time. New ioctl numbers must be appended.
*/
typedef enum zfs_ioc {
/*
@@ -1085,93 +1087,93 @@ typedef enum zfs_ioc {
*/
ZFS_IOC_FIRST = ('Z' << 8),
ZFS_IOC = ZFS_IOC_FIRST,
- ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST,
- ZFS_IOC_POOL_DESTROY,
- ZFS_IOC_POOL_IMPORT,
- ZFS_IOC_POOL_EXPORT,
- ZFS_IOC_POOL_CONFIGS,
- ZFS_IOC_POOL_STATS,
- ZFS_IOC_POOL_TRYIMPORT,
- ZFS_IOC_POOL_SCAN,
- ZFS_IOC_POOL_FREEZE,
- ZFS_IOC_POOL_UPGRADE,
- ZFS_IOC_POOL_GET_HISTORY,
- ZFS_IOC_VDEV_ADD,
- ZFS_IOC_VDEV_REMOVE,
- ZFS_IOC_VDEV_SET_STATE,
- ZFS_IOC_VDEV_ATTACH,
- ZFS_IOC_VDEV_DETACH,
- ZFS_IOC_VDEV_SETPATH,
- ZFS_IOC_VDEV_SETFRU,
- ZFS_IOC_OBJSET_STATS,
- ZFS_IOC_OBJSET_ZPLPROPS,
- ZFS_IOC_DATASET_LIST_NEXT,
- ZFS_IOC_SNAPSHOT_LIST_NEXT,
- ZFS_IOC_SET_PROP,
- ZFS_IOC_CREATE,
- ZFS_IOC_DESTROY,
- ZFS_IOC_ROLLBACK,
- ZFS_IOC_REN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- ZFS_IOC_REMAP,
- ZFS_IOC_POOL_CHECKPOINT,
- ZFS_IOC_POOL_DISCARD_CHECKPOINT,
+ ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST, /* 0x5a00 */
+ ZFS_IOC_POOL_DESTROY, /* 0x5a01 */
+ ZFS_IOC_POOL_IMPORT, /* 0x5a02 */
+ ZFS_IOC_POOL_EXPORT, /* 0x5a03 */
+ ZFS_IOC_POOL_CONFIGS, /* 0x5a04 */
+ ZFS_IOC_POOL_STATS, /* 0x5a05 */
+ ZFS_IOC_POOL_TRYIMPORT, /* 0x5a06 */
+ ZFS_IOC_POOL_SCAN, /* 0x5a07 */
+ ZFS_IOC_POOL_FREEZE, /* 0x5a08 */
+ ZFS_IOC_POOL_UPGRADE, /* 0x5a09 */
+ ZFS_IOC_POOL_GET_HISTORY, /* 0x5a0a */
+ ZFS_IOC_VDEV_ADD, /* 0x5a0b */
+ ZFS_IOC_VDEV_REMOVE, /* 0x5a0c */
+ ZFS_IOC_VDEV_SET_STATE, /* 0x5a0d */
+ ZFS_IOC_VDEV_ATTACH, /* 0x5a0e */
+ ZFS_IOC_VDEV_DETACH, /* 0x5a0f */
+ ZFS_IOC_VDEV_SETPATH, /* 0x5a10 */
+ ZFS_IOC_VDEV_SETFRU, /* 0x5a11 */
+ ZFS_IOC_OBJSET_STATS, /* 0x5a12 */
+ ZFS_IOC_OBJSET_ZPLPROPS, /* 0x5a13 */
+ ZFS_IOC_DATASET_LIST_NEXT, /* 0x5a14 */
+ ZFS_IOC_SNAPSHOT_LIST_NEXT, /* 0x5a15 */
+ ZFS_IOC_SET_PROP, /* 0x5a16 */
+ ZFS_IOC_CREATE, /* 0x5a17 */
+ ZFS_IOC_DESTROY, /* 0x5a18 */
+ ZFS_IOC_ROLLBACK, /* 0x5a19 */
+ ZFS_IOC_RENAME, /* 0x5a1a */
+ ZFS_IOC_RECV, /* 0x5a1b */
+ ZFS_IOC_SEND, /* 0x5a1c */
+ ZFS_IOC_INJECT_FAULT, /* 0x5a1d */
+ ZFS_IOC_CLEAR_FAULT, /* 0x5a1e */
+ ZFS_IOC_INJECT_LIST_NEXT, /* 0x5a1f */
+ ZFS_IOC_ERROR_LOG, /* 0x5a20 */
+ ZFS_IOC_CLEAR, /* 0x5a21 */
+ ZFS_IOC_PROMOTE, /* 0x5a22 */
+ ZFS_IOC_SNAPSHOT, /* 0x5a23 */
+ ZFS_IOC_DSOBJ_TO_DSNAME, /* 0x5a24 */
+ ZFS_IOC_OBJ_TO_PATH, /* 0x5a25 */
+ ZFS_IOC_POOL_SET_PROPS, /* 0x5a26 */
+ ZFS_IOC_POOL_GET_PROPS, /* 0x5a27 */
+ ZFS_IOC_SET_FSACL, /* 0x5a28 */
+ ZFS_IOC_GET_FSACL, /* 0x5a29 */
+ ZFS_IOC_SHARE, /* 0x5a2a */
+ ZFS_IOC_INHERIT_PROP, /* 0x5a2b */
+ ZFS_IOC_SMB_ACL, /* 0x5a2c */
+ ZFS_IOC_USERSPACE_ONE, /* 0x5a2d */
+ ZFS_IOC_USERSPACE_MANY, /* 0x5a2e */
+ ZFS_IOC_USERSPACE_UPGRADE, /* 0x5a2f */
+ ZFS_IOC_HOLD, /* 0x5a30 */
+ ZFS_IOC_RELEASE, /* 0x5a31 */
+ ZFS_IOC_GET_HOLDS, /* 0x5a32 */
+ ZFS_IOC_OBJSET_RECVD_PROPS, /* 0x5a33 */
+ ZFS_IOC_VDEV_SPLIT, /* 0x5a34 */
+ ZFS_IOC_NEXT_OBJ, /* 0x5a35 */
+ ZFS_IOC_DIFF, /* 0x5a36 */
+ ZFS_IOC_TMP_SNAPSHOT, /* 0x5a37 */
+ ZFS_IOC_OBJ_TO_STATS, /* 0x5a38 */
+ ZFS_IOC_SPACE_WRITTEN, /* 0x5a39 */
+ ZFS_IOC_SPACE_SNAPS, /* 0x5a3a */
+ ZFS_IOC_DESTROY_SNAPS, /* 0x5a3b */
+ ZFS_IOC_POOL_REGUID, /* 0x5a3c */
+ ZFS_IOC_POOL_REOPEN, /* 0x5a3d */
+ ZFS_IOC_SEND_PROGRESS, /* 0x5a3e */
+ ZFS_IOC_LOG_HISTORY, /* 0x5a3f */
+ ZFS_IOC_SEND_NEW, /* 0x5a40 */
+ ZFS_IOC_SEND_SPACE, /* 0x5a41 */
+ ZFS_IOC_CLONE, /* 0x5a42 */
+ ZFS_IOC_BOOKMARK, /* 0x5a43 */
+ ZFS_IOC_GET_BOOKMARKS, /* 0x5a44 */
+ ZFS_IOC_DESTROY_BOOKMARKS, /* 0x5a45 */
+ ZFS_IOC_CHANNEL_PROGRAM, /* 0x5a46 */
+ ZFS_IOC_RECV_NEW, /* 0x5a47 */
+ ZFS_IOC_POOL_SYNC, /* 0x5a48 */
+ ZFS_IOC_LOAD_KEY, /* 0x5a49 */
+ ZFS_IOC_UNLOAD_KEY, /* 0x5a4a */
+ ZFS_IOC_CHANGE_KEY, /* 0x5a4b */
+ ZFS_IOC_REMAP, /* 0x5a4c */
+ ZFS_IOC_POOL_CHECKPOINT, /* 0x5a4d */
+ ZFS_IOC_POOL_DISCARD_CHECKPOINT, /* 0x5a4e */
/*
* Linux - 3/64 numbers reserved.
*/
ZFS_IOC_LINUX = ('Z' << 8) + 0x80,
- ZFS_IOC_EVENTS_NEXT,
- ZFS_IOC_EVENTS_CLEAR,
- ZFS_IOC_EVENTS_SEEK,
+ ZFS_IOC_EVENTS_NEXT, /* 0x5a81 */
+ ZFS_IOC_EVENTS_CLEAR, /* 0x5a82 */
+ ZFS_IOC_EVENTS_SEEK, /* 0x5a83 */
/*
* FreeBSD - 1/64 numbers reserved.
@@ -1193,13 +1195,19 @@ typedef enum zfs_ioc {
* The enum implicitly includes all the error codes from errno.h.
* New code should use and extend this enum for errors that are
* not described precisely by generic errno codes.
+ *
+ * These numbers should not change over time. New entries should be appended.
*/
typedef enum {
ZFS_ERR_CHECKPOINT_EXISTS = 1024,
ZFS_ERR_DISCARDING_CHECKPOINT,
ZFS_ERR_NO_CHECKPOINT,
ZFS_ERR_DEVRM_IN_PROGRESS,
- ZFS_ERR_VDEV_TOO_BIG
+ ZFS_ERR_VDEV_TOO_BIG,
+ ZFS_ERR_IOC_CMD_UNAVAIL,
+ ZFS_ERR_IOC_ARG_UNAVAIL,
+ ZFS_ERR_IOC_ARG_REQUIRED,
+ ZFS_ERR_IOC_ARG_BADTYPE,
} zfs_errno_t;
/*