aboutsummaryrefslogtreecommitdiffstats
path: root/misc-utils/lsblk.c
AgeCommit message (Collapse)AuthorFilesLines
2025-10-11treewide: consolidate --list-columns option in usage() to ↵Christian Goeschel Ndjomouo1-1/+1
USAGE_LIST_COLUMNS_OPTION() This consolidates the --list-columns description in the usage() of ls-like tools to the USAGE_LIST_COLUMNS_OPTION() macro. It makes it simplier and ensures a consistent definition. Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2025-09-01lib/canonicalize: use ul_ prefixKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2025-08-26Merge branch 'feat/support_lsblk_columns_env' of ↵Karel Zak1-0/+1
https://github.com/cgoesche/util-linux-fork * 'feat/support_lsblk_columns_env' of https://github.com/cgoesche/util-linux-fork: lsblk: add support for LSBLK_COLUMNS environmental variable as an alternative to --output
2025-08-22lsblk: add support for LSBLK_COLUMNS environmental variable as an ↵cgoesche1-0/+1
alternative to --output Addresses: #2816 Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2025-08-22lsblk: (typo) rename list_colunms() to list_columns()cgoesche1-2/+2
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2025-07-02lsblk: fix possible use-after-freeKarel Zak1-3/+6
Signed-off-by: Karel Zak <kzak@redhat.com>
2025-07-01lsblk: fix memory leak [coverity scan]Karel Zak1-0/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2025-06-27lsblk: use md as fallback TYPE when md/level emptycodefiles1-1/+1
2025-06-06treewide: replace postal address in license specifier with a terse URLBenno Schulenberg1-3/+2
This brings the license specifier into the internet age. Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2025-05-29lib/strutils: call gettext() only when argument of --hyperlink is invalidBenno Schulenberg1-2/+1
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2025-04-29docs,usage: harmonize description of --hyperlink, and add 2 missing onesBenno Schulenberg1-0/+2
Harmonize the description by placing the option in a separate file. Also, use _when_/<when> (instead of _mode_/<mode>) as the optional argument, since the possible values are: "always", "never", "auto". Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2025-04-23swapoff: check blkid_probe_lookup_value() return code [coverity scan]Karel Zak1-2/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2025-04-07Use the 'fallthrough' attributeMatteo Croce1-1/+1
C23[1] and CPP17[2] introduced the 'fallthrough' attribute to let the compiler know that we're intentionally falling through a case statement. This suppress a warning with new compilers when doing an implicit fallthrough. [1] https://en.cppreference.com/w/c/language/attributes/fallthrough [2] https://en.cppreference.com/w/cpp/language/attributes/fallthrough
2025-04-02lsblk: avoid strcasecmp() for ASCII-only stringsKarel Zak1-3/+4
Use cctype.h for locale-independent string comparison and to avoid tricky string conversions like in tr_TR locales. Fixes: https://github.com/util-linux/util-linux/issues/3490 Signed-off-by: Karel Zak <kzak@redhat.com>
2024-12-09lsblk: add --hyperlink command line optionKarel Zak1-1/+15
Signed-off-by: Karel Zak <kzak@redhat.com>
2024-09-09lsblk: update --helpKarel Zak1-3/+5
* Add missing "--properties-by" parameter. * Shorten some strings. Signed-off-by: Karel Zak <kzak@redhat.com>
2024-08-21fix typosYang Hau1-2/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2024-06-24lsblk: add --properties-by optionKarel Zak1-2/+9
This new option allows for controlling the method(s) used by lsblk to gather file system and partition data about devices. Fixes: https://github.com/util-linux/util-linux/issues/2047 Signed-off-by: Karel Zak <kzak@redhat.com>
2024-06-04*: spelling and grammar fixesVille Skyttä1-1/+1
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
2024-04-22lsblk: simplify SOURCES codeKarel Zak1-5/+3
This complicated implementation originated from an early version of zero-separated items for libsmartcols. It is no longer necessary. References: https://github.com/util-linux/util-linux/pull/2983 Signed-off-by: Karel Zak <kzak@redhat.com>
2024-03-26lsblk: (refactor) refer to a parameter instead of a file static varMasatake YAMATO1-1/+1
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2024-01-11lsblk: add docs for filters and countersKarel Zak1-4/+4
Fixes: https://github.com/util-linux/util-linux/issues/2697 Signed-off-by: Karel Zak <kzak@redhat.com>
2024-01-09lsblk: explain FSAVAIL in better wayKarel Zak1-1/+1
Addresses: https://github.com/util-linux/util-linux/discussions/2690 Signed-off-by: Karel Zak <kzak@redhat.com>
2023-12-07lsblk: add --list-columnsKarel Zak1-24/+57
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-23Merge branch 'PR/libsmartcols-filter' of github.com:karelzak/util-linux-workKarel Zak1-116/+437
* 'PR/libsmartcols-filter' of github.com:karelzak/util-linux-work: (88 commits) meson: remove scols filter sample tests: use array keys in more robust way lsblk: update after rebase tests: add libsmartcols filter tests libsmartcols: (sample) fix error message tests: use scols_column_set_properties() in 'fromfile' sample libsmartcols: improve and fix scols_column_set_properties() libsmartcols: (samples) remove filter.c libsmartcols: add filter support to 'fromfile' sample libsmartcols: fix filter param copying tests: don't keep bison messages in tests autotools: use stamp file to build filter parser, improve portability meson: use bison --defines=HEADER libsmartcols: fix typo in parser tokens libsmartcols: add scols-filter.5 man page libsmartcols: (filter) add upper case EQ,NE,LE,LT,GT and GE operators ci: packit: add flex meson: fix copy & past error libsmartcols: build filter scanner and parser header files too meson: add missing scols sample ...
2023-11-22lsblk: add hint that partition start is in sectorsKarel Zak1-1/+1
Reported-by: Dusty Mabe <dustymabe@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-20lsblk: update after rebaseKarel Zak1-4/+4
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-20lsblk: make sure all line data are deallocatedKarel Zak1-19/+23
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-20libsmartcols: cleanup datafunc() APIKarel Zak1-4/+4
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-20lsblk: ignore duplicate lines for countersKarel Zak1-3/+9
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-20lsblk: report all unknown columns in filterKarel Zak1-5/+9
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-20lsblk: define cell data-types, use raw data for SIZEsKarel Zak1-21/+59
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-20lsblk: rename sortdata to rawdataKarel Zak1-55/+55
We can use the data for another purpose too. Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-20lsblk: always set column typeKarel Zak1-20/+25
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-20lsblk: support normalized column names on command lineKarel Zak1-0/+18
For example column name "LOG-SEC" is possible to use as LOG_SEC in some output formats and in filter expressions. Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-20lsblk: add scols counters supportKarel Zak1-4/+122
* add --ct-filter <expr> to restrict the next next counters * add --ct <name>[:<param>:func] to define counter. The counter assigned to the previously specified filter, if no filter specified then it's applied to all output lines. Examples: $ lsblk --ct "number of block devices" ... Summary: 21 number of block devices The filter uses default count() function and is applied to all lines. $ lsblk --ct-filter 'TRAN=="nvme"' --ct "number of NVMEs" ... Summary: 4 number of NVMEs The filter is restricted by filter. $ lsblk --bytes --ct-filter 'TRAN=="sata" && TYPE=="disk"' --ct "size of all SATAs disks":SIZE:sum ... Summary: 320083771392 size of all SATAs disks The counter uses sum() built-in function for specified column (SIZE) and is restricted by filter. Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-20lsblk: split filter allocation and initializationKarel Zak1-21/+23
A small refactoring to parse filters during getopt_long() time. Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-20lsblk: fix in-tree filteringKarel Zak1-4/+3
The function device_to_scols() is used recursively (for children). It's impossible leave the function on filter status=false, it's necessary to continue in the tree. Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-20lsblk: add --highlightKarel Zak1-2/+24
The new option can colorize lines specified by scols query. The columns (in the expression) does not have to be in the output. Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-20lsblk: add --filterKarel Zak1-32/+137
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-11-14lsblk: add separate MAJ and MIN columnsKarel Zak1-0/+14
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-10-25Merge branch 'refine-the-choice-of-stream-related-functions-in-usage' of ↵Karel Zak1-3/+3
https://github.com/masatake/util-linux * 'refine-the-choice-of-stream-related-functions-in-usage' of https://github.com/masatake/util-linux: Make the ways of using output stream consistent in usage() Use fputs instead of fprintf if possible
2023-10-25Make the ways of using output stream consistent in usage()Masatake YAMATO1-2/+2
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-10-25Use fputs instead of fprintf if possibleMasatake YAMATO1-1/+1
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-10-23lsblk: use zero to separate lines in multi-line cellsKarel Zak1-18/+24
Fixes: https://github.com/util-linux/util-linux/issues/2533 Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-03misc: constify some fieldsThomas Weißschuh1-4/+4
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-01-24lsblk: use sysfs_blkdev_is_removable()Karel Zak1-8/+7
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-01-02Merge branch 'lsblk-nvme' of https://github.com/mbroz/util-linuxKarel Zak1-3/+9
* 'lsblk-nvme' of https://github.com/mbroz/util-linux: Update email. lsblk: add revision output to --nvme list lsblk: read firmware revision from udev
2022-12-23Update email.Milan Broz1-1/+1
This email no longer works. Signed-off-by: Milan Broz <gmazyland@gmail.com>
2022-12-23lsblk: add revision output to --nvme listMilan Broz1-0/+1
This is similar to --scsi output now. Signed-off-by: Milan Broz <gmazyland@gmail.com>
2022-12-23lsblk: read firmware revision from udevMilan Broz1-2/+7
This supports more device types like NVMEs. Signed-off-by: Milan Broz <gmazyland@gmail.com>
2022-12-21lsblk: add mmc transportThomas Weißschuh1-0/+2
2022-10-25lsblk: improve mountpoint columns formattingKarel Zak1-2/+2
Let's mark the columns by no-extreme libsmartcols flag. It makes output more compact if there are too long mount paths. Signed-off-by: Karel Zak <kzak@redhat.com>
2022-09-05lsblk: add PARTN columnKarel Zak1-0/+7
Add PARTN column, the source for this column is ID_PART_ENTRY_NUMBER from udev db, the original source of this information comes from libblkid. There is also another PARTN in udevdb, but it's based on data from kernel uevent. Fixes: https://github.com/util-linux/util-linux/issues/1787 Signed-off-by: Karel Zak <kzak@redhat.com>
2022-09-01lsblk: add DISK-SEQ (aka /sys/block//diskseqKarel Zak1-0/+7
Addreses: https://github.com/util-linux/util-linux/issues/1786 Signed-off-by: Karel Zak <kzak@redhat.com>
2022-06-07lsblk: fix memory leak and unnecessary allocationKarel Zak1-5/+9
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-06-06lsblk: simplify code by ul_path_count_dirents()Karel Zak1-13/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-06-06lsblk: enable 'MQ' for NVMe/virtio by defaultzhenwei pi1-0/+2
NVMe/virtio devices typically has MQ feature, enable this column by default for option '--nvme/--virtio'. Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2022-06-06lsblk: introduce 'MQ' columnzhenwei pi1-0/+33
Typically a modern block device supports mutil queues feature, count queues by walking '$sysfs/mq' directory. If no '$sysfs/mq' exists, it is a legacy single queue. ~# lsblk --nvme -o NAME,TYPE,MODEL,TRAN,RQ-SIZE,MQ NAME TYPE MODEL TRAN RQ-SIZE MQ nvme0n1 disk INTEL SSDPF2KX038TZ nvme 1023 135 nvme3n1 disk INTEL SSDPE2KX020T8 nvme 1023 128 nvme1n1 disk SAMSUNG MZQL23T8HCLS-00A07 nvme 1023 129 nvme2n2 disk RP2A03T8RK004LX nvme 1023 64 nvme2n3 disk RP2A03T8RK004LX nvme 1023 64 Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2022-06-06lsblk: add -v/--virtiozhenwei pi1-1/+22
Add -v/--virtio to filter the virtio block devices. Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2022-06-06lsblk: support virtio blockzhenwei pi1-1/+3
virtio blk is quite popular in the virtual machines, support 'TRAN' column for a virtio block device. Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2022-06-06lsblk: add -N/--nvmezhenwei pi1-1/+23
Add -N/--nvme to filter NVMe device only, NVMe usually has a larger I/O depth, also show COL_RQ_SIZE by default. Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2022-04-25lsblk: add ID columnKarel Zak1-0/+10
Addresses: https://github.com/util-linux/util-linux/issues/1658 Signed-off-by: Karel Zak <kzak@redhat.com>
2022-04-25lsblk: make ID-LINK code more readableKarel Zak1-5/+5
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-04-22lsblk: add ID-LINK columnKarel Zak1-0/+7
Addresses: https://github.com/util-linux/util-linux/issues/1658 Signed-off-by: Karel Zak <kzak@redhat.com>
2022-04-01lsblk: fix JSON output when without --bytesKarel Zak1-6/+6
Fixes: https://github.com/util-linux/util-linux/issues/1636 Signed-off-by: Karel Zak <kzak@redhat.com>
2022-02-14lsblk: update --help output for -yKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-02-11lsblk: add -y/--shellKarel Zak1-1/+8
Fixes: https://github.com/util-linux/util-linux/issues/1594 Signed-off-by: Karel Zak <kzak@redhat.com>
2022-01-12lsblk: sort usage() outputKarel Zak1-2/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-01-12lsblk: add --noemptyKarel Zak1-1/+10
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-08-31lsblk: add zoned columns to "lsblk -z"Naohiro Aota1-1/+7
Add zoned columns to the "-z" option as follow. $ lsblk -z -i NAME ZONED ZONE-SZ ZONE-NR ZONE-AMAX ZONE-OMAX ZONE-APP ZONE-WGRAN sda host-managed 256M 55880 0 128 672K 4K sdb host-managed 256M 55880 0 128 672K 4K zram0 none 0B 0 0 0 0B 0B nvme2n1 none 0B 0 0 0 0B 0B |-nvme2n1p1 none 0B 0 0 0 0B 0B |-nvme2n1p2 none 0B 0 0 0 0B 0B `-nvme2n1p3 none 0B 0 0 0 0B 0B nvme0n1 none 0B 0 0 0 0B 0B nvme1n1 none 0B 0 0 0 0B 0B nvme0n2 host-managed 2G 1844 14 14 4M 4K nvme1n2 host-managed 2G 1844 14 14 4M 4K Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
2021-08-31lsblk: add columns of zoned parametersNaohiro Aota1-0/+52
Several parameters for zoned devices are missing from lsblk's columns. This commit introduces them as following. ZONE-SZ zone size ZONE-WGRAN zone write granularity ZONE-APP zone append max bytes ZONE-NR number of zones ZONE-OMAX maximum number of open zones ZONE-AMAX maximum number of active zones Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
2021-08-31lsblk: factor out function to read sysfs param as bytesNaohiro Aota1-25/+21
Factor out a new function device_read_bytes() to read a sysfs path as bytes for a preparation for the next commit and to reduce the code duplication. Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
2021-08-06lib/buffer: add support for "safe" encodingKarel Zak1-2/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-08-05lib/buffer: retun size of the buffer and dataKarel Zak1-2/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-09lsblk: sort list of columnsKarel Zak1-97/+91
It's better to maintain sorted list and it's also better for --help output. Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-09lsblk: add column START for partition start offsetsKarel Zak1-1/+8
Fix: https://github.com/karelzak/util-linux/issues/1340 Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-11lsblk: use MOUNTTARGETS in default outputKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-08lsblk: use MOUNTPOINTS in --fsKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-08lsblk: add FSROOTS columnKarel Zak1-0/+20
It displays filesystem root attached to system, for example btrfs with two mounted subvolumes: $ lsblk -oNAME,SIZE,MOUNTPOINTS,FSROOTS /dev/sdc1 NAME SIZE MOUNTPOINTS FSROOTS sdc1 50M /mnt/A /foo /mnt/B /bar Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-08lsblk: print all device mountpointsKarel Zak1-10/+41
* add libmount FS to struct lsblk_device * add new column MOUNTPOINTS (pl.) with multi-line cells to display all mountpoints relevant for the device * the old MOUNTPOINT is backwardly compatible and it (usually) displays the last device mountpoint from /proc/self/mountinfo For example btrfs with more subvolumes: $ lsblk -o+MOUNTPOINTS /dev/sdc1 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT MOUNTPOINTS sdc1 8:33 0 50M 0 part /mnt/test /mnt/A /mnt/test /mnt/B Note, in this case MOUNTPOINT displays mount point where is mounted root of the filesystem. Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-24lsblk: add dependence between CD/DVD block and packet devicesKarel Zak1-4/+30
This dependence is defined by   $ cat /sys/class/pktcdvd/device_map pktcdvd0 252:0 11:0 Unfortunately, there is not any direct sysfs way how to refer this relationship in /sys/{block,dev/block}. So, we have to read the device_map file and then compare device numbers with the list. $ lsblk /dev/sr0 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 1024M 0 rom └─pktcdvd0 252:0 1 0B 0 disk Addresses: https://github.com/karelzak/util-linux/issues/1185 Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-12bash-completion: (lsblk) update columnsKarel Zak1-1/+1
and fix lsblk --help output Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-12lsblk: add --width optionKarel Zak1-2/+12
Addresses: https://github.com/karelzak/util-linux/issues/1160 Signed-off-by: Karel Zak <kzak@redhat.com>
2020-09-09lsblk: show all empty, except loopdevsKarel Zak1-4/+9
This patch improves the previous commit to accept also another empty devices. Addresses: https://github.com/karelzak/util-linux/issues/1118 Signed-off-by: Karel Zak <kzak@redhat.com>
2020-09-09lsblk: ignore only loopdevs without backing fileKarel Zak1-1/+11
* do not ignore all empty devices, we need more smart solution * ignore only loop devices without backing file, for example: # touch img # losetup -f img losetup: img: Warning: file is smaller than 512 bytes; the loop device may be useless or invisible for system tools. - old version display nothing - new version: # lsblk /dev/loop0 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 0B 0 loop Addresses: https://github.com/karelzak/util-linux/issues/1118 Signed-off-by: Karel Zak <kzak@redhat.com>
2020-09-09lsblk: print zero rather than empty SIZEKarel Zak1-2/+0
Addresses: https://github.com/karelzak/util-linux/issues/1118 Signed-off-by: Karel Zak <kzak@redhat.com>
2020-09-02lsblk: fix -T optional argumentKarel Zak1-2/+5
Addresses: https://github.com/karelzak/util-linux/issues/1132 Signed-off-by: Karel Zak <kzak@redhat.com>
2020-07-14lsblk: Add SERIAL column to the SCSI output mode.Milan Broz1-0/+1
If there are several identical disks, disk serial number can help to distinguish exact drive. This could be helpful in debugging RAID failures and similar problems. Signed-off-by: Milan Broz <gmazyland@gmail.com>
2020-05-14lsblk: Ignore hidden devicesRitika Srivastava1-0/+5
Lsblk throws the following error for nvmeNcXnY devices. lsblk: nvme1c1n1: unknown device name This is because nvmeNcXnY devices are hidden and do not have the file /sys/block/<nvmeNcXnY>/dev. Following patch was added https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/commit/?id=d51f05bfecb299a830897106460bf395be440c0a Which made lsblk read from /sys/block/<nvmeNcXnY>/device/dev which do exist for nvmeNcXnY devices. After the above patch, the unknown error goes away. However, another error is encountered in the very next step. nvme1c1n1: failed to initialize sysfs handler This is because lsblk looks for /sys/dev/block/242:1 (nvmeNcXnY major:minor) pathname which usually exists for other block devices but not for the nvmeNcXnY devices as they are hidden. Below patch does not even print this error for hidden devices and exits silently. [kzak@redhat.com: - add prefix to make sysfs_devname_is_hidden() usable for /sys dumps - use the function in initialize_device() more early] Signed-off-by: Ritika Srivastava <ritika.srivastava@oracle.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-06lsblk: add dax (direct access) capability columnAnthony Iliopoulos1-0/+5
Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
2020-02-25lsblk: fix -P regression from v2.34Karel Zak1-4/+5
Since v2.34 --list prints devices only once to make the output user-readable. Unfortunately, it's regression for scripts/applications where we need to parse lsblk output. So, let's make --pairs and --raw backwardly compatible with versions before 2.34 and print all hierarchy. Addresses: https://github.com/ibm-s390-tools/s390-tools/issues/80 Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-04lsblk: add PARTTYPENAME columnKarel Zak1-1/+12
Print also partition type in human-readable way. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1777261 Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-15lsblk: add FSVER to --fsKarel Zak1-0/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-12lsblk: add FSVER (filesystem version) columnKarel Zak1-0/+7
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1764523 Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-15lsblk: read also GROUP,OWNER and MODE from dumpsKarel Zak1-19/+31
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-14include/xalloc: ensure xstrdup() and xstrndup() returns nonnull attributeSami Kerola1-1/+7
Turned out lsblk is passing null as argument to xstrdup(), so fix that and add assert() to make sure promise of not returning null is kept in future. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-06-27lsblk: force to print PKNAME for partitionKarel Zak1-0/+3
PKNAME (parent kernel device name) is based on printed tree according to parent -> child relationship. The tree is optional and not printed if partition specified (.e.g "lsblk -o+PKNAME /dev/sda1"), but old versions print the PKNAME also in this case. Addresses: https://github.com/karelzak/util-linux/issues/813 Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23lsblk: make sure __process_one_device() has proper arguments [coverity scan]Karel Zak1-2/+7
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23lsblk: check ul_path_scanf() return value [coverity scan]Karel Zak1-4/+5
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23lsblk: check stat() return code [coverity scan]Karel Zak1-2/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-06lsblk: fix heap-use-after-freeKarel Zak1-0/+1
Addresses: https://github.com/karelzak/util-linux/issues/787 Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-02lsblk: add more debug messagesKarel Zak1-5/+15
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16misc: consolidate version printing and close_stdout()Karel Zak1-8/+8
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-11lib/fileutils: add xreaddir()Karel Zak1-18/+1
Remove duplicate code and keep only one implementation in include/fileutils.h. Signed-off-by: Karel Zak <kzak@redhat.com>
2019-03-19lscpu: fix excl[] array orderKarel Zak1-0/+1
It (rows and columns) must be in ASCII order. Signed-off-by: Karel Zak <kzak@redhat.com>
2019-03-18lsblk: force tree on --json --tree independently on used columnsKarel Zak1-0/+9
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-20lsblk: allow to specify tree columnKarel Zak1-9/+17
* document --tree (was missing in the man page) * add optional argument to --tree to specify tree For example: $ lsblk -o KNAME,SIZE,MOUNTPOINT --tree=KNAME /dev/dm-0 KNAME SIZE MOUNTPOINT dm-0 232.9G └─dm-1 232.9G └─dm-2 232.9G Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-10lsblk: fix null pointer dereferencesSami Kerola1-2/+2
Both catched with -Wnull-dereference compiler option: Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-12-07lsblk: add --mergeKarel Zak1-19/+52
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: add --dedup <column>Karel Zak1-2/+64
The target use-case are systems with large number of multi-path devices or systems with duplicate (copied) filesystems. The feature is flexible enough to use arbitrary column (for example WWM or UUID, ...) as de-duplication key. For example tree with multi-path devices sd{c,d,e,f} ./lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 223.6G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi ├─sda2 8:2 0 200M 0 part /boot ├─sda3 8:3 0 130.3G 0 part ├─sda4 8:4 0 50G 0 part / └─sda5 8:5 0 42.9G 0 part sdb 8:16 0 74.5G 0 disk └─sdb1 8:17 0 74.5G 0 part /home/archive sdc 8:32 0 100M 0 disk └─mpatha 253:0 0 100M 0 mpath ├─mpatha1 253:1 0 50M 0 part └─mpatha2 253:2 0 49M 0 part sdd 8:48 0 100M 0 disk └─mpatha 253:0 0 100M 0 mpath ├─mpatha1 253:1 0 50M 0 part └─mpatha2 253:2 0 49M 0 part sde 8:64 0 100M 0 disk └─mpatha 253:0 0 100M 0 mpath ├─mpatha1 253:1 0 50M 0 part └─mpatha2 253:2 0 49M 0 part sdf 8:80 0 100M 0 disk └─mpatha 253:0 0 100M 0 mpath ├─mpatha1 253:1 0 50M 0 part └─mpatha2 253:2 0 49M 0 part De-duplicate by WWN: ./lsblk -M WWN NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 223.6G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi ├─sda2 8:2 0 200M 0 part /boot ├─sda3 8:3 0 130.3G 0 part ├─sda4 8:4 0 50G 0 part / └─sda5 8:5 0 42.9G 0 part sdb 8:16 0 74.5G 0 disk └─sdb1 8:17 0 74.5G 0 part /home/archive sdc 8:32 0 100M 0 disk └─mpatha 253:0 0 100M 0 mpath ├─mpatha1 253:1 0 50M 0 part └─mpatha2 253:2 0 49M 0 part Addresses: https://github.com/karelzak/util-linux/issues/616 Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: remember whole-disk, remove unused struct memberKarel Zak1-8/+12
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: make device_get_data() more genericKarel Zak1-56/+78
* independent on smartcols line * keep sort data optional Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: apply --nodeps to partitions tooKarel Zak1-3/+3
The new implementation differentiates between partitions and another dependences -- this is regression, we need root devices only. Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: read queue/discard_granularity only when necessaryKarel Zak1-12/+17
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: reuse 'removable' flag from parentKarel Zak1-5/+29
It's used in the default output, let's make it a little bit more effective. Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: don't keep sysfs dirs openKarel Zak1-16/+46
Don't keep open sysfs file descriptors for all time to avoid problems on systems with huge number of block devices. Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: rename set_device()Karel Zak1-6/+6
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: add commentsKarel Zak1-12/+46
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: add process_all_devices_inverse()Karel Zak1-35/+90
This is necessary to implement --inverse. Note that this new implementation scans /sys/dev/block/ to get top-level devices and than it calls process_one_device(). Note that standard non-inverse tree does not use process_one_device() as it's more effective to scan /sys/block where are no partitions. Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: reorder functionsKarel Zak1-56/+57
The goal is to call process_one_device() from process_all_devices(), so let's it keep in code in the right order. Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: make process_partitions() more readableKarel Zak1-11/+11
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: remove unncessary parent pointerKarel Zak1-32/+18
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: use real rather than hardcoded parentKarel Zak1-4/+9
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: use devtree functionsKarel Zak1-92/+104
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: process_one_device() refactoringKarel Zak1-11/+24
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: add devtree_get_device_or_new()Karel Zak1-13/+26
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: keep functions names consistentKarel Zak1-12/+12
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: remove unused reset_device()Karel Zak1-25/+0
Now all is maintained by reference counting ion the devtree. Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: fix devtree deallocationKarel Zak1-2/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: split sysfs reading and scols table fillingKarel Zak1-22/+56
This change allows read devices from sysfs only once and reuse device properties if the device is references more than once in the tree (RAIDs, etc.). * every device is in the tree only once (tree->devices list) * iterate_block_devices() reuse already read devices (for example if already read for any dependence) * the smartscols table is build from the final tree The patch temporary disables dependencies evaluation (in process_blkdev() to keep the patch small and simple. Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: remove badly named debug interface nameKarel Zak1-20/+20
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: properly initialize structsKarel Zak1-4/+5
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: rename reset_lsblk_device() to reset_device()Karel Zak1-6/+6
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07lsblk: rename blkdev_cxt to lsblk_deviceKarel Zak1-232/+232
The patch does not change code logic and semantic -- just rename. * set_cxt() to set_device() * struct blkdev_cxt to lsblk_device Signed-off-by: Karel Zak <kzak@redhat.com>
2018-10-03lsblk: always use "part" as TYPE for partitionsKarel Zak1-1/+4
The current code uses "part" or "disk" only if nothing else is possible to recognize. It means for example partitions on loops (or RAIDs, etc) are marked as "loop" rather than "part". Addresses: https://github.com/karelzak/util-linux/issues/700 Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-19lsblk: move udev and blkid stuff to lsblk-properties.cKarel Zak1-193/+16
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-19lsblk: cleanup udev/blkid properties codeKarel Zak1-98/+124
* split properties to separate struct which is allocated only when udev or blkid provides some information * use separate function for udev and blkid and hide details in generic get_device_properties() * make sure we do not overwrite stuff udev and blkid (but this is only theoretic issue as we do not call get_properties_by_blkid() directly from code) Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14lsblk: encapsulate stat() usageKarel Zak1-12/+16
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14lsblk: differentiate between swap and mountKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14lsblk: use lsblk_ prefix mountpoint getterKarel Zak1-2/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14lsblk: init/deinit libmount stuffKarel Zak1-0/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14lsblk: move mount stuff to lsblk-mnt.cKarel Zak1-107/+0
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14lsblk: add lsblk.hKarel Zak1-81/+3
* move core struct to the header file * move debug stuff to the header file Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-13lsblk: add columns FSAVAIL,FSSIZE,FSUSED,FSUSE%Karel Zak1-6/+84
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-11lsblk: don't ask udev when --sysroot specifiedKarel Zak1-0/+2
We use --sysroot to get information about block devices from /proc and /sys dumps. In this case does not make sense to read anything from udev as udevd is about the current system devices. Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-10lsblk: prefer MODEL from udev DBKarel Zak1-2/+12
sysfs device model is truncated to 16 characters: > cat /sys/block/sda/device/model Crucial_CT128MX1 > udevadm info --query=property /dev/sda | grep MODEL= ID_MODEL=Crucial_CT128MX100SSD1 sysfs uses INQUARY response which has the 16 characters limitation and udev uses something else. Addresses: https://github.com/karelzak/util-linux/issues/690 Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-10lsblk: add PATH columnKarel Zak1-0/+6
$ lsblk -o+PATH NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT PATH sda 8:0 0 223.6G 0 disk /dev/sda ├─sda1 8:1 0 200M 0 part /boot/efi /dev/sda1 ├─sda2 8:2 0 200M 0 part /boot /dev/sda2 ├─sda3 8:3 0 130.3G 0 part /dev/sda3 ├─sda4 8:4 0 50G 0 part / /dev/sda4 ├─sda5 8:5 0 35.1G 0 part /dev/sda5 └─sda6 8:6 0 7.8G 0 part /dev/sda6 Requested-by: Marcel Partap <mpartap@gmx.net> Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21lsblk: fix ul_path_read_string() usageKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21lsblk: fix COL_SCHEDKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21lsblk: document --sysrootKarel Zak1-0/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21lsblk: fix sysfs_devno_to_devname() usageKarel Zak1-0/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21lsblk: follow --sysroot when read mountpointsKarel Zak1-2/+16
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21lsblk: use prefix for DM nameKarel Zak1-4/+14
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21lsblk: add --sysrootKarel Zak1-3/+13
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21lsblk: use new ul_path_* APIKarel Zak1-94/+82
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-19lsblk: add partition table UUID and type fields.Milan Broz1-0/+27
This patch adds PTUUID and PTTYPE fields to lsblk, that are corresponding fields to ID_PART_TABLE_UUID and ID_PART_TABLE_TYPE in udev database. [kzak@redhat.com: - small change in PTUUID description] Signed-off-by: Milan Broz <gmazyland@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-15lsblk: don't exclude RAM disks on --allKarel Zak1-1/+1
Reported-by: Milan Broz <gmazyland@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-03lsblk: consolidate column types for JSON and qsort()Karel Zak1-24/+47
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-17include/debug: introduce __UL_INIT_DEBUG_FROM_STRING()Karel Zak1-1/+1
Let's make it possible to use debug.h without environment variables. Suggested-by: J William Piggott <elseifthen@gmx.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-12include/debug: don't print pointer address for SUID programsKarel Zak1-0/+2
* introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing * use __UL_DEBUG_FL_NOADDR when SUID * move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK to provide access to the current mask from ul_debugobj(). It's better than modify all ul_debugobj() calls and use the global mask as argument. * remove never used UL_DEBUG_DEFINE_FLAG Reported-by: halfdog <me@halfdog.net> Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-29misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier1-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>
2017-06-27misc: introduce print_usage_help_options()Ruediger Meier1-2/+1
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>
2017-06-26misc: cosmetics, remove argument from usage(FILE*)Ruediger Meier1-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>
2017-06-26misc: consolidate usage() "Available columns"Karel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-09lsblk: add option --treeKarel Zak1-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>
2017-05-18misc: consolidate smartcols error messagesKarel Zak1-5/+5
... just to keep translators happy Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-19lsblk: don't duplicate columnsKarel Zak1-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>
2017-04-19lsblk: add ZONED columnDamien Le Moal1-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>
2017-04-13lsblk: fix --inverse --listKarel Zak1-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>
2017-04-13lsblk: move scols_flags to lsblk control structKarel Zak1-18/+19
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-20misc: add static keyword to where needed [smatch scan]Sami Kerola1-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>
2017-02-20misc: do not use plain 0 as NULL [smatch scan]Sami Kerola1-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>
2017-02-13docs: Fix word repetitionsYuri Chornoivan1-1/+1
2016-12-19lsblk: use errtryhelp()Karel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-11-02lsblk: sort by MAJ:MIN by defaultKarel Zak1-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>
2016-06-02lsblk: improve support for nvmeKarel Zak1-1/+5
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-31misc: Fix various typosSebastian Rasmussen1-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>
2016-05-25lsblk: use ID_WWN_WITH_EXTENSION is possibleKarel Zak1-1/+6
Addresses: https://github.com/karelzak/util-linux/issues/321 Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-16mount, umount, swapon, fsck, lsblk, findmnt: harmonize six error messagesBenno Schulenberg1-2/+1
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-08Revert "include sysmacros.h where used"Karel Zak1-1/+0
This reverts commit 46a40c018438b7b2b25083a5e5a4a21055a0c1e9.
2016-03-08include sysmacros.h where usedMike Frysinger1-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>
2016-03-07lib: remove openat fallback functions (include/at.h)Ruediger Meier1-8/+3
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>
2016-02-18lib: rename strmode() and setmode()Ruediger Meier1-1/+1
On BSD they are part of the standard C library. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-03docs: fix typos found by codespellRuediger Meier1-1/+1
Using "codespell" from https://github.com/lucasdemarchi/codespell Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-01-22lsblk: remove useless warningsKarel Zak1-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>
2016-01-12lsblk: use unsigned type for SIZEKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-10lsblk: allow to --sort by hidden columnKarel Zak1-2/+8
For example: lsblk -o NAME --sort SIZE prints NAMEs, but sort by SIZEs. Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-15mount, umount, swapon, fsck, lsblk, findmnt: ignore malformed linesKarel Zak1-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>
2015-08-31lsblk: fix resource leak [coverity scan]Andreas Henriksson1-1/+3
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2015-07-31lsblk: Display mountpoint even for top-level deviceMilan Broz1-2/+1
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>
2015-06-04lsblk: add --jsonKarel Zak1-2/+14
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-29lsblk: use internally sysfs devnamesKarel Zak1-5/+4
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>
2015-05-28lib/sysfs: rename devname functions, cleanupKarel Zak1-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>
2015-05-26Fix /sys to /dev node name translationStanislav Brabec1-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>
2015-04-22lib/strutils: fix string_add_to_idarray() int vs. size_tKarel Zak1-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>
2015-04-01lsblk: don't ignore dependences for partitioned deviesKarel Zak1-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>
2015-04-01lsblk: follow kernel for inverse treeKarel Zak1-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>
2015-04-01lsblk: add debug supportKarel Zak1-11/+76
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-29lsblk: implement SOMEOK (=64) return codeKarel Zak1-13/+27
Signed-off-by: Karel Zak <kzak@redhat.com>