]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
losetup: fix JSON MAJ:MIN
authorKarel Zak <kzak@redhat.com>
Mon, 28 Aug 2023 11:21:33 +0000 (13:21 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 28 Aug 2023 11:55:59 +0000 (13:55 +0200)
Fixes: https://github.com/util-linux/util-linux/issues/2460
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/losetup.c

index dfdfc58721404831f00c506222dc4d1fe85dfc50..e17b4a3e458b805fc5420f702008c3756ccc2703 100644 (file)
@@ -255,7 +255,8 @@ static int set_scols_data(struct loopdev_cxt *lc, struct libscols_line *ln)
                {
                        dev_t dev = 0;
                        if (loopcxt_get_backing_devno(lc, &dev) == 0 && dev)
-                               xasprintf(&np, "%8u:%-3u", major(dev), minor(dev));
+                               xasprintf(&np, raw || json ? "%u:%u" : "%8u:%-3u",
+                                               major(dev), minor(dev));
                        break;
                }
                case COL_MAJMIN:
@@ -266,8 +267,8 @@ static int set_scols_data(struct loopdev_cxt *lc, struct libscols_line *ln)
                            && stat(loopcxt_get_device(lc), &st) == 0
                            && S_ISBLK(st.st_mode)
                            && major(st.st_rdev) == LOOPDEV_MAJOR)
-                               xasprintf(&np, "%3u:%-3u", major(st.st_rdev),
-                                                          minor(st.st_rdev));
+                               xasprintf(&np, raw || json ? "%u:%u" :"%3u:%-3u",
+                                               major(st.st_rdev), minor(st.st_rdev));
                        break;
                }
                case COL_BACK_INO: