]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
zramctl: cannonicalize devname when no fullpath specified
authorKarel Zak <kzak@redhat.com>
Mon, 11 Aug 2014 12:39:46 +0000 (14:39 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 11 Aug 2014 12:39:46 +0000 (14:39 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/zramctl.c

index a8d0bbdd701f2ce925e703e7bbb7dd254b277d36..63c2c131ae63b1628f66781ce860d87b7b2d23e0 100644 (file)
@@ -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;