util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Milan Broz <mbroz@redhat.com>
To: util-linux@vger.kernel.org
Cc: Milan Broz <mbroz@redhat.com>
Subject: [PATCH 1/3] lsblk: add parent kernel name column
Date: Fri, 19 Oct 2012 14:10:39 +0200	[thread overview]
Message-ID: <1350648641-19388-1-git-send-email-mbroz@redhat.com> (raw)

For raw output used in scripts it is sometimes necessary
to reconstruct tree of devices.

Parent kernel name (PKNAME) provides needed information
to do that easily.

Signed-off-by: Milan Broz <mbroz@redhat.com>
---
 misc-utils/lsblk.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 26dfaf9..1118e7e 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -97,6 +97,7 @@ enum {
 	COL_DZERO,
 	COL_WWN,
 	COL_RAND,
+	COL_PKNAME,
 };
 
 /* column names */
@@ -111,6 +112,7 @@ struct colinfo {
 static struct colinfo infos[] = {
 	[COL_NAME]   = { "NAME",    0.25, TT_FL_TREE | TT_FL_NOEXTREMES, N_("device name") },
 	[COL_KNAME]  = { "KNAME",   0.3, 0, N_("internal kernel device name") },
+	[COL_PKNAME] = { "PKNAME",   0.3, 0, N_("internal parent kernel device name") },
 	[COL_MAJMIN] = { "MAJ:MIN", 6, 0, N_("major:minor device number") },
 	[COL_FSTYPE] = { "FSTYPE",  0.1, TT_FL_TRUNC, N_("filesystem type") },
 	[COL_TARGET] = { "MOUNTPOINT", 0.10, TT_FL_TRUNC, N_("where the device is mounted") },
@@ -144,7 +146,6 @@ static struct colinfo infos[] = {
 	[COL_DMAX]   = { "DISC-MAX", 6, TT_FL_RIGHT, N_("discard max bytes") },
 	[COL_DZERO]  = { "DISC-ZERO", 1, TT_FL_RIGHT, N_("discard zeroes data") },
 	[COL_WWN]    = { "WWN",     18, 0, N_("unique storage identifier") },
-
 };
 
 struct lsblk {
@@ -600,6 +601,10 @@ static void set_tt_data(struct blkdev_cxt *cxt, int col, int id, struct tt_line
 	case COL_KNAME:
 		tt_line_set_data(ln, col, xstrdup(cxt->name));
 		break;
+	case COL_PKNAME:
+		if (cxt->parent)
+			tt_line_set_data(ln, col, xstrdup(cxt->parent->name));
+		break;
 	case COL_OWNER:
 	{
 		struct passwd *pw = st_rc ? NULL : getpwuid(cxt->st.st_uid);
-- 
1.7.10.4


             reply	other threads:[~2012-10-19 12:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-19 12:10 Milan Broz [this message]
2012-10-19 12:10 ` [PATCH 2/3] lsblk: add SCSI H:C:T:L attribute Milan Broz
2012-10-19 12:10 ` [PATCH 3/3] lsblk: add SCSI transport type attribute Milan Broz
2012-10-23 12:10 ` [PATCH 1/3] lsblk: add parent kernel name column Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1350648641-19388-1-git-send-email-mbroz@redhat.com \
    --to=mbroz@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).