mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-30 17:18:21 +03:00
device_mapper: empty string for missing uuid
Constify name & uuid within dm_active_device. Set uuid to "" for case the DM device has no uuid. Do not store "empty" device uuid in radix tree.
This commit is contained in:
parent
57e6e94a83
commit
336cb32884
@ -176,10 +176,10 @@ struct dm_names {
|
||||
struct dm_active_device {
|
||||
struct dm_list list;
|
||||
dev_t devno;
|
||||
char *name; /* device name */
|
||||
const char *name; /* device name */
|
||||
|
||||
uint32_t event_nr; /* valid when DM_DEVICE_LIST_HAS_EVENT_NR is set */
|
||||
char *uuid; /* valid uuid when DM_DEVICE_LIST_HAS_UUID is set */
|
||||
const char *uuid; /* valid uuid when DM_DEVICE_LIST_HAS_UUID is set */
|
||||
};
|
||||
|
||||
struct dm_versions {
|
||||
|
@ -828,12 +828,12 @@ int dm_task_get_device_list(struct dm_task *dmt, struct dm_list **devs_list,
|
||||
names = (struct dm_names *)((char *) names + next);
|
||||
|
||||
dm_dev->devno = (dev_t) names->dev;
|
||||
dm_dev->name = (char*)(dm_dev + 1);
|
||||
dm_dev->name = (const char *)(dm_dev + 1);
|
||||
dm_dev->event_nr = 0;
|
||||
dm_dev->uuid = NULL;
|
||||
dm_dev->uuid = "";
|
||||
|
||||
len = strlen(names->name) + 1;
|
||||
memcpy(dm_dev->name, names->name, len);
|
||||
memcpy((char*)dm_dev->name, names->name, len);
|
||||
|
||||
dm_new_dev = _align_ptr((char*)(dm_dev + 1) + len);
|
||||
if (_check_has_event_nr()) {
|
||||
@ -845,10 +845,10 @@ int dm_task_get_device_list(struct dm_task *dmt, struct dm_list **devs_list,
|
||||
if ((event_nr[1] & DM_NAME_LIST_FLAG_HAS_UUID)) {
|
||||
*devs_features |= DM_DEVICE_LIST_HAS_UUID;
|
||||
uuid_ptr = _align_ptr(event_nr + 2);
|
||||
dm_dev->uuid = (char*) dm_new_dev;
|
||||
len = strlen(uuid_ptr) + 1;
|
||||
memcpy(dm_new_dev, uuid_ptr, len);
|
||||
dm_dev->uuid = (const char *) dm_new_dev;
|
||||
dm_new_dev = _align_ptr((char*)dm_new_dev + len);
|
||||
memcpy(dm_dev->uuid, uuid_ptr, len);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1364,7 +1364,8 @@ int dev_cache_update_dm_devs(struct cmd_context *cmd)
|
||||
if (!radix_tree_insert_ptr(_cache.dm_devnos, &d, sizeof(d), dm_dev))
|
||||
return_0;
|
||||
|
||||
if (!radix_tree_insert_ptr(_cache.dm_uuids, dm_dev->uuid, strlen(dm_dev->uuid), dm_dev))
|
||||
if (dm_dev->uuid[0] &&
|
||||
!radix_tree_insert_ptr(_cache.dm_uuids, dm_dev->uuid, strlen(dm_dev->uuid), dm_dev))
|
||||
return_0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user