From: Pali Rohár Date: Thu, 5 Nov 2020 18:22:58 +0000 (+0100) Subject: libblkid: iso9660: add support for multisession via session_offset hint X-Git-Tag: v2.37-rc1~266^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf2f10bb5929e6b28195017de99f1ec1843e0671;p=thirdparty%2Futil-linux.git libblkid: iso9660: add support for multisession via session_offset hint 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 --- diff --git a/libblkid/src/superblocks/iso9660.c b/libblkid/src/superblocks/iso9660.c index 1057da8614..6e0073c7e5 100644 --- a/libblkid/src/superblocks/iso9660.c +++ b/libblkid/src/superblocks/iso9660.c @@ -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 } } };