From 07ae1d4943d2ffc80db44eef74c7608aa4027986 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Wed, 23 Jun 2010 12:32:08 +0000 Subject: [PATCH] Add lv_path to reports to offer full /dev pathname. --- WHATS_NEW | 4 +++- lib/report/columns.h | 1 + lib/report/report.c | 24 ++++++++++++++++++++++++ man/lvs.8.in | 2 +- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 47ff00239..99ddcdd26 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.68 - =============================== + Add lv_path to reports to offer full /dev pathname. Fix typo in warning message about missing device with allocated data areas. Add device name and offset to output of error messages in raw_read_mda_header(). Use flexible data[] in cmirrord request to prevent abort in runtime size checks. @@ -14,7 +15,8 @@ Version 2.02.68 - Add --force, --nofsck and --resizefs to lvresize/extend/reduce man pages. Fix lvm2cmd example in documentation. Allow use of lvm2app and lvm2cmd headers in C++ code. - Remove some unused #includes from clvmd files. + Remove unused #includes from clvmd files and introduce clvmd-common.h. + Move common inclusions to clvmd-common.h. Use #include "" for libdevmapper.h and configure.h throughout tree. Fix LVM_PATH expansion when exec_prefix=NONE (2.02.67). Fix segfault in clvmd -R if no response from daemon received. diff --git a/lib/report/columns.h b/lib/report/columns.h index 141497151..a1d419c95 100644 --- a/lib/report/columns.h +++ b/lib/report/columns.h @@ -57,6 +57,7 @@ /* *INDENT-OFF* */ FIELD(LVS, lv, STR, "LV UUID", lvid.id[1], 38, uuid, "lv_uuid", "Unique identifier.") FIELD(LVS, lv, STR, "LV", lvid, 4, lvname, "lv_name", "Name. LVs created for internal use are enclosed in brackets.") +FIELD(LVS, lv, STR, "Path", lvid, 4, lvpath, "lv_path", "Full pathname for LV.") FIELD(LVS, lv, STR, "Attr", lvid, 4, lvstatus, "lv_attr", "Various attributes - see man page.") FIELD(LVS, lv, NUM, "Maj", major, 3, int32, "lv_major", "Persistent major number or -1 if not persistent.") FIELD(LVS, lv, NUM, "Min", minor, 3, int32, "lv_minor", "Persistent minor number or -1 if not persistent.") diff --git a/lib/report/report.c b/lib/report/report.c index 063db0739..f71a46f81 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -523,6 +523,30 @@ static int _lvname_disp(struct dm_report *rh, struct dm_pool *mem, return 1; } +static int _lvpath_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private __attribute((unused))) +{ + const struct logical_volume *lv = (const struct logical_volume *) data; + char *repstr; + size_t len; + + len = strlen(lv->vg->cmd->dev_dir) + strlen(lv->vg->name) + strlen(lv->name) + 2; + if (!(repstr = dm_pool_zalloc(mem, len))) { + log_error("dm_pool_alloc failed"); + return 0; + } + + if (dm_snprintf(repstr, len, "%s%s/%s", lv->vg->cmd->dev_dir, lv->vg->name, lv->name) < 0) { + log_error("lvpath snprintf failed"); + return 0; + } + + dm_report_field_set_value(field, repstr, NULL); + + return 1; +} + static int _origin_disp(struct dm_report *rh, struct dm_pool *mem, struct dm_report_field *field, const void *data, void *private) diff --git a/man/lvs.8.in b/man/lvs.8.in index 1c4bcc43e..baa14ab49 100644 --- a/man/lvs.8.in +++ b/man/lvs.8.in @@ -55,7 +55,7 @@ to select all logical volume segment columns. Use \fb-o help\fP to view the full list of columns available. .IP Column names include: -lv_uuid, lv_name, lv_attr, lv_major, lv_minor, lv_read_ahead, lv_kernel_major, +lv_uuid, lv_name, lv_path, lv_attr, lv_major, lv_minor, lv_read_ahead, lv_kernel_major, lv_kernel_minor, lv_kernel_read_ahead, lv_size, seg_count, origin, origin_size, snap_percent, copy_percent, move_pv, convert_lv, lv_tags, mirror_log, modules, segtype, stripes, stripesize, regionsize, chunksize, seg_start, seg_start_pe,