]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
probe.c (probe_udf): Add specific UDF probing code, and probe
authorTheodore Ts'o <tytso@mit.edu>
Tue, 22 Jul 2003 05:06:36 +0000 (01:06 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 22 Jul 2003 05:06:36 +0000 (01:06 -0400)
UDF before checking for ISO9660 filesystems.

lib/blkid/ChangeLog
lib/blkid/probe.c
lib/blkid/probe.h

index 2d01b919dbf51a6b21854a25e9678b9c27918720..0a4e790496241de3dbf07afcd522a6ec4428e2b8 100644 (file)
@@ -1,3 +1,8 @@
+2003-07-22  Theodore Ts'o  <tytso@mit.edu>
+
+       * probe.c (probe_udf): Add specific UDF probing code, and probe
+               UDF before checking for ISO9660 filesystems.
+
 2003-07-21  Theodore Ts'o  <tytso@mit.edu>
 
        * probe.c (blkid_known_fstype): New function which returns true if
index 2421fff19c06025e7a180359cd359ed68839613c..505400c50fb04acc42b51c20f72480174a2866e7 100644 (file)
@@ -244,6 +244,50 @@ static int probe_romfs(int fd, blkid_cache cache, blkid_dev dev,
        return 0;
 }
 
+static char
+*udf_magic[] = { "BEA01", "BOOT2", "CD001", "CDW02", "NSR02",
+                "NSR03", "TEA01", 0 };
+
+static int probe_udf(int fd, blkid_cache cache, blkid_dev dev,
+                      struct blkid_magic *id, unsigned char *buf)
+{
+       int j, bs;
+       struct iso_volume_descriptor isosb;
+       char **m;
+
+       /* determine the block size by scanning in 2K increments
+          (block sizes larger than 2K will be null padded) */
+       for (bs = 1; bs < 16; bs++) {
+               lseek(fd, bs*2048+32768, SEEK_SET);
+               if (read(fd, (char *)&isosb, sizeof(isosb)) != sizeof(isosb))
+                       return 1;
+               if (isosb.id[0])
+                       break;
+       }
+
+       /* Scan up to another 64 blocks looking for additional VSD's */
+       for (j = 1; j < 64; j++) {
+               if (j > 1) {
+                       lseek(fd, j*bs*2048+32768, SEEK_SET);
+                       if (read(fd, (char *)&isosb, sizeof(isosb))
+                           != sizeof(isosb))
+                               return 1;
+               }
+               /* If we find NSR0x then call it udf:
+                  NSR01 for UDF 1.00
+                  NSR02 for UDF 1.50
+                  NSR03 for UDF 2.00 */
+               if (!strncmp(isosb.id, "NSR0", 4))
+                       return 0;
+               for (m = udf_magic; *m; m++)
+                       if (!strncmp(*m, isosb.id, 5))
+                               break;
+               if (*m == 0)
+                       return 1;
+       }
+       return 1;
+}
+
 /*
  * BLKID_BLK_OFFS is at least as large as the highest bim_kboff defined
  * in the type_array table below + bim_kbalign.
@@ -283,15 +327,15 @@ static struct blkid_magic type_array[] = {
   { "bfs",      0,      0,  4, "\316\372\173\033",     0 },
   { "cramfs",   0,      0,  4, "E=\315\034",           0 },
   { "qnx4",     0,      4,  6, "QNX4FS",               0 },
+  { "udf",     32,      1,  5, "BEA01",                probe_udf },
+  { "udf",     32,      1,  5, "BOOT2",                probe_udf },
+  { "udf",     32,      1,  5, "CD001",                probe_udf },
+  { "udf",     32,      1,  5, "CDW02",                probe_udf },
+  { "udf",     32,      1,  5, "NSR02",                probe_udf },
+  { "udf",     32,      1,  5, "NSR03",                probe_udf },
+  { "udf",     32,      1,  5, "TEA01",                probe_udf },
   { "iso9660", 32,      1,  5, "CD001",                0 },
   { "iso9660", 32,      9,  5, "CDROM",                0 },
-  { "udf",     32,      1,  5, "BEA01",                0 },
-  { "udf",     32,      1,  5, "BOOT2",                0 },
-  { "udf",     32,      1,  5, "CD001",                0 },
-  { "udf",     32,      1,  5, "CDW02",                0 },
-  { "udf",     32,      1,  5, "NSR02",                0 },
-  { "udf",     32,      1,  5, "NSR03",                0 },
-  { "udf",     32,      1,  5, "TEA01",                0 },
   { "jfs",     32,      0,  4, "JFS1",                 probe_jfs },
   { "hfs",      1,      0,  2, "BD",                   0 },
   { "ufs",      8,  0x55c,  4, "T\031\001\000",        0 },
index 8ab8d72c0e594371372e5e83f552dce394048294..d418aeff32d957a3021e06cb04242e717cc30cf6 100644 (file)
@@ -209,6 +209,14 @@ struct hfs_super_block {
        __u32   h_blksize;
 };
 
+#define ISODCL(from, to) (to - from + 1)
+struct iso_volume_descriptor {
+       char type[ISODCL(1,1)]; /* 711 */
+       char id[ISODCL(2,6)];
+       char version[ISODCL(7,7)];
+       char data[ISODCL(8,2048)];
+};
+
 /*
  * Byte swap functions
  */