1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

system_id: avoid munging vg and lv fields

Munge the WRITE/WRITE_LOCKED flags in a temp variable
instead of in the vg/lv fields.
This commit is contained in:
David Teigland 2015-03-05 10:23:16 -06:00
parent 8bb76aea81
commit 5e25bca1a9

View File

@ -394,6 +394,7 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
{ {
char buffer[4096]; char buffer[4096];
const struct format_type *fmt = NULL; const struct format_type *fmt = NULL;
uint64_t status = vg->status;
if (!id_write_format(&vg->id, buffer, sizeof(buffer))) if (!id_write_format(&vg->id, buffer, sizeof(buffer)))
return_0; return_0;
@ -413,19 +414,14 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
* Removing WRITE and adding WRITE_LOCKED makes it read-only * Removing WRITE and adding WRITE_LOCKED makes it read-only
* to old versions of lvm that only look for WRITE. * to old versions of lvm that only look for WRITE.
*/ */
if ((vg->status & LVM_WRITE) && vg_flag_write_locked(vg)) { if ((status & LVM_WRITE) && vg_flag_write_locked(vg)) {
vg->status &= ~LVM_WRITE; status &= ~LVM_WRITE;
vg->status |= LVM_WRITE_LOCKED; status |= LVM_WRITE_LOCKED;
} }
if (!_print_flag_config(f, vg->status, VG_FLAGS)) if (!_print_flag_config(f, status, VG_FLAGS))
return_0; return_0;
if (vg->status & LVM_WRITE_LOCKED) {
vg->status |= LVM_WRITE;
vg->status &= ~LVM_WRITE_LOCKED;
}
if (!_out_tags(f, &vg->tags)) if (!_out_tags(f, &vg->tags))
return_0; return_0;
@ -621,6 +617,7 @@ static int _print_lv(struct formatter *f, struct logical_volume *lv)
int seg_count; int seg_count;
struct tm *local_tm; struct tm *local_tm;
time_t ts; time_t ts;
uint64_t status = lv->status;
outnl(f); outnl(f);
outf(f, "%s {", lv->name); outf(f, "%s {", lv->name);
@ -636,19 +633,14 @@ static int _print_lv(struct formatter *f, struct logical_volume *lv)
* Removing WRITE and adding WRITE_LOCKED makes it read-only * Removing WRITE and adding WRITE_LOCKED makes it read-only
* to old versions of lvm that only look for WRITE. * to old versions of lvm that only look for WRITE.
*/ */
if ((lv->status & LVM_WRITE) && vg_flag_write_locked(lv->vg)) { if ((status & LVM_WRITE) && vg_flag_write_locked(lv->vg)) {
lv->status &= ~LVM_WRITE; status &= ~LVM_WRITE;
lv->status |= LVM_WRITE_LOCKED; status |= LVM_WRITE_LOCKED;
} }
if (!_print_flag_config(f, lv->status, LV_FLAGS)) if (!_print_flag_config(f, status, LV_FLAGS))
return_0; return_0;
if (lv->status & LVM_WRITE_LOCKED) {
lv->status |= LVM_WRITE;
lv->status &= ~LVM_WRITE_LOCKED;
}
if (!_out_tags(f, &lv->tags)) if (!_out_tags(f, &lv->tags))
return_0; return_0;