]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: detect session_offset hint for optical discs
authorPali Rohár <pali.rohar@gmail.com>
Thu, 5 Nov 2020 18:21:15 +0000 (19:21 +0100)
committerPali Rohár <pali.rohar@gmail.com>
Tue, 10 Nov 2020 22:40:52 +0000 (23:40 +0100)
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 <pali.rohar@gmail.com>
libblkid/src/probe.c

index 0128b38a9c641799886c8a6b02630802351f667d..eb71e48d4ae635f515a328d3106ba6055253ab85 100644 (file)
@@ -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