mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-30 18:56:23 +03:00
libzfs: teach zfs_create_ancestors() to accept properties
This will be used to support creating non-mountable ancestors in zfs(8). Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Rob Norris <robn@despairlabs.com> Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name> Closes #17000
This commit is contained in:
committed by
Brian Behlendorf
parent
1eace59060
commit
2f3f1ab1ba
@@ -766,6 +766,8 @@ _LIBZFS_H void libzfs_add_handle(get_all_cb_t *, zfs_handle_t *);
|
|||||||
_LIBZFS_H int zfs_create(libzfs_handle_t *, const char *, zfs_type_t,
|
_LIBZFS_H int zfs_create(libzfs_handle_t *, const char *, zfs_type_t,
|
||||||
nvlist_t *);
|
nvlist_t *);
|
||||||
_LIBZFS_H int zfs_create_ancestors(libzfs_handle_t *, const char *);
|
_LIBZFS_H int zfs_create_ancestors(libzfs_handle_t *, const char *);
|
||||||
|
_LIBZFS_H int zfs_create_ancestors_props(libzfs_handle_t *, const char *,
|
||||||
|
nvlist_t *);
|
||||||
_LIBZFS_H int zfs_destroy(zfs_handle_t *, boolean_t);
|
_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(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(libzfs_handle_t *, nvlist_t *, boolean_t);
|
||||||
|
|||||||
@@ -356,6 +356,7 @@
|
|||||||
<elf-symbol name='zfs_component_namecheck' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
<elf-symbol name='zfs_component_namecheck' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||||
<elf-symbol name='zfs_create' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
<elf-symbol name='zfs_create' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||||
<elf-symbol name='zfs_create_ancestors' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
<elf-symbol name='zfs_create_ancestors' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||||
|
<elf-symbol name='zfs_create_ancestors_props' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||||
<elf-symbol name='zfs_crypto_attempt_load_keys' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
<elf-symbol name='zfs_crypto_attempt_load_keys' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||||
<elf-symbol name='zfs_crypto_clone_check' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
<elf-symbol name='zfs_crypto_clone_check' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||||
<elf-symbol name='zfs_crypto_create' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
<elf-symbol name='zfs_crypto_create' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||||
|
|||||||
@@ -3581,7 +3581,8 @@ zfs_dataset_exists(libzfs_handle_t *hdl, const char *path, zfs_type_t types)
|
|||||||
* Fail if the initial prefixlen-ancestor does not already exist.
|
* Fail if the initial prefixlen-ancestor does not already exist.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
create_parents(libzfs_handle_t *hdl, char *target, int prefixlen)
|
create_parents(libzfs_handle_t *hdl, char *target, int prefixlen,
|
||||||
|
nvlist_t *props)
|
||||||
{
|
{
|
||||||
zfs_handle_t *h;
|
zfs_handle_t *h;
|
||||||
char *cp;
|
char *cp;
|
||||||
@@ -3617,8 +3618,7 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zfs_create(hdl, target, ZFS_TYPE_FILESYSTEM,
|
if (zfs_create(hdl, target, ZFS_TYPE_FILESYSTEM, props) != 0) {
|
||||||
NULL) != 0) {
|
|
||||||
opname = dgettext(TEXT_DOMAIN, "create");
|
opname = dgettext(TEXT_DOMAIN, "create");
|
||||||
goto ancestorerr;
|
goto ancestorerr;
|
||||||
}
|
}
|
||||||
@@ -3656,6 +3656,17 @@ ancestorerr:
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
zfs_create_ancestors(libzfs_handle_t *hdl, const char *path)
|
zfs_create_ancestors(libzfs_handle_t *hdl, const char *path)
|
||||||
|
{
|
||||||
|
return zfs_create_ancestors_props(hdl, path, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates non-existing ancestors of the given path, applying extra
|
||||||
|
* properties provided in an nvlist.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
zfs_create_ancestors_props(libzfs_handle_t *hdl, const char *path,
|
||||||
|
nvlist_t *props)
|
||||||
{
|
{
|
||||||
int prefix;
|
int prefix;
|
||||||
char *path_copy;
|
char *path_copy;
|
||||||
@@ -3679,7 +3690,7 @@ zfs_create_ancestors(libzfs_handle_t *hdl, const char *path)
|
|||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
if ((path_copy = strdup(path)) != NULL) {
|
if ((path_copy = strdup(path)) != NULL) {
|
||||||
rc = create_parents(hdl, path_copy, prefix);
|
rc = create_parents(hdl, path_copy, prefix, props);
|
||||||
free(path_copy);
|
free(path_copy);
|
||||||
}
|
}
|
||||||
if (path_copy == NULL || rc != 0)
|
if (path_copy == NULL || rc != 0)
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ extern uint32_t zfs_namespace_prop_flag(zfs_prop_t);
|
|||||||
extern boolean_t zfs_is_mountable_internal(zfs_handle_t *);
|
extern boolean_t zfs_is_mountable_internal(zfs_handle_t *);
|
||||||
extern int zfs_mount_setattr(zfs_handle_t *, uint32_t);
|
extern int zfs_mount_setattr(zfs_handle_t *, uint32_t);
|
||||||
extern void remove_mountpoint(zfs_handle_t *);
|
extern void remove_mountpoint(zfs_handle_t *);
|
||||||
extern int create_parents(libzfs_handle_t *, char *, int);
|
extern int create_parents(libzfs_handle_t *, char *, int, nvlist_t *);
|
||||||
|
|
||||||
extern zfs_handle_t *make_dataset_handle(libzfs_handle_t *, const char *);
|
extern zfs_handle_t *make_dataset_handle(libzfs_handle_t *, const char *);
|
||||||
extern zfs_handle_t *make_bookmark_handle(zfs_handle_t *, const char *,
|
extern zfs_handle_t *make_bookmark_handle(zfs_handle_t *, const char *,
|
||||||
|
|||||||
@@ -4947,7 +4947,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
|
|||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
|
|
||||||
if (flags->isprefix && !flags->istail && !flags->dryrun &&
|
if (flags->isprefix && !flags->istail && !flags->dryrun &&
|
||||||
create_parents(hdl, destsnap, strlen(tosnap)) != 0) {
|
create_parents(hdl, destsnap, strlen(tosnap), NULL) != 0) {
|
||||||
err = zfs_error(hdl, EZFS_BADRESTORE, errbuf);
|
err = zfs_error(hdl, EZFS_BADRESTORE, errbuf);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user