]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect-image: unknown/unsupported diskseq is indicated by 0, not by UINT64_MAX
authorLennart Poettering <lennart@poettering.net>
Fri, 10 Feb 2023 15:03:46 +0000 (16:03 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 10 Feb 2023 17:03:21 +0000 (18:03 +0100)
At almost all places if diskseq is not supported we encode this as
diskseq zero. But in two places we got the check for that wrong,
assuming it was UINT64_MAX.

Fix that.

src/shared/dissect-image.c

index c0d052e0ea36dd9da9363593491f0a6a05e9c659..a71f11794cf3363da087d01fee4e54806a595bc9 100644 (file)
@@ -435,7 +435,7 @@ static int make_partition_devname(
         assert(nr != 0); /* zero is not a valid partition nr */
         assert(ret);
 
-        if (!FLAGS_SET(flags, DISSECT_IMAGE_DISKSEQ_DEVNODE) || diskseq == UINT64_MAX) {
+        if (!FLAGS_SET(flags, DISSECT_IMAGE_DISKSEQ_DEVNODE) || diskseq == 0) {
 
                 /* Given a whole block device node name (e.g. /dev/sda or /dev/loop7) generate a partition
                  * device name (e.g. /dev/sda7 or /dev/loop7p5). The rule the kernel uses is simple: if whole
@@ -499,7 +499,7 @@ static int open_partition(
                 return -ENXIO;
 
         /* Also check diskseq. */
-        if (loop->diskseq > 0) {
+        if (loop->diskseq != 0) {
                 uint64_t diskseq;
 
                 r = fd_get_diskseq(fd, &diskseq);
@@ -573,7 +573,7 @@ static int dissect_image(
          * Returns -ENXIO if we couldn't find any partition suitable as root or /usr partition
          * Returns -ENOTUNIQ if we only found multiple generic partitions and thus don't know what to do with that */
 
-        uint64_t diskseq = m->loop ? m->loop->diskseq : UINT64_MAX;
+        uint64_t diskseq = m->loop ? m->loop->diskseq : 0;
 
         if (verity && verity->root_hash) {
                 sd_id128_t fsuuid, vuuid;