From 4cbf9d52f3687b1e2d903e50755fdad2a45ba082 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 13 Nov 2023 14:38:40 +0100 Subject: [PATCH 1/3] mount-tool: reduce scope of enum --- src/mount/mount-tool.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c index 90feb2f197..29bde2ab8e 100644 --- a/src/mount/mount-tool.c +++ b/src/mount/mount-tool.c @@ -1410,18 +1410,18 @@ static int discover_device(void) { return 0; } -enum { - COLUMN_NODE, - COLUMN_PATH, - COLUMN_MODEL, - COLUMN_WWN, - COLUMN_FSTYPE, - COLUMN_LABEL, - COLUMN_UUID, - _COLUMN_MAX, -}; - static int list_devices(void) { + enum { + COLUMN_NODE, + COLUMN_PATH, + COLUMN_MODEL, + COLUMN_WWN, + COLUMN_FSTYPE, + COLUMN_LABEL, + COLUMN_UUID, + _COLUMN_MAX, + }; + _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL; _cleanup_(table_unrefp) Table *table = NULL; int r; From 409614382714832673df753251de58a50aeda5bd Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 13 Nov 2023 14:39:04 +0100 Subject: [PATCH 2/3] mount-tool: rely on format-table.c's ersatz logic Let the table logic handle the special casing ov unavailable data, rather than doing that ourselves. --- src/mount/mount-tool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c index 29bde2ab8e..53c1102267 100644 --- a/src/mount/mount-tool.c +++ b/src/mount/mount-tool.c @@ -1450,6 +1450,7 @@ static int list_devices(void) { return log_error_errno(r, "Failed to set sort index: %m"); table_set_header(table, arg_legend); + table_set_ersatz_string(table, TABLE_ERSATZ_DASH); FOREACH_DEVICE(e, d) { for (unsigned c = 0; c < _COLUMN_MAX; c++) { @@ -1486,7 +1487,7 @@ static int list_devices(void) { break; } - r = table_add_cell(table, NULL, c == COLUMN_NODE ? TABLE_PATH : TABLE_STRING, strna(x)); + r = table_add_cell(table, NULL, c == COLUMN_NODE ? TABLE_PATH : TABLE_STRING, x); if (r < 0) return table_log_add_error(r); } From b86155d0710ce1236a4c1be41518b27eccea95d9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 13 Nov 2023 16:12:03 +0100 Subject: [PATCH 3/3] mount-tool: make internal and external column name match --- src/mount/mount-tool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c index 53c1102267..3e19d4bbe5 100644 --- a/src/mount/mount-tool.c +++ b/src/mount/mount-tool.c @@ -1438,7 +1438,7 @@ static int list_devices(void) { if (r < 0) return log_error_errno(r, "Failed to add property match: %m"); - table = table_new("NODE", "PATH", "MODEL", "WWN", "TYPE", "LABEL", "UUID"); + table = table_new("NODE", "PATH", "MODEL", "WWN", "FSTYPE", "LABEL", "UUID"); if (!table) return log_oom();