* [PATCH] libblkid: detect squashfs 3 vs 4
@ 2014-05-20 10:23 Ruediger Meier
2014-05-20 15:12 ` Stanislav Brabec
2014-05-26 10:06 ` Karel Zak
0 siblings, 2 replies; 3+ messages in thread
From: Ruediger Meier @ 2014-05-20 10:23 UTC (permalink / raw)
To: util-linux; +Cc: Stanislav Brabec, Miklos Szeredi
From: Ruediger Meier <ruediger.meier@ga-group.nl>
Detect squashfs version <= 3 as squashfs3 and version >= 4 as squashfs.
squashfs kernel module version 4.0 (kernel 2.6.29) is not backward
compatible to open squashfs created with previous versions.
Also fixed version number parsing, see
$ mkdir test
$ mksquashfs test test.sqsh
$ blkid -p test.sqsh
- test.sqsh: VERSION="1024.0" TYPE="squashfs" USAGE="filesystem"
+ test.sqsh: VERSION="4.0" TYPE="squashfs" USAGE="filesystem"
This patch comes from openSUSE / SLE. Original author was probably
Miklos Szeredi.
Internal SUSE references: bnc#666893, sr226509
CC: Stanislav Brabec <sbrabec@suse.cz>
CC: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
libblkid/src/superblocks/squashfs.c | 63 ++++++++++++++++++++++++++--------
libblkid/src/superblocks/superblocks.c | 1 +
libblkid/src/superblocks/superblocks.h | 1 +
3 files changed, 50 insertions(+), 15 deletions(-)
diff --git a/libblkid/src/superblocks/squashfs.c b/libblkid/src/superblocks/squashfs.c
index 595c8e2..a35d60f 100644
--- a/libblkid/src/superblocks/squashfs.c
+++ b/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 errno ? -errno : 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_idinfo =
.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 }
+ }
+};
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index 17da89a..91ca2ea 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -146,6 +146,7 @@ static const struct blkid_idinfo *idinfos[] =
&oracleasm_idinfo,
&vxfs_idinfo,
&squashfs_idinfo,
+ &squashfs3_idinfo,
&netware_idinfo,
&btrfs_idinfo,
&ubifs_idinfo,
diff --git a/libblkid/src/superblocks/superblocks.h b/libblkid/src/superblocks/superblocks.h
index 2cae66a..3bbfb9c 100644
--- a/libblkid/src/superblocks/superblocks.h
+++ b/libblkid/src/superblocks/superblocks.h
@@ -57,6 +57,7 @@ extern const struct blkid_idinfo luks_idinfo;
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;
--
1.8.4.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] libblkid: detect squashfs 3 vs 4
2014-05-20 10:23 [PATCH] libblkid: detect squashfs 3 vs 4 Ruediger Meier
@ 2014-05-20 15:12 ` Stanislav Brabec
2014-05-26 10:06 ` Karel Zak
1 sibling, 0 replies; 3+ messages in thread
From: Stanislav Brabec @ 2014-05-20 15:12 UTC (permalink / raw)
To: Ruediger Meier; +Cc: util-linux, Miklos Szeredi
Ruediger Meier wrote:
> From: Ruediger Meier <ruediger.meier@ga-group.nl>
>
> Detect squashfs version <= 3 as squashfs3 and version >= 4 as squashfs.
>
> squashfs kernel module version 4.0 (kernel 2.6.29) is not backward
> compatible to open squashfs created with previous versions.
Thanks for the upstreaming effort. Patch porting and upstreaming is
still in my queue.
If anybody else is interested:
https://build.opensuse.org/package/show/Base:System/util-linux
(credits and descriptions are in util-linux.changes and util-linux.spec)
> This patch comes from openSUSE / SLE. Original author was probably
> Miklos Szeredi.
Yes, it looks so.
--
Best Regards / S pozdravem,
Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o. e-mail: sbrabec@suse.cz
Lihovarská 1060/12 tel: +49 911 7405384547
190 00 Praha 9 fax: +420 284 084 001
Czech Republic http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libblkid: detect squashfs 3 vs 4
2014-05-20 10:23 [PATCH] libblkid: detect squashfs 3 vs 4 Ruediger Meier
2014-05-20 15:12 ` Stanislav Brabec
@ 2014-05-26 10:06 ` Karel Zak
1 sibling, 0 replies; 3+ messages in thread
From: Karel Zak @ 2014-05-26 10:06 UTC (permalink / raw)
To: Ruediger Meier; +Cc: util-linux, Stanislav Brabec, Miklos Szeredi
On Tue, May 20, 2014 at 10:23:33AM +0000, Ruediger Meier wrote:
> libblkid/src/superblocks/squashfs.c | 63 ++++++++++++++++++++++++++--------
> libblkid/src/superblocks/superblocks.c | 1 +
> libblkid/src/superblocks/superblocks.h | 1 +
> 3 files changed, 50 insertions(+), 15 deletions(-)
Applied, thanks.
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-26 10:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-20 10:23 [PATCH] libblkid: detect squashfs 3 vs 4 Ruediger Meier
2014-05-20 15:12 ` Stanislav Brabec
2014-05-26 10:06 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox