]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: iso9660: add support for multisession via session_offset hint
authorPali Rohár <pali.rohar@gmail.com>
Thu, 5 Nov 2020 18:22:58 +0000 (19:22 +0100)
committerPali Rohár <pali.rohar@gmail.com>
Tue, 10 Nov 2020 22:40:53 +0000 (23:40 +0100)
The only required change is to read disc from offset specified by
session_offset instead of beginning of disc (offset 0).

So either blkid's --offset or --hint session_offset argument would work for
correct detection of multisession ISO9660 optical disc or disc image.

Although the ISO9660 specification allows also non-2kB sector sizes,
current blkid implementation has hardcoded ISO9660 sector size to 2kB.
Therefore there is check that session_offset is multiple of 2048.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
libblkid/src/superblocks/iso9660.c

index 1057da8614f62e383a368f0c08477024995d2c55..6e0073c7e5a07570035eb7c87ae4b023c50afaad 100644 (file)
@@ -171,7 +171,13 @@ static int probe_iso9660(blkid_probe pr, const struct blkid_idmag *mag)
        struct iso_volume_descriptor *iso;
        unsigned char label[32];
        int i;
-       int off;
+       uint64_t off;
+
+       if (blkid_probe_get_hint(pr, mag->hoff, &off) < 0)
+               off = 0;
+
+       if (off % 2048)
+               return 1;
 
        if (strcmp(mag->magic, "CDROM") == 0)
                return probe_iso9660_hsfs(pr, mag);
@@ -201,7 +207,7 @@ static int probe_iso9660(blkid_probe pr, const struct blkid_idmag *mag)
                probe_iso9660_set_uuid(pr, &iso->created);
 
        /* Joliet Extension and Boot Record */
-       off = ISO_VD_OFFSET;
+       off += ISO_VD_OFFSET;
        for (i = 0; i < ISO_VD_MAX; i++) {
                struct boot_record *boot= (struct boot_record *)
                        blkid_probe_get_buffer(pr,
@@ -267,8 +273,8 @@ const struct blkid_idinfo iso9660_idinfo =
        .flags          = BLKID_IDINFO_TOLERANT,
        .magics         =
        {
-               { .magic = "CD001", .len = 5, .kboff = 32, .sboff = 1 },
-               { .magic = "CDROM", .len = 5, .kboff = 32, .sboff = 9 },
+               { .magic = "CD001", .len = 5, .kboff = 32, .sboff = 1, .hoff = "session_offset" },
+               { .magic = "CDROM", .len = 5, .kboff = 32, .sboff = 9, .hoff = "session_offset" },
                { NULL }
        }
 };