diff options
author | Milan Broz | 2011-07-05 23:29:30 +0200 |
---|---|---|
committer | Karel Zak | 2011-07-15 15:35:10 +0200 |
commit | 01e487c02085a2a4efbc8b1475cd22052e32de2d (patch) | |
tree | 9a8ff62f363ef749396cb7cfcf5b7b760e1007c5 /misc-utils/lsblk.c | |
parent | dmesg: fix typo in usage() (diff) | |
download | kernel-qcow2-util-linux-01e487c02085a2a4efbc8b1475cd22052e32de2d.tar.gz kernel-qcow2-util-linux-01e487c02085a2a4efbc8b1475cd22052e32de2d.tar.xz kernel-qcow2-util-linux-01e487c02085a2a4efbc8b1475cd22052e32de2d.zip |
lsblk: add state attribute
Add device state column. For normal disk it could be running or offline,
for device-mapper devices running or suspended.
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/lsblk.c')
-rw-r--r-- | misc-utils/lsblk.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index b6bc28b7d..259b77093 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -67,6 +67,7 @@ enum { COL_RM, COL_MODEL, COL_SIZE, + COL_STATE, COL_OWNER, COL_GROUP, COL_MODE, @@ -108,6 +109,7 @@ static struct colinfo infos[__NCOLUMNS] = { [COL_ROTA] = { "ROTA", 1, TT_FL_RIGHT, N_("rotational device") }, [COL_MODEL] = { "MODEL", 0.1, TT_FL_TRUNC, N_("device identifier") }, [COL_SIZE] = { "SIZE", 6, TT_FL_RIGHT, N_("size of the device") }, + [COL_STATE] = { "STATE", 7, TT_FL_TRUNC, N_("state of the device") }, [COL_OWNER] = { "OWNER", 0.1, TT_FL_TRUNC, N_("user name"), }, [COL_GROUP] = { "GROUP", 0.1, TT_FL_TRUNC, N_("group name") }, [COL_MODE] = { "MODE", 10, 0, N_("device node permissions") }, @@ -522,6 +524,17 @@ static void set_tt_data(struct blkdev_cxt *cxt, int col, int id, struct tt_line tt_line_set_data(ln, col, p); } break; + case COL_STATE: + if (!cxt->partition && !cxt->dm_name) { + p = sysfs_strdup(&cxt->sysfs, "device/state"); + } else if (cxt->dm_name) { + int x = 0; + if (sysfs_read_int(&cxt->sysfs, "dm/suspended", &x) == 0) + p = x ? xstrdup("suspended") : xstrdup("running"); + } + if (p) + tt_line_set_data(ln, col, p); + break; case COL_ALIOFF: p = sysfs_strdup(&cxt->sysfs, "alignment_offset"); if (p) |