From: Pali Rohár Date: Thu, 5 Nov 2020 18:21:15 +0000 (+0100) Subject: libblkid: detect session_offset hint for optical discs X-Git-Tag: v2.37-rc1~266^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=427ea35512b0edc012cf1e5bac5ff6295f912a1d;p=thirdparty%2Futil-linux.git libblkid: detect session_offset hint for optical discs When offset and session_offset hint are not specified then sets session_offset hint from CDROMMULTISESSION ioctl which returns start position of the last session of multisession optical disc. It is expected that session_offset hint contains position offset in bytes where starts session of multisession optical disc which should be read. Filesystems designed for optical discs are expected to use this value when dealing with multisession optical disc to know where they should start reading optical disc or image of optical disc. Signed-off-by: Pali Rohár --- diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c index 0128b38a9c..eb71e48d4a 100644 --- a/libblkid/src/probe.c +++ b/libblkid/src/probe.c @@ -983,6 +983,14 @@ int blkid_probe_set_device(blkid_probe pr, int fd, if (pr->flags & BLKID_FL_CDROM_DEV) { cdrom_size_correction(pr, last_written); + +# ifdef CDROMMULTISESSION + if (!pr->off && blkid_probe_get_hint(pr, "session_offset", NULL) < 0) { + struct cdrom_multisession multisession = { .addr_format = CDROM_LBA }; + if (ioctl(fd, CDROMMULTISESSION, &multisession) == 0 && multisession.xa_flag) + blkid_probe_set_hint(pr, "session_offset", (multisession.addr.lba << 11)); + } +# endif } } #endif