From: Karel Zak Date: Mon, 11 Aug 2014 12:39:46 +0000 (+0200) Subject: zramctl: cannonicalize devname when no fullpath specified X-Git-Tag: v2.26-rc1~537 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=342436c66a3321112262626e2207250be1d73872;p=thirdparty%2Futil-linux.git zramctl: cannonicalize devname when no fullpath specified Signed-off-by: Karel Zak --- diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c index a8d0bbdd70..63c2c131ae 100644 --- a/sys-utils/zramctl.c +++ b/sys-utils/zramctl.c @@ -158,6 +158,12 @@ static struct sysfs_cxt *zram_get_sysfs(struct zram *z) return NULL; if (sysfs_init(&z->sysfs, devno, NULL)) return NULL; + if (*z->devname != '/') { + /* cannonicalize the device name according to /sys */ + char name[PATH_MAX]; + if (sysfs_get_devname(&z->sysfs, name, sizeof(name))) + snprintf(z->devname, sizeof(z->devname), "/dev/%s", name); + } } return &z->sysfs;