summaryrefslogtreecommitdiffstats
path: root/misc-utils/lsblk.c
Commit message (Collapse)AuthorAgeFilesLines
* include/xalloc: ensure xstrdup() and xstrndup() returns nonnull attributeSami Kerola2019-07-141-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>
* lsblk: force to print PKNAME for partitionKarel Zak2019-06-271-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>
* lsblk: make sure __process_one_device() has proper arguments [coverity scan]Karel Zak2019-05-231-2/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: check ul_path_scanf() return value [coverity scan]Karel Zak2019-05-231-4/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: check stat() return code [coverity scan]Karel Zak2019-05-231-2/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: fix heap-use-after-freeKarel Zak2019-05-061-0/+1
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/787 Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: add more debug messagesKarel Zak2019-05-021-5/+15
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-8/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/fileutils: add xreaddir()Karel Zak2019-04-111-18/+1Star
| | | | | | | Remove duplicate code and keep only one implementation in include/fileutils.h. Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: fix excl[] array orderKarel Zak2019-03-191-0/+1
| | | | | | It (rows and columns) must be in ASCII order. Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: force tree on --json --tree independently on used columnsKarel Zak2019-03-181-0/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: allow to specify tree columnKarel Zak2019-02-201-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>
* lsblk: fix null pointer dereferencesSami Kerola2018-12-101-2/+2
| | | | | | Both catched with -Wnull-dereference compiler option: Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lsblk: add --mergeKarel Zak2018-12-071-19/+52
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: add --dedup <column>Karel Zak2018-12-071-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>
* lsblk: remember whole-disk, remove unused struct memberKarel Zak2018-12-071-8/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: make device_get_data() more genericKarel Zak2018-12-071-56/+78
| | | | | | | * independent on smartcols line * keep sort data optional Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: apply --nodeps to partitions tooKarel Zak2018-12-071-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>
* lsblk: read queue/discard_granularity only when necessaryKarel Zak2018-12-071-12/+17
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: reuse 'removable' flag from parentKarel Zak2018-12-071-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>
* lsblk: don't keep sysfs dirs openKarel Zak2018-12-071-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>
* lsblk: rename set_device()Karel Zak2018-12-071-6/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: add commentsKarel Zak2018-12-071-12/+46
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: add process_all_devices_inverse()Karel Zak2018-12-071-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>
* lsblk: reorder functionsKarel Zak2018-12-071-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>
* lsblk: make process_partitions() more readableKarel Zak2018-12-071-11/+11
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: remove unncessary parent pointerKarel Zak2018-12-071-32/+18Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: use real rather than hardcoded parentKarel Zak2018-12-071-4/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: use devtree functionsKarel Zak2018-12-071-92/+104
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: process_one_device() refactoringKarel Zak2018-12-071-11/+24
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: add devtree_get_device_or_new()Karel Zak2018-12-071-13/+26
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: keep functions names consistentKarel Zak2018-12-071-12/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: remove unused reset_device()Karel Zak2018-12-071-25/+0Star
| | | | | | Now all is maintained by reference counting ion the devtree. Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: fix devtree deallocationKarel Zak2018-12-071-2/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: split sysfs reading and scols table fillingKarel Zak2018-12-071-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>
* lsblk: remove badly named debug interface nameKarel Zak2018-12-071-20/+20
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: properly initialize structsKarel Zak2018-12-071-4/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: rename reset_lsblk_device() to reset_device()Karel Zak2018-12-071-6/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: rename blkdev_cxt to lsblk_deviceKarel Zak2018-12-071-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>
* lsblk: always use "part" as TYPE for partitionsKarel Zak2018-10-031-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>
* lsblk: move udev and blkid stuff to lsblk-properties.cKarel Zak2018-09-191-193/+16Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: cleanup udev/blkid properties codeKarel Zak2018-09-191-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>
* lsblk: encapsulate stat() usageKarel Zak2018-09-141-12/+16
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: differentiate between swap and mountKarel Zak2018-09-141-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: use lsblk_ prefix mountpoint getterKarel Zak2018-09-141-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: init/deinit libmount stuffKarel Zak2018-09-141-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: move mount stuff to lsblk-mnt.cKarel Zak2018-09-141-107/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: add lsblk.hKarel Zak2018-09-141-81/+3Star
| | | | | | | * move core struct to the header file * move debug stuff to the header file Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: add columns FSAVAIL,FSSIZE,FSUSED,FSUSE%Karel Zak2018-09-131-6/+84
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: don't ask udev when --sysroot specifiedKarel Zak2018-09-111-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>