From: Kay Sievers Date: Thu, 16 Aug 2007 13:02:53 +0000 (+0200) Subject: volume_id: fix sqashfs detection X-Git-Tag: 174~1850 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82d4209792035676f1aea2cdaa38bbbf2bd43e04;p=systemd volume_id: fix sqashfs detection --- diff --git a/extras/volume_id/lib/Makefile b/extras/volume_id/lib/Makefile index 0a37c26e..ce07d8dd 100644 --- a/extras/volume_id/lib/Makefile +++ b/extras/volume_id/lib/Makefile @@ -13,7 +13,7 @@ INSTALL_DATA = ${INSTALL} -m 644 INSTALL_LIB = ${INSTALL} -m 755 SHLIB_CUR = 0 -SHLIB_REV = 79 +SHLIB_REV = 80 SHLIB_AGE = 0 SHLIB = libvolume_id.so.$(SHLIB_CUR).$(SHLIB_REV).$(SHLIB_AGE) diff --git a/extras/volume_id/lib/squashfs.c b/extras/volume_id/lib/squashfs.c index 99cc78aa..402a114e 100644 --- a/extras/volume_id/lib/squashfs.c +++ b/extras/volume_id/lib/squashfs.c @@ -29,7 +29,15 @@ #define SQUASHFS_MAGIC 0x73717368 struct squashfs_super { - uint32_t s_magic; + uint32_t s_magic; + uint32_t inodes; + uint32_t bytes_used_2; + uint32_t uid_start_2; + uint32_t guid_start_2; + uint32_t inode_table_start_2; + uint32_t directory_table_start_2; + uint16_t s_major; + uint16_t s_minor; } PACKED; int volume_id_probe_squashfs(struct volume_id *id, uint64_t off, uint64_t size) @@ -38,15 +46,25 @@ int volume_id_probe_squashfs(struct volume_id *id, uint64_t off, uint64_t size) info("probing at offset 0x%llx", (unsigned long long) off); - sqs = (struct squashfs_super *) volume_id_get_buffer(id, off + 0x200, 0x200); + sqs = (struct squashfs_super *) volume_id_get_buffer(id, off, 0x200); if (sqs == NULL) return -1; - if (sqs->s_magic == SQUASHFS_MAGIC || sqs->s_magic == bswap_32(SQUASHFS_MAGIC)) { - volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); - id->type = "squashfs"; - return 0; + if (sqs->s_magic == SQUASHFS_MAGIC) { + snprintf(id->type_version, sizeof(id->type_version), "%u.%u", + sqs->s_major, sqs->s_minor); + goto found; + } + if (sqs->s_magic == bswap_32(SQUASHFS_MAGIC)) { + snprintf(id->type_version, sizeof(id->type_version), "%u.%u", + bswap_16(sqs->s_major), bswap_16(sqs->s_minor)); + goto found; } return -1; + +found: + volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); + id->type = "squashfs"; + return 0; }