[PATCH 6/7] zramctl: fix mount point printout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



See sample belo how a device mount point was printed without and with
full <device> path.  This change adds the mount point markup to the short
device name printout.

$ zramctl zram3
NAME  ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
zram3 lz4             1M   4K   62B    4K       1

$ zramctl /dev/zram3
NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram3 lz4             1M   4K   62B    4K       1 [SWAP]

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 sys-utils/zramctl.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c
index 9c5b6ed..afbc0e8 100644
--- a/sys-utils/zramctl.c
+++ b/sys-utils/zramctl.c
@@ -294,7 +294,15 @@ static int fill_table_row(struct libscols_table *tb, struct zram *z)
 			char path[PATH_MAX] = { '\0' };
 			int fl;
 
-			check_mount_point(z->devname, &fl, path, sizeof(path));
+			if (!access(z->devname, F_OK))
+				check_mount_point(z->devname, &fl, path, sizeof(path));
+			else {
+				char *zdevpath;
+
+				xasprintf(&zdevpath, "/dev/%s", z->devname);
+				check_mount_point(zdevpath, &fl, path, sizeof(path));
+				free(zdevpath);
+			}
 			if (*path)
 				str = xstrdup(path);
 			break;
-- 
2.0.3

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux