diff --git a/device_mapper/all.h b/device_mapper/all.h index cdd3b4a77..2bea150af 100644 --- a/device_mapper/all.h +++ b/device_mapper/all.h @@ -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 { diff --git a/device_mapper/ioctl/libdm-iface.c b/device_mapper/ioctl/libdm-iface.c index b240669c3..336749b47 100644 --- a/device_mapper/ioctl/libdm-iface.c +++ b/device_mapper/ioctl/libdm-iface.c @@ -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); } } diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index 189094464..7e6d59191 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -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; }