]> sourceware.org Git - lvm2.git/commitdiff
libdm: introduce and use DEV_UUID macro
authorPeter Rajnoha <prajnoha@redhat.com>
Wed, 10 Oct 2012 15:02:19 +0000 (17:02 +0200)
committerPeter Rajnoha <prajnoha@redhat.com>
Wed, 10 Oct 2012 15:16:15 +0000 (17:16 +0200)
To automatically prefer mangled UUID over unmangled UUID. The same
logic that is already used for dm name mangling...

libdm/ioctl/libdm-iface.c
libdm/libdm-common.h

index ac3442e3b9fa726cb9028fea2e6eb9894c1466bd..3b6731d2d12a7a91cce9c2b232cec5888b649072 100644 (file)
@@ -1083,7 +1083,7 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
        }
 
        /* Does driver support device number referencing? */
-       if (_dm_version_minor < 3 && !DEV_NAME(dmt) && !dmt->uuid && dmi->dev) {
+       if (_dm_version_minor < 3 && !DEV_NAME(dmt) && !DEV_UUID(dmt) && dmi->dev) {
                if (!_lookup_dev_name(dmi->dev, dmi->name, sizeof(dmi->name))) {
                        log_error("Unable to find name for device (%" PRIu32
                                  ":%" PRIu32 ")", dmt->major, dmt->minor);
@@ -1099,8 +1099,8 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
                              dmt->major < 0))
                strncpy(dmi->name, DEV_NAME(dmt), sizeof(dmi->name));
 
-       if (dmt->uuid)
-               strncpy(dmi->uuid, dmt->uuid, sizeof(dmi->uuid));
+       if (DEV_UUID(dmt))
+               strncpy(dmi->uuid, DEV_UUID(dmt), sizeof(dmi->uuid));
 
        if (dmt->type == DM_DEVICE_SUSPEND)
                dmi->flags |= DM_SUSPEND_FLAG;
@@ -1510,7 +1510,7 @@ static int _check_children_not_suspended_v4(struct dm_task *dmt, uint64_t device
                else
                        log_error(INTERNAL_ERROR "Attempt to suspend device %s%s%s%.0d%s%.0d%s%s"
                                  "that uses already-suspended device (%u:%u)", 
-                                 DEV_NAME(dmt) ? : "", dmt->uuid ? : "",
+                                 DEV_NAME(dmt) ? : "", DEV_UUID(dmt) ? : "",
                                  dmt->major > 0 ? "(" : "",
                                  dmt->major > 0 ? dmt->major : 0,
                                  dmt->major > 0 ? ":" : "",
@@ -1792,6 +1792,7 @@ int dm_task_run(struct dm_task *dmt)
        unsigned ioctl_retry = 1;
        int retryable = 0;
        const char *dev_name = DEV_NAME(dmt);
+       const char *dev_uuid = DEV_UUID(dmt);
 
        if ((unsigned) dmt->type >=
            (sizeof(_cmd_data_v4) / sizeof(*_cmd_data_v4))) {
@@ -1807,7 +1808,7 @@ int dm_task_run(struct dm_task *dmt)
                return _create_and_load_v4(dmt);
 
        if (dmt->type == DM_DEVICE_MKNODES && !dev_name &&
-           !dmt->uuid && dmt->major <= 0)
+           !dev_uuid && dmt->major <= 0)
                return _mknodes_v4(dmt);
 
        if ((dmt->type == DM_DEVICE_RELOAD) && dmt->suppress_identical_reload)
@@ -1828,8 +1829,8 @@ int dm_task_run(struct dm_task *dmt)
                          "%s%s%s %s%.0d%s%.0d%s%s",
                          suspended_counter,
                          dev_name ? : "",
-                         dmt->uuid ? " UUID " : "",
-                         dmt->uuid ? : "",
+                         dev_uuid ? " UUID " : "",
+                         dev_uuid ? : "",
                          dmt->major > 0 ? "(" : "",
                          dmt->major > 0 ? dmt->major : 0,
                          dmt->major > 0 ? ":" : "",
index 75ee60ef2510919f8c1814a8f5212a563af855dd..4705a77ccb817a046c8b0ddb2c1c9d30e3958f70 100644 (file)
@@ -21,6 +21,7 @@
 #define DM_DEFAULT_NAME_MANGLING_MODE_ENV_VAR_NAME "DM_DEFAULT_NAME_MANGLING_MODE"
 
 #define DEV_NAME(dmt) (dmt->mangled_dev_name ? : dmt->dev_name)
+#define DEV_UUID(DMT) (dmt->mangled_uuid ? : dmt->uuid)
 
 int mangle_string(const char *str, const char *str_name, size_t len,
                  char *buf, size_t buf_len, dm_string_mangling_t mode);
This page took 0.044357 seconds and 5 git commands to generate.