Commit Graph

55 Commits

Author SHA1 Message Date
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
Sami Kerola f65b3bb625 lsblk: inform about depencency to /sys/dev/block
The lsblk depends on /sys/dev/block/ symlinks, which appeared in
kernel 2.6.27.  Users with old, or non-sysfs configured, kernel
got ealier message

lsblk: md0: failed to initialize sysfs handler
lsblk: xvda: failed to initialize sysfs handler
[...]

that I found a little too difficult to understand.  This patch will
change the message to

lsblk: failed to access sysfs directory: /sys/dev/block: No such file or directory

and informs in manual page what could be reason to that.

[kzak@redhat.com: - use access() rather than opendir()]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-10 14:51:26 +02:00
Ilias Mamedov f17f5f481a lsblk: add udev support
[kzak@redhat.com: - enable udev support by default
                  - don't check for libudev.h
                  - minor udev code refactoring in lsblk.c]

Signed-off-by: Ilias Mamedov <arknir@yandex.ru>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-03 14:25:43 +02:00
Benno Schulenberg f14f02f581 textual: add some guiding comments for translators
These are picked up by xgettext and put in the POT file.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-02 14:13:44 +02:00
Benno Schulenberg 1117f18f8e lsblk: correct mistaken word
Reported-by: Petr Písař <petr.pisar@atlas.cz>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-02 14:13:43 +02:00
Karel Zak 6aace32f0b lsblk: fix compiler warnings [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01 12:40:03 +02:00
Karel Zak 9feec79cc5 misc: use unsigned int for bit-fileds
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-29 10:51:06 +02:00
Karel Zak c87638ad30 include: [strutils.c] add list parsers
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-27 16:41:21 +02:00
Karel Zak bdc3ed6678 include; [tt.c] check for array size in columns parser
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-27 16:21:11 +02:00
Milan Broz 270e66eca4 lsblk: ignore device if disappear while processing
If lsblk runing on system where many devices appears and disappears
during lsblk run, lsblk should not fail or crash but just ignore
disappeared device.

Let's detect context initialization failures and skip device
instead of failing.

Also fix possible dereferencing of NULL parent pointer and
properly handle some error paths.

Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-21 23:19:52 +02:00
Milan Broz 64c9e22aa4 lsblk: add queue request size attribute
Add queue request size parameter.

Very useful for tuning multipath performance.

Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-15 15:41:22 +02:00
Milan Broz 01e487c020 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>
2011-07-15 15:35:10 +02:00
Francesco Cosoleto 5d2a98490e This adds a second parameter to size_to_human_string() to return a
string with a different format based on the following flags:

        SIZE_SUFFIX_1LETTER  = "1K"
        SIZE_SUFFIX_3LETTER  = "1KiB",
        SIZE_SUFFIX_SPACE    = "1 KiB" or "1 K"

[kzak@redhat.com: - rename flags to SIZE_SUFFIX_* format,
                  - fix suffix[] buffer size
                  - add 3 letter version to the test]

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-26 15:32:33 +02:00
Karel Zak 9cfe1b9c6a lsblk: use sysfs_read_u64() rather than sysfs_strdup() + atol()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-18 12:17:43 +02:00
Karel Zak 90e9fcda3b lib: [sysfs.c] make sysfs_read_* function more robust
The functions does not modify result if the requested sysfs attribute
does not exist.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-18 11:57:17 +02:00
Martin K. Petersen 98055888e9 lsblk: improve discard support
Use atol() instead of atoi() when extracting discard_max_bytes.

Only print discard_alignment and discard_zeroes_data if the device
supports discard. This prevents printing of undefined values with older
kernels.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2011-05-18 11:13:36 +02:00
Karel Zak 766ab9b08d lsblk: use generic sysfs functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-16 20:22:52 +02:00
Karel Zak 6ea1bdd32c lsblk: add --pairs to output in key="value" format
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-10 10:38:29 +02:00
Martin K. Petersen 2d2322461c lsblk: add support for discard topology (-D option)
I got tired of poking around in sysfs to find the discard topology.
Here's a patch against lsblk that adds a -D option to present this
information in a human-readable form:

NAME                  DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda                          0        0B       0B         0
└─sda1                       0        0B       0B         0
sdb                          0      512B       2G         1
└─sdb1                       0      512B       2G         1

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-05 10:09:26 +02:00
Karel Zak ed34643cbc lsblk: fix strtoul() usage [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-11 13:36:00 +01:00
Karel Zak eb9a65bb54 lsblk: use ssize_t for readlink() return code
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-11 10:49:08 +01:00
Milan Broz 18eac5bad9 lsblk: add TYPE column to lsblk output
[kzak@redhat.com: - fix leaks
                  - use lowercase for TYPEs]

Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-10 15:49:36 +01:00
Karel Zak 6c7d5ae9a2 move struct option to .rodata
It does not make sense to have writable large arrays of "struct
option" on the stack.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-03 15:00:30 +01:00
Dave Reisner 449f9336bb lsblk: bitwise or TT_FL_ASCII with tt_flags instead of setting
Signed-off-by: Dave Reisner <d@falconindy.com>
2011-02-21 17:10:55 +01:00
Karel Zak cc6b1d11ea lsblk: fix readlink() usage
Reported-by: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-18 14:36:04 +01:00
Benno Schulenberg e22d8b9519 textual: fix three typos in message strings and improve consistency
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-02-16 15:30:13 +01:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
Solaris lacks err, errx, warn and warnx.  This also means the err.h header
doesn't exist.  Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-02-14 17:45:24 +01:00
Karel Zak d015794e09 partx, lsblk: fix gettext calls
Reported-by: Peter Breitenlohner <peb@mppmu.mpg.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-11 09:06:27 +01:00
Karel Zak 627970a7f9 lsblk: use "RM" for removable
Suggested by Przemoc <noreply-comment@blogger.com> at my blog.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-10 11:18:51 +01:00
Karel Zak 218f9d3d66 remove duplicate includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-04 22:36:09 +01:00
Karel Zak 61cbc01a89 lsblk: rename "RA" column to "RE"
The RA abbreviation is usually used for readahead, the column in
lsblk(8) means removable.

Signed-off-by: Karel Zak <kzak@redhat.com>
2010-12-26 23:53:21 +01:00