]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: adjust "partno" column
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 24 Oct 2025 08:34:17 +0000 (10:34 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 17 Nov 2025 13:36:27 +0000 (22:36 +0900)
In a typical output from systemd-repart, the output is very wide any any wasted
space is bad because it pushes the interesting information even further to the
right. We usually need at most one or two digits to express the partition
numbers, so let's shorten the title of the column to effectively remove two
columns in the output.

In JSON output, the old field name is retained. This follows the pattern
already used for field "drop-in_files".

Also right-align the columns with numbers always to the right. I doesn't make
sense to align the columns which are only used for JSON output, so stop setting
alignment for those.

src/repart/repart.c

index 698bbfab62c1d1e3fc8877590e87102dea1f4995..d0087771d49dbbb20a26ba7b99472daeaee0f6c8 100644 (file)
@@ -3988,17 +3988,17 @@ static int context_dump_partitions(Context *context) {
                 return 0;
         }
 
-        t = table_new("type",
+        t = table_new("type",         /* 0 */
                       "label",
                       "uuid",
-                      "partno",
+                      "part",
                       "file",
                       "node",
                       "offset",
                       "old size",
                       "raw size",
                       "size",
-                      "old padding",
+                      "old padding",  /* 10 */
                       "raw padding",
                       "padding",
                       "activity",
@@ -4008,6 +4008,9 @@ static int context_dump_partitions(Context *context) {
         if (!t)
                 return log_oom();
 
+        /* For compatiblity, use the original longer name for JSON output. */
+        table_set_json_field_name(t, 3, "partno");
+
         /* Starting in v257, these fields would be automatically formatted with underscores. This would have
          * been a breaking change, so to avoid that let's hard-code their original names. */
         table_set_json_field_name(t, 15, "drop-in_files");
@@ -4024,13 +4027,13 @@ static int context_dump_partitions(Context *context) {
                                                     split_path_col);
         }
 
-        (void) table_set_align_percent(t, table_get_cell(t, 0, 5), 100);
+        (void) table_set_align_percent(t, table_get_cell(t, 0, 3), 100);
         (void) table_set_align_percent(t, table_get_cell(t, 0, 6), 100);
         (void) table_set_align_percent(t, table_get_cell(t, 0, 7), 100);
         (void) table_set_align_percent(t, table_get_cell(t, 0, 8), 100);
         (void) table_set_align_percent(t, table_get_cell(t, 0, 9), 100);
-        (void) table_set_align_percent(t, table_get_cell(t, 0, 10), 100);
         (void) table_set_align_percent(t, table_get_cell(t, 0, 11), 100);
+        (void) table_set_align_percent(t, table_get_cell(t, 0, 12), 100);
 
         LIST_FOREACH(partitions, p, context->partitions) {
                 _cleanup_free_ char *size_change = NULL, *padding_change = NULL, *partname = NULL, *rh = NULL;