From: Theodore Ts'o Date: Thu, 5 May 2005 22:06:04 +0000 (-0400) Subject: Fix libblkid's magic number recognition for the cramfs filesystem, X-Git-Tag: E2FSPROGS-1_38-WIP-0509~23 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=4c4e3f784330978fa127edaa3936957d38c7e93a;p=tools%2Fe2fsprogs.git Fix libblkid's 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. --- diff --git a/lib/blkid/ChangeLog b/lib/blkid/ChangeLog index 5d9ef2e..1f9083f 100644 --- a/lib/blkid/ChangeLog +++ b/lib/blkid/ChangeLog @@ -1,3 +1,10 @@ +2005-05-05 Theodore Ts'o + + * 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 * cache.c (blkid_get_cache): Use a much more paranoid diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index 14292b5..a67598e 100644 --- a/lib/blkid/probe.c +++ b/lib/blkid/probe.c @@ -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 }, diff --git a/lib/blkid/probe.h b/lib/blkid/probe.h index c1d923f..e545ef1 100644 --- a/lib/blkid/probe.h +++ b/lib/blkid/probe.h @@ -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;