diff --git a/lib/device/dev-mpath.c b/lib/device/dev-mpath.c index 27b0f41a6..2040edac3 100644 --- a/lib/device/dev-mpath.c +++ b/lib/device/dev-mpath.c @@ -815,7 +815,7 @@ const char *dev_mpath_component_wwid(struct cmd_context *cmd, struct device *dev /* /sys/dev/block/253:7/slaves/sda/device/wwid */ - if (dm_snprintf(slaves_path, sizeof(slaves_path), "%s/dev/block/%d:%d/slaves", + if (dm_snprintf(slaves_path, sizeof(slaves_path), "%sdev/block/%d:%d/slaves", dm_sysfs_dir(), (int)MAJOR(dev->dev), (int)MINOR(dev->dev)) < 0) { log_warn("Sysfs path to check mpath components is too long."); return NULL; @@ -845,7 +845,7 @@ const char *dev_mpath_component_wwid(struct cmd_context *cmd, struct device *dev /* read /sys/block/sda/device/wwid */ - if (dm_snprintf(wwid_path, sizeof(wwid_path), "%s/block/%s/device/wwid", + if (dm_snprintf(wwid_path, sizeof(wwid_path), "%sblock/%s/device/wwid", dm_sysfs_dir(), slave_name) < 0) { log_warn("Failed to create sysfs wwid path for %s", slave_name); continue; diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c index 939eb4aeb..1dc895b54 100644 --- a/lib/device/dev-type.c +++ b/lib/device/dev-type.c @@ -548,7 +548,7 @@ static int _has_sys_partition(struct device *dev) int minor = (int) MINOR(dev->dev); /* check if dev is a partition */ - if (dm_snprintf(path, sizeof(path), "%s/dev/block/%d:%d/partition", + if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d/partition", dm_sysfs_dir(), major, minor) < 0) { log_warn("WARNING: %s: partition path is too long.", dev_name(dev)); return 0; @@ -775,7 +775,7 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result) * - basename ../../block/md0/md0 = md0 * Parent's 'dev' sysfs attribute = /sys/block/md0/dev */ - if (dm_snprintf(path, sizeof(path), "%s/dev/block/%d:%d", + if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d", dm_sysfs_dir(), major, minor) < 0) { log_warn("WARNING: %s: major:minor sysfs path is too long.", dev_name(dev)); return 0; @@ -787,7 +787,7 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result) temp_path[size] = '\0'; - if (dm_snprintf(path, sizeof(path), "%s/block/%s/dev", + if (dm_snprintf(path, sizeof(path), "%sblock/%s/dev", dm_sysfs_dir(), basename(dirname(temp_path))) < 0) { log_warn("WARNING: sysfs path for %s is too long.", basename(dirname(temp_path))); @@ -1095,7 +1095,7 @@ int wipe_known_signatures(struct cmd_context *cmd, struct device *dev, static int _snprintf_attr(char *buf, size_t buf_size, const char *sysfs_dir, const char *attribute, dev_t dev) { - if (dm_snprintf(buf, buf_size, "%s/dev/block/%d:%d/%s", sysfs_dir, + if (dm_snprintf(buf, buf_size, "%sdev/block/%d:%d/%s", sysfs_dir, (int)MAJOR(dev), (int)MINOR(dev), attribute) < 0) { log_warn("WARNING: sysfs path for %s attribute is too long.", attribute); diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c index 0db401537..779883d03 100644 --- a/lib/metadata/vdo_manip.c +++ b/lib/metadata/vdo_manip.c @@ -148,7 +148,7 @@ static int _sysfs_get_kvdo_value(const char *dm_name, const struct dm_info *dmin char temp[64]; int fd, size, r = 0; - if (dm_snprintf(path, sizeof(path), "%s/block/dm-%d/vdo/%s", + if (dm_snprintf(path, sizeof(path), "%sblock/dm-%d/vdo/%s", dm_sysfs_dir(), dminfo->minor, vdo_param) < 0) { log_debug("Failed to build kvdo path."); return 0;