summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/grouping.c
Commit message (Collapse)AuthorAgeFilesLines
* libsmartcols: fix docsKarel Zak2019-06-131-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: (groups) improve scols_table_group_lines() args check ↵Karel Zak2019-05-151-3/+3
| | | | | | [coverity scan] Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: (groups) use print functions tp calculate grpsetKarel Zak2019-05-031-68/+2Star
| | | | | | | Now we have extra code to calculate grpset. It seems better to use only one way how we wall the tree. Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: (groups) print group childrent after regualr treeKarel Zak2019-05-031-1/+27
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: (groups) improve debug messagesKarel Zak2019-05-031-1/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: fix groups reset, add debugsKarel Zak2019-05-021-11/+26
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: (groups) remove hardcoded const numbersKarel Zak2019-05-021-12/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: fix typos [codespell]Sami Kerola2019-02-181-2/+2
| | | | | Reference: https://github.com/codespell-project/codespell Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libsmartcols: use list_add_tail() in more robust wayKarel Zak2019-02-181-0/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: remove extra ';' outside of a function [-Wextra-semi]Sami Kerola2019-01-021-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libsmartcols: fix variable shadowingSami Kerola2018-12-101-2/+2
| | | | | | | | libsmartcols/src/grouping.c:115:26: warning: declaration of ‘ln’ shadows a previous local [-Wshadow] libsmartcols/src/grouping.c:108:24: note: shadowed declaration is here Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libsmartcols: add lines grouping supportKarel Zak2018-12-071-0/+587
For some use-case we need to describe M:N relation between output lines. The nice examples are RAIDs or multi-path devices in lsblk output. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 955.7M 0 loop ┌┈▶ ├─test-thin-metadata 253:0 0 2M 0 dm └┬▶ └─test-thin-data 253:1 0 953.7M 0 dm └┈┈test-thin-pool 253:2 0 953.7M 0 dm In this example two line (test-thin-metadata and test-thin-data) are parents for another line (test-thin-pool). The new API uses term "group" for parental line -- the number of group members is unlimited and every group has at least one child. It's possible that group's child is member of another group: NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 955.7M 0 loop ┌┈▶ ├─test-thin-metadata 253:0 0 2M 0 dm └┬▶ └─test-thin-data 253:1 0 953.7M 0 dm ┌┈▶ └┈┈test-thin-pool 253:2 0 953.7M 0 dm ┆ └─test-thin 253:3 0 190.8M 0 dm └┬▶ loop1 7:1 0 190.8M 0 loop └┈┈┈┈┈test-thin-extsnap 253:4 0 190.8M 0 dm For now multi-group relation is unsupported and one line can be member of one group only. The library API and printing code is ready to support this feature, but not sure if we really need it. All what is necessary is to create array of groups in the line struct. Note that grouping is independent on standard parent->child relations between lines and grouping can connect arbitrary lines. The restriction is only that group child cannot be child of another line or child of another group. These cross reference are (and probably will be) impossible. The patch is relative large, but easy to review. Changes: * add new UTF symbols * add scols_symbols_set_group_* public API to modify new symbols * add struct libscols_group, used only internally * add "grpset" array to table struct -- the array is used to keep position of the group in the output. Every active group uses three items in the grpset. If there is more overlapping groups than bigger grpset is allocated. Signed-off-by: Karel Zak <kzak@redhat.com>