zramctl: cannonicalize devname when no fullpath specified

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2014-08-11 14:39:46 +02:00
parent 929c7b2817
commit 342436c66a
1 changed files with 6 additions and 0 deletions

View 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;