mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 10:54:35 +03:00
zpool: Provide GUID to zpool-reguid(8) with -g (#16239)
This commit extends the zpool-reguid(8) command with a -g flag, which allows the user to specify the GUID to set. This change also adds some general tests for zpool-reguid(8). Sponsored-by: Wasabi Technology, Inc. Sponsored-by: Klara, Inc. Signed-off-by: Mateusz Piotrowski <0mp@FreeBSD.org> Reviewed-by: Rob Norris <rob.norris@klarasystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Tony Hutter <hutter2@llnl.gov>
This commit is contained in:
committed by
GitHub
parent
2420ee6e12
commit
6be8bf5552
@@ -556,6 +556,7 @@
|
||||
<elf-symbol name='zpool_scan' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zpool_search_import' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zpool_set_bootenv' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zpool_set_guid' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zpool_set_prop' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zpool_set_vdev_prop' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zpool_skip_pool' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
@@ -6639,6 +6640,11 @@
|
||||
<parameter type-id='9c313c2d' name='guid'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='zpool_set_guid' mangled-name='zpool_set_guid' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zpool_set_guid'>
|
||||
<parameter type-id='4c81de99' name='zhp'/>
|
||||
<parameter type-id='713a56f5' name='guid'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='zpool_reguid' mangled-name='zpool_reguid' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zpool_reguid'>
|
||||
<parameter type-id='4c81de99' name='zhp'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
|
||||
@@ -4310,22 +4310,55 @@ zpool_vdev_clear(zpool_handle_t *zhp, uint64_t guid)
|
||||
|
||||
/*
|
||||
* Change the GUID for a pool.
|
||||
*
|
||||
* Similar to zpool_reguid(), but may take a GUID.
|
||||
*
|
||||
* If the guid argument is NULL, then no GUID is passed in the nvlist to the
|
||||
* ioctl().
|
||||
*/
|
||||
int
|
||||
zpool_reguid(zpool_handle_t *zhp)
|
||||
zpool_set_guid(zpool_handle_t *zhp, const uint64_t *guid)
|
||||
{
|
||||
char errbuf[ERRBUFLEN];
|
||||
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||
nvlist_t *nvl = NULL;
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
int error = -1;
|
||||
|
||||
if (guid != NULL) {
|
||||
if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0)
|
||||
return (no_memory(hdl));
|
||||
|
||||
if (nvlist_add_uint64(nvl, ZPOOL_REGUID_GUID, *guid) != 0) {
|
||||
nvlist_free(nvl);
|
||||
return (no_memory(hdl));
|
||||
}
|
||||
|
||||
zcmd_write_src_nvlist(hdl, &zc, nvl);
|
||||
}
|
||||
|
||||
(void) snprintf(errbuf, sizeof (errbuf),
|
||||
dgettext(TEXT_DOMAIN, "cannot reguid '%s'"), zhp->zpool_name);
|
||||
|
||||
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
|
||||
if (zfs_ioctl(hdl, ZFS_IOC_POOL_REGUID, &zc) == 0)
|
||||
return (0);
|
||||
error = zfs_ioctl(hdl, ZFS_IOC_POOL_REGUID, &zc);
|
||||
if (error) {
|
||||
return (zpool_standard_error(hdl, errno, errbuf));
|
||||
}
|
||||
if (guid != NULL) {
|
||||
zcmd_free_nvlists(&zc);
|
||||
nvlist_free(nvl);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (zpool_standard_error(hdl, errno, errbuf));
|
||||
/*
|
||||
* Change the GUID for a pool.
|
||||
*/
|
||||
int
|
||||
zpool_reguid(zpool_handle_t *zhp)
|
||||
{
|
||||
return (zpool_set_guid(zhp, NULL));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user