mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
dev-cache: also add dev name for device found in sysfs only
For the case when we print device name associated with struct device that was not found in /dev, but in sysfs, for example when printing devices where LV device mismatch is found.
This commit is contained in:
parent
91d32f9d1b
commit
7ed5a65ee5
@ -433,11 +433,29 @@ static struct dm_list *_get_or_add_list_by_index_key(struct dm_hash_table *idx,
|
|||||||
|
|
||||||
static struct device *_insert_sysfs_dev(dev_t devno, const char *devname)
|
static struct device *_insert_sysfs_dev(dev_t devno, const char *devname)
|
||||||
{
|
{
|
||||||
|
char path[PATH_MAX];
|
||||||
|
char *path_copy;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
||||||
|
if (dm_snprintf(path, sizeof(path), "%s%s", _cache.dev_dir, devname) < 0) {
|
||||||
|
log_error("_insert_sysfs_dev: %s: dm_snprintf failed", devname);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(dev = _dev_create(devno)))
|
if (!(dev = _dev_create(devno)))
|
||||||
return_NULL;
|
return_NULL;
|
||||||
|
|
||||||
|
if (!(path_copy = dm_pool_strdup(_cache.mem, path))) {
|
||||||
|
log_error("_insert_sysfs_dev: %s: dm_pool_strdup failed", devname);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_add_alias(dev, path_copy)) {
|
||||||
|
log_error("Couldn't add alias to dev cache.");
|
||||||
|
_free(dev);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!btree_insert(_cache.sysfs_only_devices, (uint32_t) devno, dev)) {
|
if (!btree_insert(_cache.sysfs_only_devices, (uint32_t) devno, dev)) {
|
||||||
log_error("Couldn't add device to binary tree of sysfs-only devices in dev cache.");
|
log_error("Couldn't add device to binary tree of sysfs-only devices in dev cache.");
|
||||||
_free(dev);
|
_free(dev);
|
||||||
|
Loading…
Reference in New Issue
Block a user