1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

convert pv->vg_name[0] to \!is_orphan(pv)

This commit is contained in:
Dave Wysochanski 2007-06-14 15:48:05 +00:00
parent b5c344937b
commit 3df2c388b1
4 changed files with 22 additions and 10 deletions

View File

@ -1687,6 +1687,17 @@ int pv_write_orphan(struct cmd_context *cmd, struct physical_volume *pv)
return 1;
}
/**
* is_orphan - Determine whether a pv is an orphan based on its vg_name
* @pv: handle to the physical volume
*/
int is_orphan(pv_t *pv)
{
return (pv_field(pv, vg_name)[0] ? 0 : 1);
}
/*
* Returns:
* 0 - fail

View File

@ -436,6 +436,7 @@ struct list *get_vgids(struct cmd_context *cmd, int full_scan);
int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
struct list *mdas, int64_t label_sector);
int pv_write_orphan(struct cmd_context *cmd, struct physical_volume *pv);
int is_orphan(pv_t *pv);
/* pe_start and pe_end relate to any existing data so that new metadata
* areas can avoid overlap */

View File

@ -45,14 +45,14 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
/* Allow partial & exported VGs to be destroyed. */
/* We must have -ff to overwrite a non orphan */
if (pv && pv->vg_name[0] && arg_count(cmd, force_ARG) != 2) {
if (pv && !is_orphan(pv) && arg_count(cmd, force_ARG) != 2) {
log_error("Can't initialize physical volume \"%s\" of "
"volume group \"%s\" without -ff", name, get_pv_vg_name(pv));
return 0;
}
/* prompt */
if (pv && pv->vg_name[0] && !arg_count(cmd, yes_ARG) &&
if (pv && !is_orphan(pv) && !arg_count(cmd, yes_ARG) &&
yes_no_prompt(_really_init, name, get_pv_vg_name(pv)) == 'n') {
log_print("%s: physical volume not initialized", name);
return 0;
@ -103,12 +103,12 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
}
}
if (pv && pv->vg_name[0] && arg_count(cmd, force_ARG)) {
if (pv && !is_orphan(pv) && arg_count(cmd, force_ARG)) {
log_print("WARNING: Forcing physical volume creation on "
"%s%s%s%s", name,
pv->vg_name[0] ? " of volume group \"" : "",
pv->vg_name[0] ? pv->vg_name : "",
pv->vg_name[0] ? "\"" : "");
!is_orphan(pv) ? " of volume group \"" : "",
!is_orphan(pv) ? get_pv_vg_name(pv) : "",
!is_orphan(pv) ? "\"" : "");
}
return 1;

View File

@ -43,7 +43,7 @@ static int pvremove_check(struct cmd_context *cmd, const char *name)
}
/* orphan ? */
if (!pv->vg_name[0])
if (!is_orphan(pv))
return 1;
/* Allow partial & exported VGs to be destroyed. */
@ -64,9 +64,9 @@ static int pvremove_check(struct cmd_context *cmd, const char *name)
if (arg_count(cmd, force_ARG)) {
log_print("WARNING: Wiping physical volume label from "
"%s%s%s%s", name,
pv->vg_name[0] ? " of volume group \"" : "",
pv->vg_name[0] ? get_pv_vg_name(pv) : "",
pv->vg_name[0] ? "\"" : "");
!is_orphan(pv) ? " of volume group \"" : "",
!is_orphan(pv) ? get_pv_vg_name(pv) : "",
!is_orphan(pv) ? "\"" : "");
}
return 1;