diff options
Diffstat (limited to 'tools/pvchange.c')
-rw-r--r-- | tools/pvchange.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/pvchange.c b/tools/pvchange.c index dd72bf1bd..a92bdd8b0 100644 --- a/tools/pvchange.c +++ b/tools/pvchange.c @@ -26,6 +26,7 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg, struct pvchange_params *params = (struct pvchange_params *) handle->custom_handle; const char *pv_name = pv_dev_name(pv); char uuid[64] __attribute__((aligned(8))); + struct use_id *uid; unsigned done = 0; int used; @@ -147,6 +148,9 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg, if (arg_is_set(cmd, uuid_ARG)) { /* --uuid: Change PV ID randomly */ + + uid = get_uid_for_pvid(cmd, pv->dev->pvid); + memcpy(&pv->old_id, &pv->id, sizeof(pv->id)); if (!id_create(&pv->id)) { log_error("Failed to generate new random UUID for %s.", @@ -184,6 +188,16 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg, goto bad; } + if (uid) { + if (uid->pvid) + free(uid->pvid); + if (!(uid->pvid = strndup((char *)&pv->id, ID_LEN))) + log_error("Failed to set pvid for devices file."); + if (!device_ids_write(cmd)) + log_warn("Failed to update devices file."); + unlock_devices_file(cmd); + } + log_print_unless_silent("Physical volume \"%s\" changed", pv_name); params->done++; @@ -210,6 +224,9 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv) goto out; } + if (arg_is_set(cmd, uuid_ARG)) + cmd->edit_devices_file = 1; + if (!(handle = init_processing_handle(cmd, NULL))) { log_error("Failed to initialize processing handle."); ret = ECMD_FAILED; |