* [PATCH 1/3] lsblk: Add revision column
@ 2012-11-02 17:56 Milan Broz
2012-11-02 17:56 ` [PATCH 2/3] lsblk: Add vendor column Milan Broz
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Milan Broz @ 2012-11-02 17:56 UTC (permalink / raw)
To: util-linux; +Cc: Milan Broz
Signed-off-by: Milan Broz <mbroz@redhat.com>
---
misc-utils/lsblk.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index c57e78f..671d912 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -100,6 +100,7 @@ enum {
COL_PKNAME,
COL_HCTL,
COL_TRANSPORT,
+ COL_REV,
};
/* column names */
@@ -150,6 +151,7 @@ static struct colinfo infos[] = {
[COL_WWN] = { "WWN", 18, 0, N_("unique storage identifier") },
[COL_HCTL] = { "HCTL", 10, 0, N_("Host:Channel:Target:Lun for SCSI") },
[COL_TRANSPORT] = { "TRAN", 6, 0, N_("device transport type") },
+ [COL_REV] = { "REV", 4, TT_FL_RIGHT, N_("device revision") },
};
struct lsblk {
@@ -766,6 +768,13 @@ 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_REV:
+ if (!cxt->partition && cxt->nslaves == 0) {
+ p = sysfs_strdup(&cxt->sysfs, "device/rev");
+ if (p)
+ tt_line_set_data(ln, col, p);
+ }
+ break;
case COL_SIZE:
if (cxt->size) {
if (lsblk->bytes) {
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] lsblk: Add vendor column
2012-11-02 17:56 [PATCH 1/3] lsblk: Add revision column Milan Broz
@ 2012-11-02 17:56 ` Milan Broz
2012-11-02 17:56 ` [PATCH 3/3] lsblk: Add --scsi switch Milan Broz
2012-11-07 16:43 ` [PATCH 1/3] lsblk: Add revision column Karel Zak
2 siblings, 0 replies; 4+ messages in thread
From: Milan Broz @ 2012-11-02 17:56 UTC (permalink / raw)
To: util-linux; +Cc: Milan Broz
Signed-off-by: Milan Broz <mbroz@redhat.com>
---
misc-utils/lsblk.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 671d912..f8bc6ea 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -101,6 +101,7 @@ enum {
COL_HCTL,
COL_TRANSPORT,
COL_REV,
+ COL_VENDOR,
};
/* column names */
@@ -152,6 +153,7 @@ static struct colinfo infos[] = {
[COL_HCTL] = { "HCTL", 10, 0, N_("Host:Channel:Target:Lun for SCSI") },
[COL_TRANSPORT] = { "TRAN", 6, 0, N_("device transport type") },
[COL_REV] = { "REV", 4, TT_FL_RIGHT, N_("device revision") },
+ [COL_VENDOR] = { "VENDOR", 0.1, TT_FL_TRUNC, N_("device vendor") },
};
struct lsblk {
@@ -775,6 +777,13 @@ 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_VENDOR:
+ if (!cxt->partition && cxt->nslaves == 0) {
+ p = sysfs_strdup(&cxt->sysfs, "device/vendor");
+ if (p)
+ tt_line_set_data(ln, col, p);
+ }
+ break;
case COL_SIZE:
if (cxt->size) {
if (lsblk->bytes) {
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] lsblk: Add --scsi switch
2012-11-02 17:56 [PATCH 1/3] lsblk: Add revision column Milan Broz
2012-11-02 17:56 ` [PATCH 2/3] lsblk: Add vendor column Milan Broz
@ 2012-11-02 17:56 ` Milan Broz
2012-11-07 16:43 ` [PATCH 1/3] lsblk: Add revision column Karel Zak
2 siblings, 0 replies; 4+ messages in thread
From: Milan Broz @ 2012-11-02 17:56 UTC (permalink / raw)
To: util-linux; +Cc: Milan Broz
The --scsi switch prints similar information to lsscsi command.
Signed-off-by: Milan Broz <mbroz@redhat.com>
---
misc-utils/lsblk.8 | 2 ++
misc-utils/lsblk.c | 23 ++++++++++++++++++++---
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/misc-utils/lsblk.8 b/misc-utils/lsblk.8
index ced0a13..c280ed4 100644
--- a/misc-utils/lsblk.8
+++ b/misc-utils/lsblk.8
@@ -74,6 +74,8 @@ Use the raw output format. All potentially unsafe characters are hex-escaped
Print dependencies in inverse order.
.IP "\fB\-t, \-\-topology\fP"
Output info about block device topology.
+.IP "\fB\-S, \-\-scsi\fP"
+Output info about SCSI devices.
This option is equivalent to "-o NAME,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE".
.IP "\fB\-V, \-\-version\fP"
Output version information and exit.
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index f8bc6ea..bca4449 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -1,7 +1,7 @@
/*
* lsblk(8) - list block devices
*
- * Copyright (C) 2010,2011 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2010,2011,2012 Red Hat, Inc. All rights reserved.
* Written by Milan Broz <mbroz@redhat.com>
* Karel Zak <kzak@redhat.com>
*
@@ -162,6 +162,7 @@ struct lsblk {
unsigned int bytes:1; /* print SIZE in bytes */
unsigned int inverse:1; /* print inverse dependencies */
unsigned int nodeps:1; /* don't print slaves/holders */
+ unsigned int scsi:1; /* print only device with HCTL (SCSI) */
};
struct lsblk *lsblk; /* global handler */
@@ -588,7 +589,7 @@ static char *get_transport(struct blkdev_cxt *cxt)
char *attr = NULL;
const char *trans = NULL;
- /* SPI - Serial Peripheral Interface */
+ /* SCSI - Serial Peripheral Interface */
if (sysfs_scsi_host_is(sysfs, "spi"))
trans = "spi";
@@ -976,6 +977,10 @@ static int set_cxt(struct blkdev_cxt *cxt,
cxt->nholders = sysfs_count_dirents(&cxt->sysfs, "holders");
cxt->nslaves = sysfs_count_dirents(&cxt->sysfs, "slaves");
+ /* ignore non-SCSI devices */
+ if (lsblk->scsi && sysfs_scsi_get_hctl(&cxt->sysfs, NULL, NULL, NULL, NULL))
+ return -1;
+
return 0;
}
@@ -1330,6 +1335,7 @@ static void __attribute__((__noreturn__)) help(FILE *out)
" -r, --raw use raw output format\n"
" -s, --inverse inverse dependencies\n"
" -t, --topology output info about topology\n"
+ " -S, --scsi output info about SCSI devices\n"
" -V, --version output version information and exit\n"));
fprintf(out, _("\nAvailable columns (for --output):\n"));
@@ -1374,6 +1380,7 @@ int main(int argc, char *argv[])
{ "include", 1, 0, 'I' },
{ "topology", 0, 0, 't' },
{ "pairs", 0, 0, 'P' },
+ { "scsi", 0, 0, 'S' },
{ "version", 0, 0, 'V' },
{ NULL, 0, 0, 0 },
};
@@ -1394,7 +1401,7 @@ int main(int argc, char *argv[])
memset(lsblk, 0, sizeof(*lsblk));
while((c = getopt_long(argc, argv,
- "abdDe:fhlnmo:PiI:rstV", longopts, NULL)) != -1) {
+ "abdDe:fhlnmo:PiI:rstVS", longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
@@ -1473,6 +1480,16 @@ int main(int argc, char *argv[])
columns[ncolumns++] = COL_RQ_SIZE;
columns[ncolumns++] = COL_RA;
break;
+ case 'S':
+ lsblk->nodeps = 1;
+ lsblk->scsi = 1;
+ columns[ncolumns++] = COL_NAME;
+ columns[ncolumns++] = COL_HCTL;
+ columns[ncolumns++] = COL_TYPE;
+ columns[ncolumns++] = COL_VENDOR;
+ columns[ncolumns++] = COL_MODEL;
+ columns[ncolumns++] = COL_REV;
+ break;
case 'V':
printf(_("%s from %s\n"), program_invocation_short_name,
PACKAGE_STRING);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] lsblk: Add revision column
2012-11-02 17:56 [PATCH 1/3] lsblk: Add revision column Milan Broz
2012-11-02 17:56 ` [PATCH 2/3] lsblk: Add vendor column Milan Broz
2012-11-02 17:56 ` [PATCH 3/3] lsblk: Add --scsi switch Milan Broz
@ 2012-11-07 16:43 ` Karel Zak
2 siblings, 0 replies; 4+ messages in thread
From: Karel Zak @ 2012-11-07 16:43 UTC (permalink / raw)
To: Milan Broz; +Cc: util-linux
On Fri, Nov 02, 2012 at 06:56:29PM +0100, Milan Broz wrote:
> misc-utils/lsblk.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
All three patches applied. Thanks.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-07 16:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-02 17:56 [PATCH 1/3] lsblk: Add revision column Milan Broz
2012-11-02 17:56 ` [PATCH 2/3] lsblk: Add vendor column Milan Broz
2012-11-02 17:56 ` [PATCH 3/3] lsblk: Add --scsi switch Milan Broz
2012-11-07 16:43 ` [PATCH 1/3] lsblk: Add revision column Karel Zak
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).