diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2022-09-06 14:40:06 +0200 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2022-09-06 15:49:27 +0200 |
commit | 973d0bd5b7110ad16fe26362c2586c961591ba4a (patch) | |
tree | 3b5ae88e62ff2de4925d28476a6b17714af2f15f /lib/report | |
parent | 0eebd9d7802c724ee71b6ebb80940ea6007f9c7a (diff) | |
download | lvm2-973d0bd5b7110ad16fe26362c2586c961591ba4a.tar.gz |
report: fix lv_active column type from STR to BIN
Fix lv_active to be of BIN type instead of STR. This allows lv_active to
follow the report/binary_values_as_numeric setting as well as --binary
cmd line switch. Also, it makes it possible to use -S|--select with
either textual or numeric representation of the value, like 'lvs -S
active=active' but also 'lvs -S active=1'.
Diffstat (limited to 'lib/report')
-rw-r--r-- | lib/report/columns.h | 2 | ||||
-rw-r--r-- | lib/report/report.c | 13 | ||||
-rw-r--r-- | lib/report/values.h | 1 |
3 files changed, 9 insertions, 7 deletions
diff --git a/lib/report/columns.h b/lib/report/columns.h index d702635d2..8719a7e7d 100644 --- a/lib/report/columns.h +++ b/lib/report/columns.h @@ -63,7 +63,7 @@ FIELD(LVS, lv, BIN, "FixMin", lvid, 10, lvfixedminor, lv_fixed_minor, "Set if LV FIELD(LVS, lv, BIN, "SkipAct", lvid, 15, lvskipactivation, lv_skip_activation, "Set if LV is skipped on activation.", 0) FIELD(LVS, lv, BIN, "AutoAct", lvid, 0, lvautoactivation, lv_autoactivation, "Set if LV autoactivation is enabled.", 0) FIELD(LVS, lv, STR, "WhenFull", lvid, 15, lvwhenfull, lv_when_full, "For thin pools, behavior when full.", 0) -FIELD(LVS, lv, STR, "Active", lvid, 0, lvactive, lv_active, "Active state of the LV.", 0) +FIELD(LVS, lv, BIN, "Active", lvid, 0, lvactive, lv_active, "Active state of the LV.", 0) FIELD(LVS, lv, BIN, "ActLocal", lvid, 10, lvactivelocally, lv_active_locally, "Set if the LV is active locally.", 0) FIELD(LVS, lv, BIN, "ActRemote", lvid, 10, lvactiveremotely, lv_active_remotely, "Set if the LV is active remotely.", 0) FIELD(LVS, lv, BIN, "ActExcl", lvid, 10, lvactiveexclusively, lv_active_exclusively, "Set if the LV is active exclusively.", 0) diff --git a/lib/report/report.c b/lib/report/report.c index f666ca842..9172c1f0e 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -3808,14 +3808,15 @@ static int _lvactive_disp(struct dm_report *rh, struct dm_pool *mem, struct dm_report_field *field, const void *data, void *private) { - char *repstr; + const struct logical_volume *lv = (const struct logical_volume *) data; + int active; - if (!(repstr = lv_active_dup(mem, (const struct logical_volume *) data))) { - log_error("Failed to allocate buffer for active."); - return 0; - } + if (!activation()) + return _binary_undef_disp(rh, mem, field, private); - return _field_set_value(field, repstr, NULL); + active = lv_is_active(lv); + + return _binary_disp(rh, mem, field, active, GET_FIRST_RESERVED_NAME(lv_active_y), private); } static int _lvactivelocally_disp(struct dm_report *rh, struct dm_pool *mem, diff --git a/lib/report/values.h b/lib/report/values.h index 71175fa6e..3efe2b83f 100644 --- a/lib/report/values.h +++ b/lib/report/values.h @@ -99,6 +99,7 @@ FIELD_RESERVED_BINARY_VALUE(lv_merging, lv_merging, "", "merging") FIELD_RESERVED_BINARY_VALUE(lv_converting, lv_converting, "", "converting") FIELD_RESERVED_BINARY_VALUE(lv_allocation_locked, lv_allocation_locked, "", "allocation locked", "locked") FIELD_RESERVED_BINARY_VALUE(lv_fixed_minor, lv_fixed_minor, "", "fixed minor", "fixed") +FIELD_RESERVED_BINARY_VALUE(lv_active, lv_active, "", "active") FIELD_RESERVED_BINARY_VALUE(lv_active_locally, lv_active_locally, "", "active locally", "active", "locally") FIELD_RESERVED_BINARY_VALUE(lv_active_remotely, lv_active_remotely, "", "active remotely", "active", "remotely") FIELD_RESERVED_BINARY_VALUE(lv_active_exclusively, lv_active_exclusively, "", "active exclusively", "active", "exclusively") |