Whamcloud - gitweb
Fix libblkid's magic number recognition for the cramfs filesystem,
authorTheodore Ts'o <tytso@mit.edu>
Thu, 5 May 2005 22:06:04 +0000 (18:06 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 5 May 2005 22:06:04 +0000 (18:06 -0400)
and add support to pull out the label for cramfs filesystems.
Thanks to Karel Zak (kzak at redhat.com) for the patch.

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

index 5d9ef2e..1f9083f 100644 (file)
@@ -1,3 +1,10 @@
+2005-05-05  Theodore Ts'o  <tytso@mit.edu>
+
+       * probe.c (probe_cramfs), probe.h: Fix magic number recognition
+               for the cramfs filesystem, and add support to pull out the
+               label for cramfs filesystems.  Thanks to Karel Zak (kzak
+               at redhat.com) for the patch.
+
 2005-03-31  Theodore Ts'o  <tytso@mit.edu>
 
        * cache.c (blkid_get_cache): Use a much more paranoid
index 14292b5..a67598e 100644 (file)
@@ -303,6 +303,23 @@ static int probe_romfs(int fd __BLKID_ATTR((unused)),
        return 0;
 }
 
+static int probe_cramfs(int fd __BLKID_ATTR((unused)), 
+                      blkid_cache cache __BLKID_ATTR((unused)), 
+                      blkid_dev dev,
+                      struct blkid_magic *id __BLKID_ATTR((unused)), 
+                      unsigned char *buf)
+{
+       struct cramfs_super_block *csb;
+       const char *label = 0;
+
+       csb = (struct cramfs_super_block *)buf;
+
+       if (strlen((char *) csb->name))
+               label = (char *) csb->name;
+       blkid_set_tag(dev, "LABEL", label, 0);
+       return 0;
+}
+
 static int probe_swap0(int fd __BLKID_ATTR((unused)),
                       blkid_cache cache __BLKID_ATTR((unused)),
                       blkid_dev dev,
@@ -489,7 +506,7 @@ static struct blkid_magic type_array[] = {
   { "xfs",      0,      0,  4, "XFSB",                 probe_xfs },
   { "romfs",    0,      0,  8, "-rom1fs-",             probe_romfs },
   { "bfs",      0,      0,  4, "\316\372\173\033",     0 },
-  { "cramfs",   0,      0,  4, "E=\315\034",           0 },
+  { "cramfs",   0,      0,  4, "E=\315\050",           probe_cramfs },
   { "qnx4",     0,      4,  6, "QNX4FS",               0 },
   { "udf",     32,      1,  5, "BEA01",                probe_udf },
   { "udf",     32,      1,  5, "BOOT2",                probe_udf },
index c1d923f..e545ef1 100644 (file)
@@ -108,6 +108,21 @@ struct romfs_super_block {
        unsigned char   ros_volume[16];
 };
 
+struct cramfs_super_block {
+       __u8            magic[4];
+       __u32           size;
+       __u32           flags;
+       __u32           future;
+       __u8            signature[16];
+       struct cramfs_info {
+               __u32           crc;
+               __u32           edition;
+               __u32           blocks;
+               __u32           files;
+       } info;
+       __u8            name[16];
+};
+
 struct swap_id_block {
 /*     unsigned char   sws_boot[1024]; */
        __u32           sws_version;