summaryrefslogtreecommitdiffstats
path: root/misc-utils/lsblk.c
Commit message (Collapse)AuthorAgeFilesLines
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | Consolidate --help and --version descriptions. We are now able to align them to the other options. We changed include/c.h. The rest of this patch was generated by sed, plus manually setting the right alignment numbers. We do not change anything but white spaces in the --help output. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: cosmetics, remove argument from usage(FILE*)Ruediger Meier2017-06-261-3/+4
| | | | | | | | | | | | | | This patch is trivial and changes nothing, because we were always using usage(stdout) Now all our usage() functions look very similar. If wanted we could auto-generate another big cosmetical patch to remove all the useless "FILE *out" constants and use printf and puts rather than their f* friends. Such patch could be automatically synchronized with the translation project (newlines!) to not make the translators sick. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: consolidate usage() "Available columns"Karel Zak2017-06-261-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: add option --treeKarel Zak2017-06-091-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now lsblk uses --list when --sort <column> is specified. This patch allows to specify --tree to overwrite this default behavior add to force tree-like output. In this case tree branches are sorted by the <column>. $ lsblk --sort SIZE NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda2 8:2 0 200M 0 part /boot sda1 8:1 0 200M 0 part /boot/efi sda6 8:6 0 7.8G 0 part [SWAP] sda5 8:5 0 35.1G 0 part /home/misc sda4 8:4 0 50G 0 part / sdb1 8:17 0 74.5G 0 part /home/archive sdb 8:16 0 74.5G 0 disk sda3 8:3 0 130.3G 0 part /home sda 8:0 0 223.6G 0 disk $ lsblk --sort SIZE --tree NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb 8:16 0 74.5G 0 disk └─sdb1 8:17 0 74.5G 0 part /home/archive sda 8:0 0 223.6G 0 disk ├─sda2 8:2 0 200M 0 part /boot ├─sda1 8:1 0 200M 0 part /boot/efi ├─sda6 8:6 0 7.8G 0 part [SWAP] ├─sda5 8:5 0 35.1G 0 part /home/misc ├─sda4 8:4 0 50G 0 part / └─sda3 8:3 0 130.3G 0 part /home Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate smartcols error messagesKarel Zak2017-05-181-5/+5
| | | | | | ... just to keep translators happy Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: don't duplicate columnsKarel Zak2017-04-191-49/+55
| | | | | | | | | | | | | | | | | | | | | | $ lsblk --discard --perms NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO NAME SIZE OWNER GROUP MODE sdb 0 0B 0B 0 sdb 74.5G root disk brw-rw---- └─sdb1 0 0B 0B 0 └─sdb1 74.5G root disk brw-rw---- sda 0 512B 2G 0 sda 223.6G root disk brw-rw---- ├─sda4 0 512B 2G 0 ├─sda4 50G root disk brw-rw---- ├─sda2 0 512B 2G 0 ├─sda2 200M root disk brw-rw---- ├─sda5 0 512B 2G 0 ├─sda5 35.1G root disk brw-rw---- ├─sda3 0 512B 2G 0 ├─sda3 130.3G root disk brw-rw---- ├─sda1 0 512B 2G 0 ├─sda1 200M root disk brw-rw---- └─sda6 0 512B 2G 0 └─sda6 7.8G root disk brw-rw---- ... see NAME column. It's fine to support duplicated columns when requested by user (e.g. -o NAME,NAME,SIZE), but it does not make sense for the default output when multiple command options specified. Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: add ZONED columnDamien Le Moal2017-04-191-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the column "ZONED" to the output to display block devices zone model information. Example output: > lsblk -o+ZONED NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT ZONED sda 8:0 0 111.8G 0 disk none ├─sda1 8:1 0 500M 0 part /boot none ├─sda2 8:2 0 87.3G 0 part / none └─sda3 8:3 0 24G 0 part [SWAP] none sdb 8:16 0 12.8T 0 disk host-managed sdc 8:32 0 5.5T 0 disk host-managed or: > lsblk --zoned NAME ZONED sda none ├─sda1 none ├─sda2 none └─sda3 none sdb host-managed sdc host-managed Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
* lsblk: fix --inverse --listKarel Zak2017-04-131-0/+7
| | | | | | | Let's follow --inverse dependencies although --list output requested. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1441175 Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: move scols_flags to lsblk control structKarel Zak2017-04-131-18/+19
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: add static keyword to where needed [smatch scan]Sami Kerola2017-02-201-3/+3
| | | | | | | text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be static? Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-201-29/+29
| | | | | | | | | | text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer Since many 'struct option' has used zero as NULL make them more readable in same go by reindenting, and using named argument requirements. Reference: https://lwn.net/Articles/93577/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* docs: Fix word repetitionsYuri Chornoivan2017-02-131-1/+1
|
* lsblk: use errtryhelp()Karel Zak2016-12-191-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: sort by MAJ:MIN by defaultKarel Zak2016-11-021-0/+5
| | | | | | | Since Linux kernel 4.8 /sys entries are no more sorted and all is in the native order. It makes lsblk output messy. Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: improve support for nvmeKarel Zak2016-06-021-1/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: Fix various typosSebastian Rasmussen2016-05-311-6/+6
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* lsblk: use ID_WWN_WITH_EXTENSION is possibleKarel Zak2016-05-251-1/+6
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/321 Signed-off-by: Karel Zak <kzak@redhat.com>
* mount, umount, swapon, fsck, lsblk, findmnt: harmonize six error messagesBenno Schulenberg2016-03-161-2/+1Star
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* Revert "include sysmacros.h where used"Karel Zak2016-03-081-1/+0Star
| | | | This reverts commit 46a40c018438b7b2b25083a5e5a4a21055a0c1e9.
* include sysmacros.h where usedMike Frysinger2016-03-081-0/+1
| | | | | | | | BSD/Linux systems stick major/minor/makedev in sysmacros.h. Newer Linux libraries have been moving away from including sysmacros.h implicitly via sys/types.h, so include it directly. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lib: remove openat fallback functions (include/at.h)Ruediger Meier2016-03-071-8/+3Star
| | | | | | | | | | | | | | I have validated that we are still compatible at least back to - openSUSE 11.4 - SLE 11 - RHEL/CentOS 6 - OSX 10.10.x, (Xcode 6.3) - FreeBSD 10.2 Confirmed incompatibility: - OSX 10.9.x, (Xcode 6.2) Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib: rename strmode() and setmode()Ruediger Meier2016-02-181-1/+1
| | | | | | On BSD they are part of the standard C library. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* docs: fix typos found by codespellRuediger Meier2016-02-031-1/+1
| | | | | | Using "codespell" from https://github.com/lucasdemarchi/codespell Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lsblk: remove useless warningsKarel Zak2016-01-221-5/+5
| | | | | | | It's seems better to keep the warnings only in the debug output. Reported-by: Kay Sievers <kay@vrfy.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: use unsigned type for SIZEKarel Zak2016-01-121-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: allow to --sort by hidden columnKarel Zak2015-12-101-2/+8
| | | | | | | | | | For example: lsblk -o NAME --sort SIZE prints NAMEs, but sort by SIZEs. Signed-off-by: Karel Zak <kzak@redhat.com>
* mount, umount, swapon, fsck, lsblk, findmnt: ignore malformed linesKarel Zak2015-10-151-0/+11
| | | | | | | | | | | | | | | | | The libmount provides way how to deal with parsing errors in fstab -- on error callback function is executed and according to the return libmount manipulate with the malformed line, possible are three states: 1/ fatal error; all file ignored (callback rc < 0) 2/ recoverable error; malformed line ignored (callback rc > 0) 3/ ignore the error (callback rc == 0) The 2/ is the default if no callback specified. Unfortunately our utils uses 3/. The correct way is to use 2/. Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: fix resource leak [coverity scan]Andreas Henriksson2015-08-311-1/+3
| | | | Signed-off-by: Andreas Henriksson <andreas@fatal.se>
* lsblk: Display mountpoint even for top-level deviceMilan Broz2015-07-311-2/+1Star
| | | | | | | | | | | | | | | | | | | | If a filesystem is mounted on top-level block device with existing partitions, the mountpoint is not displayed in the lsblk output. This situation can happen by a configuration mistake and lsblk could be used to detect such a mistake. This patch allows searching for a mountpoint for all displayed devices, not only for leaf nodes. (It should be pretty cheap operation, mtab is parsed only once.) For example: lsblk /dev/loop1 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop1 7:1 0 128M 0 loop /mnt/tst └─loop1p1 259:0 0 127M 0 loop Signed-off-by: Milan Broz <gmazyland@gmail.com>
* lsblk: add --jsonKarel Zak2015-06-041-2/+14
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: use internally sysfs devnamesKarel Zak2015-05-291-5/+4Star
| | | | | | | It seems better to keep the strange sysfs devnames internally and translate to real devnames only on output or when we read from /dev. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: rename devname functions, cleanupKarel Zak2015-05-281-8/+11
| | | | | | | | | | | | | | | | | | Well, I don't have mental power to use function names like sysfs_devname_to_dev_name() so this patch renames to sysfs_devname_sys_to_dev() sysfs_devname_dev_to_sys() It also cleanups usage of the functions. We have to be sure that sysfs.c code returns regular devnames. The existence of the sysfs devnames (with '!') should be completely hidden in sysfs specific code. Signed-off-by: Karel Zak <kzak@redhat.com>
* Fix /sys to /dev node name translationStanislav Brabec2015-05-261-0/+1
| | | | | | | | | | | | | | linux/drivers/base/core.c: device_get_devnode() defines a translation of '!' in sysfs nodes to '/' in /dev nodes. The same translation has to be done to properly support device nodes with slash (e. g. device nodes of cciss driver and several other drivers). Introduce new helper sysfs_devname_to_devno() and use it where appropriate. Fixes for example lsblk -f on devices using cciss driver. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* lib/strutils: fix string_add_to_idarray() int vs. size_tKarel Zak2015-04-221-6/+8
| | | | | | | | | | | | | | | | | | | | The function uses "int" as argument, but for array size (and index) is better to use unsigned type (size_t). If we mix "size_t" in util (e.g. fdisk) and "int" in lib/strutils.c then result is unexpected behavior on ppc64. # sfdisk --list -o DEVICE,START,SIZE /dev/sdb Disk /dev/sdb: 50 MiB, 52428800 bytes, 102400 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 32768 bytes Disklabel type: gpt Disk identifier: 3B8559DB-33AF-43E9-BEFC-C331D829B539 lt-sfdisk: libfdisk/src/label.c:178: fdisk_label_get_field: Assertion `id > 0' failed. The patch cleanup all code to use size_t everywhere. Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: don't ignore dependences for partitioned deviesKarel Zak2015-04-011-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | The code only lists partitions, but ignore another dependencies on whole-disk device: $ lsblk /dev/sdb NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb 8:16 0 298.1G 0 disk └─sdb1 8:17 0 298.1G 0 part $ ls /sys/block/sdb/holders/ dm-0 fixed version: $ lsblk /dev/sdb NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb 8:16 0 298.1G 0 disk ├─sdb1 8:17 0 298.1G 0 part └─mpatha 253:0 0 298.1G 0 mpath └─mpatha1 253:1 0 298.1G 0 part Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: follow kernel for inverse treeKarel Zak2015-04-011-1/+3
| | | | | | | | | | | | | | | | | | For multi-path devices kernel defines dependence between the device and whole-list: $ ls /sys/block/dm-0/slaves/ sdb but lsblk inserts partition into the tree: $ lsblk -s -oNAME,KNAME /dev/dm-1 mpatha1 dm-1 └─mpatha dm-0 └─sdb1 sdb1 <--- ! └─sdb sdb Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: add debug supportKarel Zak2015-04-011-11/+76
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: implement SOMEOK (=64) return codeKarel Zak2015-01-291-13/+27
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+4
| | | | | | | | | This adds a concise description of a tool to its usage text. A first form of this patch was proposed by Steven Honeyman (see http://www.spinics.net/lists/util-linux-ng/msg09994.html). Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* lsblk: add SUBSYSTEMS columnKarel Zak2014-12-021-0/+37
| | | | | | | | $ lsblk -oNAME,SIZE,TYPE,SUBSYSTEMS /dev/sr0 NAME SIZE TYPE SUBSYSTEMS sr0 7.8M rom block:scsi:usb:pci Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: add HOTPLUG columnKarel Zak2014-12-021-1/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: fix compiler warningSami Kerola2014-10-011-4/+4
| | | | | | warning: ISO C forbids empty initializer braces [-Wpedantic] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: remove some inconsistent periods from error messagesBenno Schulenberg2014-08-111-2/+2
| | | | | | While doing so, also improve translatability and some wordings. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* Merge branch 'master' of https://github.com/yurchor/util-linuxKarel Zak2014-07-221-1/+1
|\ | | | | | | | | * 'master' of https://github.com/yurchor/util-linux: Fix typos in user visible messages
| * Fix typos in user visible messagesYuri Chornoivan2014-07-031-1/+1
| |
* | lsblk: check number of used columnsKarel Zak2014-07-181-45/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | lsblk: differentiate between infos[] and columns[]Karel Zak2014-07-181-3/+3
|/ | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: add debug messagesKarel Zak2014-06-061-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: fix, set default sort_id = -1Ruediger Meier2014-05-211-1/+0Star
| | | | | | | | 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>