]> 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>
Fri, 24 Nov 2023 09:32:53 +0000 (10:32 +0100)
Fixes: https://github.com/util-linux/util-linux/issues/2460
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/losetup.c

index 75071360d6e170c935cf5891551d737610088cd1..1705379ba1c84c3cb71a739892ce8194dc2c1502 100644 (file)
@@ -253,7 +253,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:
@@ -264,8 +265,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: