diff options
author | Karel Zak | 2015-05-28 12:09:41 +0200 |
---|---|---|
committer | Karel Zak | 2015-05-28 12:09:41 +0200 |
commit | 6c62abc42bb1c2aad60d0da1ce3f7498ac48cd1b (patch) | |
tree | 54c6cbf4b0a972c7bf63ae2da33077ad7d9f307e /misc-utils/lsblk.c | |
parent | lib/sysfs: Fix /dev to /sys node name translation (diff) | |
download | kernel-qcow2-util-linux-6c62abc42bb1c2aad60d0da1ce3f7498ac48cd1b.tar.gz kernel-qcow2-util-linux-6c62abc42bb1c2aad60d0da1ce3f7498ac48cd1b.tar.xz kernel-qcow2-util-linux-6c62abc42bb1c2aad60d0da1ce3f7498ac48cd1b.zip |
lib/sysfs: rename devname functions, cleanup
Well, I don't have mental power to use function names like
sysfs_devname_to_dev_name()
so this patch renames to
sysfs_devname_sys_to_dev()
sysfs_devname_dev_to_sys()
It also cleanups usage of the functions. We have to be sure that
sysfs.c code returns regular devnames. The existence of the sysfs
devnames (with '!') should be completely hidden in sysfs specific
code.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/lsblk.c')
-rw-r--r-- | misc-utils/lsblk.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index d826c778f..c98e28a0e 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -421,7 +421,6 @@ static char *get_device_path(struct blkdev_cxt *cxt) return canonicalize_dm_name(cxt->name); snprintf(path, sizeof(path), "/dev/%s", cxt->name); - sysfs_devname_to_dev_name(path); return xstrdup(path); } @@ -1153,30 +1152,33 @@ static int set_cxt(struct blkdev_cxt *cxt, cxt->name = xstrdup(name); cxt->partition = wholedisk != NULL; + /* make sure that the name is usable in paths */ + sysfs_devname_sys_to_dev(cxt->name); + cxt->filename = get_device_path(cxt); if (!cxt->filename) { - warnx(_("%s: failed to get device path"), name); + warnx(_("%s: failed to get device path"), cxt->name); return -1; } DBG(CXT, ul_debugobj(cxt, "%s: filename=%s", cxt->name, cxt->filename)); - devno = sysfs_devname_to_devno(name, wholedisk ? wholedisk->name : NULL); + devno = sysfs_devname_to_devno(cxt->name, wholedisk ? wholedisk->name : NULL); if (!devno) { - warnx(_("%s: unknown device name"), name); + warnx(_("%s: unknown device name"), cxt->name); return -1; } if (lsblk->inverse) { if (sysfs_init(&cxt->sysfs, devno, wholedisk ? &wholedisk->sysfs : NULL)) { - warnx(_("%s: failed to initialize sysfs handler"), name); + warnx(_("%s: failed to initialize sysfs handler"), cxt->name); return -1; } if (parent) parent->sysfs.parent = &cxt->sysfs; } else { if (sysfs_init(&cxt->sysfs, devno, parent ? &parent->sysfs : NULL)) { - warnx(_("%s: failed to initialize sysfs handler"), name); + warnx(_("%s: failed to initialize sysfs handler"), cxt->name); return -1; } } @@ -1197,14 +1199,15 @@ static int set_cxt(struct blkdev_cxt *cxt, DBG(CXT, ul_debugobj(cxt, "zero size device -- ignore")); return -1; } - if (is_dm(name)) { + if (is_dm(cxt->name)) { cxt->dm_name = sysfs_strdup(&cxt->sysfs, "dm/name"); if (!cxt->dm_name) { - warnx(_("%s: failed to get dm name"), name); + warnx(_("%s: failed to get dm name"), cxt->name); return -1; } } + /* use "name" (sysfs-like name) here */ cxt->npartitions = sysfs_count_partitions(&cxt->sysfs, name); cxt->nholders = sysfs_count_dirents(&cxt->sysfs, "holders"); cxt->nslaves = sysfs_count_dirents(&cxt->sysfs, "slaves"); |