diff options
author | David Teigland <teigland@redhat.com> | 2022-06-06 14:04:20 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2022-06-09 14:33:30 -0500 |
commit | e36b180a6983c4fa07d6714a0bf81e6935487359 (patch) | |
tree | 4e92ee6af7217a0185c4c7be9edfc72f0f4adeb6 /lib/device/dev-cache.c | |
parent | 7cb63b05dad453d015bbe462b799fb031dd6952c (diff) | |
download | lvm2-e36b180a6983c4fa07d6714a0bf81e6935487359.tar.gz |
filter-mpath: get wwids from sysfs vpd_pg83
to compare with wwids in /etc/multipath/wwids when
excluding multipath components. The wwid printed
from the sysfs wwid file may not be the wwid used
in multipath wwids. Save the wwids found for each
device on dev->wwids to avoid repeating reading
and parsing the sysfs files.
Diffstat (limited to 'lib/device/dev-cache.c')
-rw-r--r-- | lib/device/dev-cache.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index 0eb2568b5..65e1cb138 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -80,6 +80,7 @@ static void _dev_init(struct device *dev) dm_list_init(&dev->aliases); dm_list_init(&dev->ids); + dm_list_init(&dev->wwids); } void dev_destroy_file(struct device *dev) @@ -383,6 +384,22 @@ out: return 1; } +int get_sysfs_binary(const char *path, char *buf, size_t buf_size, int *retlen) +{ + int ret; + int fd; + + fd = open(path, O_RDONLY); + if (fd < 0) + return 0; + ret = read(fd, buf, buf_size); + close(fd); + if (ret <= 0) + return 0; + *retlen = ret; + return 1; +} + int get_sysfs_value(const char *path, char *buf, size_t buf_size, int error_if_no_value) { FILE *fp; @@ -1336,6 +1353,7 @@ int dev_cache_exit(void) dm_hash_iterate(n, _cache.names) { dev = (struct device *) dm_hash_get_data(_cache.names, n); free_dids(&dev->ids); + free_wwids(&dev->wwids); } } |