diff options
author | Sven-Göran Bergh <sgb@systemasis.org> | 2013-01-14 02:21:41 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-01-14 02:21:41 +0100 |
commit | 6928d9f0495d814a08195d0e9805fd91cbb3d384 (patch) | |
tree | 7c70e4c9a721fcb0673b48907908c53d19737b21 | |
parent | 6967578728a3eef43b7b2be4080dafc1b87f528d (diff) | |
download | busybox-w32-6928d9f0495d814a08195d0e9805fd91cbb3d384.tar.gz busybox-w32-6928d9f0495d814a08195d0e9805fd91cbb3d384.tar.bz2 busybox-w32-6928d9f0495d814a08195d0e9805fd91cbb3d384.zip |
volume_id: add squashfs detection
function old new delta
volume_id_probe_squashfs - 74 +74
fs1 12 16 +4
Signed-off-by: Sven-Göran Bergh <sgb@systemasis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | util-linux/Config.src | 10 | ||||
-rw-r--r-- | util-linux/volume_id/squashfs.c | 59 | ||||
-rw-r--r-- | util-linux/volume_id/volume_id.c | 3 | ||||
-rw-r--r-- | util-linux/volume_id/volume_id_internal.h | 2 |
4 files changed, 74 insertions, 0 deletions
diff --git a/util-linux/Config.src b/util-linux/Config.src index e4516ddb7..6c1b928da 100644 --- a/util-linux/Config.src +++ b/util-linux/Config.src | |||
@@ -841,6 +841,16 @@ config FEATURE_VOLUMEID_ROMFS | |||
841 | help | 841 | help |
842 | TODO | 842 | TODO |
843 | 843 | ||
844 | config FEATURE_VOLUMEID_SQUASHFS | ||
845 | bool "SquashFS filesystem" | ||
846 | default y | ||
847 | depends on VOLUMEID && FEATURE_BLKID_TYPE | ||
848 | help | ||
849 | Squashfs is a compressed read-only filesystem for Linux. Squashfs is | ||
850 | intended for general read-only filesystem use and in constrained block | ||
851 | device/memory systems (e.g. embedded systems) where low overhead is | ||
852 | needed. | ||
853 | |||
844 | config FEATURE_VOLUMEID_SYSV | 854 | config FEATURE_VOLUMEID_SYSV |
845 | bool "sysv filesystem" | 855 | bool "sysv filesystem" |
846 | default y | 856 | default y |
diff --git a/util-linux/volume_id/squashfs.c b/util-linux/volume_id/squashfs.c new file mode 100644 index 000000000..331ac20fd --- /dev/null +++ b/util-linux/volume_id/squashfs.c | |||
@@ -0,0 +1,59 @@ | |||
1 | /* | ||
2 | * volume_id - reads filesystem label and uuid | ||
3 | * | ||
4 | * Copyright (C) 2012 S-G Bergh <sgb@systemasis.org> | ||
5 | * | ||
6 | * Licensed under GPLv2, see file LICENSE in this source tree. | ||
7 | */ | ||
8 | |||
9 | //config:config FEATURE_VOLUMEID_SQUASHFS | ||
10 | //config: bool "SquashFS filesystem" | ||
11 | //config: default y | ||
12 | //config: depends on VOLUMEID && FEATURE_BLKID_TYPE | ||
13 | //config: help | ||
14 | //config: Squashfs is a compressed read-only filesystem for Linux. Squashfs is | ||
15 | //config: intended for general read-only filesystem use and in constrained block | ||
16 | //config: device/memory systems (e.g. embedded systems) where low overhead is | ||
17 | //config: needed. | ||
18 | |||
19 | //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_SQUASHFS) += squashfs.o | ||
20 | |||
21 | #include "volume_id_internal.h" | ||
22 | |||
23 | struct squashfs_superblock { | ||
24 | uint32_t magic; | ||
25 | /* | ||
26 | uint32_t dummy[6]; | ||
27 | uint16_t major; | ||
28 | uint16_t minor; | ||
29 | */ | ||
30 | } PACKED; | ||
31 | |||
32 | int FAST_FUNC volume_id_probe_squashfs(struct volume_id *id /*,uint64_t off*/) | ||
33 | { | ||
34 | #define off ((uint64_t)0) | ||
35 | struct squashfs_superblock *sb; | ||
36 | |||
37 | dbg("SquashFS: probing at offset 0x%llx", (unsigned long long) off); | ||
38 | sb = volume_id_get_buffer(id, off, 0x200); | ||
39 | if (!sb) | ||
40 | return -1; | ||
41 | |||
42 | // Old SquashFS (pre 4.0) can be both big and little endian, so test for both. | ||
43 | // Likewise, it is commonly used in firwmare with some non-standard signatures. | ||
44 | #define pack(a,b,c,d) ( (uint32_t)((a * 256 + b) * 256 + c) * 256 + d ) | ||
45 | #define SIG1 pack('s','q','s','h') | ||
46 | #define SIG2 pack('h','s','q','s') | ||
47 | #define SIG3 pack('s','h','s','q') | ||
48 | #define SIG4 pack('q','s','h','s') | ||
49 | if (sb->magic == SIG1 | ||
50 | || sb->magic == SIG2 | ||
51 | || sb->magic == SIG3 | ||
52 | || sb->magic == SIG4 | ||
53 | ) { | ||
54 | IF_FEATURE_BLKID_TYPE(id->type = "squashfs";) | ||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | return -1; | ||
59 | } | ||
diff --git a/util-linux/volume_id/volume_id.c b/util-linux/volume_id/volume_id.c index 3c3c69818..f0fc84c05 100644 --- a/util-linux/volume_id/volume_id.c +++ b/util-linux/volume_id/volume_id.c | |||
@@ -99,6 +99,9 @@ static const probe_fptr fs1[] = { | |||
99 | #if ENABLE_FEATURE_VOLUMEID_MAC | 99 | #if ENABLE_FEATURE_VOLUMEID_MAC |
100 | volume_id_probe_mac_partition_map, | 100 | volume_id_probe_mac_partition_map, |
101 | #endif | 101 | #endif |
102 | #if ENABLE_FEATURE_VOLUMEID_SQUASHFS | ||
103 | volume_id_probe_squashfs, | ||
104 | #endif | ||
102 | #if ENABLE_FEATURE_VOLUMEID_XFS | 105 | #if ENABLE_FEATURE_VOLUMEID_XFS |
103 | volume_id_probe_xfs, | 106 | volume_id_probe_xfs, |
104 | #endif | 107 | #endif |
diff --git a/util-linux/volume_id/volume_id_internal.h b/util-linux/volume_id/volume_id_internal.h index e26ebaab6..3f02bd50d 100644 --- a/util-linux/volume_id/volume_id_internal.h +++ b/util-linux/volume_id/volume_id_internal.h | |||
@@ -227,6 +227,8 @@ int FAST_FUNC volume_id_probe_reiserfs(struct volume_id *id /*,uint64_t off*/); | |||
227 | 227 | ||
228 | int FAST_FUNC volume_id_probe_romfs(struct volume_id *id /*,uint64_t off*/); | 228 | int FAST_FUNC volume_id_probe_romfs(struct volume_id *id /*,uint64_t off*/); |
229 | 229 | ||
230 | int FAST_FUNC volume_id_probe_squashfs(struct volume_id *id /*,uint64_t off*/); | ||
231 | |||
230 | int FAST_FUNC volume_id_probe_sysv(struct volume_id *id /*,uint64_t off*/); | 232 | int FAST_FUNC volume_id_probe_sysv(struct volume_id *id /*,uint64_t off*/); |
231 | 233 | ||
232 | int FAST_FUNC volume_id_probe_udf(struct volume_id *id /*,uint64_t off*/); | 234 | int FAST_FUNC volume_id_probe_udf(struct volume_id *id /*,uint64_t off*/); |