]> sourceware.org Git - dm.git/commitdiff
Additional LVM- prefix matching for transitional period.
authorAlasdair Kergon <agk@redhat.com>
Sat, 12 Nov 2005 22:46:48 +0000 (22:46 +0000)
committerAlasdair Kergon <agk@redhat.com>
Sat, 12 Nov 2005 22:46:48 +0000 (22:46 +0000)
WHATS_NEW
lib/libdm-deptree.c

index 4add3345d616852e96a0e4aff53dbdd6383e7d2e..3de28a71f0578d4b99fa022b323a455337c57ab2 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 1.02.01 - 
 =============================
+  Additional LVM- prefix matching for transitional period.
 
 Version 1.02.00 - 10 Nov 2005
 =============================
index 34d41bbf027719552c1d25eeb57a3324a12bdc05..30a1e6d4a6867db4ad138333a956080ddad8a30e 100644 (file)
@@ -25,6 +25,9 @@
 
 #define MAX_TARGET_PARAMSIZE 500000
 
+/* FIXME Fix interface so this is used only by LVM */
+#define UUID_PREFIX "LVM-"
+
 /* Supported segment types */
 enum {
        SEG_ERROR, 
@@ -348,8 +351,15 @@ static struct dm_tree_node *_find_dm_tree_node(struct dm_tree *dtree,
 static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
                                                       const char *uuid)
 {
-       /* FIXME Do we need to cope with missing LVM- prefix too? */
-       return dm_hash_lookup(dtree->uuids, uuid);
+       struct dm_tree_node *node;
+
+       if ((node = dm_hash_lookup(dtree->uuids, uuid)))
+               return node;
+
+       if (strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1))
+               return NULL;
+
+       return dm_hash_lookup(dtree->uuids, uuid + sizeof(UUID_PREFIX) - 1);
 }
 
 static int _deps(struct dm_task **dmt, struct dm_pool *mem, uint32_t major, uint32_t minor,
@@ -653,13 +663,13 @@ static int _uuid_prefix_matches(const char *uuid, const char *uuid_prefix, size_
        if (uuid_prefix_len <= 4)
                return 0;
 
-       if (!strncmp(uuid, "LVM-", 4))
+       if (!strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1))
                return 0;
 
-       if (strncmp(uuid_prefix, "LVM-", 4))
+       if (strncmp(uuid_prefix, UUID_PREFIX, sizeof(UUID_PREFIX) - 1))
                return 0;
 
-       if (!strncmp(uuid, uuid_prefix + 4, uuid_prefix_len - 4))
+       if (!strncmp(uuid, uuid_prefix + sizeof(UUID_PREFIX) - 1, uuid_prefix_len - (sizeof(UUID_PREFIX) - 1)))
                return 1;
 
        return 0;
@@ -1026,7 +1036,7 @@ int dm_tree_suspend_children(struct dm_tree_node *dnode,
                }
 
                /* Ignore if it doesn't belong to this VG */
-               if (uuid_prefix && strncmp(uuid, uuid_prefix, uuid_prefix_len))
+               if (!_uuid_prefix_matches(uuid, uuid_prefix, uuid_prefix_len))
                        continue;
 
                if (dm_tree_node_num_children(child, 0))
@@ -1371,8 +1381,8 @@ int dm_tree_preload_children(struct dm_tree_node *dnode,
                        continue;
 
                /* Ignore if it doesn't belong to this VG */
-               if (uuid_prefix && child->info.exists &&
-                   strncmp(child->uuid, uuid_prefix, uuid_prefix_len))
+               if (child->info.exists &&
+                   !_uuid_prefix_matches(child->uuid, uuid_prefix, uuid_prefix_len))
                        continue;
 
                if (dm_tree_node_num_children(child, 0))
@@ -1435,7 +1445,7 @@ int dm_tree_children_use_uuid(struct dm_tree_node *dnode,
                        return 1;
                }
 
-               if (!strncmp(uuid, uuid_prefix, uuid_prefix_len))
+               if (_uuid_prefix_matches(uuid, uuid_prefix, uuid_prefix_len))
                        return 1;
 
                if (dm_tree_node_num_children(child, 0))
This page took 0.027735 seconds and 5 git commands to generate.