Commit Graph

85 Commits

Author SHA1 Message Date
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
Milan Broz 150db7a956 lsblk: add read-ahead column.
Signed-off-by: Milan Broz <mbroz@redhat.com>
2012-07-26 10:55:05 +02:00
Karel Zak 98f2dc7a2b lsblk: use err_exclusive_options()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 09:24:36 +02:00
Karel Zak 9e9bceeb50 lsblk: fix dm_name usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-25 18:04:10 +02:00
Karel Zak 32c67d2c58 lsblk: check sysfs_read_u64 return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-21 13:08:18 +02:00
Karel Zak 9c53a49c44 lsblk: check ioctl result [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-21 11:58:39 +02:00
Karel Zak 2dc03af7f0 lsblk: fix usage, improve exclude/include lists parsing
Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-19 17:41:35 +02:00
Karel Zak 2ef4e8ba1a lsblk: add --include option
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-19 16:06:22 +02:00
Karel Zak 8acc8979c4 Merge branch '2012wk24' of git://github.com/kerolasa/lelux-utiliteetit
* '2012wk24' of git://github.com/kerolasa/lelux-utiliteetit: (24 commits)
  more: fix pointer wrap around compiler warnings
  more: fix search repetition regression
  lscpu: values in /proc/bus/pci/devices are always unsigned
  scriptreplay: fix compiler format warning
  lib/mbsalign: abort() when non-expected case is encountered
  mkfs.cramfs: disallow unknown command line options
  fsck.cramfs: disallow unknown command line options
  setarch: disallow unknown command line options
  hexdump: print sensible message when all input file arguments fail
  mount: (new) use exclusive_option()
  dmesg: use exclusive_option()
  wipefs: use exclusive_option()
  wdctl: correct manual section reference
  wdctl: use exclusive_option()
  prlimit: use exclusive_option()
  lscpu: use exclusive_option()
  losetup: use exclusive_option()
  chcpu: use exclusive_option()
  lsblk: use exclusive_option()
  findmnt: use exclusive_option()
  ...
2012-06-19 13:01:29 +02:00
Bernhard Voelker f6da50d49b lsblk: permit option --exclude more than once
Previously, `lsblk -e 8 -e 11` did not exlude maj:8 as requested.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-06-19 11:06:48 +02:00
Sami Kerola 0518765347 lsblk: use exclusive_option()
This commit fixes exclusions which where meant to happen, but where not
successful.  For example

lsblk -r -l	# did exclude
lsblk -l -r	# did not exclude

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-17 17:59:59 +02:00
Karel Zak 9d738ff822 lsblk: use fallback for TYPE
... bug introduced by 1edd8af70b

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-15 13:13:40 +02:00
Sami Kerola 1edd8af70b lsblk: use blkdev_scsi_type_to_name()
Replace inline version of similar, but less complete, functionality
with the lib/blkdev.c function.  The function will inform if a type is
unknown, which appears as hex string value.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 22:06:06 +02:00
Karel Zak 1ea962b208 lsblk: fix /sys/.../ro usage
Reported-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-03 16:24:12 +02:00
Karel Zak d324270eee lsblk: remove private \x<hex> coding, decode data from udev
* remove private encoding code (all encoding will be in lib/tt.c)
 * decode LABELs from udev

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-26 09:20:47 +02:00
Karel Zak aa0903e06b lsblk: add support for PARTUUID= and PARTLABEL=
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-19 14:39:44 +02:00
Sami Kerola c05a80ca63 misc-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:56:48 +02:00
Peter Rajnoha 8265242b22 lsblk: count with terminating character, man page -s entry
Signed-off-by: Peter Rajnoha <prajnoha@redhat.com>
2012-04-04 13:32:25 +02:00
Karel Zak 9554f7abd8 lsblk: use libmount to get mountpoints/swaps
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-03 13:43:50 +02:00
Karel Zak 451d76463c misc: clenaup SIZE columns in lsblk and findmnt
Note that lib/tt.c will never truncate columns without TT_FL_TRUNC or
relative column width. So it's fine to set small width for columns
with SIZEs, the defined width is minimal width.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-20 11:04:48 +01:00
Sami Kerola 6f312c8957 xalloc: use xasprintf in all files
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:05 +01:00
Milan Broz 5791238768 lsblk: add --version switch
[kzak@redhat.com: - update usage() and man page]

Signed-off-by: Milan Broz <mbroz@redhat.com>
2012-03-08 16:19:57 +01:00
Karel Zak 7c9c872c2b lsblk: escape unsafe chars in parsable output
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-08 16:04:45 +01:00
Karel Zak 540d506f71 lsblk: use readlink_at from at.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-07 14:28:52 +01:00
Peter Rajnoha 09a71aa1d5 lsblk: add inverse tree support (-s)
$ lsblk --inverse -o NAME /dev/dm-0
NAME
luks-10d813de-fa82-4f67-a86c-23d5d0e7c30e (dm-0)
└─sda6
  └─sda

Signed-off-by: Peter Rajnoha <prajnoha@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-07 13:54:11 +01:00
Karel Zak 205eb00283 lsblk: remove (dm-N) from NAME for raw/pair output format
$ lsblk -P -o NAME /dev/dm-0
 NAME="luks-10d813de-fa82-4f67-a86c-23d5d0e7c30e (dm-0)"

the (dm-0) sucks in the parsable output...

Reported-by: Peter Rajnoha <prajnoha@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-07 13:11:54 +01:00
Sami Kerola 7cebf0bb4f docs: corrections to FSF license files, and postal address
The COPYING and Documentation/licenses/COPYING* files are being
replaced by files from GNU web site.

http://www.gnu.org/licenses/gpl-2.0.txt
http://www.gnu.org/licenses/lgpl-2.1.txt

Postal addresses to FSF in other files are updated to match with the
address in license files.

Reference: http://lists.gnu.org/archive/html/freefont-announce/2005-04/msg00001.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-24 14:13:35 +01:00
Karel Zak 1dc42eb620 lsblk: check stat() return code
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-03 00:01:32 +01:00
Karel Zak 38a8d69e29 lsblk: add UUID to --fs output
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-16 13:22:28 +01:00
Karel Zak 7aa69cf2e3 lib,tt: add TT_FL_NOEXTREMES
If you mark a column with TT_FL_NOEXTREMES flag then extremely
large fields will no have effect to column width. Foe example:

 without the TT_FL_NOEXTREMES flag for the 'AAA' column:

	 AAA         BBB CCC  DDD
	 aa          bbb ccc  ddd
	 aaaaaaaaaaa  bb ccc  ddd
	 aa           bb ccc  ddd
	 aa           bb ccc  ddd

 with the flags:

	 AAA  BBB CCC  DDD
	 aa   bbb ccc  dddddddddd
	 aaaaaaaaaaa
	       bb ccc  dddddddd
	 aa    bb ccc  dddddd
	 aa    bb ccc  ddddddddd

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-10 12:39:02 +01:00
Davidlohr Bueso 507d39c287 lsblk: remove __NCOLUMNS
We use ARRAY_SIZE() instead to define the amount of available columns.

[kzak@redhat.com: - fix compiler warnings [-Wsign-compare]]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-02 16:18:56 +01:00