Commit graph

115 commits

Author SHA1 Message Date
Sami Kerola
7fe033ef9a lsblk: fix compiler warning
warning: ISO C forbids empty initializer braces [-Wpedantic]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:42 +02:00
Benno Schulenberg
1d23119072 textual: remove some inconsistent periods from error messages
While doing so, also improve translatability and some wordings.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-08-11 14:51:54 +02:00
Karel Zak
ccef45168b Merge branch 'master' of https://github.com/yurchor/util-linux
* 'master' of https://github.com/yurchor/util-linux:
  Fix typos in user visible messages
2014-07-22 12:01:50 +02:00
Karel Zak
b6327c6fd8 lsblk: check number of used columns
The current code does not check size of the columns[] array when add
the next on command line specified column. We check the array size for
"-o <columns>" but not for another options.

Old version:

   $ for x in $(seq 0 100); do echo "-t"; done | xargs lsblk
   xargs: lsblk: terminated by signal 11

new version:

  $ for x in $(seq 0 100); do echo "-t"; done | xargs lsblk
  lsblk: too many columns specified, the limit is 83 columns.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-18 13:47:53 +02:00
Karel Zak
03df0d1150 lsblk: differentiate between infos[] and columns[]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-18 13:45:32 +02:00
Yuri Chornoivan
b5af3ee835 Fix typos in user visible messages 2014-07-03 09:33:15 +03:00
Karel Zak
710ed55dcd libsmartcols: add debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-06 13:47:06 +02:00
Ruediger Meier
4e9e0d1e06 lsblk: fix, set default sort_id = -1
Introduced in 642048e4:
 $ lsblk -o SIZE /dev/loop1
lsblk: the sort column has to be between output columns.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-21 11:59:24 +00:00
Karel Zak
642048e4a4 lsblk: add --sort <column>
This implementation allow to sort output by arbitrary output column.

Note that output is always converted to human readable strings, but
sort functions in many cases work with original data (stored as
private data to cells by scols_cell_set_userdata()).

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-20 15:12:51 +02:00
Masatake YAMATO
1b4d2a4a4a lsblk: add -O option to show all available columns
Simple command line for gathering information as many as possible is
useful when understanding a system, especially when trouble shooting.

This patch introduces -O option which enables all available columns.

[kzak@redhat.com: - define collisions between options,
                  - define columns when parse argv[]]

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-06 10:56:52 +02:00
Karel Zak
0925a9dd6c libsmartcols: clean up flags usage
* rename flags functions to scols_table_enable_*
 * rename *_no_foo() functions to _nofoo()
 * output formats are mutually exclusive, so don't use flags there
 * don't assume symbols in scols_new_table(), use scols_table_set_symbols()

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 16:09:57 +02:00
Karel Zak
5c5941df74 lsblk: remove unnecessary code
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:20 +02:00
Karel Zak
bb6e822ad2 lsblk: clean up data preparation
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:20 +02:00
Ondrej Oprala
9bd4e5c0bd lsblk: use libsmartcols
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:18 +02:00
Karel Zak
5a2fd9329e lsblk: add PARTFLAGS column
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-07 11:14:46 +01:00
Michael Marineau
4686ba17a8 lsblk: add PARTTYPE tag
To stay in sync with blkid add PARTTYPE as an available output column.
2014-02-10 10:47:21 +01:00
Karel Zak
71d842c019 lsblk: fix -D segfault
References: https://bugzilla.redhat.com/show_bug.cgi?id=1031262
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-18 11:27:35 +01:00
Benno Schulenberg
3e59c48159 textual: remove duplicate mention of '--help' from lsblk help text
Also improve the alphabetization of the other options.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-14 14:54:47 +02:00
Karel Zak
a239b17926 lsblk: use TT_FL_FREEDATA for tt table
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:59 +02:00
Karel Zak
50fccba1ab misc: use libmnt_table reference counter
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-21 16:07:51 +02:00
Karel Zak
6195f9e6fa misc: use libmnt_cache reference counting
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-21 14:38:38 +02:00
Karel Zak
da531dd8d5 lsblk: use devno to get mountpoint
The device (for example LVM logical volume) could be renamed and then
the device name from /proc/self/mountinfo does not match with reality.
So, we also need to check devno. Unfortunately we cannot completely
rely on devno, because for example btrfs uses psudo device numbers.

References: https://bugzilla.redhat.com/show_bug.cgi?id=980463
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-07-08 14:21:03 +02:00
Karel Zak
460c7afb79 lsblk: add SERIAL column
... to return short serial number of the disk (from udev db)

Addresses: https://github.com/karelzak/util-linux/issues/33
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-13 13:33:41 +02:00
Yuri Chornoivan
ef75bc880e Fix various typos 2013-04-26 12:50:03 +02:00
Karel Zak
c7e76cd145 lsblk: add --paths
Now it's not so simple to generate full paths to devices if you want to
use user friendly names like /dev/mapper/foo. Let's make it easy.
2013-03-29 17:16:09 +01:00
Karel Zak
65060bd04d lsblk: check returns [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27 14:13:12 +01:00
Karel Zak
d44e3391b7 lsblk: resuse udev handler
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-18 13:37:00 +01:00
Sami Kerola
39b232c169 lsblk: make usage() translator friendly
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-25 16:40:04 +01:00
Karel Zak
e421313dc2 textual: use UTIL_LINUX_VERSION everywhere
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-25 12:05:26 +01:00
Milan Broz
2adb1a44c2 lsblk: Add write-same attribute to topology info
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-07 18:12:02 +01:00
Karel Zak
b5fd07bcdb lsblk: don't care about xasprintf() return code
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-12 12:09:44 +01:00
Karel Zak
742b877b2d lsblk: fix copy & past bug
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-27 10:44:28 +01:00
Karel Zak
9b5535b388 lsblk: add TRANsport to --scsi output
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-07 14:34:51 +01:00
Karel Zak
a0e3e3de7b lsblk: don't ignore disk device
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-07 14:25:32 +01:00
Milan Broz
28ffc2b735 lsblk: Add --scsi switch
The --scsi switch prints similar information to lsscsi command.

Signed-off-by: Milan Broz <mbroz@redhat.com>
2012-11-07 13:20:45 +01:00
Milan Broz
99f43b721f lsblk: Add vendor column
Signed-off-by: Milan Broz <mbroz@redhat.com>
2012-11-07 13:20:42 +01:00
Milan Broz
d6681ceeb1 lsblk: Add revision column
Signed-off-by: Milan Broz <mbroz@redhat.com>
2012-11-07 13:20:26 +01:00
Karel Zak
9f51089e7f misc: make readlink() usage more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 12:40:39 +02:00
Karel Zak
2f2f7e80f1 lsblk: use new sysfs functions, clean up get_transport()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 12:21:37 +02:00
Karel Zak
23a11c74a6 lib/sysfs: add functions for SCSI host attributes
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 12:18:57 +02:00
Karel Zak
d0f7e5b4a0 include/sysfs: add SCSI host:channel:target:lun support
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 12:15:58 +02:00
Milan Broz
a5fb4d23eb lsblk: add SCSI transport type attribute
Patch adds "SCSI transport layer" similar attribute to "lsscsi -t".

This is useful for script where you want to distinguish e.g. FC, iSCSI
or USB devices from local disks.

Detection logic is quite simplified in comparison to lsscsi but it
should provide the same output (except detailed transport attributes).

Signed-off-by: Milan Broz <mbroz@redhat.com>
2012-10-23 10:27:07 +02:00
Milan Broz
699e5c4f96 lsblk: add SCSI H:C:T:L attribute
For block devices it is sometimes useful to print SCSI device ID"
Host:Channel:Target:LUN.

Patch adds column name HCTL which can be used in lsblk.

Signed-off-by: Milan Broz <mbroz@redhat.com>
2012-10-23 10:27:06 +02:00
Milan Broz
310c060356 lsblk: add parent kernel name column
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>
2012-10-23 10:27:04 +02:00
Peter Rajnoha
8d687180b2 lsblk: fix reporting of 'part' type
Partitions are incorrectly marked with 'disk' type on
lsblk output while it should be marked as 'part' type.

Before:
$ lsblk /dev/sda
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  128M  0 disk
`-sda1   8:1    0   64M  0 disk

With this patch applied:
$ lsblk /dev/sda
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  128M  0 disk
`-sda1   8:1    0   64M  0 part

Signed-off-by: Peter Rajnoha <prajnoha@redhat.com>
2012-10-02 10:23:51 +02:00
Peter Rajnoha
da30cb2a87 lsblk: fix processing of dm partition mappings
As blkid_devno_to_wholedisk returns parent dm device for
a partition mapping, the condition used in lsblk incorrectly
checked the parent-child relationship.

In this particular case, we need to process the dm partition
mapping like any other non-partition device as dm devices always
use proper holders/slaves sysfs hierarchy instead of
/sys/block/<parent>/<name> that is used for real partitions.

Example (test1 is a partition mapping and sdb1 is a real partition):
$ lsblk
NAME             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                8:0    0  128M  0 disk
`-test (dm-0)    253:0    0  128M  0 dm
  `-test1 (dm-1) 253:1    0  127M  0 part
sdb                8:16   0  128M  0 disk
`-sdb1             8:17   0  127M  0 disk

Before this patch (test1 skipped!):
$ lsblk -s /dev/mapper/test1
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
test (dm-0) 253:0    0  128M  0 dm
`-sda         8:0    0  128M  0 disk

$ lsblk -s /dev/sdb1
NAME  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb1    8:17   0  127M  0 disk
`-sdb   8:16   0  128M  0 disk

With this patch (test1 processed correctly):
$ lsblk -s /dev/mapper/test1
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
test1 (dm-1)  253:1    0  127M  0 part
`-test (dm-0) 253:0    0  128M  0 dm
  `-sda         8:0    0  128M  0 disk

$ lsblk -s /dev/sdb1
NAME  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb1    8:17   0  127M  0 disk
`-sdb   8:16   0  128M  0 disk
2012-09-21 12:25:32 +02:00
Yuri Chornoivan
bbac757b1e textual: fix typos in messages 2012-09-04 17:26:31 +02:00
Milan Broz
12b06c3dfc lsblk: add add_random columns
Allow printing of queue/add_random attribute which describes
if device adds randomness to kernel RNG pool.

Signed-off-by: Milan Broz <mbroz@redhat.com>
2012-09-04 17:21:53 +02:00
Karel Zak
88ca32b38b lsblk: add WWN, improve udev support
* read WWN from udev DB

 * use *_ENC properties from udev DB to get original unmodified
   strings (otherwise for example blank space is replaced with '_' in
   ID_FS_LABEL)

 * always read from udev, libblkid is fallback solution only

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-08-14 18:15:38 +02:00
Milan Broz
43bca82786 lsblk: support -o +<attr> for adding attribute to output fields.
Signed-off-by: Milan Broz <mbroz@redhat.com>
2012-07-26 16:37:03 +02:00