3
0
forked from pool/util-linux
util-linux/util-linux-ng-2.16-squashfs3-detect.patch

119 lines
3.5 KiB
Diff
Raw Normal View History

---
shlibs/blkid/src/superblocks/superblocks.c | 1
shlibs/blkid/src/superblocks/superblocks.h | 1
shlibs/blkid/src/superblocks/squashfs.c | 63 +++++++++++++++++++++++++++---------
3 files changed, 50 insertions(+), 15 deletions(-)
Index: util-linux-2.19/shlibs/blkid/src/superblocks/superblocks.c
===================================================================
--- util-linux-2.19.orig/libblkid/src/superblocks/superblocks.c
+++ util-linux-2.19/libblkid/src/superblocks/superblocks.c
@@ -131,6 +131,7 @@ static const struct blkid_idinfo *idinfo
&oracleasm_idinfo,
&vxfs_idinfo,
&squashfs_idinfo,
+ &squashfs3_idinfo,
&netware_idinfo,
&btrfs_idinfo,
&ubifs_idinfo,
Index: util-linux-2.19/shlibs/blkid/src/superblocks/superblocks.h
===================================================================
--- util-linux-2.19.orig/libblkid/src/superblocks/superblocks.h
+++ util-linux-2.19/libblkid/src/superblocks/superblocks.h
@@ -54,6 +54,7 @@ extern const struct blkid_idinfo luks_id
extern const struct blkid_idinfo highpoint37x_idinfo;
extern const struct blkid_idinfo highpoint45x_idinfo;
extern const struct blkid_idinfo squashfs_idinfo;
+extern const struct blkid_idinfo squashfs3_idinfo;
extern const struct blkid_idinfo netware_idinfo;
extern const struct blkid_idinfo sysv_idinfo;
extern const struct blkid_idinfo xenix_idinfo;
Index: util-linux-2.19/shlibs/blkid/src/superblocks/squashfs.c
===================================================================
--- util-linux-2.19.orig/libblkid/src/superblocks/squashfs.c
+++ util-linux-2.19/libblkid/src/superblocks/squashfs.c
@@ -31,20 +31,46 @@ struct sqsh_super_block {
static int probe_squashfs(blkid_probe pr, const struct blkid_idmag *mag)
{
struct sqsh_super_block *sq;
+ uint16_t major;
+ uint16_t minor;
sq = blkid_probe_get_sb(pr, mag, struct sqsh_super_block);
if (!sq)
return -1;
- if (strcmp(mag->magic, "sqsh") == 0 ||
- strcmp(mag->magic, "qshs") == 0)
- blkid_probe_sprintf_version(pr, "%u.%u",
- sq->s_major,
- sq->s_minor);
- else
- blkid_probe_sprintf_version(pr, "%u.%u",
- swab16(sq->s_major),
- swab16(sq->s_minor));
+ major = le16_to_cpu(sq->s_major);
+ minor = le16_to_cpu(sq->s_minor);
+ if (major < 4)
+ return -1;
+
+ blkid_probe_sprintf_version(pr, "%u.%u", major, minor);
+
+ return 0;
+}
+
+static int probe_squashfs3(blkid_probe pr, const struct blkid_idmag *mag)
+{
+ struct sqsh_super_block *sq;
+ uint16_t major;
+ uint16_t minor;
+
+ sq = blkid_probe_get_sb(pr, mag, struct sqsh_super_block);
+ if (!sq)
+ return -1;
+
+ if (strcmp(mag->magic, "sqsh") == 0) {
+ major = be16_to_cpu(sq->s_major);
+ minor = be16_to_cpu(sq->s_minor);
+ } else {
+ major = le16_to_cpu(sq->s_major);
+ minor = le16_to_cpu(sq->s_minor);
+ }
+
+ if (major > 3)
+ return -1;
+
+ blkid_probe_sprintf_version(pr, "%u.%u", major, minor);
+
return 0;
}
@@ -55,14 +81,21 @@ const struct blkid_idinfo squashfs_idinf
.probefunc = probe_squashfs,
.magics =
{
- { .magic = "sqsh", .len = 4 },
- { .magic = "hsqs", .len = 4 }, /* swap */
-
- /* LZMA version */
- { .magic = "qshs", .len = 4 },
- { .magic = "shsq", .len = 4 }, /* swap */
+ { .magic = "hsqs", .len = 4 },
{ NULL }
}
};
+const struct blkid_idinfo squashfs3_idinfo =
+{
+ .name = "squashfs3",
+ .usage = BLKID_USAGE_FILESYSTEM,
+ .probefunc = probe_squashfs3,
+ .magics =
+ {
+ { .magic = "sqsh", .len = 4 }, /* big endian */
+ { .magic = "hsqs", .len = 4 }, /* little endian */
+ { NULL }
+ }
+};