diff --git a/.cirrus.yml b/.cirrus.yml deleted file mode 100644 index e155ff84..00000000 --- a/.cirrus.yml +++ /dev/null @@ -1,25 +0,0 @@ -compute_engine_instance: - platform: freebsd - image_project: freebsd-org-cloud-dev - image: freebsd-13-2-release-amd64 - cpu: 2 - memory: 4G - -task: - name: Build aquaBSD test images - timeout_in: 30m - env: - CLICOLOR_FORCE: - setup_script: - - uname -a - - df -h - - pkg --version - - pkg install -y git-lite - - git clone https://github.com/inobulles/bob --depth 1 --branch main - - ( cd bob && sh build.sh && sh-bin/bob install ) - build_script: - - bob install - test_script: - - bob test - post_script: - - df -h diff --git a/.gitignore b/.gitignore index cdc664d2..8ad7e63b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ rootfs/ my-aquarium .build *.sw[nop] +.bob +.cache +compile_commands.json diff --git a/README.md b/README.md index 5ed79eaa..13ffb020 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,15 @@ With [Bob the Builder](https://github.com/inobulles/bob) installed: ```console bob test install ``` + +## Installed directory structure + +- `/usr/local/aquarium/`: The base directory for all aquarium-related stuff. This can be modified with `-r`. + - `/usr/local/aquarium/tmpls.remote`: List of sanctioned templates. + - `/usr/local/aquarium/db`: Database of all aquariums. + - `/usr/local/aquarium/tmpls/`: All cached templates. + - `/usr/local/aquarium/tmpls/amd64.freebsd.14.1-RELEASE-p5.txz`: Example of a cached template. + - `/usr/local/aquarium/kerns/`: All cached kernels. + - `/usr/local/aquarium/kerns/amd64.freebsd.14.1-RELEASE-p5.txz`: Example of a cached kernel. + - `/usr/local/aquarium/roots/`: Physical locations of the root file systems of the aquariums. + - `/usr/local/aquarium/roots/7538ef/`: Example of a root file system. diff --git a/build.fl b/build.fl new file mode 100644 index 00000000..97efa929 --- /dev/null +++ b/build.fl @@ -0,0 +1,60 @@ +# This Source Form is subject to the terms of the AQUA Software License, v. 1.0. +# Copyright (c) 2024 Aymeric Wibo + +import bob + +assert Platform.os() == "FreeBSD", "Aquariums are only supported on FreeBSD" + +let OPENZFS_INCLUDES = "/usr/src/sys/contrib/openzfs/include" +assert Fs.exists(OPENZFS_INCLUDES), "OpenZFS includes not found (is /usr/src populated?)" + +let LIBSPL_INCLUDES = "/usr/src/sys/contrib/openzfs/lib/libspl/include" +assert Fs.exists(OPENZFS_INCLUDES), "libspl includes not found (is /usr/src populated?)" + +let OS_LIBSPL_INCLUDES = "/usr/src/sys/contrib/openzfs/lib/libspl/include/os/freebsd" +assert Fs.exists(OS_LIBSPL_INCLUDES), "OS-specific libspl includes not found (is /usr/src populated?)" + +deps = [ + Dep.git("https://github.com/inobulles/libcopyfile", "v0.1.1"), + Dep.git("https://github.com/inobulles/libmkfs_msdos", "v0.1.0"), +] + +# Compile library and frontend sources. + +let lib_src = Fs.list("src/lib").where(|path| path.endswith(".c")) +let cmd_src = Fs.list("src/aquarium").where(|path| path.endswith(".c")) + +let cc = Cc([ + "-g", "-std=c11", "-fPIC", + "-I" + OPENZFS_INCLUDES, + "-I" + LIBSPL_INCLUDES, + "-I" + OS_LIBSPL_INCLUDES, + "-Isrc", "-isystem=/usr/local/include", + "-Wall", "-Wextra", "-Werror" +]) + +let lib_obj = cc.compile(lib_src) +let cmd_obj = cc.compile(cmd_src) + +# Create static & dynamic libraries and frontend executable. +# It's best we statically link in libaquarium to the frontend as it is a setuid binary. +# This also means it will be runnable in the temporary prefix by Bob, as LD_LIBRARY_PATH doesn't work with setuid binaries (see rtld(1)). + +let libs = ["-larchive", "-lcrypto", "-lfetch", "-lgeom", "-ljail", "-lzfs", "-lcopyfile", "-lmkfs_msdos", "-lnvpair"] + +let archive = Linker([]).archive(lib_obj) +let dyn_lib = Linker(["-shared"] + libs).link(lib_obj) +let cmd = Linker([archive] + libs).link(cmd_obj) + +# Installation map. + +install = { + archive: "lib/libaquarium.a", + dyn_lib: "lib/libaquarium.so", + cmd: "bin/aquarium", + "src/aquarium.h": "include/aquarium.h", +} + +# Default runner. + +run = ["aquarium"] diff --git a/build.wren b/build.wren deleted file mode 100644 index 19bbdd1e..00000000 --- a/build.wren +++ /dev/null @@ -1,100 +0,0 @@ -// This Source Form is subject to the terms of the AQUA Software License, v. 1.0. -// Copyright (c) 2023 Aymeric Wibo - -// install dependencies - -Deps.git_inherit("https://github.com/inobulles/libcopyfile") -Deps.git_inherit("https://github.com/inobulles/libmkfs_msdos") - -// C compilation - -var cc = CC.new() - -cc.add_opt("-g") -cc.add_opt("-std=c99") -cc.add_opt("-Isrc/lib/include") -cc.add_opt("-Isrc") -cc.add_opt("-isystem=/usr/local/include") -cc.add_opt("-L/usr/local/lib") -cc.add_opt("-fPIC") -cc.add_opt("-Wall") -cc.add_opt("-Wextra") - -var lib_src = File.list("src/lib") - .where { |path| path.endsWith(".c") } - -var aquarium_src = File.list("src/aquarium") - .where { |path| path.endsWith(".c") } - -var installer_src = File.list("src/installer") - .where { |path| path.endsWith(".c") } - -var src = lib_src.toList + aquarium_src.toList + installer_src - -src - .each { |path| cc.compile(path) } - -// create static & dynamic libraries - -var linker = Linker.new() - -linker.archive(lib_src.toList, "libaquarium.a") -linker.link(lib_src.toList, ["archive", "copyfile", "crypto", "fetch", "geom", "jail", "mkfs_msdos", "zfs"], "libaquarium.so", true) - -// create aquarium command-line frontend - -linker.link(aquarium_src.toList, ["aquarium", "archive", "copyfile"], "aquarium") - -// create installer command-line frontend - -linker.link(installer_src.toList, ["aquarium"], "installer") - -// copy over headers - -File.list("src", 1) - .where { |path| path.endsWith(".h") } - .each { |path| Resources.install(path) } - -// running - -class Runner { - static run(args) { File.exec("installer", args) } -} - -// installation map - -class Installer { - static aquarium(path) { - File.chmod(path, File.EXTRA, File.SETUID) - File.chown(path, "root", "wheel") - - return "%(Meta.prefix())/bin/aquarium" - } -} - -var install = { - "aquarium": ":aquarium", - "installer": "bin/installer", - "libaquarium.a": "lib/libaquarium.a", - "libaquarium.so": "lib/libaquarium.so", - "aquarium.h": "include/aquarium.h", -} - -// testing - -class Tests { - // e2e tests - - static img_aquabsd_installer { // try to compile an aquaBSD installer image - return File.exec("sh", ["build.sh"]) - } - - static img_just_vim_yo { // try to compile an aquaBSD image with just vim installed - return File.exec("sh", ["build.sh"]) - } -} - -var tests = [ - // "img_aquabsd_installer", // disable this one for now, because it takes a long time and is relatively unstable - "img_just_vim_yo", -] diff --git a/src/aquarium.h b/src/aquarium.h index d2a5cad3..1bc06f9b 100644 --- a/src/aquarium.h +++ b/src/aquarium.h @@ -29,6 +29,7 @@ typedef enum { typedef enum { AQUARIUM_TEMPLATE_KIND_BASE, AQUARIUM_TEMPLATE_KIND_KERNEL, + AQUARIUM_TEMPLATE_KIND_OVERLAY, } aquarium_template_kind_t; typedef enum { @@ -76,6 +77,7 @@ typedef struct { char* base_path; char* templates_path; char* kernels_path; + char* overlays_path; char* aquariums_path; // file paths @@ -156,7 +158,11 @@ int aquarium_os_load_epair_kmod(void); int aquarium_os_load_bridge_kmod(void); int aquarium_create_struct(aquarium_opts_t* opts); -int aquarium_create(aquarium_opts_t* opts, char const* path, char const* template, char const* kernel_template); +int aquarium_create( + aquarium_opts_t* opts, char const* pointer_path, + char const* template, char const* kernel_template, + char const* const* overlays, size_t overlay_count +); int aquarium_enter(aquarium_opts_t* opts, char const* path, aquarium_enter_cb_t cb, void* param); int aquarium_enter_setdown(char const* path, aquarium_os_t os); diff --git a/src/aquarium/aquarium.c b/src/aquarium/aquarium.c index 5f7f9ba0..ff98af16 100644 --- a/src/aquarium/aquarium.c +++ b/src/aquarium/aquarium.c @@ -1,9 +1,10 @@ // This Source Form is subject to the terms of the AQUA Software License, v. 1.0. -// Copyright (c) 2023 Aymeric Wibo +// Copyright (c) 2024 Aymeric Wibo #include #include "util.h" +#include #include #include #include @@ -13,8 +14,9 @@ #include #include -static char* template = "amd64.aquabsd.0.1.1-beta"; +static char* template = "amd64.freebsd.14-2-release"; static char* kernel_template = NULL; +static char* overlay_templates = NULL; static char* out_path = NULL; static char* path = NULL; @@ -22,14 +24,14 @@ static char* path = NULL; static void usage(void) { fprintf(stderr, "usage: %1$s [-r base]\n" - " %1$s [-r base] -c path [-t template] [-k kernel_template]\n" - " %1$s [-r base] [-d rulesets] [-j jailparams] [-m max_children] [-Dp] [-v interface] [-h hostname] -e path\n" - " %1$s [-r base] -i path -o image\n" - " %1$s [-r base] -I drive [-t template] [-k kernel_template]\n" - " %1$s [-r base] -l\n" - " %1$s [-r base] -s\n" - " %1$s [-r base] -T path -o template\n" - " %1$s [-r base] -y path source_file ... target_directory\n", + " %1$s [-r base] [-t template] [-k kernel_template] [-O overlay_templates] create path\n" + " %1$s [-r base] [-d rulesets] [-j jailparams] [-m max_children] [-Dp] [-v interface] [-h hostname] enter path\n" + " %1$s [-r base] image path image\n" + " %1$s [-r base] tmpls\n" + " %1$s [-r base] sweep\n" + " %1$s [-r base] export path template\n" + " %1$s [-r base] mount path target mount_path\n" + " %1$s [-r base] cp path source_file ... target_directory\n", getprogname()); exit(EXIT_FAILURE); @@ -108,6 +110,7 @@ static inline void __list_templates_dir(const char* path, const char* kind) { static int do_list_templates(aquarium_opts_t* opts) { __list_templates_dir(opts->templates_path, "BASE"); __list_templates_dir(opts->kernels_path, "KERNEL"); + __list_templates_dir(opts->overlays_path, "OVERLAY"); return EXIT_SUCCESS; } @@ -117,62 +120,20 @@ static int do_create(aquarium_opts_t* opts) { usage(); } - if (aquarium_create(opts, path, template, kernel_template) < 0) { - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} - -static int do_install(aquarium_opts_t* opts) { - if (!path) { - usage(); - } - - char* const target = path; - - // find our drive - - aquarium_drive_t* drives = NULL; - size_t drives_len = 0; - - if (aquarium_drives_read(&drives, &drives_len) < 0) { - return EXIT_FAILURE; - } - - aquarium_drive_t* const drive = aquarium_drives_find(drives, drives_len, target); + char** overlays = NULL; + size_t overlay_count = 0; - if (!drive) { - return EXIT_FAILURE; - } - - // create partition table on target - - if (aquarium_format_new_table(opts, drive) < 0) { - return EXIT_FAILURE; - } - - // create ZFS filesystem on target - - char const* const root = "/mnt"; - - if (aquarium_format_create_zfs(opts, drive, root) < 0) { - return EXIT_FAILURE; - } - - // extract templates - - if (template && aquarium_extract_template(opts, root, template, AQUARIUM_TEMPLATE_KIND_BASE) < 0) { - return EXIT_FAILURE; - } + if (overlay_templates != NULL) { + char* tok; - if (kernel_template && aquarium_extract_template(opts, root, kernel_template, AQUARIUM_TEMPLATE_KIND_KERNEL) < 0) { - return EXIT_FAILURE; + while ((tok = strsep(&overlay_templates, ","))) { + overlays = realloc(overlays, ++overlay_count * sizeof *overlays); + assert(overlays != NULL); + overlays[overlay_count - 1] = tok; + } } - // create ESP on target - - if (aquarium_format_create_esp(opts, drive, root) < 0) { + if (aquarium_create(opts, path, template, kernel_template, (void*) overlays, overlay_count) < 0) { return EXIT_FAILURE; } @@ -246,35 +207,75 @@ static int do_img_out(aquarium_opts_t* opts) { return aquarium_img_out(opts, aquarium_path, out_path) < 0 ? EXIT_FAILURE : EXIT_SUCCESS; } -static char** copy_args = NULL; -static size_t copy_args_len = 0; - -static int do_copy(aquarium_opts_t* opts) { - char* const aquarium_path = aquarium_db_read_pointer_file(opts, path); - - if (!aquarium_path) { - return EXIT_FAILURE; - } - - char* const target = copy_args[--copy_args_len]; - +static void validate_target(char* target) { // make sure target directory doesn't refer to $HOME // we have no [easy] way of getting the $HOME of the aquarium, and even if we did, what user should we assume? // this doesn't stop shells from expanding '~', but it's better than nothing if (*target == '~') { - warnx("target directory '%s' refers to $HOME ('~'), which is unsupported", target); - return EXIT_FAILURE; + errx(EXIT_FAILURE, "target directory '%s' refers to $HOME ('~'), which is unsupported", target); } // also make sure it doesn't contain any ".."'s, as that can be used to copy to outside of the aquarium // XXX technically we could count these and path components to see if we really do break out of the aquarium, but that's a lot of work if (strstr(target, "..")) { - warnx("target directory '%s' contains '..', which is unsupported", target); + errx(EXIT_FAILURE, "target directory '%s' contains '..', which is unsupported", target); + } +} + +static char* mount_target = NULL; +static char* mount_path = NULL; + +static int do_mount(aquarium_opts_t* opts) { + char* const src_aq = aquarium_db_read_pointer_file(opts, path); + + if (!src_aq) { return EXIT_FAILURE; } + char* const target_aq = aquarium_db_read_pointer_file(opts, mount_target); + + if (!target_aq) { + return EXIT_FAILURE; + } + + validate_target(mount_path); + + if (opts->initial_uid && setuid(0) < 0) { + errx(EXIT_FAILURE, "setuid(0): %s", strerror(errno)); + } + + char* full_target = NULL; + asprintf(&full_target, "%s/%s", target_aq, mount_path); + assert(full_target != NULL); + + struct iovec iov_fd[] = { + __AQUARIUM_IOV("fstype", "nullfs"), + __AQUARIUM_IOV("from", src_aq), + __AQUARIUM_IOV("fspath", full_target), + }; + + if (nmount(iov_fd, sizeof(iov_fd) / sizeof(*iov_fd), 0) < 0 && errno != ENOENT) { + errx(EXIT_FAILURE, "nmount: failed to bind mount \"%s\" to \"%s\": %s", src_aq, full_target, strerror(errno)); + } + + return 0; +} + +static char** copy_args = NULL; +static size_t copy_args_len = 0; + +static int do_copy(aquarium_opts_t* opts) { + char* const aquarium_path = aquarium_db_read_pointer_file(opts, path); + + if (!aquarium_path) { + return EXIT_FAILURE; + } + + char* const target = copy_args[--copy_args_len]; + validate_target(target); + // make sure all files are (recursively) readable by the user for (size_t i = 0; i < copy_args_len; i++) { @@ -371,7 +372,7 @@ int main(int argc, char* argv[]) { int c; - while ((c = getopt(argc, argv, "c:d:De:fh:i:I:j:k:lm:o:pr:st:T:v:y:")) != -1) { + while ((c = getopt(argc, argv, "d:Dfh:j:k:m:o:O:pr:t:v:")) != -1) { // general options if (c == 'd') { @@ -407,58 +408,90 @@ int main(int argc, char* argv[]) { opts->vnet_bridge = optarg; } - // action options + // name-passing options + + else if (c == 'k') { + kernel_template = optarg; + } - else if (c == 'c') { + else if (c == 't') { + template = optarg; + } + + else if (c == 'o') { + out_path = optarg; + } + + else if (c == 'O') { + overlay_templates = optarg; + } + + else { + usage(); + } + } + + argc -= optind; + argv += optind; + + if (argc > 0) { + argc--; + char* const instr = *argv++; + + if (strcmp(instr, "create") == 0) { action = do_create; - path = optarg; + path = *argv++; + argc--; } - else if (c == 'e') { + else if (strcmp(instr, "enter") == 0) { action = do_enter; - path = optarg; + path = *argv++; + argc--; } - else if (c == 'i') { + else if (strcmp(instr, "image") == 0) { action = do_img_out; - path = optarg; - } - - else if (c == 'I') { - action = do_install; - path = optarg; + path = *argv++; + out_path = *argv++; + argc -= 2; } - else if (c == 'l') { + else if (strcmp(instr, "tmpls") == 0) { action = do_list_templates; } - else if (c == 's') { + else if (strcmp(instr, "sweep") == 0) { action = do_sweep; } - else if (c == 'T') { + else if (strcmp(instr, "export") == 0) { action = do_out; - path = optarg; + path = *argv++; + out_path = *argv++; + argc -= 2; } - else if (c == 'y') { - action = do_copy; - path = optarg; - } + else if (strcmp(instr, "mount") == 0) { + action = do_mount; + path = *argv++; - // name-passing options + mount_target = *argv++; + mount_path = *argv++; - else if (c == 'k') { - kernel_template = optarg; + argc -= 3; } - else if (c == 't') { - template = optarg; - } + else if (strcmp(instr, "cp") == 0) { + action = do_copy; - else if (c == 'o') { - out_path = optarg; + path = *argv++; + argc--; + + copy_args = argv; + copy_args_len = argc; + + argc = 0; } else { @@ -466,15 +499,7 @@ int main(int argc, char* argv[]) { } } - argc -= optind; - argv += optind; - - if (action == do_copy) { - copy_args = argv; - copy_args_len = argc; - } - - else if (argc) { + if (argc != 0) { usage(); } diff --git a/src/aquarium/util.h b/src/aquarium/util.h index 67360356..cd9a1ae2 100644 --- a/src/aquarium/util.h +++ b/src/aquarium/util.h @@ -185,7 +185,7 @@ static int mkdir_recursive(char const* _path) { static int copy_recursive(char* source, char* target) { char* const path_argv[] = { source, NULL }; - FTS* const fts = fts_open(path_argv, FTS_PHYSICAL | FTS_XDEV, NULL); + FTS* const fts = fts_open(path_argv, FTS_PHYSICAL | FTS_XDEV | FTS_NOCHDIR, NULL); if (fts == NULL) { warnx("fts_open(\"%s\"): %s", source, strerror(errno)); @@ -227,7 +227,7 @@ static int copy_recursive(char* source, char* target) { break; case FTS_D: - case FTS_DC: {} + case FTS_DC:; if (mkdir_recursive(abs_path) < 0) { goto err_mkdir; @@ -241,7 +241,7 @@ static int copy_recursive(char* source, char* target) { case FTS_DEFAULT: default: - if (copyfile(path, abs_path, 0, COPYFILE_ALL) < 0) { + if (copyfile(path, abs_path, NULL, COPYFILE_ALL) < 0) { warnx("copyfile(\"%s\", \"%s\"): %s", path, abs_path, strerror(errno)); goto err_copy; } diff --git a/src/lib/create.c b/src/lib/create.c index 6bd765c0..5d8217e3 100644 --- a/src/lib/create.c +++ b/src/lib/create.c @@ -64,6 +64,7 @@ int aquarium_create_struct(aquarium_opts_t* opts) { TRY_MKDIR(opts->base_path) TRY_MKDIR(opts->templates_path) TRY_MKDIR(opts->kernels_path) + TRY_MKDIR(opts->overlays_path) TRY_MKDIR(opts->aquariums_path) // try creating sanctioned templates file @@ -238,7 +239,11 @@ static int config(aquarium_opts_t* opts, char* path) { return rv; } -int aquarium_create(aquarium_opts_t* opts, char const* pointer_path, char const* template, char const* kernel_template) { +int aquarium_create( + aquarium_opts_t* opts, char const* pointer_path, + char const* template, char const* kernel_template, + char const* const* overlays, size_t overlay_count +) { int rv = -1; // make sure our template is legal @@ -321,6 +326,8 @@ int aquarium_create(aquarium_opts_t* opts, char const* pointer_path, char const* } // extract templates + // TODO It would be nice if we could get all the downloads done first, and only then extract the templates. + // That way, if there's a downloading issue, we fail fast. if (template && aquarium_extract_template(opts, path, template, AQUARIUM_TEMPLATE_KIND_BASE) < 0) { goto extract_template_err; @@ -330,6 +337,13 @@ int aquarium_create(aquarium_opts_t* opts, char const* pointer_path, char const* goto extract_template_err; } + for (size_t i = 0; i < overlay_count; i++) { + if (aquarium_extract_template(opts, path, overlays[i], AQUARIUM_TEMPLATE_KIND_OVERLAY) < 0) { + goto extract_template_err; + } + + } + // write info to aquarium database FILE* const db_fp = fopen(opts->db_path, "a"); diff --git a/src/lib/enter.c b/src/lib/enter.c index 6ffa06c3..3e64a613 100644 --- a/src/lib/enter.c +++ b/src/lib/enter.c @@ -220,7 +220,7 @@ static int devfs_apply_opts(aquarium_opts_t* opts) { // we necessarily need to start by hiding everything - APPLY_RULESET(1); // devfsrules_hide_all + // APPLY_RULESET(1); // devfsrules_hide_all for (size_t i = 0; i < opts->ruleset_count; i++) { aquarium_devfs_ruleset_t const ruleset = opts->rulesets[i]; diff --git a/src/lib/format.c b/src/lib/format.c index 295c03fb..a8e29437 100644 --- a/src/lib/format.c +++ b/src/lib/format.c @@ -386,7 +386,7 @@ static zpool_handle_t* create_zfs_pool(libzfs_handle_t* handle, char const* name } ADD_PROP(root, root_err, string, ZPOOL_CONFIG_TYPE, VDEV_TYPE_ROOT); - ADD_PROP(root, root_err, nvlist_array, ZPOOL_CONFIG_CHILDREN, &vdev, 1); + ADD_PROP(root, root_err, nvlist_array, ZPOOL_CONFIG_CHILDREN, (nvlist_t const* const*) &vdev, 1); // give the pool itself some properties diff --git a/src/lib/include/README.md b/src/lib/include/README.md deleted file mode 100644 index 21ebf273..00000000 --- a/src/lib/include/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# `include/` subdirectory - -## Why is this here? - -FreeBSD, at least as of `13-RELEASE` & `14-CURRENT`, includes the `libzfs.h` header in base (in `/usr/include`). -This file isn't meant for usage (in fact it doesn't exist whatsoever on aquaBSD core), which is why it has a couple dependency issues. -More specifically, the following files are required by `libzfs.h`, but aren't installed on base: - -| Header file | Path in OpenZFS source tree | -|----------------------|-----------------------------------------| -| `libnvpair.h` | `include/libnvpair.h` | -| `ucred.h` | `lib/libspl/include/ucred.h` | -| `sys/avl.h` | `lib/libspl/include/sys/avl.h` | -| `sys/avl_impl.h` | `lib/libspl/include/sys/avl_impl.h` | -| `sys/zio_priority.h` | `lib/libspl/include/sys/zio_priority.h` | -| `sys/fs/zfs.h` | `lib/libspl/include/sys/fs/zfs.h` | -| `sys/varargs.h` | `lib/libspl/include/sys/varargs.h` | -| `sys/mnttab.h` | `lib/libspl/include/sys/mnttab.h` | - -Additionally, the `libzfs_core.h` is required (`include/libzfs_core.h` in OpenZFS source tree), and is installed on base, but depends on `libnvpair.h`, which isn't. - -The same thing is true for `sys/nvpair.h` library (which doesn't exist on aquaBSD core either); it's installed on FreeBSD base and depends on the following types, which are only defined in the OpenZFS source tree: - -| Type | Equivalent | Path to definition in OpenZFS source tree | -|------------|-------------|-------------------------------------------| -| `uint_t` | `u_int` | `include/os/freebsd/spl/sys/types.h` | -| `uchar_t` | `u_char` | `include/os/freebsd/spl/sys/types.h` | -| `ulong_t` | `u_long` | `include/os/freebsd/spl/sys/types.h` | -| `hrtime_t` | `long long` | `include/os/freebsd/spl/sys/time.h` | - -As not to copy the entirety of the OpenZFS source tree over for a few types, they're defined "manually" at the top of `include/sys/nvpair.h`. - -## Where do these files come from? - -From the [OpenZFS source tree](https://github.com/openzfs/zfs), at the paths specified in the previous section. - -## Why did you take the time to write this file? - -Procrastination. - -## Notes - -More information on the issue can be found on this FreeBSD forum post: [Missing ZFS headers?](https://forums.freebsd.org/threads/missing-zfs-headers.82564/) diff --git a/src/lib/include/libnvpair.h b/src/lib/include/libnvpair.h deleted file mode 100644 index bc50c3b7..00000000 --- a/src/lib/include/libnvpair.h +++ /dev/null @@ -1,197 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2013, Joyent, Inc. All rights reserved. - */ - -#ifndef _LIBNVPAIR_H -#define _LIBNVPAIR_H extern __attribute__((visibility("default"))) - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * All interfaces described in this file are private to Solaris, and - * are subject to change at any time and without notice. The public - * nvlist/nvpair interfaces, as documented in manpage sections 3NVPAIR, - * are all imported from included above. - */ - -_LIBNVPAIR_H int nvpair_value_match(nvpair_t *, int, char *, char **); -_LIBNVPAIR_H int nvpair_value_match_regex(nvpair_t *, int, char *, regex_t *, - char **); - -_LIBNVPAIR_H void nvlist_print(FILE *, nvlist_t *); -_LIBNVPAIR_H int nvlist_print_json(FILE *, nvlist_t *); -_LIBNVPAIR_H void dump_nvlist(nvlist_t *, int); - -/* - * Private nvlist printing interface that allows the caller some control - * over output rendering (as opposed to nvlist_print and dump_nvlist). - * - * Obtain an opaque nvlist_prtctl_t cookie using nvlist_prtctl_alloc - * (NULL on failure); on return the cookie is set up for default formatting - * and rendering. Quote the cookie in subsequent customisation functions and - * then pass the cookie to nvlist_prt to render the nvlist. Finally, - * use nvlist_prtctl_free to release the cookie. - * - * For all nvlist_lookup_xxx and nvlist_lookup_xxx_array functions - * we have a corresponding brace of functions that appoint replacement - * rendering functions: - * - * extern void nvlist_prtctl_xxx(nvlist_prtctl_t, - * void (*)(nvlist_prtctl_t ctl, void *private, const char *name, - * xxxtype value)) - * - * and - * - * extern void nvlist_prtctl_xxx_array(nvlist_prtctl_t, - * void (*)(nvlist_prtctl_t ctl, void *private, const char *name, - * xxxtype value, uint_t count)) - * - * where xxxtype is the C datatype corresponding to xxx, eg int8_t for "int8" - * and char * for "string". The function that is appointed to render the - * specified datatype receives as arguments the cookie, the nvlist - * member name, the value of that member (or a pointer for array function), - * and (for array rendering functions) a count of the number of elements. - */ - -typedef struct nvlist_prtctl *nvlist_prtctl_t; /* opaque */ - -enum nvlist_indent_mode { - NVLIST_INDENT_ABS, /* Absolute indentation */ - NVLIST_INDENT_TABBED /* Indent with tabstops */ -}; - -_LIBNVPAIR_H nvlist_prtctl_t nvlist_prtctl_alloc(void); -_LIBNVPAIR_H void nvlist_prtctl_free(nvlist_prtctl_t); -_LIBNVPAIR_H void nvlist_prt(nvlist_t *, nvlist_prtctl_t); - -/* Output stream */ -_LIBNVPAIR_H void nvlist_prtctl_setdest(nvlist_prtctl_t, FILE *); -_LIBNVPAIR_H FILE *nvlist_prtctl_getdest(nvlist_prtctl_t); - -/* Indentation mode, start indent, indent increment; default tabbed/0/1 */ -_LIBNVPAIR_H void nvlist_prtctl_setindent(nvlist_prtctl_t, - enum nvlist_indent_mode, int, int); -_LIBNVPAIR_H void nvlist_prtctl_doindent(nvlist_prtctl_t, int); - -enum nvlist_prtctl_fmt { - NVLIST_FMT_MEMBER_NAME, /* name fmt; default "%s = " */ - NVLIST_FMT_MEMBER_POSTAMBLE, /* after nvlist member; default "\n" */ - NVLIST_FMT_BTWN_ARRAY /* between array members; default " " */ -}; - -_LIBNVPAIR_H void nvlist_prtctl_setfmt(nvlist_prtctl_t, enum nvlist_prtctl_fmt, - const char *); -_LIBNVPAIR_H void nvlist_prtctl_dofmt(nvlist_prtctl_t, enum nvlist_prtctl_fmt, - ...); - -/* - * Function prototypes for interfaces that appoint a new rendering function - * for single-valued nvlist members. - * - * A replacement function receives arguments as follows: - * - * nvlist_prtctl_t Print control structure; do not change preferences - * for this object from a print callback function. - * - * void * The function-private cookie argument registered - * when the replacement function was appointed. - * - * nvlist_t * The full nvlist that is being processed. The - * rendering function is called to render a single - * member (name and value passed as below) but it may - * want to reference or incorporate other aspects of - * the full nvlist. - * - * const char * Member name to render - * - * valtype Value of the member to render - * - * The function must return non-zero if it has rendered output for this - * member, or 0 if it wants to default to standard rendering for this - * one member. - */ - -#define NVLIST_PRINTCTL_SVDECL(funcname, valtype) \ - _LIBNVPAIR_H void funcname(nvlist_prtctl_t, \ - int (*)(nvlist_prtctl_t, void *, nvlist_t *, const char *, valtype), \ - void *) - -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_boolean, int); -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_boolean_value, boolean_t); -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_byte, uchar_t); -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_int8, int8_t); -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_uint8, uint8_t); -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_int16, int16_t); -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_uint16, uint16_t); -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_int32, int32_t); -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_uint32, uint32_t); -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_int64, int64_t); -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_uint64, uint64_t); -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_double, double); -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_string, char *); -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_hrtime, hrtime_t); -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_nvlist, nvlist_t *); - -#undef NVLIST_PRINTCTL_SVDECL /* was just for "clarity" above */ - -/* - * Function prototypes for interfaces that appoint a new rendering function - * for array-valued nvlist members. - * - * One additional argument is taken: uint_t for the number of array elements - * - * Return values as above. - */ -#define NVLIST_PRINTCTL_AVDECL(funcname, vtype) \ - _LIBNVPAIR_H void funcname(nvlist_prtctl_t, \ - int (*)(nvlist_prtctl_t, void *, nvlist_t *, const char *, vtype, uint_t), \ - void *) - -NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_boolean_array, boolean_t *); -NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_byte_array, uchar_t *); -NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_int8_array, int8_t *); -NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_uint8_array, uint8_t *); -NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_int16_array, int16_t *); -NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_uint16_array, uint16_t *); -NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_int32_array, int32_t *); -NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_uint32_array, uint32_t *); -NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_int64_array, int64_t *); -NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_uint64_array, uint64_t *); -NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_string_array, char **); -NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_nvlist_array, nvlist_t **); - -#undef NVLIST_PRINTCTL_AVDECL /* was just for "clarity" above */ - -#ifdef __cplusplus -} -#endif - -#endif /* _LIBNVPAIR_H */ diff --git a/src/lib/include/libzfs.h b/src/lib/include/libzfs.h deleted file mode 100644 index c0883a98..00000000 --- a/src/lib/include/libzfs.h +++ /dev/null @@ -1,970 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2020 by Delphix. All rights reserved. - * Copyright Joyent, Inc. - * Copyright (c) 2013 Steven Hartland. All rights reserved. - * Copyright (c) 2016, Intel Corporation. - * Copyright 2016 Nexenta Systems, Inc. - * Copyright (c) 2017 Open-E, Inc. All Rights Reserved. - * Copyright (c) 2019 Datto Inc. - * Copyright (c) 2021, Colm Buckley - */ - -#ifndef _LIBZFS_H -#define _LIBZFS_H extern __attribute__((visibility("default"))) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Miscellaneous ZFS constants - */ -#define ZFS_MAXPROPLEN MAXPATHLEN -#define ZPOOL_MAXPROPLEN MAXPATHLEN - -/* - * libzfs errors - */ -typedef enum zfs_error { - EZFS_SUCCESS = 0, /* no error -- success */ - EZFS_NOMEM = 2000, /* out of memory */ - EZFS_BADPROP, /* invalid property value */ - EZFS_PROPREADONLY, /* cannot set readonly property */ - EZFS_PROPTYPE, /* property does not apply to dataset type */ - EZFS_PROPNONINHERIT, /* property is not inheritable */ - EZFS_PROPSPACE, /* bad quota or reservation */ - EZFS_BADTYPE, /* dataset is not of appropriate type */ - EZFS_BUSY, /* pool or dataset is busy */ - EZFS_EXISTS, /* pool or dataset already exists */ - EZFS_NOENT, /* no such pool or dataset */ - EZFS_BADSTREAM, /* bad backup stream */ - EZFS_DSREADONLY, /* dataset is readonly */ - EZFS_VOLTOOBIG, /* volume is too large for 32-bit system */ - EZFS_INVALIDNAME, /* invalid dataset name */ - EZFS_BADRESTORE, /* unable to restore to destination */ - EZFS_BADBACKUP, /* backup failed */ - EZFS_BADTARGET, /* bad attach/detach/replace target */ - EZFS_NODEVICE, /* no such device in pool */ - EZFS_BADDEV, /* invalid device to add */ - EZFS_NOREPLICAS, /* no valid replicas */ - EZFS_RESILVERING, /* resilvering (healing reconstruction) */ - EZFS_BADVERSION, /* unsupported version */ - EZFS_POOLUNAVAIL, /* pool is currently unavailable */ - EZFS_DEVOVERFLOW, /* too many devices in one vdev */ - EZFS_BADPATH, /* must be an absolute path */ - EZFS_CROSSTARGET, /* rename or clone across pool or dataset */ - EZFS_ZONED, /* used improperly in local zone */ - EZFS_MOUNTFAILED, /* failed to mount dataset */ - EZFS_UMOUNTFAILED, /* failed to unmount dataset */ - EZFS_UNSHARENFSFAILED, /* failed to unshare over nfs */ - EZFS_SHARENFSFAILED, /* failed to share over nfs */ - EZFS_PERM, /* permission denied */ - EZFS_NOSPC, /* out of space */ - EZFS_FAULT, /* bad address */ - EZFS_IO, /* I/O error */ - EZFS_INTR, /* signal received */ - EZFS_ISSPARE, /* device is a hot spare */ - EZFS_INVALCONFIG, /* invalid vdev configuration */ - EZFS_RECURSIVE, /* recursive dependency */ - EZFS_NOHISTORY, /* no history object */ - EZFS_POOLPROPS, /* couldn't retrieve pool props */ - EZFS_POOL_NOTSUP, /* ops not supported for this type of pool */ - EZFS_POOL_INVALARG, /* invalid argument for this pool operation */ - EZFS_NAMETOOLONG, /* dataset name is too long */ - EZFS_OPENFAILED, /* open of device failed */ - EZFS_NOCAP, /* couldn't get capacity */ - EZFS_LABELFAILED, /* write of label failed */ - EZFS_BADWHO, /* invalid permission who */ - EZFS_BADPERM, /* invalid permission */ - EZFS_BADPERMSET, /* invalid permission set name */ - EZFS_NODELEGATION, /* delegated administration is disabled */ - EZFS_UNSHARESMBFAILED, /* failed to unshare over smb */ - EZFS_SHARESMBFAILED, /* failed to share over smb */ - EZFS_BADCACHE, /* bad cache file */ - EZFS_ISL2CACHE, /* device is for the level 2 ARC */ - EZFS_VDEVNOTSUP, /* unsupported vdev type */ - EZFS_NOTSUP, /* ops not supported on this dataset */ - EZFS_ACTIVE_SPARE, /* pool has active shared spare devices */ - EZFS_UNPLAYED_LOGS, /* log device has unplayed logs */ - EZFS_REFTAG_RELE, /* snapshot release: tag not found */ - EZFS_REFTAG_HOLD, /* snapshot hold: tag already exists */ - EZFS_TAGTOOLONG, /* snapshot hold/rele: tag too long */ - EZFS_PIPEFAILED, /* pipe create failed */ - EZFS_THREADCREATEFAILED, /* thread create failed */ - EZFS_POSTSPLIT_ONLINE, /* onlining a disk after splitting it */ - EZFS_SCRUBBING, /* currently scrubbing */ - EZFS_NO_SCRUB, /* no active scrub */ - EZFS_DIFF, /* general failure of zfs diff */ - EZFS_DIFFDATA, /* bad zfs diff data */ - EZFS_POOLREADONLY, /* pool is in read-only mode */ - EZFS_SCRUB_PAUSED, /* scrub currently paused */ - EZFS_ACTIVE_POOL, /* pool is imported on a different system */ - EZFS_CRYPTOFAILED, /* failed to setup encryption */ - EZFS_NO_PENDING, /* cannot cancel, no operation is pending */ - EZFS_CHECKPOINT_EXISTS, /* checkpoint exists */ - EZFS_DISCARDING_CHECKPOINT, /* currently discarding a checkpoint */ - EZFS_NO_CHECKPOINT, /* pool has no checkpoint */ - EZFS_DEVRM_IN_PROGRESS, /* a device is currently being removed */ - EZFS_VDEV_TOO_BIG, /* a device is too big to be used */ - EZFS_IOC_NOTSUPPORTED, /* operation not supported by zfs module */ - EZFS_TOOMANY, /* argument list too long */ - EZFS_INITIALIZING, /* currently initializing */ - EZFS_NO_INITIALIZE, /* no active initialize */ - EZFS_WRONG_PARENT, /* invalid parent dataset (e.g ZVOL) */ - EZFS_TRIMMING, /* currently trimming */ - EZFS_NO_TRIM, /* no active trim */ - EZFS_TRIM_NOTSUP, /* device does not support trim */ - EZFS_NO_RESILVER_DEFER, /* pool doesn't support resilver_defer */ - EZFS_EXPORT_IN_PROGRESS, /* currently exporting the pool */ - EZFS_REBUILDING, /* resilvering (sequential reconstrution) */ - EZFS_UNKNOWN -} zfs_error_t; - -/* - * The following data structures are all part - * of the zfs_allow_t data structure which is - * used for printing 'allow' permissions. - * It is a linked list of zfs_allow_t's which - * then contain avl tree's for user/group/sets/... - * and each one of the entries in those trees have - * avl tree's for the permissions they belong to and - * whether they are local,descendent or local+descendent - * permissions. The AVL trees are used primarily for - * sorting purposes, but also so that we can quickly find - * a given user and or permission. - */ -typedef struct zfs_perm_node { - avl_node_t z_node; - char z_pname[MAXPATHLEN]; -} zfs_perm_node_t; - -typedef struct zfs_allow_node { - avl_node_t z_node; - char z_key[MAXPATHLEN]; /* name, such as joe */ - avl_tree_t z_localdescend; /* local+descendent perms */ - avl_tree_t z_local; /* local permissions */ - avl_tree_t z_descend; /* descendent permissions */ -} zfs_allow_node_t; - -typedef struct zfs_allow { - struct zfs_allow *z_next; - char z_setpoint[MAXPATHLEN]; - avl_tree_t z_sets; - avl_tree_t z_crperms; - avl_tree_t z_user; - avl_tree_t z_group; - avl_tree_t z_everyone; -} zfs_allow_t; - -/* - * Basic handle types - */ -typedef struct zfs_handle zfs_handle_t; -typedef struct zpool_handle zpool_handle_t; -typedef struct libzfs_handle libzfs_handle_t; - -_LIBZFS_H int zpool_wait(zpool_handle_t *, zpool_wait_activity_t); -_LIBZFS_H int zpool_wait_status(zpool_handle_t *, zpool_wait_activity_t, - boolean_t *, boolean_t *); - -/* - * Library initialization - */ -_LIBZFS_H libzfs_handle_t *libzfs_init(void); -_LIBZFS_H void libzfs_fini(libzfs_handle_t *); - -_LIBZFS_H libzfs_handle_t *zpool_get_handle(zpool_handle_t *); -_LIBZFS_H libzfs_handle_t *zfs_get_handle(zfs_handle_t *); - -_LIBZFS_H void libzfs_print_on_error(libzfs_handle_t *, boolean_t); - -_LIBZFS_H void zfs_save_arguments(int argc, char **, char *, int); -_LIBZFS_H int zpool_log_history(libzfs_handle_t *, const char *); - -_LIBZFS_H int libzfs_errno(libzfs_handle_t *); -_LIBZFS_H const char *libzfs_error_init(int); -_LIBZFS_H const char *libzfs_error_action(libzfs_handle_t *); -_LIBZFS_H const char *libzfs_error_description(libzfs_handle_t *); -_LIBZFS_H int zfs_standard_error(libzfs_handle_t *, int, const char *); -_LIBZFS_H void libzfs_mnttab_init(libzfs_handle_t *); -_LIBZFS_H void libzfs_mnttab_fini(libzfs_handle_t *); -_LIBZFS_H void libzfs_mnttab_cache(libzfs_handle_t *, boolean_t); -_LIBZFS_H int libzfs_mnttab_find(libzfs_handle_t *, const char *, - struct mnttab *); -_LIBZFS_H void libzfs_mnttab_add(libzfs_handle_t *, const char *, - const char *, const char *); -_LIBZFS_H void libzfs_mnttab_remove(libzfs_handle_t *, const char *); - -/* - * Basic handle functions - */ -_LIBZFS_H zpool_handle_t *zpool_open(libzfs_handle_t *, const char *); -_LIBZFS_H zpool_handle_t *zpool_open_canfail(libzfs_handle_t *, const char *); -_LIBZFS_H void zpool_close(zpool_handle_t *); -_LIBZFS_H const char *zpool_get_name(zpool_handle_t *); -_LIBZFS_H int zpool_get_state(zpool_handle_t *); -_LIBZFS_H const char *zpool_state_to_name(vdev_state_t, vdev_aux_t); -_LIBZFS_H const char *zpool_pool_state_to_name(pool_state_t); -_LIBZFS_H void zpool_free_handles(libzfs_handle_t *); - -/* - * Iterate over all active pools in the system. - */ -typedef int (*zpool_iter_f)(zpool_handle_t *, void *); -_LIBZFS_H int zpool_iter(libzfs_handle_t *, zpool_iter_f, void *); -_LIBZFS_H boolean_t zpool_skip_pool(const char *); - -/* - * Functions to create and destroy pools - */ -_LIBZFS_H int zpool_create(libzfs_handle_t *, const char *, nvlist_t *, - nvlist_t *, nvlist_t *); -_LIBZFS_H int zpool_destroy(zpool_handle_t *, const char *); -_LIBZFS_H int zpool_add(zpool_handle_t *, nvlist_t *); - -typedef struct splitflags { - /* do not split, but return the config that would be split off */ - int dryrun : 1; - - /* after splitting, import the pool */ - int import : 1; - int name_flags; -} splitflags_t; - -typedef struct trimflags { - /* requested vdevs are for the entire pool */ - boolean_t fullpool; - - /* request a secure trim, requires support from device */ - boolean_t secure; - - /* after starting trim, block until trim completes */ - boolean_t wait; - - /* trim at the requested rate in bytes/second */ - uint64_t rate; -} trimflags_t; - -/* - * Functions to manipulate pool and vdev state - */ -_LIBZFS_H int zpool_scan(zpool_handle_t *, pool_scan_func_t, pool_scrub_cmd_t); -_LIBZFS_H int zpool_initialize(zpool_handle_t *, pool_initialize_func_t, - nvlist_t *); -_LIBZFS_H int zpool_initialize_wait(zpool_handle_t *, pool_initialize_func_t, - nvlist_t *); -_LIBZFS_H int zpool_trim(zpool_handle_t *, pool_trim_func_t, nvlist_t *, - trimflags_t *); - -_LIBZFS_H int zpool_clear(zpool_handle_t *, const char *, nvlist_t *); -_LIBZFS_H int zpool_reguid(zpool_handle_t *); -_LIBZFS_H int zpool_reopen_one(zpool_handle_t *, void *); - -_LIBZFS_H int zpool_sync_one(zpool_handle_t *, void *); - -_LIBZFS_H int zpool_vdev_online(zpool_handle_t *, const char *, int, - vdev_state_t *); -_LIBZFS_H int zpool_vdev_offline(zpool_handle_t *, const char *, boolean_t); -_LIBZFS_H int zpool_vdev_attach(zpool_handle_t *, const char *, - const char *, nvlist_t *, int, boolean_t); -_LIBZFS_H int zpool_vdev_detach(zpool_handle_t *, const char *); -_LIBZFS_H int zpool_vdev_remove(zpool_handle_t *, const char *); -_LIBZFS_H int zpool_vdev_remove_cancel(zpool_handle_t *); -_LIBZFS_H int zpool_vdev_indirect_size(zpool_handle_t *, const char *, - uint64_t *); -_LIBZFS_H int zpool_vdev_split(zpool_handle_t *, char *, nvlist_t **, - nvlist_t *, splitflags_t); - -_LIBZFS_H int zpool_vdev_fault(zpool_handle_t *, uint64_t, vdev_aux_t); -_LIBZFS_H int zpool_vdev_degrade(zpool_handle_t *, uint64_t, vdev_aux_t); -_LIBZFS_H int zpool_vdev_clear(zpool_handle_t *, uint64_t); - -_LIBZFS_H nvlist_t *zpool_find_vdev(zpool_handle_t *, const char *, boolean_t *, - boolean_t *, boolean_t *); -_LIBZFS_H nvlist_t *zpool_find_vdev_by_physpath(zpool_handle_t *, const char *, - boolean_t *, boolean_t *, boolean_t *); -_LIBZFS_H int zpool_label_disk(libzfs_handle_t *, zpool_handle_t *, - const char *); -_LIBZFS_H uint64_t zpool_vdev_path_to_guid(zpool_handle_t *zhp, - const char *path); - -_LIBZFS_H const char *zpool_get_state_str(zpool_handle_t *); - -/* - * Functions to manage pool properties - */ -_LIBZFS_H int zpool_set_prop(zpool_handle_t *, const char *, const char *); -_LIBZFS_H int zpool_get_prop(zpool_handle_t *, zpool_prop_t, char *, - size_t proplen, zprop_source_t *, boolean_t literal); -_LIBZFS_H uint64_t zpool_get_prop_int(zpool_handle_t *, zpool_prop_t, - zprop_source_t *); -_LIBZFS_H int zpool_props_refresh(zpool_handle_t *); - -_LIBZFS_H const char *zpool_prop_to_name(zpool_prop_t); -_LIBZFS_H const char *zpool_prop_values(zpool_prop_t); - -/* - * Pool health statistics. - */ -typedef enum { - /* - * The following correspond to faults as defined in the (fault.fs.zfs.*) - * event namespace. Each is associated with a corresponding message ID. - * This must be kept in sync with the zfs_msgid_table in - * lib/libzfs/libzfs_status.c. - */ - ZPOOL_STATUS_CORRUPT_CACHE, /* corrupt /kernel/drv/zpool.cache */ - ZPOOL_STATUS_MISSING_DEV_R, /* missing device with replicas */ - ZPOOL_STATUS_MISSING_DEV_NR, /* missing device with no replicas */ - ZPOOL_STATUS_CORRUPT_LABEL_R, /* bad device label with replicas */ - ZPOOL_STATUS_CORRUPT_LABEL_NR, /* bad device label with no replicas */ - ZPOOL_STATUS_BAD_GUID_SUM, /* sum of device guids didn't match */ - ZPOOL_STATUS_CORRUPT_POOL, /* pool metadata is corrupted */ - ZPOOL_STATUS_CORRUPT_DATA, /* data errors in user (meta)data */ - ZPOOL_STATUS_FAILING_DEV, /* device experiencing errors */ - ZPOOL_STATUS_VERSION_NEWER, /* newer on-disk version */ - ZPOOL_STATUS_HOSTID_MISMATCH, /* last accessed by another system */ - ZPOOL_STATUS_HOSTID_ACTIVE, /* currently active on another system */ - ZPOOL_STATUS_HOSTID_REQUIRED, /* multihost=on and hostid=0 */ - ZPOOL_STATUS_IO_FAILURE_WAIT, /* failed I/O, failmode 'wait' */ - ZPOOL_STATUS_IO_FAILURE_CONTINUE, /* failed I/O, failmode 'continue' */ - ZPOOL_STATUS_IO_FAILURE_MMP, /* failed MMP, failmode not 'panic' */ - ZPOOL_STATUS_BAD_LOG, /* cannot read log chain(s) */ - ZPOOL_STATUS_ERRATA, /* informational errata available */ - - /* - * If the pool has unsupported features but can still be opened in - * read-only mode, its status is ZPOOL_STATUS_UNSUP_FEAT_WRITE. If the - * pool has unsupported features but cannot be opened at all, its - * status is ZPOOL_STATUS_UNSUP_FEAT_READ. - */ - ZPOOL_STATUS_UNSUP_FEAT_READ, /* unsupported features for read */ - ZPOOL_STATUS_UNSUP_FEAT_WRITE, /* unsupported features for write */ - - /* - * These faults have no corresponding message ID. At the time we are - * checking the status, the original reason for the FMA fault (I/O or - * checksum errors) has been lost. - */ - ZPOOL_STATUS_FAULTED_DEV_R, /* faulted device with replicas */ - ZPOOL_STATUS_FAULTED_DEV_NR, /* faulted device with no replicas */ - - /* - * The following are not faults per se, but still an error possibly - * requiring administrative attention. There is no corresponding - * message ID. - */ - ZPOOL_STATUS_VERSION_OLDER, /* older legacy on-disk version */ - ZPOOL_STATUS_FEAT_DISABLED, /* supported features are disabled */ - ZPOOL_STATUS_RESILVERING, /* device being resilvered */ - ZPOOL_STATUS_OFFLINE_DEV, /* device offline */ - ZPOOL_STATUS_REMOVED_DEV, /* removed device */ - ZPOOL_STATUS_REBUILDING, /* device being rebuilt */ - ZPOOL_STATUS_REBUILD_SCRUB, /* recommend scrubbing the pool */ - ZPOOL_STATUS_NON_NATIVE_ASHIFT, /* (e.g. 512e dev with ashift of 9) */ - ZPOOL_STATUS_COMPATIBILITY_ERR, /* bad 'compatibility' property */ - ZPOOL_STATUS_INCOMPATIBLE_FEAT, /* feature set outside compatibility */ - - /* - * Finally, the following indicates a healthy pool. - */ - ZPOOL_STATUS_OK -} zpool_status_t; - -_LIBZFS_H zpool_status_t zpool_get_status(zpool_handle_t *, char **, - zpool_errata_t *); -_LIBZFS_H zpool_status_t zpool_import_status(nvlist_t *, char **, - zpool_errata_t *); - -/* - * Statistics and configuration functions. - */ -_LIBZFS_H nvlist_t *zpool_get_config(zpool_handle_t *, nvlist_t **); -_LIBZFS_H nvlist_t *zpool_get_features(zpool_handle_t *); -_LIBZFS_H int zpool_refresh_stats(zpool_handle_t *, boolean_t *); -_LIBZFS_H int zpool_get_errlog(zpool_handle_t *, nvlist_t **); - -/* - * Import and export functions - */ -_LIBZFS_H int zpool_export(zpool_handle_t *, boolean_t, const char *); -_LIBZFS_H int zpool_export_force(zpool_handle_t *, const char *); -_LIBZFS_H int zpool_import(libzfs_handle_t *, nvlist_t *, const char *, - char *altroot); -_LIBZFS_H int zpool_import_props(libzfs_handle_t *, nvlist_t *, const char *, - nvlist_t *, int); -_LIBZFS_H void zpool_print_unsup_feat(nvlist_t *config); - -/* - * Miscellaneous pool functions - */ -struct zfs_cmd; - -_LIBZFS_H const char *zfs_history_event_names[]; - -typedef enum { - VDEV_NAME_PATH = 1 << 0, - VDEV_NAME_GUID = 1 << 1, - VDEV_NAME_FOLLOW_LINKS = 1 << 2, - VDEV_NAME_TYPE_ID = 1 << 3, -} vdev_name_t; - -_LIBZFS_H char *zpool_vdev_name(libzfs_handle_t *, zpool_handle_t *, nvlist_t *, - int name_flags); -_LIBZFS_H int zpool_upgrade(zpool_handle_t *, uint64_t); -_LIBZFS_H int zpool_get_history(zpool_handle_t *, nvlist_t **, uint64_t *, - boolean_t *); -_LIBZFS_H int zpool_events_next(libzfs_handle_t *, nvlist_t **, int *, unsigned, - int); -_LIBZFS_H int zpool_events_clear(libzfs_handle_t *, int *); -_LIBZFS_H int zpool_events_seek(libzfs_handle_t *, uint64_t, int); -_LIBZFS_H void zpool_obj_to_path_ds(zpool_handle_t *, uint64_t, uint64_t, - char *, size_t); -_LIBZFS_H void zpool_obj_to_path(zpool_handle_t *, uint64_t, uint64_t, char *, - size_t); -_LIBZFS_H int zfs_ioctl(libzfs_handle_t *, int, struct zfs_cmd *); -_LIBZFS_H int zpool_get_physpath(zpool_handle_t *, char *, size_t); -_LIBZFS_H void zpool_explain_recover(libzfs_handle_t *, const char *, int, - nvlist_t *); -_LIBZFS_H int zpool_checkpoint(zpool_handle_t *); -_LIBZFS_H int zpool_discard_checkpoint(zpool_handle_t *); -_LIBZFS_H boolean_t zpool_is_draid_spare(const char *); - -/* - * Basic handle manipulations. These functions do not create or destroy the - * underlying datasets, only the references to them. - */ -_LIBZFS_H zfs_handle_t *zfs_open(libzfs_handle_t *, const char *, int); -_LIBZFS_H zfs_handle_t *zfs_handle_dup(zfs_handle_t *); -_LIBZFS_H void zfs_close(zfs_handle_t *); -_LIBZFS_H zfs_type_t zfs_get_type(const zfs_handle_t *); -_LIBZFS_H zfs_type_t zfs_get_underlying_type(const zfs_handle_t *); -_LIBZFS_H const char *zfs_get_name(const zfs_handle_t *); -_LIBZFS_H zpool_handle_t *zfs_get_pool_handle(const zfs_handle_t *); -_LIBZFS_H const char *zfs_get_pool_name(const zfs_handle_t *); - -/* - * Property management functions. Some functions are shared with the kernel, - * and are found in sys/fs/zfs.h. - */ - -/* - * zfs dataset property management - */ -_LIBZFS_H const char *zfs_prop_default_string(zfs_prop_t); -_LIBZFS_H uint64_t zfs_prop_default_numeric(zfs_prop_t); -_LIBZFS_H const char *zfs_prop_column_name(zfs_prop_t); -_LIBZFS_H boolean_t zfs_prop_align_right(zfs_prop_t); - -_LIBZFS_H nvlist_t *zfs_valid_proplist(libzfs_handle_t *, zfs_type_t, - nvlist_t *, uint64_t, zfs_handle_t *, zpool_handle_t *, boolean_t, - const char *); - -_LIBZFS_H const char *zfs_prop_to_name(zfs_prop_t); -_LIBZFS_H int zfs_prop_set(zfs_handle_t *, const char *, const char *); -_LIBZFS_H int zfs_prop_set_list(zfs_handle_t *, nvlist_t *); -_LIBZFS_H int zfs_prop_get(zfs_handle_t *, zfs_prop_t, char *, size_t, - zprop_source_t *, char *, size_t, boolean_t); -_LIBZFS_H int zfs_prop_get_recvd(zfs_handle_t *, const char *, char *, size_t, - boolean_t); -_LIBZFS_H int zfs_prop_get_numeric(zfs_handle_t *, zfs_prop_t, uint64_t *, - zprop_source_t *, char *, size_t); -_LIBZFS_H int zfs_prop_get_userquota_int(zfs_handle_t *zhp, - const char *propname, uint64_t *propvalue); -_LIBZFS_H int zfs_prop_get_userquota(zfs_handle_t *zhp, const char *propname, - char *propbuf, int proplen, boolean_t literal); -_LIBZFS_H int zfs_prop_get_written_int(zfs_handle_t *zhp, const char *propname, - uint64_t *propvalue); -_LIBZFS_H int zfs_prop_get_written(zfs_handle_t *zhp, const char *propname, - char *propbuf, int proplen, boolean_t literal); -_LIBZFS_H int zfs_prop_get_feature(zfs_handle_t *zhp, const char *propname, - char *buf, size_t len); -_LIBZFS_H uint64_t getprop_uint64(zfs_handle_t *, zfs_prop_t, char **); -_LIBZFS_H uint64_t zfs_prop_get_int(zfs_handle_t *, zfs_prop_t); -_LIBZFS_H int zfs_prop_inherit(zfs_handle_t *, const char *, boolean_t); -_LIBZFS_H const char *zfs_prop_values(zfs_prop_t); -_LIBZFS_H int zfs_prop_is_string(zfs_prop_t prop); -_LIBZFS_H nvlist_t *zfs_get_all_props(zfs_handle_t *); -_LIBZFS_H nvlist_t *zfs_get_user_props(zfs_handle_t *); -_LIBZFS_H nvlist_t *zfs_get_recvd_props(zfs_handle_t *); -_LIBZFS_H nvlist_t *zfs_get_clones_nvl(zfs_handle_t *); - -_LIBZFS_H int zfs_wait_status(zfs_handle_t *, zfs_wait_activity_t, - boolean_t *, boolean_t *); - -/* - * zfs encryption management - */ -_LIBZFS_H int zfs_crypto_get_encryption_root(zfs_handle_t *, boolean_t *, - char *); -_LIBZFS_H int zfs_crypto_create(libzfs_handle_t *, char *, nvlist_t *, - nvlist_t *, boolean_t stdin_available, uint8_t **, uint_t *); -_LIBZFS_H int zfs_crypto_clone_check(libzfs_handle_t *, zfs_handle_t *, char *, - nvlist_t *); -_LIBZFS_H int zfs_crypto_attempt_load_keys(libzfs_handle_t *, char *); -_LIBZFS_H int zfs_crypto_load_key(zfs_handle_t *, boolean_t, char *); -_LIBZFS_H int zfs_crypto_unload_key(zfs_handle_t *); -_LIBZFS_H int zfs_crypto_rewrap(zfs_handle_t *, nvlist_t *, boolean_t); - -typedef struct zprop_list { - int pl_prop; - char *pl_user_prop; - struct zprop_list *pl_next; - boolean_t pl_all; - size_t pl_width; - size_t pl_recvd_width; - boolean_t pl_fixed; -} zprop_list_t; - -_LIBZFS_H int zfs_expand_proplist(zfs_handle_t *, zprop_list_t **, boolean_t, - boolean_t); -_LIBZFS_H void zfs_prune_proplist(zfs_handle_t *, uint8_t *); - -#define ZFS_MOUNTPOINT_NONE "none" -#define ZFS_MOUNTPOINT_LEGACY "legacy" - -#define ZFS_FEATURE_DISABLED "disabled" -#define ZFS_FEATURE_ENABLED "enabled" -#define ZFS_FEATURE_ACTIVE "active" - -#define ZFS_UNSUPPORTED_INACTIVE "inactive" -#define ZFS_UNSUPPORTED_READONLY "readonly" - -/* - * zpool property management - */ -_LIBZFS_H int zpool_expand_proplist(zpool_handle_t *, zprop_list_t **, - boolean_t); -_LIBZFS_H int zpool_prop_get_feature(zpool_handle_t *, const char *, char *, - size_t); -_LIBZFS_H const char *zpool_prop_default_string(zpool_prop_t); -_LIBZFS_H uint64_t zpool_prop_default_numeric(zpool_prop_t); -_LIBZFS_H const char *zpool_prop_column_name(zpool_prop_t); -_LIBZFS_H boolean_t zpool_prop_align_right(zpool_prop_t); - -/* - * Functions shared by zfs and zpool property management. - */ -_LIBZFS_H int zprop_iter(zprop_func func, void *cb, boolean_t show_all, - boolean_t ordered, zfs_type_t type); -_LIBZFS_H int zprop_get_list(libzfs_handle_t *, char *, zprop_list_t **, - zfs_type_t); -_LIBZFS_H void zprop_free_list(zprop_list_t *); - -#define ZFS_GET_NCOLS 5 - -typedef enum { - GET_COL_NONE, - GET_COL_NAME, - GET_COL_PROPERTY, - GET_COL_VALUE, - GET_COL_RECVD, - GET_COL_SOURCE -} zfs_get_column_t; - -/* - * Functions for printing zfs or zpool properties - */ -typedef struct zprop_get_cbdata { - int cb_sources; - zfs_get_column_t cb_columns[ZFS_GET_NCOLS]; - int cb_colwidths[ZFS_GET_NCOLS + 1]; - boolean_t cb_scripted; - boolean_t cb_literal; - boolean_t cb_first; - zprop_list_t *cb_proplist; - zfs_type_t cb_type; -} zprop_get_cbdata_t; - -_LIBZFS_H void zprop_print_one_property(const char *, zprop_get_cbdata_t *, - const char *, const char *, zprop_source_t, const char *, - const char *); - -/* - * Iterator functions. - */ -typedef int (*zfs_iter_f)(zfs_handle_t *, void *); -_LIBZFS_H int zfs_iter_root(libzfs_handle_t *, zfs_iter_f, void *); -_LIBZFS_H int zfs_iter_children(zfs_handle_t *, zfs_iter_f, void *); -_LIBZFS_H int zfs_iter_dependents(zfs_handle_t *, boolean_t, zfs_iter_f, - void *); -_LIBZFS_H int zfs_iter_filesystems(zfs_handle_t *, zfs_iter_f, void *); -_LIBZFS_H int zfs_iter_snapshots(zfs_handle_t *, boolean_t, zfs_iter_f, void *, - uint64_t, uint64_t); -_LIBZFS_H int zfs_iter_snapshots_sorted(zfs_handle_t *, zfs_iter_f, void *, - uint64_t, uint64_t); -_LIBZFS_H int zfs_iter_snapspec(zfs_handle_t *, const char *, zfs_iter_f, - void *); -_LIBZFS_H int zfs_iter_bookmarks(zfs_handle_t *, zfs_iter_f, void *); -_LIBZFS_H int zfs_iter_mounted(zfs_handle_t *, zfs_iter_f, void *); - -typedef struct get_all_cb { - zfs_handle_t **cb_handles; - size_t cb_alloc; - size_t cb_used; -} get_all_cb_t; - -_LIBZFS_H void zfs_foreach_mountpoint(libzfs_handle_t *, zfs_handle_t **, - size_t, zfs_iter_f, void *, boolean_t); -_LIBZFS_H void libzfs_add_handle(get_all_cb_t *, zfs_handle_t *); - -/* - * Functions to create and destroy datasets. - */ -_LIBZFS_H int zfs_create(libzfs_handle_t *, const char *, zfs_type_t, - nvlist_t *); -_LIBZFS_H int zfs_create_ancestors(libzfs_handle_t *, const char *); -_LIBZFS_H int zfs_destroy(zfs_handle_t *, boolean_t); -_LIBZFS_H int zfs_destroy_snaps(zfs_handle_t *, char *, boolean_t); -_LIBZFS_H int zfs_destroy_snaps_nvl(libzfs_handle_t *, nvlist_t *, boolean_t); -_LIBZFS_H int zfs_destroy_snaps_nvl_os(libzfs_handle_t *, nvlist_t *); -_LIBZFS_H int zfs_clone(zfs_handle_t *, const char *, nvlist_t *); -_LIBZFS_H int zfs_snapshot(libzfs_handle_t *, const char *, boolean_t, - nvlist_t *); -_LIBZFS_H int zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, - nvlist_t *props); -_LIBZFS_H int zfs_rollback(zfs_handle_t *, zfs_handle_t *, boolean_t); - -typedef struct renameflags { - /* recursive rename */ - int recursive : 1; - - /* don't unmount file systems */ - int nounmount : 1; - - /* force unmount file systems */ - int forceunmount : 1; -} renameflags_t; - -_LIBZFS_H int zfs_rename(zfs_handle_t *, const char *, renameflags_t); - -typedef struct sendflags { - /* Amount of extra information to print. */ - int verbosity; - - /* recursive send (ie, -R) */ - boolean_t replicate; - - /* for recursive send, skip sending missing snapshots */ - boolean_t skipmissing; - - /* for incrementals, do all intermediate snapshots */ - boolean_t doall; - - /* if dataset is a clone, do incremental from its origin */ - boolean_t fromorigin; - - /* field no longer used, maintained for backwards compatibility */ - boolean_t pad; - - /* send properties (ie, -p) */ - boolean_t props; - - /* do not send (no-op, ie. -n) */ - boolean_t dryrun; - - /* parsable verbose output (ie. -P) */ - boolean_t parsable; - - /* show progress (ie. -v) */ - boolean_t progress; - - /* large blocks (>128K) are permitted */ - boolean_t largeblock; - - /* WRITE_EMBEDDED records of type DATA are permitted */ - boolean_t embed_data; - - /* compressed WRITE records are permitted */ - boolean_t compress; - - /* raw encrypted records are permitted */ - boolean_t raw; - - /* only send received properties (ie. -b) */ - boolean_t backup; - - /* include snapshot holds in send stream */ - boolean_t holds; - - /* stream represents a partially received dataset */ - boolean_t saved; -} sendflags_t; - -typedef boolean_t (snapfilter_cb_t)(zfs_handle_t *, void *); - -_LIBZFS_H int zfs_send(zfs_handle_t *, const char *, const char *, - sendflags_t *, int, snapfilter_cb_t, void *, nvlist_t **); -_LIBZFS_H int zfs_send_one(zfs_handle_t *, const char *, int, sendflags_t *, - const char *); -_LIBZFS_H int zfs_send_progress(zfs_handle_t *, int, uint64_t *, uint64_t *); -_LIBZFS_H int zfs_send_resume(libzfs_handle_t *, sendflags_t *, int outfd, - const char *); -_LIBZFS_H int zfs_send_saved(zfs_handle_t *, sendflags_t *, int, const char *); -_LIBZFS_H nvlist_t *zfs_send_resume_token_to_nvlist(libzfs_handle_t *hdl, - const char *token); - -_LIBZFS_H int zfs_promote(zfs_handle_t *); -_LIBZFS_H int zfs_hold(zfs_handle_t *, const char *, const char *, - boolean_t, int); -_LIBZFS_H int zfs_hold_nvl(zfs_handle_t *, int, nvlist_t *); -_LIBZFS_H int zfs_release(zfs_handle_t *, const char *, const char *, - boolean_t); -_LIBZFS_H int zfs_get_holds(zfs_handle_t *, nvlist_t **); -_LIBZFS_H uint64_t zvol_volsize_to_reservation(zpool_handle_t *, uint64_t, - nvlist_t *); - -typedef int (*zfs_userspace_cb_t)(void *arg, const char *domain, - uid_t rid, uint64_t space); - -_LIBZFS_H int zfs_userspace(zfs_handle_t *, zfs_userquota_prop_t, - zfs_userspace_cb_t, void *); - -_LIBZFS_H int zfs_get_fsacl(zfs_handle_t *, nvlist_t **); -_LIBZFS_H int zfs_set_fsacl(zfs_handle_t *, boolean_t, nvlist_t *); - -typedef struct recvflags { - /* print informational messages (ie, -v was specified) */ - boolean_t verbose; - - /* the destination is a prefix, not the exact fs (ie, -d) */ - boolean_t isprefix; - - /* - * Only the tail of the sent snapshot path is appended to the - * destination to determine the received snapshot name (ie, -e). - */ - boolean_t istail; - - /* do not actually do the recv, just check if it would work (ie, -n) */ - boolean_t dryrun; - - /* rollback/destroy filesystems as necessary (eg, -F) */ - boolean_t force; - - /* set "canmount=off" on all modified filesystems */ - boolean_t canmountoff; - - /* - * Mark the file systems as "resumable" and do not destroy them if the - * receive is interrupted - */ - boolean_t resumable; - - /* byteswap flag is used internally; callers need not specify */ - boolean_t byteswap; - - /* do not mount file systems as they are extracted (private) */ - boolean_t nomount; - - /* Was holds flag set in the compound header? */ - boolean_t holds; - - /* skip receive of snapshot holds */ - boolean_t skipholds; - - /* mount the filesystem unless nomount is specified */ - boolean_t domount; - - /* force unmount while recv snapshot (private) */ - boolean_t forceunmount; -} recvflags_t; - -_LIBZFS_H int zfs_receive(libzfs_handle_t *, const char *, nvlist_t *, - recvflags_t *, int, avl_tree_t *); - -typedef enum diff_flags { - ZFS_DIFF_PARSEABLE = 0x1, - ZFS_DIFF_TIMESTAMP = 0x2, - ZFS_DIFF_CLASSIFY = 0x4 -} diff_flags_t; - -_LIBZFS_H int zfs_show_diffs(zfs_handle_t *, int, const char *, const char *, - int); - -/* - * Miscellaneous functions. - */ -_LIBZFS_H const char *zfs_type_to_name(zfs_type_t); -_LIBZFS_H void zfs_refresh_properties(zfs_handle_t *); -_LIBZFS_H int zfs_name_valid(const char *, zfs_type_t); -_LIBZFS_H zfs_handle_t *zfs_path_to_zhandle(libzfs_handle_t *, const char *, - zfs_type_t); -_LIBZFS_H int zfs_parent_name(zfs_handle_t *, char *, size_t); -_LIBZFS_H boolean_t zfs_dataset_exists(libzfs_handle_t *, const char *, - zfs_type_t); -_LIBZFS_H int zfs_spa_version(zfs_handle_t *, int *); -_LIBZFS_H boolean_t zfs_bookmark_exists(const char *path); - -/* - * Mount support functions. - */ -_LIBZFS_H boolean_t is_mounted(libzfs_handle_t *, const char *special, char **); -_LIBZFS_H boolean_t zfs_is_mounted(zfs_handle_t *, char **); -_LIBZFS_H int zfs_mount(zfs_handle_t *, const char *, int); -_LIBZFS_H int zfs_mount_at(zfs_handle_t *, const char *, int, const char *); -_LIBZFS_H int zfs_unmount(zfs_handle_t *, const char *, int); -_LIBZFS_H int zfs_unmountall(zfs_handle_t *, int); -_LIBZFS_H int zfs_mount_delegation_check(void); - -#if defined(__linux__) || defined(__APPLE__) -_LIBZFS_H int zfs_parse_mount_options(char *mntopts, unsigned long *mntflags, - unsigned long *zfsflags, int sloppy, char *badopt, char *mtabopt); -_LIBZFS_H void zfs_adjust_mount_options(zfs_handle_t *zhp, const char *mntpoint, - char *mntopts, char *mtabopt); -#endif - -/* - * Share support functions. - */ -_LIBZFS_H boolean_t zfs_is_shared(zfs_handle_t *); -_LIBZFS_H int zfs_share(zfs_handle_t *); -_LIBZFS_H int zfs_unshare(zfs_handle_t *); - -/* - * Protocol-specific share support functions. - */ -_LIBZFS_H boolean_t zfs_is_shared_nfs(zfs_handle_t *, char **); -_LIBZFS_H boolean_t zfs_is_shared_smb(zfs_handle_t *, char **); -_LIBZFS_H int zfs_share_nfs(zfs_handle_t *); -_LIBZFS_H int zfs_share_smb(zfs_handle_t *); -_LIBZFS_H int zfs_shareall(zfs_handle_t *); -_LIBZFS_H int zfs_unshare_nfs(zfs_handle_t *, const char *); -_LIBZFS_H int zfs_unshare_smb(zfs_handle_t *, const char *); -_LIBZFS_H int zfs_unshareall_nfs(zfs_handle_t *); -_LIBZFS_H int zfs_unshareall_smb(zfs_handle_t *); -_LIBZFS_H int zfs_unshareall_bypath(zfs_handle_t *, const char *); -_LIBZFS_H int zfs_unshareall_bytype(zfs_handle_t *, const char *, const char *); -_LIBZFS_H int zfs_unshareall(zfs_handle_t *); -_LIBZFS_H int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, char *, - void *, void *, int, zfs_share_op_t); -_LIBZFS_H void zfs_commit_nfs_shares(void); -_LIBZFS_H void zfs_commit_smb_shares(void); -_LIBZFS_H void zfs_commit_all_shares(void); -_LIBZFS_H void zfs_commit_shares(const char *); - -_LIBZFS_H int zfs_nicestrtonum(libzfs_handle_t *, const char *, uint64_t *); - -/* - * Utility functions to run an external process. - */ -#define STDOUT_VERBOSE 0x01 -#define STDERR_VERBOSE 0x02 -#define NO_DEFAULT_PATH 0x04 /* Don't use $PATH to lookup the command */ - -_LIBZFS_H int libzfs_run_process(const char *, char **, int); -_LIBZFS_H int libzfs_run_process_get_stdout(const char *, char *[], char *[], - char **[], int *); -_LIBZFS_H int libzfs_run_process_get_stdout_nopath(const char *, char *[], - char *[], char **[], int *); - -_LIBZFS_H void libzfs_free_str_array(char **, int); - -_LIBZFS_H int libzfs_envvar_is_set(char *); - -/* - * Utility functions for zfs version - */ -_LIBZFS_H void zfs_version_userland(char *, int); -_LIBZFS_H int zfs_version_kernel(char *, int); -_LIBZFS_H int zfs_version_print(void); - -/* - * Given a device or file, determine if it is part of a pool. - */ -_LIBZFS_H int zpool_in_use(libzfs_handle_t *, int, pool_state_t *, char **, - boolean_t *); - -/* - * Label manipulation. - */ -_LIBZFS_H int zpool_clear_label(int); -_LIBZFS_H int zpool_set_bootenv(zpool_handle_t *, const nvlist_t *); -_LIBZFS_H int zpool_get_bootenv(zpool_handle_t *, nvlist_t **); - -/* - * Management interfaces for SMB ACL files - */ - -_LIBZFS_H int zfs_smb_acl_add(libzfs_handle_t *, char *, char *, char *); -_LIBZFS_H int zfs_smb_acl_remove(libzfs_handle_t *, char *, char *, char *); -_LIBZFS_H int zfs_smb_acl_purge(libzfs_handle_t *, char *, char *); -_LIBZFS_H int zfs_smb_acl_rename(libzfs_handle_t *, char *, char *, char *, - char *); - -/* - * Enable and disable datasets within a pool by mounting/unmounting and - * sharing/unsharing them. - */ -_LIBZFS_H int zpool_enable_datasets(zpool_handle_t *, const char *, int); -_LIBZFS_H int zpool_disable_datasets(zpool_handle_t *, boolean_t); -_LIBZFS_H void zpool_disable_datasets_os(zpool_handle_t *, boolean_t); -_LIBZFS_H void zpool_disable_volume_os(const char *); - -/* - * Parse a features file for -o compatibility - */ -typedef enum { - ZPOOL_COMPATIBILITY_OK, - ZPOOL_COMPATIBILITY_WARNTOKEN, - ZPOOL_COMPATIBILITY_BADTOKEN, - ZPOOL_COMPATIBILITY_BADFILE, - ZPOOL_COMPATIBILITY_NOFILES -} zpool_compat_status_t; - -_LIBZFS_H zpool_compat_status_t zpool_load_compat(const char *, - boolean_t *, char *, size_t); - -#ifdef __FreeBSD__ - -/* - * Attach/detach the given filesystem to/from the given jail. - */ -_LIBZFS_H int zfs_jail(zfs_handle_t *zhp, int jailid, int attach); - -/* - * Set loader options for next boot. - */ -_LIBZFS_H int zpool_nextboot(libzfs_handle_t *, uint64_t, uint64_t, - const char *); - -#endif /* __FreeBSD__ */ - -#ifdef __cplusplus -} -#endif - -#endif /* _LIBZFS_H */ diff --git a/src/lib/include/libzfs_core.h b/src/lib/include/libzfs_core.h deleted file mode 100644 index 9020d70d..00000000 --- a/src/lib/include/libzfs_core.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright (c) 2012, 2020 by Delphix. All rights reserved. - * Copyright (c) 2017 Datto Inc. - * Copyright 2017 RackTop Systems. - * Copyright (c) 2017 Open-E, Inc. All Rights Reserved. - */ - -#ifndef _LIBZFS_CORE_H -#define _LIBZFS_CORE_H extern __attribute__((visibility("default"))) - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -_LIBZFS_CORE_H int libzfs_core_init(void); -_LIBZFS_CORE_H void libzfs_core_fini(void); - -struct zfs_cmd; -_LIBZFS_CORE_H int lzc_ioctl_fd(int, unsigned long, struct zfs_cmd *); - -/* - * NB: this type should be kept binary-compatible with dmu_objset_type_t. - */ -enum lzc_dataset_type { - LZC_DATSET_TYPE_ZFS = 2, - LZC_DATSET_TYPE_ZVOL -}; - -_LIBZFS_CORE_H int lzc_snapshot(nvlist_t *, nvlist_t *, nvlist_t **); -_LIBZFS_CORE_H int lzc_create(const char *, enum lzc_dataset_type, nvlist_t *, - uint8_t *, uint_t); -_LIBZFS_CORE_H int lzc_clone(const char *, const char *, nvlist_t *); -_LIBZFS_CORE_H int lzc_promote(const char *, char *, int); -_LIBZFS_CORE_H int lzc_destroy_snaps(nvlist_t *, boolean_t, nvlist_t **); -_LIBZFS_CORE_H int lzc_bookmark(nvlist_t *, nvlist_t **); -_LIBZFS_CORE_H int lzc_get_bookmarks(const char *, nvlist_t *, nvlist_t **); -_LIBZFS_CORE_H int lzc_get_bookmark_props(const char *, nvlist_t **); -_LIBZFS_CORE_H int lzc_destroy_bookmarks(nvlist_t *, nvlist_t **); -_LIBZFS_CORE_H int lzc_load_key(const char *, boolean_t, uint8_t *, uint_t); -_LIBZFS_CORE_H int lzc_unload_key(const char *); -_LIBZFS_CORE_H int lzc_change_key(const char *, uint64_t, nvlist_t *, uint8_t *, - uint_t); -_LIBZFS_CORE_H int lzc_initialize(const char *, pool_initialize_func_t, - nvlist_t *, nvlist_t **); -_LIBZFS_CORE_H int lzc_trim(const char *, pool_trim_func_t, uint64_t, boolean_t, - nvlist_t *, nvlist_t **); -_LIBZFS_CORE_H int lzc_redact(const char *, const char *, nvlist_t *); - -_LIBZFS_CORE_H int lzc_snaprange_space(const char *, const char *, uint64_t *); - -_LIBZFS_CORE_H int lzc_hold(nvlist_t *, int, nvlist_t **); -_LIBZFS_CORE_H int lzc_release(nvlist_t *, nvlist_t **); -_LIBZFS_CORE_H int lzc_get_holds(const char *, nvlist_t **); - -enum lzc_send_flags { - LZC_SEND_FLAG_EMBED_DATA = 1 << 0, - LZC_SEND_FLAG_LARGE_BLOCK = 1 << 1, - LZC_SEND_FLAG_COMPRESS = 1 << 2, - LZC_SEND_FLAG_RAW = 1 << 3, - LZC_SEND_FLAG_SAVED = 1 << 4, -}; - -_LIBZFS_CORE_H int lzc_send(const char *, const char *, int, - enum lzc_send_flags); -_LIBZFS_CORE_H int lzc_send_resume(const char *, const char *, int, - enum lzc_send_flags, uint64_t, uint64_t); -_LIBZFS_CORE_H int lzc_send_space(const char *, const char *, - enum lzc_send_flags, uint64_t *); - -struct dmu_replay_record; - -_LIBZFS_CORE_H int lzc_send_redacted(const char *, const char *, int, - enum lzc_send_flags, const char *); -_LIBZFS_CORE_H int lzc_send_resume_redacted(const char *, const char *, int, - enum lzc_send_flags, uint64_t, uint64_t, const char *); -_LIBZFS_CORE_H int lzc_receive(const char *, nvlist_t *, const char *, - boolean_t, boolean_t, int); -_LIBZFS_CORE_H int lzc_receive_resumable(const char *, nvlist_t *, const char *, - boolean_t, boolean_t, int); -_LIBZFS_CORE_H int lzc_receive_with_header(const char *, nvlist_t *, - const char *, boolean_t, boolean_t, boolean_t, int, - const struct dmu_replay_record *); -_LIBZFS_CORE_H int lzc_receive_one(const char *, nvlist_t *, const char *, - boolean_t, boolean_t, boolean_t, int, const struct dmu_replay_record *, int, - uint64_t *, uint64_t *, uint64_t *, nvlist_t **); -_LIBZFS_CORE_H int lzc_receive_with_cmdprops(const char *, nvlist_t *, - nvlist_t *, uint8_t *, uint_t, const char *, boolean_t, boolean_t, - boolean_t, int, const struct dmu_replay_record *, int, uint64_t *, - uint64_t *, uint64_t *, nvlist_t **); -_LIBZFS_CORE_H int lzc_send_space(const char *, const char *, - enum lzc_send_flags, uint64_t *); -_LIBZFS_CORE_H int lzc_send_space_resume_redacted(const char *, const char *, - enum lzc_send_flags, uint64_t, uint64_t, uint64_t, const char *, - int, uint64_t *); -_LIBZFS_CORE_H uint64_t lzc_send_progress(int); - -_LIBZFS_CORE_H boolean_t lzc_exists(const char *); - -_LIBZFS_CORE_H int lzc_rollback(const char *, char *, int); -_LIBZFS_CORE_H int lzc_rollback_to(const char *, const char *); - -_LIBZFS_CORE_H int lzc_rename(const char *, const char *); -_LIBZFS_CORE_H int lzc_destroy(const char *); - -_LIBZFS_CORE_H int lzc_channel_program(const char *, const char *, uint64_t, - uint64_t, nvlist_t *, nvlist_t **); -_LIBZFS_CORE_H int lzc_channel_program_nosync(const char *, const char *, - uint64_t, uint64_t, nvlist_t *, nvlist_t **); - -_LIBZFS_CORE_H int lzc_sync(const char *, nvlist_t *, nvlist_t **); -_LIBZFS_CORE_H int lzc_reopen(const char *, boolean_t); - -_LIBZFS_CORE_H int lzc_pool_checkpoint(const char *); -_LIBZFS_CORE_H int lzc_pool_checkpoint_discard(const char *); - -_LIBZFS_CORE_H int lzc_wait(const char *, zpool_wait_activity_t, boolean_t *); -_LIBZFS_CORE_H int lzc_wait_tag(const char *, zpool_wait_activity_t, uint64_t, - boolean_t *); -_LIBZFS_CORE_H int lzc_wait_fs(const char *, zfs_wait_activity_t, boolean_t *); - -_LIBZFS_CORE_H int lzc_set_bootenv(const char *, const nvlist_t *); -_LIBZFS_CORE_H int lzc_get_bootenv(const char *, nvlist_t **); -#ifdef __cplusplus -} -#endif - -#endif /* _LIBZFS_CORE_H */ diff --git a/src/lib/include/sys/avl.h b/src/lib/include/sys/avl.h deleted file mode 100644 index 20e88f2a..00000000 --- a/src/lib/include/sys/avl.h +++ /dev/null @@ -1,325 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* - * Copyright (c) 2014 by Delphix. All rights reserved. - */ - -#ifndef _AVL_H -#define _AVL_H extern __attribute__((visibility("default"))) - -/* - * This is a private header file. Applications should not directly include - * this file. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* - * This is a generic implementation of AVL trees for use in the Solaris kernel. - * The interfaces provide an efficient way of implementing an ordered set of - * data structures. - * - * AVL trees provide an alternative to using an ordered linked list. Using AVL - * trees will usually be faster, however they requires more storage. An ordered - * linked list in general requires 2 pointers in each data structure. The - * AVL tree implementation uses 3 pointers. The following chart gives the - * approximate performance of operations with the different approaches: - * - * Operation Link List AVL tree - * --------- -------- -------- - * lookup O(n) O(log(n)) - * - * insert 1 node constant constant - * - * delete 1 node constant between constant and O(log(n)) - * - * delete all nodes O(n) O(n) - * - * visit the next - * or prev node constant between constant and O(log(n)) - * - * - * The data structure nodes are anchored at an "avl_tree_t" (the equivalent - * of a list header) and the individual nodes will have a field of - * type "avl_node_t" (corresponding to list pointers). - * - * The type "avl_index_t" is used to indicate a position in the list for - * certain calls. - * - * The usage scenario is generally: - * - * 1. Create the list/tree with: avl_create() - * - * followed by any mixture of: - * - * 2a. Insert nodes with: avl_add(), or avl_find() and avl_insert() - * - * 2b. Visited elements with: - * avl_first() - returns the lowest valued node - * avl_last() - returns the highest valued node - * AVL_NEXT() - given a node go to next higher one - * AVL_PREV() - given a node go to previous lower one - * - * 2c. Find the node with the closest value either less than or greater - * than a given value with avl_nearest(). - * - * 2d. Remove individual nodes from the list/tree with avl_remove(). - * - * and finally when the list is being destroyed - * - * 3. Use avl_destroy_nodes() to quickly process/free up any remaining nodes. - * Note that once you use avl_destroy_nodes(), you can no longer - * use any routine except avl_destroy_nodes() and avl_destroy(). - * - * 4. Use avl_destroy() to destroy the AVL tree itself. - * - * Any locking for multiple thread access is up to the user to provide, just - * as is needed for any linked list implementation. - */ - -/* - * AVL comparator helpers - */ -#define TREE_ISIGN(a) (((a) > 0) - ((a) < 0)) -#define TREE_CMP(a, b) (((a) > (b)) - ((a) < (b))) -#define TREE_PCMP(a, b) \ - (((uintptr_t)(a) > (uintptr_t)(b)) - ((uintptr_t)(a) < (uintptr_t)(b))) - -/* - * Type used for the root of the AVL tree. - */ -typedef struct avl_tree avl_tree_t; - -/* - * The data nodes in the AVL tree must have a field of this type. - */ -typedef struct avl_node avl_node_t; - -/* - * An opaque type used to locate a position in the tree where a node - * would be inserted. - */ -typedef uintptr_t avl_index_t; - - -/* - * Direction constants used for avl_nearest(). - */ -#define AVL_BEFORE (0) -#define AVL_AFTER (1) - - -/* - * Prototypes - * - * Where not otherwise mentioned, "void *" arguments are a pointer to the - * user data structure which must contain a field of type avl_node_t. - * - * Also assume the user data structures looks like: - * struct my_type { - * ... - * avl_node_t my_link; - * ... - * }; - */ - -/* - * Initialize an AVL tree. Arguments are: - * - * tree - the tree to be initialized - * compar - function to compare two nodes, it must return exactly: -1, 0, or +1 - * -1 for <, 0 for ==, and +1 for > - * size - the value of sizeof(struct my_type) - * offset - the value of OFFSETOF(struct my_type, my_link) - */ -_AVL_H void avl_create(avl_tree_t *tree, - int (*compar) (const void *, const void *), size_t size, size_t offset); - - -/* - * Find a node with a matching value in the tree. Returns the matching node - * found. If not found, it returns NULL and then if "where" is not NULL it sets - * "where" for use with avl_insert() or avl_nearest(). - * - * node - node that has the value being looked for - * where - position for use with avl_nearest() or avl_insert(), may be NULL - */ -_AVL_H void *avl_find(avl_tree_t *tree, const void *node, avl_index_t *where); - -/* - * Insert a node into the tree. - * - * node - the node to insert - * where - position as returned from avl_find() - */ -_AVL_H void avl_insert(avl_tree_t *tree, void *node, avl_index_t where); - -/* - * Insert "new_data" in "tree" in the given "direction" either after - * or before the data "here". - * - * This might be useful for avl clients caching recently accessed - * data to avoid doing avl_find() again for insertion. - * - * new_data - new data to insert - * here - existing node in "tree" - * direction - either AVL_AFTER or AVL_BEFORE the data "here". - */ -_AVL_H void avl_insert_here(avl_tree_t *tree, void *new_data, void *here, - int direction); - - -/* - * Return the first or last valued node in the tree. Will return NULL - * if the tree is empty. - * - */ -_AVL_H void *avl_first(avl_tree_t *tree); -_AVL_H void *avl_last(avl_tree_t *tree); - - -/* - * Return the next or previous valued node in the tree. - * AVL_NEXT() will return NULL if at the last node. - * AVL_PREV() will return NULL if at the first node. - * - * node - the node from which the next or previous node is found - */ -#define AVL_NEXT(tree, node) avl_walk(tree, node, AVL_AFTER) -#define AVL_PREV(tree, node) avl_walk(tree, node, AVL_BEFORE) - - -/* - * Find the node with the nearest value either greater or less than - * the value from a previous avl_find(). Returns the node or NULL if - * there isn't a matching one. - * - * where - position as returned from avl_find() - * direction - either AVL_BEFORE or AVL_AFTER - * - * EXAMPLE get the greatest node that is less than a given value: - * - * avl_tree_t *tree; - * struct my_data look_for_value = {....}; - * struct my_data *node; - * struct my_data *less; - * avl_index_t where; - * - * node = avl_find(tree, &look_for_value, &where); - * if (node != NULL) - * less = AVL_PREV(tree, node); - * else - * less = avl_nearest(tree, where, AVL_BEFORE); - */ -_AVL_H void *avl_nearest(avl_tree_t *tree, avl_index_t where, int direction); - - -/* - * Add a single node to the tree. - * The node must not be in the tree, and it must not - * compare equal to any other node already in the tree. - * - * node - the node to add - */ -_AVL_H void avl_add(avl_tree_t *tree, void *node); - - -/* - * Remove a single node from the tree. The node must be in the tree. - * - * node - the node to remove - */ -_AVL_H void avl_remove(avl_tree_t *tree, void *node); - -/* - * Reinsert a node only if its order has changed relative to its nearest - * neighbors. To optimize performance avl_update_lt() checks only the previous - * node and avl_update_gt() checks only the next node. Use avl_update_lt() and - * avl_update_gt() only if you know the direction in which the order of the - * node may change. - */ -_AVL_H boolean_t avl_update(avl_tree_t *, void *); -_AVL_H boolean_t avl_update_lt(avl_tree_t *, void *); -_AVL_H boolean_t avl_update_gt(avl_tree_t *, void *); - -/* - * Swaps the contents of the two trees. - */ -_AVL_H void avl_swap(avl_tree_t *tree1, avl_tree_t *tree2); - -/* - * Return the number of nodes in the tree - */ -_AVL_H ulong_t avl_numnodes(avl_tree_t *tree); - -/* - * Return B_TRUE if there are zero nodes in the tree, B_FALSE otherwise. - */ -_AVL_H boolean_t avl_is_empty(avl_tree_t *tree); - -/* - * Used to destroy any remaining nodes in a tree. The cookie argument should - * be initialized to NULL before the first call. Returns a node that has been - * removed from the tree and may be free()'d. Returns NULL when the tree is - * empty. - * - * Once you call avl_destroy_nodes(), you can only continuing calling it and - * finally avl_destroy(). No other AVL routines will be valid. - * - * cookie - a "void *" used to save state between calls to avl_destroy_nodes() - * - * EXAMPLE: - * avl_tree_t *tree; - * struct my_data *node; - * void *cookie; - * - * cookie = NULL; - * while ((node = avl_destroy_nodes(tree, &cookie)) != NULL) - * free(node); - * avl_destroy(tree); - */ -_AVL_H void *avl_destroy_nodes(avl_tree_t *tree, void **cookie); - - -/* - * Final destroy of an AVL tree. Arguments are: - * - * tree - the empty tree to destroy - */ -_AVL_H void avl_destroy(avl_tree_t *tree); - - - -#ifdef __cplusplus -} -#endif - -#endif /* _AVL_H */ diff --git a/src/lib/include/sys/avl_impl.h b/src/lib/include/sys/avl_impl.h deleted file mode 100644 index c464a62a..00000000 --- a/src/lib/include/sys/avl_impl.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _AVL_IMPL_H -#define _AVL_IMPL_H extern __attribute__((visibility("default"))) - - -/* - * This is a private header file. Applications should not directly include - * this file. - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/* - * generic AVL tree implementation for kernel use - * - * There are 5 pieces of information stored for each node in an AVL tree - * - * pointer to less than child - * pointer to greater than child - * a pointer to the parent of this node - * an indication [0/1] of which child I am of my parent - * a "balance" (-1, 0, +1) indicating which child tree is taller - * - * Since they only need 3 bits, the last two fields are packed into the - * bottom bits of the parent pointer on 64 bit machines to save on space. - */ - -#ifndef _LP64 - -struct avl_node { - struct avl_node *avl_child[2]; /* left/right children */ - struct avl_node *avl_parent; /* this node's parent */ - unsigned short avl_child_index; /* my index in parent's avl_child[] */ - short avl_balance; /* balance value: -1, 0, +1 */ -}; - -#define AVL_XPARENT(n) ((n)->avl_parent) -#define AVL_SETPARENT(n, p) ((n)->avl_parent = (p)) - -#define AVL_XCHILD(n) ((n)->avl_child_index) -#define AVL_SETCHILD(n, c) ((n)->avl_child_index = (unsigned short)(c)) - -#define AVL_XBALANCE(n) ((n)->avl_balance) -#define AVL_SETBALANCE(n, b) ((n)->avl_balance = (short)(b)) - -#else /* _LP64 */ - -/* - * for 64 bit machines, avl_pcb contains parent pointer, balance and child_index - * values packed in the following manner: - * - * |63 3| 2 |1 0 | - * |-------------------------------------|-----------------|-------------| - * | avl_parent hi order bits | avl_child_index | avl_balance | - * | | | + 1 | - * |-------------------------------------|-----------------|-------------| - * - */ -struct avl_node { - struct avl_node *avl_child[2]; /* left/right children nodes */ - uintptr_t avl_pcb; /* parent, child_index, balance */ -}; - -/* - * macros to extract/set fields in avl_pcb - * - * pointer to the parent of the current node is the high order bits - */ -#define AVL_XPARENT(n) ((struct avl_node *)((n)->avl_pcb & ~7)) -#define AVL_SETPARENT(n, p) \ - ((n)->avl_pcb = (((n)->avl_pcb & 7) | (uintptr_t)(p))) - -/* - * index of this node in its parent's avl_child[]: bit #2 - */ -#define AVL_XCHILD(n) (((n)->avl_pcb >> 2) & 1) -#define AVL_SETCHILD(n, c) \ - ((n)->avl_pcb = (uintptr_t)(((n)->avl_pcb & ~4) | ((c) << 2))) - -/* - * balance indication for a node, lowest 2 bits. A valid balance is - * -1, 0, or +1, and is encoded by adding 1 to the value to get the - * unsigned values of 0, 1, 2. - */ -#define AVL_XBALANCE(n) ((int)(((n)->avl_pcb & 3) - 1)) -#define AVL_SETBALANCE(n, b) \ - ((n)->avl_pcb = (uintptr_t)((((n)->avl_pcb & ~3) | ((b) + 1)))) - -#endif /* _LP64 */ - - - -/* - * switch between a node and data pointer for a given tree - * the value of "o" is tree->avl_offset - */ -#define AVL_NODE2DATA(n, o) ((void *)((uintptr_t)(n) - (o))) -#define AVL_DATA2NODE(d, o) ((struct avl_node *)((uintptr_t)(d) + (o))) - - - -/* - * macros used to create/access an avl_index_t - */ -#define AVL_INDEX2NODE(x) ((avl_node_t *)((x) & ~1)) -#define AVL_INDEX2CHILD(x) ((x) & 1) -#define AVL_MKINDEX(n, c) ((avl_index_t)(n) | (c)) - - -/* - * The tree structure. The fields avl_root, avl_compar, and avl_offset come - * first since they are needed for avl_find(). We want them to fit into - * a single 64 byte cache line to make avl_find() as fast as possible. - */ -struct avl_tree { - struct avl_node *avl_root; /* root node in tree */ - int (*avl_compar)(const void *, const void *); - size_t avl_offset; /* offsetof(type, avl_link_t field) */ - ulong_t avl_numnodes; /* number of nodes in the tree */ -#ifndef _KERNEL - size_t avl_pad; /* For backwards ABI compatibility. */ -#endif -}; - - -/* - * This will only by used via AVL_NEXT() or AVL_PREV() - */ -_AVL_IMPL_H void *avl_walk(struct avl_tree *, void *, int); - -#ifdef __cplusplus -} -#endif - -#endif /* _AVL_IMPL_H */ diff --git a/src/lib/include/sys/fs/zfs.h b/src/lib/include/sys/fs/zfs.h deleted file mode 100644 index 2af11fc7..00000000 --- a/src/lib/include/sys/fs/zfs.h +++ /dev/null @@ -1,1669 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2020 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] - * Copyright (c) 2017, Intel Corporation. - * Copyright (c) 2019 Datto Inc. - * Portions Copyright 2010 Robert Milkowski - * Copyright (c) 2021, Colm Buckley - */ - -#ifndef _SYS_FS_ZFS_H -#define _SYS_FS_ZFS_H extern __attribute__((visibility("default"))) - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Types and constants shared between userland and the kernel. - */ - -/* - * Each dataset can be one of the following types. These constants can be - * combined into masks that can be passed to various functions. - */ -typedef enum { - ZFS_TYPE_FILESYSTEM = (1 << 0), - ZFS_TYPE_SNAPSHOT = (1 << 1), - ZFS_TYPE_VOLUME = (1 << 2), - ZFS_TYPE_POOL = (1 << 3), - ZFS_TYPE_BOOKMARK = (1 << 4) -} zfs_type_t; - -/* - * NB: lzc_dataset_type should be updated whenever a new objset type is added, - * if it represents a real type of a dataset that can be created from userland. - */ -typedef enum dmu_objset_type { - DMU_OST_NONE, - DMU_OST_META, - DMU_OST_ZFS, - DMU_OST_ZVOL, - DMU_OST_OTHER, /* For testing only! */ - DMU_OST_ANY, /* Be careful! */ - DMU_OST_NUMTYPES -} dmu_objset_type_t; - -#define ZFS_TYPE_DATASET \ - (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT) - -/* - * All of these include the terminating NUL byte. - */ -#define ZAP_MAXNAMELEN 256 -#define ZAP_MAXVALUELEN (1024 * 8) -#define ZAP_OLDMAXVALUELEN 1024 -#define ZFS_MAX_DATASET_NAME_LEN 256 - -/* - * Dataset properties are identified by these constants and must be added to - * the end of this list to ensure that external consumers are not affected - * by the change. If you make any changes to this list, be sure to update - * the property table in module/zcommon/zfs_prop.c. - */ -typedef enum { - ZPROP_CONT = -2, - ZPROP_INVAL = -1, - ZFS_PROP_TYPE = 0, - ZFS_PROP_CREATION, - ZFS_PROP_USED, - ZFS_PROP_AVAILABLE, - ZFS_PROP_REFERENCED, - ZFS_PROP_COMPRESSRATIO, - ZFS_PROP_MOUNTED, - ZFS_PROP_ORIGIN, - ZFS_PROP_QUOTA, - ZFS_PROP_RESERVATION, - ZFS_PROP_VOLSIZE, - ZFS_PROP_VOLBLOCKSIZE, - ZFS_PROP_RECORDSIZE, - ZFS_PROP_MOUNTPOINT, - ZFS_PROP_SHARENFS, - ZFS_PROP_CHECKSUM, - ZFS_PROP_COMPRESSION, - ZFS_PROP_ATIME, - ZFS_PROP_DEVICES, - ZFS_PROP_EXEC, - ZFS_PROP_SETUID, - ZFS_PROP_READONLY, - ZFS_PROP_ZONED, - ZFS_PROP_SNAPDIR, - ZFS_PROP_ACLMODE, - ZFS_PROP_ACLINHERIT, - ZFS_PROP_CREATETXG, - ZFS_PROP_NAME, /* not exposed to the user */ - ZFS_PROP_CANMOUNT, - ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */ - ZFS_PROP_XATTR, - ZFS_PROP_NUMCLONES, /* not exposed to the user */ - ZFS_PROP_COPIES, - ZFS_PROP_VERSION, - ZFS_PROP_UTF8ONLY, - ZFS_PROP_NORMALIZE, - ZFS_PROP_CASE, - ZFS_PROP_VSCAN, - ZFS_PROP_NBMAND, - ZFS_PROP_SHARESMB, - ZFS_PROP_REFQUOTA, - ZFS_PROP_REFRESERVATION, - ZFS_PROP_GUID, - ZFS_PROP_PRIMARYCACHE, - ZFS_PROP_SECONDARYCACHE, - ZFS_PROP_USEDSNAP, - ZFS_PROP_USEDDS, - ZFS_PROP_USEDCHILD, - ZFS_PROP_USEDREFRESERV, - ZFS_PROP_USERACCOUNTING, /* not exposed to the user */ - ZFS_PROP_STMF_SHAREINFO, /* not exposed to the user */ - ZFS_PROP_DEFER_DESTROY, - ZFS_PROP_USERREFS, - ZFS_PROP_LOGBIAS, - ZFS_PROP_UNIQUE, /* not exposed to the user */ - ZFS_PROP_OBJSETID, - ZFS_PROP_DEDUP, - ZFS_PROP_MLSLABEL, - ZFS_PROP_SYNC, - ZFS_PROP_DNODESIZE, - ZFS_PROP_REFRATIO, - ZFS_PROP_WRITTEN, - ZFS_PROP_CLONES, - ZFS_PROP_LOGICALUSED, - ZFS_PROP_LOGICALREFERENCED, - ZFS_PROP_INCONSISTENT, /* not exposed to the user */ - ZFS_PROP_VOLMODE, - ZFS_PROP_FILESYSTEM_LIMIT, - ZFS_PROP_SNAPSHOT_LIMIT, - ZFS_PROP_FILESYSTEM_COUNT, - ZFS_PROP_SNAPSHOT_COUNT, - ZFS_PROP_SNAPDEV, - ZFS_PROP_ACLTYPE, - ZFS_PROP_SELINUX_CONTEXT, - ZFS_PROP_SELINUX_FSCONTEXT, - ZFS_PROP_SELINUX_DEFCONTEXT, - ZFS_PROP_SELINUX_ROOTCONTEXT, - ZFS_PROP_RELATIME, - ZFS_PROP_REDUNDANT_METADATA, - ZFS_PROP_OVERLAY, - ZFS_PROP_PREV_SNAP, - ZFS_PROP_RECEIVE_RESUME_TOKEN, - ZFS_PROP_ENCRYPTION, - ZFS_PROP_KEYLOCATION, - ZFS_PROP_KEYFORMAT, - ZFS_PROP_PBKDF2_SALT, - ZFS_PROP_PBKDF2_ITERS, - ZFS_PROP_ENCRYPTION_ROOT, - ZFS_PROP_KEY_GUID, - ZFS_PROP_KEYSTATUS, - ZFS_PROP_REMAPTXG, /* obsolete - no longer used */ - ZFS_PROP_SPECIAL_SMALL_BLOCKS, - ZFS_PROP_IVSET_GUID, /* not exposed to the user */ - ZFS_PROP_REDACTED, - ZFS_PROP_REDACT_SNAPS, - ZFS_NUM_PROPS -} zfs_prop_t; - -typedef enum { - ZFS_PROP_USERUSED, - ZFS_PROP_USERQUOTA, - ZFS_PROP_GROUPUSED, - ZFS_PROP_GROUPQUOTA, - ZFS_PROP_USEROBJUSED, - ZFS_PROP_USEROBJQUOTA, - ZFS_PROP_GROUPOBJUSED, - ZFS_PROP_GROUPOBJQUOTA, - ZFS_PROP_PROJECTUSED, - ZFS_PROP_PROJECTQUOTA, - ZFS_PROP_PROJECTOBJUSED, - ZFS_PROP_PROJECTOBJQUOTA, - ZFS_NUM_USERQUOTA_PROPS -} zfs_userquota_prop_t; - -_SYS_FS_ZFS_H const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS]; - -/* - * Pool properties are identified by these constants and must be added to the - * end of this list to ensure that external consumers are not affected - * by the change. Properties must be registered in zfs_prop_init(). - */ -typedef enum { - ZPOOL_PROP_INVAL = -1, - ZPOOL_PROP_NAME, - ZPOOL_PROP_SIZE, - ZPOOL_PROP_CAPACITY, - ZPOOL_PROP_ALTROOT, - ZPOOL_PROP_HEALTH, - ZPOOL_PROP_GUID, - ZPOOL_PROP_VERSION, - ZPOOL_PROP_BOOTFS, - ZPOOL_PROP_DELEGATION, - ZPOOL_PROP_AUTOREPLACE, - ZPOOL_PROP_CACHEFILE, - ZPOOL_PROP_FAILUREMODE, - ZPOOL_PROP_LISTSNAPS, - ZPOOL_PROP_AUTOEXPAND, - ZPOOL_PROP_DEDUPDITTO, - ZPOOL_PROP_DEDUPRATIO, - ZPOOL_PROP_FREE, - ZPOOL_PROP_ALLOCATED, - ZPOOL_PROP_READONLY, - ZPOOL_PROP_ASHIFT, - ZPOOL_PROP_COMMENT, - ZPOOL_PROP_EXPANDSZ, - ZPOOL_PROP_FREEING, - ZPOOL_PROP_FRAGMENTATION, - ZPOOL_PROP_LEAKED, - ZPOOL_PROP_MAXBLOCKSIZE, - ZPOOL_PROP_TNAME, - ZPOOL_PROP_MAXDNODESIZE, - ZPOOL_PROP_MULTIHOST, - ZPOOL_PROP_CHECKPOINT, - ZPOOL_PROP_LOAD_GUID, - ZPOOL_PROP_AUTOTRIM, - ZPOOL_PROP_COMPATIBILITY, - ZPOOL_NUM_PROPS -} zpool_prop_t; - -/* Small enough to not hog a whole line of printout in zpool(8). */ -#define ZPROP_MAX_COMMENT 32 - -#define ZPROP_VALUE "value" -#define ZPROP_SOURCE "source" - -typedef enum { - ZPROP_SRC_NONE = 0x1, - ZPROP_SRC_DEFAULT = 0x2, - ZPROP_SRC_TEMPORARY = 0x4, - ZPROP_SRC_LOCAL = 0x8, - ZPROP_SRC_INHERITED = 0x10, - ZPROP_SRC_RECEIVED = 0x20 -} zprop_source_t; - -#define ZPROP_SRC_ALL 0x3f - -#define ZPROP_SOURCE_VAL_RECVD "$recvd" -#define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS" - -/* - * Dataset flag implemented as a special entry in the props zap object - * indicating that the dataset has received properties on or after - * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties - * just as it did in earlier versions, and thereafter, local properties are - * preserved. - */ -#define ZPROP_HAS_RECVD "$hasrecvd" - -typedef enum { - ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */ - ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */ -} zprop_errflags_t; - -typedef int (*zprop_func)(int, void *); - -/* - * Properties to be set on the root file system of a new pool - * are stuffed into their own nvlist, which is then included in - * the properties nvlist with the pool properties. - */ -#define ZPOOL_ROOTFS_PROPS "root-props-nvl" - -/* - * Length of 'written@' and 'written#' - */ -#define ZFS_WRITTEN_PROP_PREFIX_LEN 8 - -/* - * Dataset property functions shared between libzfs and kernel. - */ -_SYS_FS_ZFS_H const char *zfs_prop_default_string(zfs_prop_t); -_SYS_FS_ZFS_H uint64_t zfs_prop_default_numeric(zfs_prop_t); -_SYS_FS_ZFS_H boolean_t zfs_prop_readonly(zfs_prop_t); -_SYS_FS_ZFS_H boolean_t zfs_prop_visible(zfs_prop_t prop); -_SYS_FS_ZFS_H boolean_t zfs_prop_inheritable(zfs_prop_t); -_SYS_FS_ZFS_H boolean_t zfs_prop_setonce(zfs_prop_t); -_SYS_FS_ZFS_H boolean_t zfs_prop_encryption_key_param(zfs_prop_t); -_SYS_FS_ZFS_H boolean_t zfs_prop_valid_keylocation(const char *, boolean_t); -_SYS_FS_ZFS_H const char *zfs_prop_to_name(zfs_prop_t); -_SYS_FS_ZFS_H zfs_prop_t zfs_name_to_prop(const char *); -_SYS_FS_ZFS_H boolean_t zfs_prop_user(const char *); -_SYS_FS_ZFS_H boolean_t zfs_prop_userquota(const char *); -_SYS_FS_ZFS_H boolean_t zfs_prop_written(const char *); -_SYS_FS_ZFS_H int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **); -_SYS_FS_ZFS_H int zfs_prop_string_to_index(zfs_prop_t, const char *, - uint64_t *); -_SYS_FS_ZFS_H uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed); -_SYS_FS_ZFS_H boolean_t zfs_prop_valid_for_type(int, zfs_type_t, boolean_t); - -/* - * Pool property functions shared between libzfs and kernel. - */ -_SYS_FS_ZFS_H zpool_prop_t zpool_name_to_prop(const char *); -_SYS_FS_ZFS_H const char *zpool_prop_to_name(zpool_prop_t); -_SYS_FS_ZFS_H const char *zpool_prop_default_string(zpool_prop_t); -_SYS_FS_ZFS_H uint64_t zpool_prop_default_numeric(zpool_prop_t); -_SYS_FS_ZFS_H boolean_t zpool_prop_readonly(zpool_prop_t); -_SYS_FS_ZFS_H boolean_t zpool_prop_setonce(zpool_prop_t); -_SYS_FS_ZFS_H boolean_t zpool_prop_feature(const char *); -_SYS_FS_ZFS_H boolean_t zpool_prop_unsupported(const char *); -_SYS_FS_ZFS_H int zpool_prop_index_to_string(zpool_prop_t, uint64_t, - const char **); -_SYS_FS_ZFS_H int zpool_prop_string_to_index(zpool_prop_t, const char *, - uint64_t *); -_SYS_FS_ZFS_H uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed); - -/* - * Definitions for the Delegation. - */ -typedef enum { - ZFS_DELEG_WHO_UNKNOWN = 0, - ZFS_DELEG_USER = 'u', - ZFS_DELEG_USER_SETS = 'U', - ZFS_DELEG_GROUP = 'g', - ZFS_DELEG_GROUP_SETS = 'G', - ZFS_DELEG_EVERYONE = 'e', - ZFS_DELEG_EVERYONE_SETS = 'E', - ZFS_DELEG_CREATE = 'c', - ZFS_DELEG_CREATE_SETS = 'C', - ZFS_DELEG_NAMED_SET = 's', - ZFS_DELEG_NAMED_SET_SETS = 'S' -} zfs_deleg_who_type_t; - -typedef enum { - ZFS_DELEG_NONE = 0, - ZFS_DELEG_PERM_LOCAL = 1, - ZFS_DELEG_PERM_DESCENDENT = 2, - ZFS_DELEG_PERM_LOCALDESCENDENT = 3, - ZFS_DELEG_PERM_CREATE = 4 -} zfs_deleg_inherit_t; - -#define ZFS_DELEG_PERM_UID "uid" -#define ZFS_DELEG_PERM_GID "gid" -#define ZFS_DELEG_PERM_GROUPS "groups" - -#define ZFS_MLSLABEL_DEFAULT "none" - -#define ZFS_SMB_ACL_SRC "src" -#define ZFS_SMB_ACL_TARGET "target" - -typedef enum { - ZFS_CANMOUNT_OFF = 0, - ZFS_CANMOUNT_ON = 1, - ZFS_CANMOUNT_NOAUTO = 2 -} zfs_canmount_type_t; - -typedef enum { - ZFS_LOGBIAS_LATENCY = 0, - ZFS_LOGBIAS_THROUGHPUT = 1 -} zfs_logbias_op_t; - -typedef enum zfs_share_op { - ZFS_SHARE_NFS = 0, - ZFS_UNSHARE_NFS = 1, - ZFS_SHARE_SMB = 2, - ZFS_UNSHARE_SMB = 3 -} zfs_share_op_t; - -typedef enum zfs_smb_acl_op { - ZFS_SMB_ACL_ADD, - ZFS_SMB_ACL_REMOVE, - ZFS_SMB_ACL_RENAME, - ZFS_SMB_ACL_PURGE -} zfs_smb_acl_op_t; - -typedef enum zfs_cache_type { - ZFS_CACHE_NONE = 0, - ZFS_CACHE_METADATA = 1, - ZFS_CACHE_ALL = 2 -} zfs_cache_type_t; - -typedef enum { - ZFS_SYNC_STANDARD = 0, - ZFS_SYNC_ALWAYS = 1, - ZFS_SYNC_DISABLED = 2 -} zfs_sync_type_t; - -typedef enum { - ZFS_XATTR_OFF = 0, - ZFS_XATTR_DIR = 1, - ZFS_XATTR_SA = 2 -} zfs_xattr_type_t; - -typedef enum { - ZFS_DNSIZE_LEGACY = 0, - ZFS_DNSIZE_AUTO = 1, - ZFS_DNSIZE_1K = 1024, - ZFS_DNSIZE_2K = 2048, - ZFS_DNSIZE_4K = 4096, - ZFS_DNSIZE_8K = 8192, - ZFS_DNSIZE_16K = 16384 -} zfs_dnsize_type_t; - -typedef enum { - ZFS_REDUNDANT_METADATA_ALL, - ZFS_REDUNDANT_METADATA_MOST -} zfs_redundant_metadata_type_t; - -typedef enum { - ZFS_VOLMODE_DEFAULT = 0, - ZFS_VOLMODE_GEOM = 1, - ZFS_VOLMODE_DEV = 2, - ZFS_VOLMODE_NONE = 3 -} zfs_volmode_t; - -typedef enum zfs_keystatus { - ZFS_KEYSTATUS_NONE = 0, - ZFS_KEYSTATUS_UNAVAILABLE, - ZFS_KEYSTATUS_AVAILABLE, -} zfs_keystatus_t; - -typedef enum zfs_keyformat { - ZFS_KEYFORMAT_NONE = 0, - ZFS_KEYFORMAT_RAW, - ZFS_KEYFORMAT_HEX, - ZFS_KEYFORMAT_PASSPHRASE, - ZFS_KEYFORMAT_FORMATS -} zfs_keyformat_t; - -typedef enum zfs_key_location { - ZFS_KEYLOCATION_NONE = 0, - ZFS_KEYLOCATION_PROMPT, - ZFS_KEYLOCATION_URI, - ZFS_KEYLOCATION_LOCATIONS -} zfs_keylocation_t; - -#define DEFAULT_PBKDF2_ITERATIONS 350000 -#define MIN_PBKDF2_ITERATIONS 100000 - -/* - * On-disk version number. - */ -#define SPA_VERSION_1 1ULL -#define SPA_VERSION_2 2ULL -#define SPA_VERSION_3 3ULL -#define SPA_VERSION_4 4ULL -#define SPA_VERSION_5 5ULL -#define SPA_VERSION_6 6ULL -#define SPA_VERSION_7 7ULL -#define SPA_VERSION_8 8ULL -#define SPA_VERSION_9 9ULL -#define SPA_VERSION_10 10ULL -#define SPA_VERSION_11 11ULL -#define SPA_VERSION_12 12ULL -#define SPA_VERSION_13 13ULL -#define SPA_VERSION_14 14ULL -#define SPA_VERSION_15 15ULL -#define SPA_VERSION_16 16ULL -#define SPA_VERSION_17 17ULL -#define SPA_VERSION_18 18ULL -#define SPA_VERSION_19 19ULL -#define SPA_VERSION_20 20ULL -#define SPA_VERSION_21 21ULL -#define SPA_VERSION_22 22ULL -#define SPA_VERSION_23 23ULL -#define SPA_VERSION_24 24ULL -#define SPA_VERSION_25 25ULL -#define SPA_VERSION_26 26ULL -#define SPA_VERSION_27 27ULL -#define SPA_VERSION_28 28ULL -#define SPA_VERSION_5000 5000ULL - -/* - * The incrementing pool version number has been replaced by pool feature - * flags. For more details, see zfeature.c. - */ -#define SPA_VERSION SPA_VERSION_5000 -#define SPA_VERSION_STRING "5000" - -/* - * Symbolic names for the changes that caused a SPA_VERSION switch. - * Used in the code when checking for presence or absence of a feature. - * Feel free to define multiple symbolic names for each version if there - * were multiple changes to on-disk structures during that version. - * - * NOTE: When checking the current SPA_VERSION in your code, be sure - * to use spa_version() since it reports the version of the - * last synced uberblock. Checking the in-flight version can - * be dangerous in some cases. - */ -#define SPA_VERSION_INITIAL SPA_VERSION_1 -#define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2 -#define SPA_VERSION_SPARES SPA_VERSION_3 -#define SPA_VERSION_RAIDZ2 SPA_VERSION_3 -#define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3 -#define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3 -#define SPA_VERSION_DNODE_BYTES SPA_VERSION_3 -#define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4 -#define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5 -#define SPA_VERSION_BOOTFS SPA_VERSION_6 -#define SPA_VERSION_SLOGS SPA_VERSION_7 -#define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8 -#define SPA_VERSION_FUID SPA_VERSION_9 -#define SPA_VERSION_REFRESERVATION SPA_VERSION_9 -#define SPA_VERSION_REFQUOTA SPA_VERSION_9 -#define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9 -#define SPA_VERSION_L2CACHE SPA_VERSION_10 -#define SPA_VERSION_NEXT_CLONES SPA_VERSION_11 -#define SPA_VERSION_ORIGIN SPA_VERSION_11 -#define SPA_VERSION_DSL_SCRUB SPA_VERSION_11 -#define SPA_VERSION_SNAP_PROPS SPA_VERSION_12 -#define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13 -#define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14 -#define SPA_VERSION_USERSPACE SPA_VERSION_15 -#define SPA_VERSION_STMF_PROP SPA_VERSION_16 -#define SPA_VERSION_RAIDZ3 SPA_VERSION_17 -#define SPA_VERSION_USERREFS SPA_VERSION_18 -#define SPA_VERSION_HOLES SPA_VERSION_19 -#define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20 -#define SPA_VERSION_DEDUP SPA_VERSION_21 -#define SPA_VERSION_RECVD_PROPS SPA_VERSION_22 -#define SPA_VERSION_SLIM_ZIL SPA_VERSION_23 -#define SPA_VERSION_SA SPA_VERSION_24 -#define SPA_VERSION_SCAN SPA_VERSION_25 -#define SPA_VERSION_DIR_CLONES SPA_VERSION_26 -#define SPA_VERSION_DEADLISTS SPA_VERSION_26 -#define SPA_VERSION_FAST_SNAP SPA_VERSION_27 -#define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28 -#define SPA_VERSION_BEFORE_FEATURES SPA_VERSION_28 -#define SPA_VERSION_FEATURES SPA_VERSION_5000 - -#define SPA_VERSION_IS_SUPPORTED(v) \ - (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \ - ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION)) - -/* - * ZPL version - rev'd whenever an incompatible on-disk format change - * occurs. This is independent of SPA/DMU/ZAP versioning. You must - * also update the version_table[] and help message in zfs_prop.c. - */ -#define ZPL_VERSION_1 1ULL -#define ZPL_VERSION_2 2ULL -#define ZPL_VERSION_3 3ULL -#define ZPL_VERSION_4 4ULL -#define ZPL_VERSION_5 5ULL -#define ZPL_VERSION ZPL_VERSION_5 -#define ZPL_VERSION_STRING "5" - -#define ZPL_VERSION_INITIAL ZPL_VERSION_1 -#define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2 -#define ZPL_VERSION_FUID ZPL_VERSION_3 -#define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3 -#define ZPL_VERSION_SYSATTR ZPL_VERSION_3 -#define ZPL_VERSION_USERSPACE ZPL_VERSION_4 -#define ZPL_VERSION_SA ZPL_VERSION_5 - -/* Persistent L2ARC version */ -#define L2ARC_PERSISTENT_VERSION_1 1ULL -#define L2ARC_PERSISTENT_VERSION L2ARC_PERSISTENT_VERSION_1 -#define L2ARC_PERSISTENT_VERSION_STRING "1" - -/* Rewind policy information */ -#define ZPOOL_NO_REWIND 1 /* No policy - default behavior */ -#define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */ -#define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */ -#define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */ -#define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */ -#define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */ -#define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */ - -typedef struct zpool_load_policy { - uint32_t zlp_rewind; /* rewind policy requested */ - uint64_t zlp_maxmeta; /* max acceptable meta-data errors */ - uint64_t zlp_maxdata; /* max acceptable data errors */ - uint64_t zlp_txg; /* specific txg to load */ -} zpool_load_policy_t; - -/* - * The following are configuration names used in the nvlist describing a pool's - * configuration. New on-disk names should be prefixed with ":" - * (e.g. "org.openzfs:") to avoid conflicting names being developed - * independently. - */ -#define ZPOOL_CONFIG_VERSION "version" -#define ZPOOL_CONFIG_POOL_NAME "name" -#define ZPOOL_CONFIG_POOL_STATE "state" -#define ZPOOL_CONFIG_POOL_TXG "txg" -#define ZPOOL_CONFIG_POOL_GUID "pool_guid" -#define ZPOOL_CONFIG_CREATE_TXG "create_txg" -#define ZPOOL_CONFIG_TOP_GUID "top_guid" -#define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" -#define ZPOOL_CONFIG_TYPE "type" -#define ZPOOL_CONFIG_CHILDREN "children" -#define ZPOOL_CONFIG_ID "id" -#define ZPOOL_CONFIG_GUID "guid" -#define ZPOOL_CONFIG_INDIRECT_OBJECT "com.delphix:indirect_object" -#define ZPOOL_CONFIG_INDIRECT_BIRTHS "com.delphix:indirect_births" -#define ZPOOL_CONFIG_PREV_INDIRECT_VDEV "com.delphix:prev_indirect_vdev" -#define ZPOOL_CONFIG_PATH "path" -#define ZPOOL_CONFIG_DEVID "devid" -#define ZPOOL_CONFIG_SPARE_ID "spareid" -#define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" -#define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" -#define ZPOOL_CONFIG_ASHIFT "ashift" -#define ZPOOL_CONFIG_ASIZE "asize" -#define ZPOOL_CONFIG_DTL "DTL" -#define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */ -#define ZPOOL_CONFIG_REMOVAL_STATS "removal_stats" /* not stored on disk */ -#define ZPOOL_CONFIG_CHECKPOINT_STATS "checkpoint_stats" /* not on disk */ -#define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */ -#define ZPOOL_CONFIG_INDIRECT_SIZE "indirect_size" /* not stored on disk */ - -/* container nvlist of extended stats */ -#define ZPOOL_CONFIG_VDEV_STATS_EX "vdev_stats_ex" - -/* Active queue read/write stats */ -#define ZPOOL_CONFIG_VDEV_SYNC_R_ACTIVE_QUEUE "vdev_sync_r_active_queue" -#define ZPOOL_CONFIG_VDEV_SYNC_W_ACTIVE_QUEUE "vdev_sync_w_active_queue" -#define ZPOOL_CONFIG_VDEV_ASYNC_R_ACTIVE_QUEUE "vdev_async_r_active_queue" -#define ZPOOL_CONFIG_VDEV_ASYNC_W_ACTIVE_QUEUE "vdev_async_w_active_queue" -#define ZPOOL_CONFIG_VDEV_SCRUB_ACTIVE_QUEUE "vdev_async_scrub_active_queue" -#define ZPOOL_CONFIG_VDEV_TRIM_ACTIVE_QUEUE "vdev_async_trim_active_queue" -#define ZPOOL_CONFIG_VDEV_REBUILD_ACTIVE_QUEUE "vdev_rebuild_active_queue" - -/* Queue sizes */ -#define ZPOOL_CONFIG_VDEV_SYNC_R_PEND_QUEUE "vdev_sync_r_pend_queue" -#define ZPOOL_CONFIG_VDEV_SYNC_W_PEND_QUEUE "vdev_sync_w_pend_queue" -#define ZPOOL_CONFIG_VDEV_ASYNC_R_PEND_QUEUE "vdev_async_r_pend_queue" -#define ZPOOL_CONFIG_VDEV_ASYNC_W_PEND_QUEUE "vdev_async_w_pend_queue" -#define ZPOOL_CONFIG_VDEV_SCRUB_PEND_QUEUE "vdev_async_scrub_pend_queue" -#define ZPOOL_CONFIG_VDEV_TRIM_PEND_QUEUE "vdev_async_trim_pend_queue" -#define ZPOOL_CONFIG_VDEV_REBUILD_PEND_QUEUE "vdev_rebuild_pend_queue" - -/* Latency read/write histogram stats */ -#define ZPOOL_CONFIG_VDEV_TOT_R_LAT_HISTO "vdev_tot_r_lat_histo" -#define ZPOOL_CONFIG_VDEV_TOT_W_LAT_HISTO "vdev_tot_w_lat_histo" -#define ZPOOL_CONFIG_VDEV_DISK_R_LAT_HISTO "vdev_disk_r_lat_histo" -#define ZPOOL_CONFIG_VDEV_DISK_W_LAT_HISTO "vdev_disk_w_lat_histo" -#define ZPOOL_CONFIG_VDEV_SYNC_R_LAT_HISTO "vdev_sync_r_lat_histo" -#define ZPOOL_CONFIG_VDEV_SYNC_W_LAT_HISTO "vdev_sync_w_lat_histo" -#define ZPOOL_CONFIG_VDEV_ASYNC_R_LAT_HISTO "vdev_async_r_lat_histo" -#define ZPOOL_CONFIG_VDEV_ASYNC_W_LAT_HISTO "vdev_async_w_lat_histo" -#define ZPOOL_CONFIG_VDEV_SCRUB_LAT_HISTO "vdev_scrub_histo" -#define ZPOOL_CONFIG_VDEV_TRIM_LAT_HISTO "vdev_trim_histo" -#define ZPOOL_CONFIG_VDEV_REBUILD_LAT_HISTO "vdev_rebuild_histo" - -/* Request size histograms */ -#define ZPOOL_CONFIG_VDEV_SYNC_IND_R_HISTO "vdev_sync_ind_r_histo" -#define ZPOOL_CONFIG_VDEV_SYNC_IND_W_HISTO "vdev_sync_ind_w_histo" -#define ZPOOL_CONFIG_VDEV_ASYNC_IND_R_HISTO "vdev_async_ind_r_histo" -#define ZPOOL_CONFIG_VDEV_ASYNC_IND_W_HISTO "vdev_async_ind_w_histo" -#define ZPOOL_CONFIG_VDEV_IND_SCRUB_HISTO "vdev_ind_scrub_histo" -#define ZPOOL_CONFIG_VDEV_IND_TRIM_HISTO "vdev_ind_trim_histo" -#define ZPOOL_CONFIG_VDEV_IND_REBUILD_HISTO "vdev_ind_rebuild_histo" -#define ZPOOL_CONFIG_VDEV_SYNC_AGG_R_HISTO "vdev_sync_agg_r_histo" -#define ZPOOL_CONFIG_VDEV_SYNC_AGG_W_HISTO "vdev_sync_agg_w_histo" -#define ZPOOL_CONFIG_VDEV_ASYNC_AGG_R_HISTO "vdev_async_agg_r_histo" -#define ZPOOL_CONFIG_VDEV_ASYNC_AGG_W_HISTO "vdev_async_agg_w_histo" -#define ZPOOL_CONFIG_VDEV_AGG_SCRUB_HISTO "vdev_agg_scrub_histo" -#define ZPOOL_CONFIG_VDEV_AGG_TRIM_HISTO "vdev_agg_trim_histo" -#define ZPOOL_CONFIG_VDEV_AGG_REBUILD_HISTO "vdev_agg_rebuild_histo" - -/* Number of slow IOs */ -#define ZPOOL_CONFIG_VDEV_SLOW_IOS "vdev_slow_ios" - -/* vdev enclosure sysfs path */ -#define ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH "vdev_enc_sysfs_path" - -#define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" -#define ZPOOL_CONFIG_ERRCOUNT "error_count" -#define ZPOOL_CONFIG_NOT_PRESENT "not_present" -#define ZPOOL_CONFIG_SPARES "spares" -#define ZPOOL_CONFIG_IS_SPARE "is_spare" -#define ZPOOL_CONFIG_NPARITY "nparity" -#define ZPOOL_CONFIG_HOSTID "hostid" -#define ZPOOL_CONFIG_HOSTNAME "hostname" -#define ZPOOL_CONFIG_LOADED_TIME "initial_load_time" -#define ZPOOL_CONFIG_UNSPARE "unspare" -#define ZPOOL_CONFIG_PHYS_PATH "phys_path" -#define ZPOOL_CONFIG_IS_LOG "is_log" -#define ZPOOL_CONFIG_L2CACHE "l2cache" -#define ZPOOL_CONFIG_HOLE_ARRAY "hole_array" -#define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children" -#define ZPOOL_CONFIG_IS_HOLE "is_hole" -#define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram" -#define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats" -#define ZPOOL_CONFIG_DDT_STATS "ddt_stats" -#define ZPOOL_CONFIG_SPLIT "splitcfg" -#define ZPOOL_CONFIG_ORIG_GUID "orig_guid" -#define ZPOOL_CONFIG_SPLIT_GUID "split_guid" -#define ZPOOL_CONFIG_SPLIT_LIST "guid_list" -#define ZPOOL_CONFIG_REMOVING "removing" -#define ZPOOL_CONFIG_RESILVER_TXG "resilver_txg" -#define ZPOOL_CONFIG_REBUILD_TXG "rebuild_txg" -#define ZPOOL_CONFIG_COMMENT "comment" -#define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */ -#define ZPOOL_CONFIG_SUSPENDED_REASON "suspended_reason" /* not stored */ -#define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */ -#define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */ -#define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */ -#define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */ -#define ZPOOL_CONFIG_REWIND_INFO "rewind_info" /* not stored on disk */ -#define ZPOOL_CONFIG_UNSUP_FEAT "unsup_feat" /* not stored on disk */ -#define ZPOOL_CONFIG_ENABLED_FEAT "enabled_feat" /* not stored on disk */ -#define ZPOOL_CONFIG_CAN_RDONLY "can_rdonly" /* not stored on disk */ -#define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read" -#define ZPOOL_CONFIG_FEATURE_STATS "feature_stats" /* not stored on disk */ -#define ZPOOL_CONFIG_ERRATA "errata" /* not stored on disk */ -#define ZPOOL_CONFIG_VDEV_TOP_ZAP "com.delphix:vdev_zap_top" -#define ZPOOL_CONFIG_VDEV_LEAF_ZAP "com.delphix:vdev_zap_leaf" -#define ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS "com.delphix:has_per_vdev_zaps" -#define ZPOOL_CONFIG_RESILVER_DEFER "com.datto:resilver_defer" -#define ZPOOL_CONFIG_CACHEFILE "cachefile" /* not stored on disk */ -#define ZPOOL_CONFIG_MMP_STATE "mmp_state" /* not stored on disk */ -#define ZPOOL_CONFIG_MMP_TXG "mmp_txg" /* not stored on disk */ -#define ZPOOL_CONFIG_MMP_SEQ "mmp_seq" /* not stored on disk */ -#define ZPOOL_CONFIG_MMP_HOSTNAME "mmp_hostname" /* not stored on disk */ -#define ZPOOL_CONFIG_MMP_HOSTID "mmp_hostid" /* not stored on disk */ -#define ZPOOL_CONFIG_ALLOCATION_BIAS "alloc_bias" /* not stored on disk */ -#define ZPOOL_CONFIG_EXPANSION_TIME "expansion_time" /* not stored */ -#define ZPOOL_CONFIG_REBUILD_STATS "org.openzfs:rebuild_stats" -#define ZPOOL_CONFIG_COMPATIBILITY "compatibility" - -/* - * The persistent vdev state is stored as separate values rather than a single - * 'vdev_state' entry. This is because a device can be in multiple states, such - * as offline and degraded. - */ -#define ZPOOL_CONFIG_OFFLINE "offline" -#define ZPOOL_CONFIG_FAULTED "faulted" -#define ZPOOL_CONFIG_DEGRADED "degraded" -#define ZPOOL_CONFIG_REMOVED "removed" -#define ZPOOL_CONFIG_FRU "fru" -#define ZPOOL_CONFIG_AUX_STATE "aux_state" - -/* Pool load policy parameters */ -#define ZPOOL_LOAD_POLICY "load-policy" -#define ZPOOL_LOAD_REWIND_POLICY "load-rewind-policy" -#define ZPOOL_LOAD_REQUEST_TXG "load-request-txg" -#define ZPOOL_LOAD_META_THRESH "load-meta-thresh" -#define ZPOOL_LOAD_DATA_THRESH "load-data-thresh" - -/* Rewind data discovered */ -#define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts" -#define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors" -#define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind" - -/* dRAID configuration */ -#define ZPOOL_CONFIG_DRAID_NDATA "draid_ndata" -#define ZPOOL_CONFIG_DRAID_NSPARES "draid_nspares" -#define ZPOOL_CONFIG_DRAID_NGROUPS "draid_ngroups" - -#define VDEV_TYPE_ROOT "root" -#define VDEV_TYPE_MIRROR "mirror" -#define VDEV_TYPE_REPLACING "replacing" -#define VDEV_TYPE_RAIDZ "raidz" -#define VDEV_TYPE_DRAID "draid" -#define VDEV_TYPE_DRAID_SPARE "dspare" -#define VDEV_TYPE_DISK "disk" -#define VDEV_TYPE_FILE "file" -#define VDEV_TYPE_MISSING "missing" -#define VDEV_TYPE_HOLE "hole" -#define VDEV_TYPE_SPARE "spare" -#define VDEV_TYPE_LOG "log" -#define VDEV_TYPE_L2CACHE "l2cache" -#define VDEV_TYPE_INDIRECT "indirect" - -#define VDEV_RAIDZ_MAXPARITY 3 - -#define VDEV_DRAID_MAXPARITY 3 -#define VDEV_DRAID_MIN_CHILDREN 2 -#define VDEV_DRAID_MAX_CHILDREN UINT8_MAX - -/* VDEV_TOP_ZAP_* are used in top-level vdev ZAP objects. */ -#define VDEV_TOP_ZAP_INDIRECT_OBSOLETE_SM \ - "com.delphix:indirect_obsolete_sm" -#define VDEV_TOP_ZAP_OBSOLETE_COUNTS_ARE_PRECISE \ - "com.delphix:obsolete_counts_are_precise" -#define VDEV_TOP_ZAP_POOL_CHECKPOINT_SM \ - "com.delphix:pool_checkpoint_sm" -#define VDEV_TOP_ZAP_MS_UNFLUSHED_PHYS_TXGS \ - "com.delphix:ms_unflushed_phys_txgs" - -#define VDEV_TOP_ZAP_VDEV_REBUILD_PHYS \ - "org.openzfs:vdev_rebuild" - -#define VDEV_TOP_ZAP_ALLOCATION_BIAS \ - "org.zfsonlinux:allocation_bias" - -/* vdev metaslab allocation bias */ -#define VDEV_ALLOC_BIAS_LOG "log" -#define VDEV_ALLOC_BIAS_SPECIAL "special" -#define VDEV_ALLOC_BIAS_DEDUP "dedup" - -/* vdev initialize state */ -#define VDEV_LEAF_ZAP_INITIALIZE_LAST_OFFSET \ - "com.delphix:next_offset_to_initialize" -#define VDEV_LEAF_ZAP_INITIALIZE_STATE \ - "com.delphix:vdev_initialize_state" -#define VDEV_LEAF_ZAP_INITIALIZE_ACTION_TIME \ - "com.delphix:vdev_initialize_action_time" - -/* vdev TRIM state */ -#define VDEV_LEAF_ZAP_TRIM_LAST_OFFSET \ - "org.zfsonlinux:next_offset_to_trim" -#define VDEV_LEAF_ZAP_TRIM_STATE \ - "org.zfsonlinux:vdev_trim_state" -#define VDEV_LEAF_ZAP_TRIM_ACTION_TIME \ - "org.zfsonlinux:vdev_trim_action_time" -#define VDEV_LEAF_ZAP_TRIM_RATE \ - "org.zfsonlinux:vdev_trim_rate" -#define VDEV_LEAF_ZAP_TRIM_PARTIAL \ - "org.zfsonlinux:vdev_trim_partial" -#define VDEV_LEAF_ZAP_TRIM_SECURE \ - "org.zfsonlinux:vdev_trim_secure" - -/* - * This is needed in userland to report the minimum necessary device size. - */ -#define SPA_MINDEVSIZE (64ULL << 20) - -/* - * Set if the fragmentation has not yet been calculated. This can happen - * because the space maps have not been upgraded or the histogram feature - * is not enabled. - */ -#define ZFS_FRAG_INVALID UINT64_MAX - -/* - * The location of the pool configuration repository, shared between kernel and - * userland. - */ -#define ZPOOL_CACHE_BOOT "/boot/zfs/zpool.cache" -#define ZPOOL_CACHE "/etc/zfs/zpool.cache" -/* - * Settings for zpool compatibility features files - */ -#define ZPOOL_SYSCONF_COMPAT_D SYSCONFDIR "/zfs/compatibility.d" -#define ZPOOL_DATA_COMPAT_D PKGDATADIR "/compatibility.d" -#define ZPOOL_COMPAT_MAXSIZE 16384 - -/* - * Hard-wired compatibility settings - */ -#define ZPOOL_COMPAT_LEGACY "legacy" -#define ZPOOL_COMPAT_OFF "off" - -/* - * vdev states are ordered from least to most healthy. - * A vdev that's CANT_OPEN or below is considered unusable. - */ -typedef enum vdev_state { - VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */ - VDEV_STATE_CLOSED, /* Not currently open */ - VDEV_STATE_OFFLINE, /* Not allowed to open */ - VDEV_STATE_REMOVED, /* Explicitly removed from system */ - VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */ - VDEV_STATE_FAULTED, /* External request to fault device */ - VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */ - VDEV_STATE_HEALTHY /* Presumed good */ -} vdev_state_t; - -#define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY - -/* - * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field - * of the vdev stats structure uses these constants to distinguish why. - */ -typedef enum vdev_aux { - VDEV_AUX_NONE, /* no error */ - VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */ - VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */ - VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */ - VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */ - VDEV_AUX_TOO_SMALL, /* vdev size is too small */ - VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */ - VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */ - VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */ - VDEV_AUX_UNSUP_FEAT, /* unsupported features */ - VDEV_AUX_SPARED, /* hot spare used in another pool */ - VDEV_AUX_ERR_EXCEEDED, /* too many errors */ - VDEV_AUX_IO_FAILURE, /* experienced I/O failure */ - VDEV_AUX_BAD_LOG, /* cannot read log chain(s) */ - VDEV_AUX_EXTERNAL, /* external diagnosis or forced fault */ - VDEV_AUX_SPLIT_POOL, /* vdev was split off into another pool */ - VDEV_AUX_BAD_ASHIFT, /* vdev ashift is invalid */ - VDEV_AUX_EXTERNAL_PERSIST, /* persistent forced fault */ - VDEV_AUX_ACTIVE, /* vdev active on a different host */ - VDEV_AUX_CHILDREN_OFFLINE, /* all children are offline */ - VDEV_AUX_ASHIFT_TOO_BIG, /* vdev's min block size is too large */ -} vdev_aux_t; - -/* - * pool state. The following states are written to disk as part of the normal - * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining - * states are software abstractions used at various levels to communicate - * pool state. - */ -typedef enum pool_state { - POOL_STATE_ACTIVE = 0, /* In active use */ - POOL_STATE_EXPORTED, /* Explicitly exported */ - POOL_STATE_DESTROYED, /* Explicitly destroyed */ - POOL_STATE_SPARE, /* Reserved for hot spare use */ - POOL_STATE_L2CACHE, /* Level 2 ARC device */ - POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ - POOL_STATE_UNAVAIL, /* Internal libzfs state */ - POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */ -} pool_state_t; - -/* - * mmp state. The following states provide additional detail describing - * why a pool couldn't be safely imported. - */ -typedef enum mmp_state { - MMP_STATE_ACTIVE = 0, /* In active use */ - MMP_STATE_INACTIVE, /* Inactive and safe to import */ - MMP_STATE_NO_HOSTID /* System hostid is not set */ -} mmp_state_t; - -/* - * Scan Functions. - */ -typedef enum pool_scan_func { - POOL_SCAN_NONE, - POOL_SCAN_SCRUB, - POOL_SCAN_RESILVER, - POOL_SCAN_FUNCS -} pool_scan_func_t; - -/* - * Used to control scrub pause and resume. - */ -typedef enum pool_scrub_cmd { - POOL_SCRUB_NORMAL = 0, - POOL_SCRUB_PAUSE, - POOL_SCRUB_FLAGS_END -} pool_scrub_cmd_t; - -typedef enum { - CS_NONE, - CS_CHECKPOINT_EXISTS, - CS_CHECKPOINT_DISCARDING, - CS_NUM_STATES -} checkpoint_state_t; - -typedef struct pool_checkpoint_stat { - uint64_t pcs_state; /* checkpoint_state_t */ - uint64_t pcs_start_time; /* time checkpoint/discard started */ - uint64_t pcs_space; /* checkpointed space */ -} pool_checkpoint_stat_t; - -/* - * ZIO types. Needed to interpret vdev statistics below. - */ -typedef enum zio_type { - ZIO_TYPE_NULL = 0, - ZIO_TYPE_READ, - ZIO_TYPE_WRITE, - ZIO_TYPE_FREE, - ZIO_TYPE_CLAIM, - ZIO_TYPE_IOCTL, - ZIO_TYPE_TRIM, - ZIO_TYPES -} zio_type_t; - -/* - * Pool statistics. Note: all fields should be 64-bit because this - * is passed between kernel and userland as an nvlist uint64 array. - */ -typedef struct pool_scan_stat { - /* values stored on disk */ - uint64_t pss_func; /* pool_scan_func_t */ - uint64_t pss_state; /* dsl_scan_state_t */ - uint64_t pss_start_time; /* scan start time */ - uint64_t pss_end_time; /* scan end time */ - uint64_t pss_to_examine; /* total bytes to scan */ - uint64_t pss_examined; /* total bytes located by scanner */ - uint64_t pss_to_process; /* total bytes to process */ - uint64_t pss_processed; /* total processed bytes */ - uint64_t pss_errors; /* scan errors */ - - /* values not stored on disk */ - uint64_t pss_pass_exam; /* examined bytes per scan pass */ - uint64_t pss_pass_start; /* start time of a scan pass */ - uint64_t pss_pass_scrub_pause; /* pause time of a scrub pass */ - /* cumulative time scrub spent paused, needed for rate calculation */ - uint64_t pss_pass_scrub_spent_paused; - uint64_t pss_pass_issued; /* issued bytes per scan pass */ - uint64_t pss_issued; /* total bytes checked by scanner */ -} pool_scan_stat_t; - -typedef struct pool_removal_stat { - uint64_t prs_state; /* dsl_scan_state_t */ - uint64_t prs_removing_vdev; - uint64_t prs_start_time; - uint64_t prs_end_time; - uint64_t prs_to_copy; /* bytes that need to be copied */ - uint64_t prs_copied; /* bytes copied so far */ - /* - * bytes of memory used for indirect mappings. - * This includes all removed vdevs. - */ - uint64_t prs_mapping_memory; -} pool_removal_stat_t; - -typedef enum dsl_scan_state { - DSS_NONE, - DSS_SCANNING, - DSS_FINISHED, - DSS_CANCELED, - DSS_NUM_STATES -} dsl_scan_state_t; - -typedef struct vdev_rebuild_stat { - uint64_t vrs_state; /* vdev_rebuild_state_t */ - uint64_t vrs_start_time; /* time_t */ - uint64_t vrs_end_time; /* time_t */ - uint64_t vrs_scan_time_ms; /* total run time (millisecs) */ - uint64_t vrs_bytes_scanned; /* allocated bytes scanned */ - uint64_t vrs_bytes_issued; /* read bytes issued */ - uint64_t vrs_bytes_rebuilt; /* rebuilt bytes */ - uint64_t vrs_bytes_est; /* total bytes to scan */ - uint64_t vrs_errors; /* scanning errors */ - uint64_t vrs_pass_time_ms; /* pass run time (millisecs) */ - uint64_t vrs_pass_bytes_scanned; /* bytes scanned since start/resume */ - uint64_t vrs_pass_bytes_issued; /* bytes rebuilt since start/resume */ -} vdev_rebuild_stat_t; - -/* - * Errata described by https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-ER. - * The ordering of this enum must be maintained to ensure the errata identifiers - * map to the correct documentation. New errata may only be appended to the - * list and must contain corresponding documentation at the above link. - */ -typedef enum zpool_errata { - ZPOOL_ERRATA_NONE, - ZPOOL_ERRATA_ZOL_2094_SCRUB, - ZPOOL_ERRATA_ZOL_2094_ASYNC_DESTROY, - ZPOOL_ERRATA_ZOL_6845_ENCRYPTION, - ZPOOL_ERRATA_ZOL_8308_ENCRYPTION, -} zpool_errata_t; - -/* - * Vdev statistics. Note: all fields should be 64-bit because this - * is passed between kernel and user land as an nvlist uint64 array. - * - * The vs_ops[] and vs_bytes[] arrays must always be an array size of 6 in - * order to keep subsequent members at their known fixed offsets. When - * adding a new field it must be added to the end the structure. - */ -#define VS_ZIO_TYPES 6 - -typedef struct vdev_stat { - hrtime_t vs_timestamp; /* time since vdev load */ - uint64_t vs_state; /* vdev state */ - uint64_t vs_aux; /* see vdev_aux_t */ - uint64_t vs_alloc; /* space allocated */ - uint64_t vs_space; /* total capacity */ - uint64_t vs_dspace; /* deflated capacity */ - uint64_t vs_rsize; /* replaceable dev size */ - uint64_t vs_esize; /* expandable dev size */ - uint64_t vs_ops[VS_ZIO_TYPES]; /* operation count */ - uint64_t vs_bytes[VS_ZIO_TYPES]; /* bytes read/written */ - uint64_t vs_read_errors; /* read errors */ - uint64_t vs_write_errors; /* write errors */ - uint64_t vs_checksum_errors; /* checksum errors */ - uint64_t vs_initialize_errors; /* initializing errors */ - uint64_t vs_self_healed; /* self-healed bytes */ - uint64_t vs_scan_removing; /* removing? */ - uint64_t vs_scan_processed; /* scan processed bytes */ - uint64_t vs_fragmentation; /* device fragmentation */ - uint64_t vs_initialize_bytes_done; /* bytes initialized */ - uint64_t vs_initialize_bytes_est; /* total bytes to initialize */ - uint64_t vs_initialize_state; /* vdev_initializing_state_t */ - uint64_t vs_initialize_action_time; /* time_t */ - uint64_t vs_checkpoint_space; /* checkpoint-consumed space */ - uint64_t vs_resilver_deferred; /* resilver deferred */ - uint64_t vs_slow_ios; /* slow IOs */ - uint64_t vs_trim_errors; /* trimming errors */ - uint64_t vs_trim_notsup; /* supported by device */ - uint64_t vs_trim_bytes_done; /* bytes trimmed */ - uint64_t vs_trim_bytes_est; /* total bytes to trim */ - uint64_t vs_trim_state; /* vdev_trim_state_t */ - uint64_t vs_trim_action_time; /* time_t */ - uint64_t vs_rebuild_processed; /* bytes rebuilt */ - uint64_t vs_configured_ashift; /* TLV vdev_ashift */ - uint64_t vs_logical_ashift; /* vdev_logical_ashift */ - uint64_t vs_physical_ashift; /* vdev_physical_ashift */ -} vdev_stat_t; - -/* BEGIN CSTYLED */ -#define VDEV_STAT_VALID(field, uint64_t_field_count) \ - ((uint64_t_field_count * sizeof (uint64_t)) >= \ - (offsetof(vdev_stat_t, field) + sizeof (((vdev_stat_t *)NULL)->field))) -/* END CSTYLED */ - -/* - * Extended stats - * - * These are stats which aren't included in the original iostat output. For - * convenience, they are grouped together in vdev_stat_ex, although each stat - * is individually exported as an nvlist. - */ -typedef struct vdev_stat_ex { - /* Number of ZIOs issued to disk and waiting to finish */ - uint64_t vsx_active_queue[ZIO_PRIORITY_NUM_QUEUEABLE]; - - /* Number of ZIOs pending to be issued to disk */ - uint64_t vsx_pend_queue[ZIO_PRIORITY_NUM_QUEUEABLE]; - - /* - * Below are the histograms for various latencies. Buckets are in - * units of nanoseconds. - */ - - /* - * 2^37 nanoseconds = 134s. Timeouts will probably start kicking in - * before this. - */ -#define VDEV_L_HISTO_BUCKETS 37 /* Latency histo buckets */ -#define VDEV_RQ_HISTO_BUCKETS 25 /* Request size histo buckets */ - - /* Amount of time in ZIO queue (ns) */ - uint64_t vsx_queue_histo[ZIO_PRIORITY_NUM_QUEUEABLE] - [VDEV_L_HISTO_BUCKETS]; - - /* Total ZIO latency (ns). Includes queuing and disk access time */ - uint64_t vsx_total_histo[ZIO_TYPES][VDEV_L_HISTO_BUCKETS]; - - /* Amount of time to read/write the disk (ns) */ - uint64_t vsx_disk_histo[ZIO_TYPES][VDEV_L_HISTO_BUCKETS]; - - /* "lookup the bucket for a value" histogram macros */ -#define HISTO(val, buckets) (val != 0 ? MIN(highbit64(val) - 1, \ - buckets - 1) : 0) -#define L_HISTO(a) HISTO(a, VDEV_L_HISTO_BUCKETS) -#define RQ_HISTO(a) HISTO(a, VDEV_RQ_HISTO_BUCKETS) - - /* Physical IO histogram */ - uint64_t vsx_ind_histo[ZIO_PRIORITY_NUM_QUEUEABLE] - [VDEV_RQ_HISTO_BUCKETS]; - - /* Delegated (aggregated) physical IO histogram */ - uint64_t vsx_agg_histo[ZIO_PRIORITY_NUM_QUEUEABLE] - [VDEV_RQ_HISTO_BUCKETS]; - -} vdev_stat_ex_t; - -/* - * Initialize functions. - */ -typedef enum pool_initialize_func { - POOL_INITIALIZE_START, - POOL_INITIALIZE_CANCEL, - POOL_INITIALIZE_SUSPEND, - POOL_INITIALIZE_FUNCS -} pool_initialize_func_t; - -/* - * TRIM functions. - */ -typedef enum pool_trim_func { - POOL_TRIM_START, - POOL_TRIM_CANCEL, - POOL_TRIM_SUSPEND, - POOL_TRIM_FUNCS -} pool_trim_func_t; - -/* - * DDT statistics. Note: all fields should be 64-bit because this - * is passed between kernel and userland as an nvlist uint64 array. - */ -typedef struct ddt_object { - uint64_t ddo_count; /* number of elements in ddt */ - uint64_t ddo_dspace; /* size of ddt on disk */ - uint64_t ddo_mspace; /* size of ddt in-core */ -} ddt_object_t; - -typedef struct ddt_stat { - uint64_t dds_blocks; /* blocks */ - uint64_t dds_lsize; /* logical size */ - uint64_t dds_psize; /* physical size */ - uint64_t dds_dsize; /* deflated allocated size */ - uint64_t dds_ref_blocks; /* referenced blocks */ - uint64_t dds_ref_lsize; /* referenced lsize * refcnt */ - uint64_t dds_ref_psize; /* referenced psize * refcnt */ - uint64_t dds_ref_dsize; /* referenced dsize * refcnt */ -} ddt_stat_t; - -typedef struct ddt_histogram { - ddt_stat_t ddh_stat[64]; /* power-of-two histogram buckets */ -} ddt_histogram_t; - -#define ZVOL_DRIVER "zvol" -#define ZFS_DRIVER "zfs" -#define ZFS_DEV "/dev/zfs" - -#define ZFS_SUPER_MAGIC 0x2fc12fc1 - -/* general zvol path */ -#define ZVOL_DIR "/dev/zvol/" - -#define ZVOL_MAJOR 230 -#define ZVOL_MINOR_BITS 4 -#define ZVOL_MINOR_MASK ((1U << ZVOL_MINOR_BITS) - 1) -#define ZVOL_MINORS (1 << 4) -#define ZVOL_DEV_NAME "zd" - -#define ZVOL_PROP_NAME "name" -#define ZVOL_DEFAULT_BLOCKSIZE 16384 - -typedef enum { - VDEV_INITIALIZE_NONE, - VDEV_INITIALIZE_ACTIVE, - VDEV_INITIALIZE_CANCELED, - VDEV_INITIALIZE_SUSPENDED, - VDEV_INITIALIZE_COMPLETE -} vdev_initializing_state_t; - -typedef enum { - VDEV_TRIM_NONE, - VDEV_TRIM_ACTIVE, - VDEV_TRIM_CANCELED, - VDEV_TRIM_SUSPENDED, - VDEV_TRIM_COMPLETE, -} vdev_trim_state_t; - -typedef enum { - VDEV_REBUILD_NONE, - VDEV_REBUILD_ACTIVE, - VDEV_REBUILD_CANCELED, - VDEV_REBUILD_COMPLETE, -} vdev_rebuild_state_t; - -/* - * nvlist name constants. Facilitate restricting snapshot iteration range for - * the "list next snapshot" ioctl - */ -#define SNAP_ITER_MIN_TXG "snap_iter_min_txg" -#define SNAP_ITER_MAX_TXG "snap_iter_max_txg" - -/* - * /dev/zfs ioctl numbers. - * - * These numbers cannot change over time. New ioctl numbers must be appended. - */ -typedef enum zfs_ioc { - /* - * 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 */ - 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_RECV_NEW, /* 0x5a46 */ - ZFS_IOC_POOL_SYNC, /* 0x5a47 */ - ZFS_IOC_CHANNEL_PROGRAM, /* 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 */ - ZFS_IOC_POOL_INITIALIZE, /* 0x5a4f */ - ZFS_IOC_POOL_TRIM, /* 0x5a50 */ - ZFS_IOC_REDACT, /* 0x5a51 */ - ZFS_IOC_GET_BOOKMARK_PROPS, /* 0x5a52 */ - ZFS_IOC_WAIT, /* 0x5a53 */ - ZFS_IOC_WAIT_FS, /* 0x5a54 */ - - /* - * Per-platform (Optional) - 8/128 numbers reserved. - */ - 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_SET_BOOTENV, /* 0x87 */ - ZFS_IOC_GET_BOOTENV, /* 0x88 */ - ZFS_IOC_LAST -} zfs_ioc_t; - -/* - * zvol ioctl to get dataset name - */ -#define BLKZNAME _IOR(0x12, 125, char[ZFS_MAX_DATASET_NAME_LEN]) - -/* - * ZFS-specific error codes used for returning descriptive errors - * to the userland through zfs ioctls. - * - * 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. - * - * (Keep in sync with contrib/pyzfs/libzfs_core/_constants.py) - */ -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_IOC_CMD_UNAVAIL, - ZFS_ERR_IOC_ARG_UNAVAIL, - ZFS_ERR_IOC_ARG_REQUIRED, - ZFS_ERR_IOC_ARG_BADTYPE, - ZFS_ERR_WRONG_PARENT, - ZFS_ERR_FROM_IVSET_GUID_MISSING, - ZFS_ERR_FROM_IVSET_GUID_MISMATCH, - ZFS_ERR_SPILL_BLOCK_FLAG_MISSING, - ZFS_ERR_UNKNOWN_SEND_STREAM_FEATURE, - ZFS_ERR_EXPORT_IN_PROGRESS, - ZFS_ERR_BOOKMARK_SOURCE_NOT_ANCESTOR, - ZFS_ERR_STREAM_TRUNCATED, - ZFS_ERR_STREAM_LARGE_BLOCK_MISMATCH, - ZFS_ERR_RESILVER_IN_PROGRESS, - ZFS_ERR_REBUILD_IN_PROGRESS, - ZFS_ERR_BADPROP, -} zfs_errno_t; - -/* - * Internal SPA load state. Used by FMA diagnosis engine. - */ -typedef enum { - SPA_LOAD_NONE, /* no load in progress */ - SPA_LOAD_OPEN, /* normal open */ - SPA_LOAD_IMPORT, /* import in progress */ - SPA_LOAD_TRYIMPORT, /* tryimport in progress */ - SPA_LOAD_RECOVER, /* recovery requested */ - SPA_LOAD_ERROR, /* load failed */ - SPA_LOAD_CREATE /* creation in progress */ -} spa_load_state_t; - -typedef enum { - ZPOOL_WAIT_CKPT_DISCARD, - ZPOOL_WAIT_FREE, - ZPOOL_WAIT_INITIALIZE, - ZPOOL_WAIT_REPLACE, - ZPOOL_WAIT_REMOVE, - ZPOOL_WAIT_RESILVER, - ZPOOL_WAIT_SCRUB, - ZPOOL_WAIT_TRIM, - ZPOOL_WAIT_NUM_ACTIVITIES -} zpool_wait_activity_t; - -typedef enum { - ZFS_WAIT_DELETEQ, - ZFS_WAIT_NUM_ACTIVITIES -} zfs_wait_activity_t; - -/* - * Bookmark name values. - */ -#define ZPOOL_ERR_LIST "error list" -#define ZPOOL_ERR_DATASET "dataset" -#define ZPOOL_ERR_OBJECT "object" - -#define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1) - -/* - * The following are names used in the nvlist describing - * the pool's history log. - */ -#define ZPOOL_HIST_RECORD "history record" -#define ZPOOL_HIST_TIME "history time" -#define ZPOOL_HIST_CMD "history command" -#define ZPOOL_HIST_WHO "history who" -#define ZPOOL_HIST_ZONE "history zone" -#define ZPOOL_HIST_HOST "history hostname" -#define ZPOOL_HIST_TXG "history txg" -#define ZPOOL_HIST_INT_EVENT "history internal event" -#define ZPOOL_HIST_INT_STR "history internal str" -#define ZPOOL_HIST_INT_NAME "internal_name" -#define ZPOOL_HIST_IOCTL "ioctl" -#define ZPOOL_HIST_INPUT_NVL "in_nvl" -#define ZPOOL_HIST_OUTPUT_NVL "out_nvl" -#define ZPOOL_HIST_OUTPUT_SIZE "out_size" -#define ZPOOL_HIST_DSNAME "dsname" -#define ZPOOL_HIST_DSID "dsid" -#define ZPOOL_HIST_ERRNO "errno" -#define ZPOOL_HIST_ELAPSED_NS "elapsed_ns" - -/* - * Special nvlist name that will not have its args recorded in the pool's - * history log. - */ -#define ZPOOL_HIDDEN_ARGS "hidden_args" - -/* - * The following are names used when invoking ZFS_IOC_POOL_INITIALIZE. - */ -#define ZPOOL_INITIALIZE_COMMAND "initialize_command" -#define ZPOOL_INITIALIZE_VDEVS "initialize_vdevs" - -/* - * The following are names used when invoking ZFS_IOC_POOL_TRIM. - */ -#define ZPOOL_TRIM_COMMAND "trim_command" -#define ZPOOL_TRIM_VDEVS "trim_vdevs" -#define ZPOOL_TRIM_RATE "trim_rate" -#define ZPOOL_TRIM_SECURE "trim_secure" - -/* - * The following are names used when invoking ZFS_IOC_POOL_WAIT. - */ -#define ZPOOL_WAIT_ACTIVITY "wait_activity" -#define ZPOOL_WAIT_TAG "wait_tag" -#define ZPOOL_WAIT_WAITED "wait_waited" - -/* - * The following are names used when invoking ZFS_IOC_WAIT_FS. - */ -#define ZFS_WAIT_ACTIVITY "wait_activity" -#define ZFS_WAIT_WAITED "wait_waited" - -/* - * Flags for ZFS_IOC_VDEV_SET_STATE - */ -#define ZFS_ONLINE_CHECKREMOVE 0x1 -#define ZFS_ONLINE_UNSPARE 0x2 -#define ZFS_ONLINE_FORCEFAULT 0x4 -#define ZFS_ONLINE_EXPAND 0x8 -#define ZFS_OFFLINE_TEMPORARY 0x1 - -/* - * Flags for ZFS_IOC_POOL_IMPORT - */ -#define ZFS_IMPORT_NORMAL 0x0 -#define ZFS_IMPORT_VERBATIM 0x1 -#define ZFS_IMPORT_ANY_HOST 0x2 -#define ZFS_IMPORT_MISSING_LOG 0x4 -#define ZFS_IMPORT_ONLY 0x8 -#define ZFS_IMPORT_TEMP_NAME 0x10 -#define ZFS_IMPORT_SKIP_MMP 0x20 -#define ZFS_IMPORT_LOAD_KEYS 0x40 -#define ZFS_IMPORT_CHECKPOINT 0x80 - -/* - * Channel program argument/return nvlist keys and defaults. - */ -#define ZCP_ARG_PROGRAM "program" -#define ZCP_ARG_ARGLIST "arg" -#define ZCP_ARG_SYNC "sync" -#define ZCP_ARG_INSTRLIMIT "instrlimit" -#define ZCP_ARG_MEMLIMIT "memlimit" - -#define ZCP_ARG_CLIARGV "argv" - -#define ZCP_RET_ERROR "error" -#define ZCP_RET_RETURN "return" - -#define ZCP_DEFAULT_INSTRLIMIT (10 * 1000 * 1000) -#define ZCP_MAX_INSTRLIMIT (10 * ZCP_DEFAULT_INSTRLIMIT) -#define ZCP_DEFAULT_MEMLIMIT (10 * 1024 * 1024) -#define ZCP_MAX_MEMLIMIT (10 * ZCP_DEFAULT_MEMLIMIT) - -/* - * Sysevent payload members. ZFS will generate the following sysevents with the - * given payloads: - * - * ESC_ZFS_RESILVER_START - * ESC_ZFS_RESILVER_FINISH - * - * ZFS_EV_POOL_NAME DATA_TYPE_STRING - * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 - * ZFS_EV_RESILVER_TYPE DATA_TYPE_STRING - * - * ESC_ZFS_POOL_DESTROY - * ESC_ZFS_POOL_REGUID - * - * ZFS_EV_POOL_NAME DATA_TYPE_STRING - * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 - * - * ESC_ZFS_VDEV_REMOVE - * ESC_ZFS_VDEV_CLEAR - * ESC_ZFS_VDEV_CHECK - * - * ZFS_EV_POOL_NAME DATA_TYPE_STRING - * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 - * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional) - * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64 - * - * ESC_ZFS_HISTORY_EVENT - * - * ZFS_EV_POOL_NAME DATA_TYPE_STRING - * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 - * ZFS_EV_HIST_TIME DATA_TYPE_UINT64 (optional) - * ZFS_EV_HIST_CMD DATA_TYPE_STRING (optional) - * ZFS_EV_HIST_WHO DATA_TYPE_UINT64 (optional) - * ZFS_EV_HIST_ZONE DATA_TYPE_STRING (optional) - * ZFS_EV_HIST_HOST DATA_TYPE_STRING (optional) - * ZFS_EV_HIST_TXG DATA_TYPE_UINT64 (optional) - * ZFS_EV_HIST_INT_EVENT DATA_TYPE_UINT64 (optional) - * ZFS_EV_HIST_INT_STR DATA_TYPE_STRING (optional) - * ZFS_EV_HIST_INT_NAME DATA_TYPE_STRING (optional) - * ZFS_EV_HIST_IOCTL DATA_TYPE_STRING (optional) - * ZFS_EV_HIST_DSNAME DATA_TYPE_STRING (optional) - * ZFS_EV_HIST_DSID DATA_TYPE_UINT64 (optional) - * - * The ZFS_EV_HIST_* members will correspond to the ZPOOL_HIST_* members in the - * history log nvlist. The keynames will be free of any spaces or other - * characters that could be potentially unexpected to consumers of the - * sysevents. - */ -#define ZFS_EV_POOL_NAME "pool_name" -#define ZFS_EV_POOL_GUID "pool_guid" -#define ZFS_EV_VDEV_PATH "vdev_path" -#define ZFS_EV_VDEV_GUID "vdev_guid" -#define ZFS_EV_HIST_TIME "history_time" -#define ZFS_EV_HIST_CMD "history_command" -#define ZFS_EV_HIST_WHO "history_who" -#define ZFS_EV_HIST_ZONE "history_zone" -#define ZFS_EV_HIST_HOST "history_hostname" -#define ZFS_EV_HIST_TXG "history_txg" -#define ZFS_EV_HIST_INT_EVENT "history_internal_event" -#define ZFS_EV_HIST_INT_STR "history_internal_str" -#define ZFS_EV_HIST_INT_NAME "history_internal_name" -#define ZFS_EV_HIST_IOCTL "history_ioctl" -#define ZFS_EV_HIST_DSNAME "history_dsname" -#define ZFS_EV_HIST_DSID "history_dsid" -#define ZFS_EV_RESILVER_TYPE "resilver_type" - - -/* - * We currently support block sizes from 512 bytes to 16MB. - * The benefits of larger blocks, and thus larger IO, need to be weighed - * against the cost of COWing a giant block to modify one byte, and the - * large latency of reading or writing a large block. - * - * Note that although blocks up to 16MB are supported, the recordsize - * property can not be set larger than zfs_max_recordsize (default 1MB). - * See the comment near zfs_max_recordsize in dsl_dataset.c for details. - * - * Note that although the LSIZE field of the blkptr_t can store sizes up - * to 32MB, the dnode's dn_datablkszsec can only store sizes up to - * 32MB - 512 bytes. Therefore, we limit SPA_MAXBLOCKSIZE to 16MB. - */ -#define SPA_MINBLOCKSHIFT 9 -#define SPA_OLD_MAXBLOCKSHIFT 17 -#define SPA_MAXBLOCKSHIFT 24 -#define SPA_MINBLOCKSIZE (1ULL << SPA_MINBLOCKSHIFT) -#define SPA_OLD_MAXBLOCKSIZE (1ULL << SPA_OLD_MAXBLOCKSHIFT) -#define SPA_MAXBLOCKSIZE (1ULL << SPA_MAXBLOCKSHIFT) - - -/* supported encryption algorithms */ -enum zio_encrypt { - ZIO_CRYPT_INHERIT = 0, - ZIO_CRYPT_ON, - ZIO_CRYPT_OFF, - ZIO_CRYPT_AES_128_CCM, - ZIO_CRYPT_AES_192_CCM, - ZIO_CRYPT_AES_256_CCM, - ZIO_CRYPT_AES_128_GCM, - ZIO_CRYPT_AES_192_GCM, - ZIO_CRYPT_AES_256_GCM, - ZIO_CRYPT_FUNCTIONS -}; - -#define ZIO_CRYPT_ON_VALUE ZIO_CRYPT_AES_256_GCM -#define ZIO_CRYPT_DEFAULT ZIO_CRYPT_OFF - - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_FS_ZFS_H */ diff --git a/src/lib/include/sys/mnttab.h b/src/lib/include/sys/mnttab.h deleted file mode 100644 index c08349bd..00000000 --- a/src/lib/include/sys/mnttab.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -/* Copyright 2006 Ricardo Correia */ - -#ifndef _SYS_MNTTAB_H -#define _SYS_MNTTAB_H - -#include -#include - -#ifdef MNTTAB -#undef MNTTAB -#endif /* MNTTAB */ - -#include -#include -#define MNTTAB _PATH_DEVZERO -#define MS_NOMNTTAB 0x0 -#define MS_RDONLY 0x1 -#define umount2(p, f) unmount(p, f) -#define MNT_LINE_MAX 4108 - -#define MNT_TOOLONG 1 /* entry exceeds MNT_LINE_MAX */ -#define MNT_TOOMANY 2 /* too many fields in line */ -#define MNT_TOOFEW 3 /* too few fields in line */ - -struct mnttab { - char *mnt_special; - char *mnt_mountp; - char *mnt_fstype; - char *mnt_mntopts; -}; - -/* - * NOTE: fields in extmnttab should match struct mnttab till new fields - * are encountered, this allows hasmntopt to work properly when its arg is - * a pointer to an extmnttab struct cast to a mnttab struct pointer. - */ - -struct extmnttab { - char *mnt_special; - char *mnt_mountp; - char *mnt_fstype; - char *mnt_mntopts; - uint_t mnt_major; - uint_t mnt_minor; -}; - -struct stat64; -struct statfs; - -extern int getmntany(FILE *fp, struct mnttab *mp, struct mnttab *mpref); -extern int _sol_getmntent(FILE *fp, struct mnttab *mp); -extern int getextmntent(const char *path, struct extmnttab *entry, - struct stat64 *statbuf); -extern void statfs2mnttab(struct statfs *sfs, struct mnttab *mp); -char *hasmntopt(struct mnttab *mnt, char *opt); -int getmntent(FILE *fp, struct mnttab *mp); - -#endif diff --git a/src/lib/include/sys/nvpair.h b/src/lib/include/sys/nvpair.h deleted file mode 100644 index 856c552c..00000000 --- a/src/lib/include/sys/nvpair.h +++ /dev/null @@ -1,423 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2018 by Delphix. All rights reserved. - */ - -#ifndef _SYS_NVPAIR_H -#define _SYS_NVPAIR_H extern __attribute__((visibility("default"))) - -#include -// the following comes from 'include/os/freebsd/spl/sys/types.h' in the OpenZFS source tree - -typedef u_int uint_t; -typedef u_char uchar_t; -typedef u_long ulong_t; - -#if defined(__XOPEN_OR_POSIX) -typedef enum { _B_FALSE, _B_TRUE } boolean_t; -#else -typedef enum { B_FALSE, B_TRUE } boolean_t; -#endif /* defined(__XOPEN_OR_POSIX) */ - -// #include -// the following comes from 'include/os/freebsd/spl/sys/time.h' in the OpenZFS source tree - -typedef long long hrtime_t; - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - DATA_TYPE_DONTCARE = -1, - DATA_TYPE_UNKNOWN = 0, - DATA_TYPE_BOOLEAN, - DATA_TYPE_BYTE, - DATA_TYPE_INT16, - DATA_TYPE_UINT16, - DATA_TYPE_INT32, - DATA_TYPE_UINT32, - DATA_TYPE_INT64, - DATA_TYPE_UINT64, - DATA_TYPE_STRING, - DATA_TYPE_BYTE_ARRAY, - DATA_TYPE_INT16_ARRAY, - DATA_TYPE_UINT16_ARRAY, - DATA_TYPE_INT32_ARRAY, - DATA_TYPE_UINT32_ARRAY, - DATA_TYPE_INT64_ARRAY, - DATA_TYPE_UINT64_ARRAY, - DATA_TYPE_STRING_ARRAY, - DATA_TYPE_HRTIME, - DATA_TYPE_NVLIST, - DATA_TYPE_NVLIST_ARRAY, - DATA_TYPE_BOOLEAN_VALUE, - DATA_TYPE_INT8, - DATA_TYPE_UINT8, - DATA_TYPE_BOOLEAN_ARRAY, - DATA_TYPE_INT8_ARRAY, -#if !defined(_KERNEL) && !defined(_STANDALONE) - DATA_TYPE_UINT8_ARRAY, - DATA_TYPE_DOUBLE -#else - DATA_TYPE_UINT8_ARRAY -#endif -} data_type_t; - -typedef struct nvpair { - int32_t nvp_size; /* size of this nvpair */ - int16_t nvp_name_sz; /* length of name string */ - int16_t nvp_reserve; /* not used */ - int32_t nvp_value_elem; /* number of elements for array types */ - data_type_t nvp_type; /* type of value */ - /* name string */ - /* aligned ptr array for string arrays */ - /* aligned array of data for value */ -} nvpair_t; - -/* nvlist header */ -typedef struct nvlist { - int32_t nvl_version; - uint32_t nvl_nvflag; /* persistent flags */ - uint64_t nvl_priv; /* ptr to private data if not packed */ - uint32_t nvl_flag; - int32_t nvl_pad; /* currently not used, for alignment */ -} nvlist_t; - -/* nvp implementation version */ -#define NV_VERSION 0 - -/* nvlist pack encoding */ -#define NV_ENCODE_NATIVE 0 -#define NV_ENCODE_XDR 1 - -/* nvlist persistent unique name flags, stored in nvl_nvflags */ -#define NV_UNIQUE_NAME 0x1 -#define NV_UNIQUE_NAME_TYPE 0x2 - -/* nvlist lookup pairs related flags */ -#define NV_FLAG_NOENTOK 0x1 - -/* convenience macros */ -#define NV_ALIGN(x) (((ulong_t)(x) + 7ul) & ~7ul) -#define NV_ALIGN4(x) (((x) + 3) & ~3) - -#define NVP_SIZE(nvp) ((nvp)->nvp_size) -#define NVP_NAME(nvp) ((char *)(nvp) + sizeof (nvpair_t)) -#define NVP_TYPE(nvp) ((nvp)->nvp_type) -#define NVP_NELEM(nvp) ((nvp)->nvp_value_elem) -#define NVP_VALUE(nvp) ((char *)(nvp) + NV_ALIGN(sizeof (nvpair_t) \ - + (nvp)->nvp_name_sz)) - -#define NVL_VERSION(nvl) ((nvl)->nvl_version) -#define NVL_SIZE(nvl) ((nvl)->nvl_size) -#define NVL_FLAG(nvl) ((nvl)->nvl_flag) - -/* NV allocator framework */ -typedef struct nv_alloc_ops nv_alloc_ops_t; - -typedef struct nv_alloc { - const nv_alloc_ops_t *nva_ops; - void *nva_arg; -} nv_alloc_t; - -struct nv_alloc_ops { - int (*nv_ao_init)(nv_alloc_t *, va_list); - void (*nv_ao_fini)(nv_alloc_t *); - void *(*nv_ao_alloc)(nv_alloc_t *, size_t); - void (*nv_ao_free)(nv_alloc_t *, void *, size_t); - void (*nv_ao_reset)(nv_alloc_t *); -}; - -_SYS_NVPAIR_H const nv_alloc_ops_t *nv_fixed_ops; -_SYS_NVPAIR_H nv_alloc_t *nv_alloc_nosleep; - -#if defined(_KERNEL) -_SYS_NVPAIR_H nv_alloc_t *nv_alloc_sleep; -_SYS_NVPAIR_H nv_alloc_t *nv_alloc_pushpage; -#endif - -_SYS_NVPAIR_H int nv_alloc_init(nv_alloc_t *, const nv_alloc_ops_t *, - /* args */ ...); -_SYS_NVPAIR_H void nv_alloc_reset(nv_alloc_t *); -_SYS_NVPAIR_H void nv_alloc_fini(nv_alloc_t *); - -/* list management */ -_SYS_NVPAIR_H int nvlist_alloc(nvlist_t **, uint_t, int); -_SYS_NVPAIR_H void nvlist_free(nvlist_t *); -_SYS_NVPAIR_H int nvlist_size(nvlist_t *, size_t *, int); -_SYS_NVPAIR_H int nvlist_pack(nvlist_t *, char **, size_t *, int, int); -_SYS_NVPAIR_H int nvlist_unpack(char *, size_t, nvlist_t **, int); -_SYS_NVPAIR_H int nvlist_dup(nvlist_t *, nvlist_t **, int); -_SYS_NVPAIR_H int nvlist_merge(nvlist_t *, nvlist_t *, int); - -_SYS_NVPAIR_H uint_t nvlist_nvflag(nvlist_t *); - -_SYS_NVPAIR_H int nvlist_xalloc(nvlist_t **, uint_t, nv_alloc_t *); -_SYS_NVPAIR_H int nvlist_xpack(nvlist_t *, char **, size_t *, int, - nv_alloc_t *); -_SYS_NVPAIR_H int nvlist_xunpack(char *, size_t, nvlist_t **, nv_alloc_t *); -_SYS_NVPAIR_H int nvlist_xdup(nvlist_t *, nvlist_t **, nv_alloc_t *); -_SYS_NVPAIR_H nv_alloc_t *nvlist_lookup_nv_alloc(nvlist_t *); - -_SYS_NVPAIR_H int nvlist_add_nvpair(nvlist_t *, nvpair_t *); -_SYS_NVPAIR_H int nvlist_add_boolean(nvlist_t *, const char *); -_SYS_NVPAIR_H int nvlist_add_boolean_value(nvlist_t *, const char *, boolean_t); -_SYS_NVPAIR_H int nvlist_add_byte(nvlist_t *, const char *, uchar_t); -_SYS_NVPAIR_H int nvlist_add_int8(nvlist_t *, const char *, int8_t); -_SYS_NVPAIR_H int nvlist_add_uint8(nvlist_t *, const char *, uint8_t); -_SYS_NVPAIR_H int nvlist_add_int16(nvlist_t *, const char *, int16_t); -_SYS_NVPAIR_H int nvlist_add_uint16(nvlist_t *, const char *, uint16_t); -_SYS_NVPAIR_H int nvlist_add_int32(nvlist_t *, const char *, int32_t); -_SYS_NVPAIR_H int nvlist_add_uint32(nvlist_t *, const char *, uint32_t); -_SYS_NVPAIR_H int nvlist_add_int64(nvlist_t *, const char *, int64_t); -_SYS_NVPAIR_H int nvlist_add_uint64(nvlist_t *, const char *, uint64_t); -_SYS_NVPAIR_H int nvlist_add_string(nvlist_t *, const char *, const char *); -_SYS_NVPAIR_H int nvlist_add_nvlist(nvlist_t *, const char *, nvlist_t *); -_SYS_NVPAIR_H int nvlist_add_boolean_array(nvlist_t *, const char *, - boolean_t *, uint_t); -_SYS_NVPAIR_H int nvlist_add_byte_array(nvlist_t *, const char *, uchar_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_int8_array(nvlist_t *, const char *, int8_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_uint8_array(nvlist_t *, const char *, uint8_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_int16_array(nvlist_t *, const char *, int16_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_uint16_array(nvlist_t *, const char *, uint16_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_int32_array(nvlist_t *, const char *, int32_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_uint32_array(nvlist_t *, const char *, uint32_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_int64_array(nvlist_t *, const char *, int64_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_uint64_array(nvlist_t *, const char *, uint64_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_string_array(nvlist_t *, const char *, - char * const *, uint_t); -_SYS_NVPAIR_H int nvlist_add_nvlist_array(nvlist_t *, const char *, - nvlist_t **, uint_t); -_SYS_NVPAIR_H int nvlist_add_hrtime(nvlist_t *, const char *, hrtime_t); -#if !defined(_KERNEL) && !defined(_STANDALONE) -_SYS_NVPAIR_H int nvlist_add_double(nvlist_t *, const char *, double); -#endif - -_SYS_NVPAIR_H int nvlist_remove(nvlist_t *, const char *, data_type_t); -_SYS_NVPAIR_H int nvlist_remove_all(nvlist_t *, const char *); -_SYS_NVPAIR_H int nvlist_remove_nvpair(nvlist_t *, nvpair_t *); - -_SYS_NVPAIR_H int nvlist_lookup_boolean(nvlist_t *, const char *); -_SYS_NVPAIR_H int nvlist_lookup_boolean_value(nvlist_t *, const char *, - boolean_t *); -_SYS_NVPAIR_H int nvlist_lookup_byte(nvlist_t *, const char *, uchar_t *); -_SYS_NVPAIR_H int nvlist_lookup_int8(nvlist_t *, const char *, int8_t *); -_SYS_NVPAIR_H int nvlist_lookup_uint8(nvlist_t *, const char *, uint8_t *); -_SYS_NVPAIR_H int nvlist_lookup_int16(nvlist_t *, const char *, int16_t *); -_SYS_NVPAIR_H int nvlist_lookup_uint16(nvlist_t *, const char *, uint16_t *); -_SYS_NVPAIR_H int nvlist_lookup_int32(nvlist_t *, const char *, int32_t *); -_SYS_NVPAIR_H int nvlist_lookup_uint32(nvlist_t *, const char *, uint32_t *); -_SYS_NVPAIR_H int nvlist_lookup_int64(nvlist_t *, const char *, int64_t *); -_SYS_NVPAIR_H int nvlist_lookup_uint64(nvlist_t *, const char *, uint64_t *); -_SYS_NVPAIR_H int nvlist_lookup_string(nvlist_t *, const char *, char **); -_SYS_NVPAIR_H int nvlist_lookup_nvlist(nvlist_t *, const char *, nvlist_t **); -_SYS_NVPAIR_H int nvlist_lookup_boolean_array(nvlist_t *, const char *, - boolean_t **, uint_t *); -_SYS_NVPAIR_H int nvlist_lookup_byte_array(nvlist_t *, const char *, uchar_t **, - uint_t *); -_SYS_NVPAIR_H int nvlist_lookup_int8_array(nvlist_t *, const char *, int8_t **, - uint_t *); -_SYS_NVPAIR_H int nvlist_lookup_uint8_array(nvlist_t *, const char *, - uint8_t **, uint_t *); -_SYS_NVPAIR_H int nvlist_lookup_int16_array(nvlist_t *, const char *, - int16_t **, uint_t *); -_SYS_NVPAIR_H int nvlist_lookup_uint16_array(nvlist_t *, const char *, - uint16_t **, uint_t *); -_SYS_NVPAIR_H int nvlist_lookup_int32_array(nvlist_t *, const char *, - int32_t **, uint_t *); -_SYS_NVPAIR_H int nvlist_lookup_uint32_array(nvlist_t *, const char *, - uint32_t **, uint_t *); -_SYS_NVPAIR_H int nvlist_lookup_int64_array(nvlist_t *, const char *, - int64_t **, uint_t *); -_SYS_NVPAIR_H int nvlist_lookup_uint64_array(nvlist_t *, const char *, - uint64_t **, uint_t *); -_SYS_NVPAIR_H int nvlist_lookup_string_array(nvlist_t *, const char *, - char ***, uint_t *); -_SYS_NVPAIR_H int nvlist_lookup_nvlist_array(nvlist_t *, const char *, - nvlist_t ***, uint_t *); -_SYS_NVPAIR_H int nvlist_lookup_hrtime(nvlist_t *, const char *, hrtime_t *); -_SYS_NVPAIR_H int nvlist_lookup_pairs(nvlist_t *, int, ...); -#if !defined(_KERNEL) && !defined(_STANDALONE) -_SYS_NVPAIR_H int nvlist_lookup_double(nvlist_t *, const char *, double *); -#endif - -_SYS_NVPAIR_H int nvlist_lookup_nvpair(nvlist_t *, const char *, nvpair_t **); -_SYS_NVPAIR_H int nvlist_lookup_nvpair_embedded_index(nvlist_t *, const char *, - nvpair_t **, int *, char **); -_SYS_NVPAIR_H boolean_t nvlist_exists(nvlist_t *, const char *); -_SYS_NVPAIR_H boolean_t nvlist_empty(nvlist_t *); - -/* processing nvpair */ -_SYS_NVPAIR_H nvpair_t *nvlist_next_nvpair(nvlist_t *, nvpair_t *); -_SYS_NVPAIR_H nvpair_t *nvlist_prev_nvpair(nvlist_t *, nvpair_t *); -_SYS_NVPAIR_H char *nvpair_name(nvpair_t *); -_SYS_NVPAIR_H data_type_t nvpair_type(nvpair_t *); -_SYS_NVPAIR_H int nvpair_type_is_array(nvpair_t *); -_SYS_NVPAIR_H int nvpair_value_boolean_value(nvpair_t *, boolean_t *); -_SYS_NVPAIR_H int nvpair_value_byte(nvpair_t *, uchar_t *); -_SYS_NVPAIR_H int nvpair_value_int8(nvpair_t *, int8_t *); -_SYS_NVPAIR_H int nvpair_value_uint8(nvpair_t *, uint8_t *); -_SYS_NVPAIR_H int nvpair_value_int16(nvpair_t *, int16_t *); -_SYS_NVPAIR_H int nvpair_value_uint16(nvpair_t *, uint16_t *); -_SYS_NVPAIR_H int nvpair_value_int32(nvpair_t *, int32_t *); -_SYS_NVPAIR_H int nvpair_value_uint32(nvpair_t *, uint32_t *); -_SYS_NVPAIR_H int nvpair_value_int64(nvpair_t *, int64_t *); -_SYS_NVPAIR_H int nvpair_value_uint64(nvpair_t *, uint64_t *); -_SYS_NVPAIR_H int nvpair_value_string(nvpair_t *, char **); -_SYS_NVPAIR_H int nvpair_value_nvlist(nvpair_t *, nvlist_t **); -_SYS_NVPAIR_H int nvpair_value_boolean_array(nvpair_t *, boolean_t **, - uint_t *); -_SYS_NVPAIR_H int nvpair_value_byte_array(nvpair_t *, uchar_t **, uint_t *); -_SYS_NVPAIR_H int nvpair_value_int8_array(nvpair_t *, int8_t **, uint_t *); -_SYS_NVPAIR_H int nvpair_value_uint8_array(nvpair_t *, uint8_t **, uint_t *); -_SYS_NVPAIR_H int nvpair_value_int16_array(nvpair_t *, int16_t **, uint_t *); -_SYS_NVPAIR_H int nvpair_value_uint16_array(nvpair_t *, uint16_t **, uint_t *); -_SYS_NVPAIR_H int nvpair_value_int32_array(nvpair_t *, int32_t **, uint_t *); -_SYS_NVPAIR_H int nvpair_value_uint32_array(nvpair_t *, uint32_t **, uint_t *); -_SYS_NVPAIR_H int nvpair_value_int64_array(nvpair_t *, int64_t **, uint_t *); -_SYS_NVPAIR_H int nvpair_value_uint64_array(nvpair_t *, uint64_t **, uint_t *); -_SYS_NVPAIR_H int nvpair_value_string_array(nvpair_t *, char ***, uint_t *); -_SYS_NVPAIR_H int nvpair_value_nvlist_array(nvpair_t *, nvlist_t ***, uint_t *); -_SYS_NVPAIR_H int nvpair_value_hrtime(nvpair_t *, hrtime_t *); -#if !defined(_KERNEL) && !defined(_STANDALONE) -_SYS_NVPAIR_H int nvpair_value_double(nvpair_t *, double *); -#endif - -_SYS_NVPAIR_H nvlist_t *fnvlist_alloc(void); -_SYS_NVPAIR_H void fnvlist_free(nvlist_t *); -_SYS_NVPAIR_H size_t fnvlist_size(nvlist_t *); -_SYS_NVPAIR_H char *fnvlist_pack(nvlist_t *, size_t *); -_SYS_NVPAIR_H void fnvlist_pack_free(char *, size_t); -_SYS_NVPAIR_H nvlist_t *fnvlist_unpack(char *, size_t); -_SYS_NVPAIR_H nvlist_t *fnvlist_dup(nvlist_t *); -_SYS_NVPAIR_H void fnvlist_merge(nvlist_t *, nvlist_t *); -_SYS_NVPAIR_H size_t fnvlist_num_pairs(nvlist_t *); - -_SYS_NVPAIR_H void fnvlist_add_boolean(nvlist_t *, const char *); -_SYS_NVPAIR_H void fnvlist_add_boolean_value(nvlist_t *, const char *, - boolean_t); -_SYS_NVPAIR_H void fnvlist_add_byte(nvlist_t *, const char *, uchar_t); -_SYS_NVPAIR_H void fnvlist_add_int8(nvlist_t *, const char *, int8_t); -_SYS_NVPAIR_H void fnvlist_add_uint8(nvlist_t *, const char *, uint8_t); -_SYS_NVPAIR_H void fnvlist_add_int16(nvlist_t *, const char *, int16_t); -_SYS_NVPAIR_H void fnvlist_add_uint16(nvlist_t *, const char *, uint16_t); -_SYS_NVPAIR_H void fnvlist_add_int32(nvlist_t *, const char *, int32_t); -_SYS_NVPAIR_H void fnvlist_add_uint32(nvlist_t *, const char *, uint32_t); -_SYS_NVPAIR_H void fnvlist_add_int64(nvlist_t *, const char *, int64_t); -_SYS_NVPAIR_H void fnvlist_add_uint64(nvlist_t *, const char *, uint64_t); -_SYS_NVPAIR_H void fnvlist_add_string(nvlist_t *, const char *, const char *); -_SYS_NVPAIR_H void fnvlist_add_nvlist(nvlist_t *, const char *, nvlist_t *); -_SYS_NVPAIR_H void fnvlist_add_nvpair(nvlist_t *, nvpair_t *); -_SYS_NVPAIR_H void fnvlist_add_boolean_array(nvlist_t *, const char *, - boolean_t *, uint_t); -_SYS_NVPAIR_H void fnvlist_add_byte_array(nvlist_t *, const char *, uchar_t *, - uint_t); -_SYS_NVPAIR_H void fnvlist_add_int8_array(nvlist_t *, const char *, int8_t *, - uint_t); -_SYS_NVPAIR_H void fnvlist_add_uint8_array(nvlist_t *, const char *, uint8_t *, - uint_t); -_SYS_NVPAIR_H void fnvlist_add_int16_array(nvlist_t *, const char *, int16_t *, - uint_t); -_SYS_NVPAIR_H void fnvlist_add_uint16_array(nvlist_t *, const char *, - uint16_t *, uint_t); -_SYS_NVPAIR_H void fnvlist_add_int32_array(nvlist_t *, const char *, int32_t *, - uint_t); -_SYS_NVPAIR_H void fnvlist_add_uint32_array(nvlist_t *, const char *, - uint32_t *, uint_t); -_SYS_NVPAIR_H void fnvlist_add_int64_array(nvlist_t *, const char *, int64_t *, - uint_t); -_SYS_NVPAIR_H void fnvlist_add_uint64_array(nvlist_t *, const char *, - uint64_t *, uint_t); -_SYS_NVPAIR_H void fnvlist_add_string_array(nvlist_t *, const char *, - char * const *, uint_t); -_SYS_NVPAIR_H void fnvlist_add_nvlist_array(nvlist_t *, const char *, - nvlist_t **, uint_t); - -_SYS_NVPAIR_H void fnvlist_remove(nvlist_t *, const char *); -_SYS_NVPAIR_H void fnvlist_remove_nvpair(nvlist_t *, nvpair_t *); - -_SYS_NVPAIR_H nvpair_t *fnvlist_lookup_nvpair(nvlist_t *, const char *); -_SYS_NVPAIR_H boolean_t fnvlist_lookup_boolean(nvlist_t *, const char *); -_SYS_NVPAIR_H boolean_t fnvlist_lookup_boolean_value(nvlist_t *, const char *); -_SYS_NVPAIR_H uchar_t fnvlist_lookup_byte(nvlist_t *, const char *); -_SYS_NVPAIR_H int8_t fnvlist_lookup_int8(nvlist_t *, const char *); -_SYS_NVPAIR_H int16_t fnvlist_lookup_int16(nvlist_t *, const char *); -_SYS_NVPAIR_H int32_t fnvlist_lookup_int32(nvlist_t *, const char *); -_SYS_NVPAIR_H int64_t fnvlist_lookup_int64(nvlist_t *, const char *); -_SYS_NVPAIR_H uint8_t fnvlist_lookup_uint8(nvlist_t *, const char *); -_SYS_NVPAIR_H uint16_t fnvlist_lookup_uint16(nvlist_t *, const char *); -_SYS_NVPAIR_H uint32_t fnvlist_lookup_uint32(nvlist_t *, const char *); -_SYS_NVPAIR_H uint64_t fnvlist_lookup_uint64(nvlist_t *, const char *); -_SYS_NVPAIR_H char *fnvlist_lookup_string(nvlist_t *, const char *); -_SYS_NVPAIR_H nvlist_t *fnvlist_lookup_nvlist(nvlist_t *, const char *); -_SYS_NVPAIR_H boolean_t *fnvlist_lookup_boolean_array(nvlist_t *, const char *, - uint_t *); -_SYS_NVPAIR_H uchar_t *fnvlist_lookup_byte_array(nvlist_t *, const char *, - uint_t *); -_SYS_NVPAIR_H int8_t *fnvlist_lookup_int8_array(nvlist_t *, const char *, - uint_t *); -_SYS_NVPAIR_H uint8_t *fnvlist_lookup_uint8_array(nvlist_t *, const char *, - uint_t *); -_SYS_NVPAIR_H int16_t *fnvlist_lookup_int16_array(nvlist_t *, const char *, - uint_t *); -_SYS_NVPAIR_H uint16_t *fnvlist_lookup_uint16_array(nvlist_t *, const char *, - uint_t *); -_SYS_NVPAIR_H int32_t *fnvlist_lookup_int32_array(nvlist_t *, const char *, - uint_t *); -_SYS_NVPAIR_H uint32_t *fnvlist_lookup_uint32_array(nvlist_t *, const char *, - uint_t *); -_SYS_NVPAIR_H int64_t *fnvlist_lookup_int64_array(nvlist_t *, const char *, - uint_t *); -_SYS_NVPAIR_H uint64_t *fnvlist_lookup_uint64_array(nvlist_t *, const char *, - uint_t *); - -_SYS_NVPAIR_H boolean_t fnvpair_value_boolean_value(nvpair_t *nvp); -_SYS_NVPAIR_H uchar_t fnvpair_value_byte(nvpair_t *nvp); -_SYS_NVPAIR_H int8_t fnvpair_value_int8(nvpair_t *nvp); -_SYS_NVPAIR_H int16_t fnvpair_value_int16(nvpair_t *nvp); -_SYS_NVPAIR_H int32_t fnvpair_value_int32(nvpair_t *nvp); -_SYS_NVPAIR_H int64_t fnvpair_value_int64(nvpair_t *nvp); -_SYS_NVPAIR_H uint8_t fnvpair_value_uint8(nvpair_t *nvp); -_SYS_NVPAIR_H uint16_t fnvpair_value_uint16(nvpair_t *nvp); -_SYS_NVPAIR_H uint32_t fnvpair_value_uint32(nvpair_t *nvp); -_SYS_NVPAIR_H uint64_t fnvpair_value_uint64(nvpair_t *nvp); -_SYS_NVPAIR_H char *fnvpair_value_string(nvpair_t *nvp); -_SYS_NVPAIR_H nvlist_t *fnvpair_value_nvlist(nvpair_t *nvp); - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_NVPAIR_H */ diff --git a/src/lib/include/sys/varargs.h b/src/lib/include/sys/varargs.h deleted file mode 100644 index 3d00a336..00000000 --- a/src/lib/include/sys/varargs.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_VARARGS_H -#define _LIBSPL_SYS_VARARGS_H - -#endif diff --git a/src/lib/include/sys/zio_priority.h b/src/lib/include/sys/zio_priority.h deleted file mode 100644 index 2d8e7fc3..00000000 --- a/src/lib/include/sys/zio_priority.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * CDDL HEADER START - * - * This file and its contents are supplied under the terms of the - * Common Development and Distribution License ("CDDL"), version 1.0. - * You may only use this file in accordance with the terms of version - * 1.0 of the CDDL. - * - * A full copy of the text of the CDDL should have accompanied this - * source. A copy of the CDDL is also available via the Internet at - * http://www.illumos.org/license/CDDL. - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2014, 2016 by Delphix. All rights reserved. - */ -#ifndef _ZIO_PRIORITY_H -#define _ZIO_PRIORITY_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum zio_priority { - ZIO_PRIORITY_SYNC_READ, - ZIO_PRIORITY_SYNC_WRITE, /* ZIL */ - ZIO_PRIORITY_ASYNC_READ, /* prefetch */ - ZIO_PRIORITY_ASYNC_WRITE, /* spa_sync() */ - ZIO_PRIORITY_SCRUB, /* asynchronous scrub/resilver reads */ - ZIO_PRIORITY_REMOVAL, /* reads/writes for vdev removal */ - ZIO_PRIORITY_INITIALIZING, /* initializing I/O */ - ZIO_PRIORITY_TRIM, /* trim I/O (discard) */ - ZIO_PRIORITY_REBUILD, /* reads/writes for vdev rebuild */ - ZIO_PRIORITY_NUM_QUEUEABLE, - ZIO_PRIORITY_NOW, /* non-queued i/os (e.g. free) */ -} zio_priority_t; - -#ifdef __cplusplus -} -#endif - -#endif /* _ZIO_PRIORITY_H */ diff --git a/src/lib/include/ucred.h b/src/lib/include/ucred.h deleted file mode 100644 index 8178fdec..00000000 --- a/src/lib/include/ucred.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_UCRED_H -#define _LIBSPL_UCRED_H - -typedef int ucred_t; - -#endif diff --git a/src/lib/opts.c b/src/lib/opts.c index 2c7110eb..f4cdc161 100644 --- a/src/lib/opts.c +++ b/src/lib/opts.c @@ -10,18 +10,19 @@ #include #define STONERS_GROUP "stoners" -#define BASE_PATH "/etc/aquariums" +#define BASE_PATH "/usr/local/aquarium" // directory paths -#define TEMPLATES_PATH "templates" -#define KERNELS_PATH "kernels" -#define AQUARIUMS_PATH "aquariums" +#define TEMPLATES_PATH "tmpls" +#define KERNELS_PATH "kerns" +#define OVERLAYS_PATH "overlays" +#define AQUARIUMS_PATH "roots" // file paths -#define SANCTIONED_PATH "templates_remote" -#define DB_PATH "aquarium_db" +#define SANCTIONED_PATH "tmpls.remote" +#define DB_PATH "db" // image output & filesystem creation options @@ -105,6 +106,7 @@ void aquarium_opts_free(aquarium_opts_t* opts) { TRY_FREE(opts->templates_path); TRY_FREE(opts->kernels_path); + TRY_FREE(opts->overlays_path); TRY_FREE(opts->aquariums_path); // file paths @@ -139,10 +141,12 @@ void aquarium_opts_set_base_path(aquarium_opts_t* opts, char const* base_path) { TRY_FREE(opts->templates_path); TRY_FREE(opts->kernels_path); + TRY_FREE(opts->overlays_path); TRY_FREE(opts->aquariums_path); if (asprintf(&opts->templates_path, "%s/" TEMPLATES_PATH, opts->base_path)) {} if (asprintf(&opts->kernels_path, "%s/" KERNELS_PATH, opts->base_path)) {} + if (asprintf(&opts->overlays_path, "%s/" OVERLAYS_PATH, opts->base_path)) {} if (asprintf(&opts->aquariums_path, "%s/" AQUARIUMS_PATH, opts->base_path)) {} // file paths diff --git a/src/lib/sanctioned.h b/src/lib/sanctioned.h index 993c743b..680d1bf5 100644 --- a/src/lib/sanctioned.h +++ b/src/lib/sanctioned.h @@ -1,20 +1,19 @@ // This Source Form is subject to the terms of the AQUA Software License, v. 1.0. -// Copyright (c) 2023 Aymeric Wibo +// Copyright (c) 2024 Aymeric Wibo #pragma once static char const* const SANCTIONED = + // XXX Linux kernels are unsupported as of yet, so all Linux aquariums are base template only. + // Ubuntu 20.04.6 LTS (Focal Fossa). + "b:amd64.ubuntu.focal:https:github.com/inobulles/bob-linux-images/releases/download/amd64.ubuntu.focal/amd64.ubuntu.focal.txz:123438644:e1236bcc6a755a0db1d0fa34d4f6a942a56a51778a52d344c3d8c9c4f3b13682\n" - "b:amd64.aquabsd.0622a:https:github.com/inobulles/aquabsd-core/releases/download/v0622a-beta/base.txz:100050160:60321fefa8d46642f82fb51f9a1f16c552768da3f2b65b41ffa5fbaf8ff621fe\n" - "k:amd64.aquabsd.0622a:https:github.com/inobulles/aquabsd-core/releases/download/v0622a-beta/kernel.txz:46796444:da71214c6c6ed3de41599c2cef56c5215ec0c547eb839a49669e78598839a000\n" - "b:amd64.aquabsd.0922a:https:github.com/inobulles/aquabsd-core/releases/download/v0922a-beta/base.txz:100190248:7c6ddff808a8e3209917dd8beda46101a923b0b0386c2a1aef2bcba61a0406a0\n" - "k:amd64.aquabsd.0922a:https:github.com/inobulles/aquabsd-core/releases/download/v0922a-beta/kernel.txz:47538612:ad44de7c4d071db1862aadbbaf72be0551d736a89dbb9ad005cd0f95365b79b4\n" - "b:amd64.aquabsd.1222a:https:github.com/inobulles/aquabsd-core/releases/download/v1222a-beta/base.txz:100231832:3e32bbf8273dad00eb11607caa5618005eb97024687dadb68d947c48e11cf129\n" - "k:amd64.aquabsd.1222a:https:github.com/inobulles/aquabsd-core/releases/download/v1222a-beta/kernel.txz:47628512:7105e6c8f01d5e5c60d653f258356cb8a6a50330229753218c425c9bde9542e0\n" - "b:amd64.aquabsd.0.1.0-beta:https:github.com/inobulles/aquabsd-core/releases/download/v0.1.0-beta/base.txz:102059036:c433417808a9cbf19015427667c223744e16b2e57d89dad3f7d57c73a70d6a9c\n" - "k:amd64.aquabsd.0.1.0-beta:https:github.com/inobulles/aquabsd-core/releases/download/v0.1.0-beta/kernel.txz:53594932:515baf7ea7bc94e5473f2317b9d1343a7d405e3f2f51bf9abd93db529b05b126\n" - "b:amd64.aquabsd.0.1.1-beta:https:github.com/inobulles/aquabsd-core/releases/download/v0.1.1-beta/base.txz:106180020:c7503d62a8a4dd14e0a50bc0b9017cea1b45e8d9e03137b23bc62dde4f0f1fcc\n" - "k:amd64.aquabsd.0.1.1-beta:https:github.com/inobulles/aquabsd-core/releases/download/v0.1.1-beta/kernel.txz:47144808:6674891dfbdc6aa7b8ef04fda3330bbf76dd78d24d06f3909e0e8afe82c209a8\n" + + // FreeBSD 14.2-RELEASE. + + "b:amd64.freebsd.14-2-release:https:download.freebsd.org/ftp/releases/amd64/14.2-RELEASE/base.txz:205880752:e3971a3d4f36ed1ac67d2e7a5501726de79dd3695aa76bfad2a4ebe91a88a134\n" + "k:amd64.freebsd.14-2-release:https:download.freebsd.org/ftp/releases/amd64/14.2-RELEASE/kernel.txz:57859924:b441661d86cbea3be3191db462d0477e099e7dbdc4d2ca186ebb14df1a848480\n" + "o:amd64.freebsd.14-2-release.src:https:download.freebsd.org/ftp/releases/amd64/14.2-RELEASE/src.txz:214942672:2e8a48c5209302e5372ccbaf3e0adf8f21c9cadfdc8277420bf43ac236387a93\n" ; // vim: nospell diff --git a/src/lib/sweep.c b/src/lib/sweep.c index c4656fe6..2fcd2540 100644 --- a/src/lib/sweep.c +++ b/src/lib/sweep.c @@ -1,5 +1,5 @@ // This Source Form is subject to the terms of the AQUA Software License, v. 1.0. -// Copyright (c) 2023 Aymeric Wibo +// Copyright (c) 2024 Aymeric Wibo #include #include @@ -11,17 +11,13 @@ #include static int remove_aquarium(char* path) { - // first, make sure all possible mounted filesystems are unmounted - // if this fails, try to remove things anyway + // First, make sure all possible mounted filesystems are unmounted. + // If this fails, try to remove things anyway. aquarium_os_t const os = aquarium_os_info(path); int rv = aquarium_enter_setdown(path, os); - // then, we remove all the aquarium files - // the aquarium may have already been deleted (e.g. by a nosy user) - // so we don't wanna do anything with the return value of '__aquarium_wait_for_process' - // TODO I desperately need some easy API for removing files in the standard library on aquaBSD - // I'm not (I hope) dumb enough to do something like 'asprintf(&cmd, "rm -rf %s", ent.aquarium_path)', but I know damn well other developers would be tempted to do such a thing given no other alternative + // Then, we must remove the immutable flag from the aquarium directory. pid_t pid = fork(); @@ -30,7 +26,27 @@ static int remove_aquarium(char* path) { return -1; } - if (!pid) { + if (pid == 0) { + execl("/bin/chflags", "/bin/chflags", "-R", "noschg", path, NULL); + _exit(EXIT_FAILURE); + } + + __aquarium_wait_for_process(pid); + + // Finally, we remove all the aquarium files. + // The aquarium may have already been deleted (e.g. by a nosy user). + // So we don't wanna do anything with the return value of '__aquarium_wait_for_process' + // TODO I desperately need some easy API for removing files in the standard library on aquaBSD + // I'm not (I hope) dumb enough to do something like 'asprintf(&cmd, "rm -rf %s", ent.aquarium_path)', but I know damn well other developers would be tempted to do such a thing given no other alternative. + + pid = fork(); + + if (pid < 0) { + warnx("fork: %s", strerror(errno)); + return -1; + } + + if (pid == 0) { execl("/bin/rm", "/bin/rm", "-rf", path, NULL); _exit(EXIT_FAILURE); } @@ -102,7 +118,7 @@ int aquarium_sweep(aquarium_opts_t* opts, bool go_hard) { survivor->aquarium_path = strdup(ent.aquarium_path); } - // keep things nice and clean is to go through everything under /etc/aquariums/aquariums and see which aquariums were never "recensés" (censused?) + // keep things nice and clean is to go through everything under /usr/local/aquarium/roots and see which aquariums were never "recensés" (censused?) DIR* const dp = opendir(opts->aquariums_path); diff --git a/src/lib/template.c b/src/lib/template.c index a4fa757f..fa405395 100644 --- a/src/lib/template.c +++ b/src/lib/template.c @@ -4,8 +4,10 @@ #include #include "archive.h" #include "archive_entry.h" +#include #include #include +#include #include #include #include @@ -193,6 +195,10 @@ int aquarium_download_template(aquarium_opts_t* opts, char const* path, char con sanctioned.kind = AQUARIUM_TEMPLATE_KIND_KERNEL; } + else if (*tok == 'o') { + sanctioned.kind = AQUARIUM_TEMPLATE_KIND_OVERLAY; + } + else { warnx("Unknown template kind ('%s')", tok); goto template_kind_err; @@ -325,7 +331,21 @@ int aquarium_extract_template(aquarium_opts_t* opts, char const* path, char cons // where should we look for templates? - char* const search_path = kind == AQUARIUM_TEMPLATE_KIND_KERNEL ? opts->kernels_path : opts->templates_path; + char* search_path = NULL; + + switch (kind) { + case AQUARIUM_TEMPLATE_KIND_BASE: + search_path = opts->templates_path; + break; + case AQUARIUM_TEMPLATE_KIND_KERNEL: + search_path = opts->kernels_path; + break; + case AQUARIUM_TEMPLATE_KIND_OVERLAY: + search_path = opts->overlays_path; + break; + } + + assert(search_path != NULL); // build template path // attempt to download & check it if it don't already exist