]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: udf: add support for unclosed sequential Write-Once media
authorPali Rohár <pali.rohar@gmail.com>
Sun, 8 Nov 2020 13:24:06 +0000 (14:24 +0100)
committerPali Rohár <pali.rohar@gmail.com>
Tue, 10 Nov 2020 22:40:53 +0000 (23:40 +0100)
libblkid/src/superblocks/udf.c

index 97ecdcbe4ff546253fd1529cde7766cd1fc8df7f..1d7820ff19139615c127a410f994cbd33326b062 100644 (file)
@@ -276,12 +276,24 @@ anchor:
                        return errno ? -errno : 1;
 
                /* Check that we read correct sector and detected correct block size */
-               if (le32_to_cpu(vd->tag.location) != s_off / pbs[i] + 256)
-                       continue;
+               if (le32_to_cpu(vd->tag.location) == s_off / pbs[i] + 256) {
+                       type = le16_to_cpu(vd->tag.id);
+                       if (type == TAG_ID_AVDP)
+                               goto real_blksz;
+               }
 
-               type = le16_to_cpu(vd->tag.id);
-               if (type == TAG_ID_AVDP)
-                       goto real_blksz;
+               /* UDF-2.60: 2.2.3: Unclosed sequential Write-Once media may
+                * have a single AVDP present at either sector 256 or 512. */
+               vd = (struct volume_descriptor *)
+                       blkid_probe_get_buffer(pr, s_off + 512 * pbs[i], sizeof(*vd));
+               if (!vd)
+                       return errno ? -errno : 1;
+
+               if (le32_to_cpu(vd->tag.location) == s_off / pbs[i] + 512) {
+                       type = le16_to_cpu(vd->tag.id);
+                       if (type == TAG_ID_AVDP)
+                               goto real_blksz;
+               }
 
        }
        return 1;