]> sourceware.org Git - lvm2.git/commitdiff
Refactor and add code for (lv) 'lv_path' get function.
authorDave Wysochanski <dwysocha@redhat.com>
Tue, 12 Oct 2010 16:11:34 +0000 (16:11 +0000)
committerDave Wysochanski <dwysocha@redhat.com>
Tue, 12 Oct 2010 16:11:34 +0000 (16:11 +0000)
lib/metadata/lv.c
lib/metadata/lv.h
lib/report/properties.c
lib/report/report.c

index add0a4d48cd6365f01472b3e1699b5340723d1f9..d63ce29570a787c58ae6cc2458164c2ba2b5e4a5 100644 (file)
 #include "lib.h"
 #include "metadata.h"
 #include "activate.h"
+#include "toolcontext.h"
+
+char *lv_path_dup(struct dm_pool *mem, const struct logical_volume *lv)
+{
+       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;
+       }
+       return repstr;
+}
 
 char *lv_uuid_dup(const struct logical_volume *lv)
 {
index 54ed7e094efb1973c16c32f35cfcee8c6ca515ee..eee281150a99c9598447a13eb1dae682217f9d96 100644 (file)
@@ -52,5 +52,6 @@ uint64_t lv_size(const struct logical_volume *lv);
 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);
 
 #endif
index eec4c61c30f971f9a782a9b4ee90956e68e4cffc..8890e273e870d54e4908759b01b081d790bb5249 100644 (file)
@@ -101,7 +101,7 @@ GET_LV_STR_PROPERTY_FN(lv_uuid, lv_uuid_dup(lv))
 #define _lv_uuid_set _not_implemented_set
 #define _lv_name_get _not_implemented_get
 #define _lv_name_set _not_implemented_set
-#define _lv_path_get _not_implemented_get
+GET_LV_STR_PROPERTY_FN(lv_path, lv_path_dup(lv->vg->vgmem, lv))
 #define _lv_path_set _not_implemented_set
 GET_LV_STR_PROPERTY_FN(lv_attr, lv_attr_dup(lv->vg->vgmem, lv))
 #define _lv_attr_set _not_implemented_set
index 95f4550d2950f3d6c8d507540a6a6d7866d028df..32559b8986750088a62743ea97fa580ac9ea6e94 100644 (file)
@@ -350,18 +350,9 @@ static int _lvpath_disp(struct dm_report *rh, struct dm_pool *mem,
 {
        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");
+       if (!(repstr = lv_path_dup(mem, lv)))
                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);
 
This page took 0.041315 seconds and 5 git commands to generate.