diff options
author | Ryan Moeller <ryan@iXsystems.com> | 2020-07-06 14:57:24 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-06 11:57:24 -0700 |
commit | fb91f0367e91fb74a391f56d80fa3d3a9c6a2902 (patch) | |
tree | 1ca19c49ad65b9bd4db18faa1ab51e14b7f32697 | |
parent | cd32b4f5b79c97b293f7be3fe9ddfc9024f7d734 (diff) |
Add zpool_nextboot, move zfs_jail to libzfs.h
FreeBSD has a zfsbootcfg command that wants zpool_nextboot in libzfs.
Add the function to FreeBSD's libzfs_compat.c, and while here move
the prototype for zfs_jail out of param.h in FreeBSD's SPL and into
libzfs.h under an ifdef for FreeBSD, where the prototype for
zpool_nextboot joins it.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10524
-rw-r--r-- | include/libzfs.h | 14 | ||||
-rw-r--r-- | lib/libspl/include/os/freebsd/sys/param.h | 6 | ||||
-rw-r--r-- | lib/libzfs/os/freebsd/libzfs_compat.c | 23 |
3 files changed, 37 insertions, 6 deletions
diff --git a/include/libzfs.h b/include/libzfs.h index 873e8f304..a93f694a1 100644 --- a/include/libzfs.h +++ b/include/libzfs.h @@ -893,6 +893,20 @@ int zfs_smb_acl_rename(libzfs_handle_t *, char *, char *, char *, char *); extern int zpool_enable_datasets(zpool_handle_t *, const char *, int); extern int zpool_disable_datasets(zpool_handle_t *, boolean_t); +#ifdef __FreeBSD__ + +/* + * Attach/detach the given filesystem to/from the given jail. + */ +extern int zfs_jail(zfs_handle_t *zhp, int jailid, int attach); + +/* + * Set loader options for next boot. + */ +extern int zpool_nextboot(libzfs_handle_t *, uint64_t, uint64_t, const char *); + +#endif /* __FreeBSD__ */ + #ifdef __cplusplus } #endif diff --git a/lib/libspl/include/os/freebsd/sys/param.h b/lib/libspl/include/os/freebsd/sys/param.h index c0ad8d679..e2abef189 100644 --- a/lib/libspl/include/os/freebsd/sys/param.h +++ b/lib/libspl/include/os/freebsd/sys/param.h @@ -61,10 +61,4 @@ extern size_t spl_pagesize(void); extern int execvpe(const char *name, char * const argv[], char * const envp[]); -struct zfs_handle; -/* - * Attach/detach the given filesystem to/from the given jail. - */ -extern int zfs_jail(struct zfs_handle *zhp, int jailid, int attach); - #endif diff --git a/lib/libzfs/os/freebsd/libzfs_compat.c b/lib/libzfs/os/freebsd/libzfs_compat.c index 5c3ccd28d..50a3c7b77 100644 --- a/lib/libzfs/os/freebsd/libzfs_compat.c +++ b/lib/libzfs/os/freebsd/libzfs_compat.c @@ -275,6 +275,29 @@ zfs_jail(zfs_handle_t *zhp, int jailid, int attach) } /* + * Set loader options for next boot. + */ +int +zpool_nextboot(libzfs_handle_t *hdl, uint64_t pool_guid, uint64_t dev_guid, + const char *command) +{ + zfs_cmd_t zc = { 0 }; + nvlist_t *args; + int error; + + args = fnvlist_alloc(); + fnvlist_add_uint64(args, ZPOOL_CONFIG_POOL_GUID, pool_guid); + fnvlist_add_uint64(args, ZPOOL_CONFIG_GUID, dev_guid); + fnvlist_add_string(args, "command", command); + error = zcmd_write_src_nvlist(hdl, &zc, args); + if (error == 0) + error = ioctl(hdl->libzfs_fd, ZFS_IOC_NEXTBOOT, &zc); + zcmd_free_nvlists(&zc); + nvlist_free(args); + return (error); +} + +/* * Fill given version buffer with zfs kernel version. * Returns 0 on success, and -1 on error (with errno set) */ |