Skip to contentSkip to conversation

master - report: Add lv_dm_path and lv_full_name fields.

PATCH Alasdair Kergon 1 participant 1 message Jul 2, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=64ce3a8066ead3bc2ee16e9cc286d68057bbe956
Commit:        64ce3a8066ead3bc2ee16e9cc286d68057bbe956
Parent:        5bfa2ec21d79b090276676076917808207ad4dd1
Author:        Alasdair G Kergon <[email protected]>
AuthorDate:    Wed Jul 2 17:24:05 2014 +0100
Committer:     Alasdair G Kergon <[email protected]>
CommitterDate: Wed Jul 2 17:24:05 2014 +0100

report: Add lv_dm_path and lv_full_name fields.

---
 WHATS_NEW               |    1 +
 lib/display/display.c   |    7 ++-----
 lib/metadata/lv.c       |   45 +++++++++++++++++++++++++++++++++++++++++++--
 lib/metadata/lv.h       |    2 ++
 lib/report/columns.h    |    4 +++-
 lib/report/properties.c |    4 ++++
 lib/report/report.c     |   26 ++++++++++++++++++++++++++
 7 files changed, 81 insertions(+), 8 deletions(-)
WHATS_NEW +1 -0
index c55b3fb..625d58f 100644
@@ -1,5 +1,6 @@
 Version 2.02.108 -
 =================================
+  Add lv_full_name and lv_dm_path fields to reports.
   Change lv_path field to suppress devices that never appear in /dev/vg.
   Postpone thin pool lvconvert prompts (2.02.107).
   Require --yes option to skip prompt to lvconvert thin pool chunksize.
lib/display/display.c +2 -5
index fd785ed..cd204a0 100644
@@ -95,11 +95,8 @@ const char *get_percent_string(percent_type_t def)
 
 const char *display_lvname(const struct logical_volume *lv)
 {
-	char buf[NAME_LEN * 2 + 2];
-
-	(void) snprintf(buf, sizeof(buf), "%s/%s", lv->vg->name, lv->name);
-
-	return dm_pool_strdup(lv->vg->cmd->mem, buf) ? : lv->name; /* at least LV name... */
+	/* On allocation failure, just return the LV name. */
+	return lv_fullname_dup(lv->vg->cmd->mem, lv) ? : lv->name;
 }
 
 #define BASE_UNKNOWN 0
lib/metadata/lv.c +43 -2

62 lines not on this page · raw message

lib/metadata/lv.h +2 -0
index 51920b0..86db501 100644
@@ -60,6 +60,7 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv);
 char *lv_uuid_dup(const struct logical_volume *lv);
 char *lv_tags_dup(const struct logical_volume *lv);
 char *lv_path_dup(struct dm_pool *mem, const struct logical_volume *lv);
+char *lv_dmpath_dup(struct dm_pool *mem, const struct logical_volume *lv);
 uint64_t lv_origin_size(const struct logical_volume *lv);
 char *lv_move_pv_dup(struct dm_pool *mem, const struct logical_volume *lv);
 char *lv_convert_lv_dup(struct dm_pool *mem, const struct logical_volume *lv);
@@ -71,6 +72,7 @@ char *lv_metadata_lv_dup(struct dm_pool *mem, const struct logical_volume *lv);
 char *lv_pool_lv_dup(struct dm_pool *mem, const struct logical_volume *lv);
 char *lv_modules_dup(struct dm_pool *mem, const struct logical_volume *lv);
 char *lv_name_dup(struct dm_pool *mem, const struct logical_volume *lv);
+char *lv_fullname_dup(struct dm_pool *mem, const struct logical_volume *lv);
 char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
 uint32_t lv_kernel_read_ahead(const struct logical_volume *lv);
 uint64_t lvseg_start(const struct lv_segment *seg);
lib/report/columns.h +3 -1
index 70a3b65..418e67a 100644
@@ -30,7 +30,9 @@
 /* *INDENT-OFF* */
 FIELD(LVS, lv, STR, "LV UUID", lvid.id[1], 38, uuid, lv_uuid, "Unique identifier.", 0)
 FIELD(LVS, lv, STR, "LV", lvid, 4, lvname, lv_name, "Name.  LVs created for internal use are enclosed in brackets.", 0)
-FIELD(LVS, lv, STR, "Path", lvid, 4, lvpath, lv_path, "Full pathname for LV.", 0)
+FIELD(LVS, lv, STR, "LV", lvid, 4, lvfullname, lv_full_name, "Full name of LV including its VG, namely VG/LV.", 0)
+FIELD(LVS, lv, STR, "Path", lvid, 4, lvpath, lv_path, "Full pathname for LV. Blank for internal LVs.", 0)
+FIELD(LVS, lv, STR, "DMPath", lvid, 6, lvdmpath, lv_dm_path, "Internal device-mapper pathname for LV (in /dev/mapper directory).", 0)
 FIELD(LVS, lv, STR, "Attr", lvid, 4, lvstatus, lv_attr, "Various attributes - see man page.", 0)
 FIELD(LVS, lv, STR, "Active", lvid, 6, lvactive, lv_active, "Active state of the LV.", 0)
 FIELD(LVS, lv, NUM, "Maj", major, 3, int32, lv_major, "Persistent major number or -1 if not persistent.", 0)
lib/report/properties.c +4 -0
index ce3ed53..9692de8 100644
@@ -164,8 +164,12 @@ GET_LV_STR_PROPERTY_FN(lv_uuid, lv_uuid_dup(lv))
 #define _lv_uuid_set prop_not_implemented_set
 GET_LV_STR_PROPERTY_FN(lv_name, lv_name_dup(lv->vg->vgmem, lv))
 #define _lv_name_set prop_not_implemented_set
+GET_LV_STR_PROPERTY_FN(lv_full_name, lv_fullname_dup(lv->vg->vgmem, lv))
+#define _lv_full_name_set prop_not_implemented_set
 GET_LV_STR_PROPERTY_FN(lv_path, lv_path_dup(lv->vg->vgmem, lv))
 #define _lv_path_set prop_not_implemented_set
+GET_LV_STR_PROPERTY_FN(lv_dm_path, lv_dmpath_dup(lv->vg->vgmem, lv))
+#define _lv_dm_path_set prop_not_implemented_set
 GET_LV_STR_PROPERTY_FN(lv_attr, lv_attr_dup(lv->vg->vgmem, lv))
 #define _lv_attr_set prop_not_implemented_set
 GET_LV_NUM_PROPERTY_FN(lv_major, lv->major)
lib/report/report.c +26 -0
index 34b7b07..fca1133 100644
@@ -311,6 +311,19 @@ static int _lvname_disp(struct dm_report *rh, struct dm_pool *mem,
 	return _field_set_value(field, repstr, lvname);
 }
 
+static int _lvfullname_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;
+
+	if (!(repstr = lv_fullname_dup(mem, lv)))
+		return_0;
+
+	return _field_set_value(field, repstr, NULL);
+}
+
 static int _datalv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
 			struct dm_report_field *field,
 			const void *data, void *private __attribute__((unused)))
@@ -364,6 +377,19 @@ static int _lvpath_disp(struct dm_report *rh, struct dm_pool *mem,
 	return _field_set_value(field, repstr, NULL);
 }
 
+static int _lvdmpath_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;
+
+	if (!(repstr = lv_dmpath_dup(mem, lv)))
+		return_0;
+
+	return _field_set_value(field, repstr, NULL);
+}
+
 static int _origin_disp(struct dm_report *rh, struct dm_pool *mem,
 			struct dm_report_field *field,
 			const void *data, void *private)