Big cleanup in config help and description
[oweals/busybox.git] / util-linux / volume_id / squashfs.c
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 //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_SQUASHFS) += squashfs.o
10
11 //config:config FEATURE_VOLUMEID_SQUASHFS
12 //config:       bool "SquashFS filesystem"
13 //config:       default y
14 //config:       depends on VOLUMEID && FEATURE_BLKID_TYPE
15 //config:       help
16 //config:         Squashfs is a compressed read-only filesystem for Linux. Squashfs is
17 //config:         intended for general read-only filesystem use and in constrained block
18 //config:         device/memory systems (e.g. embedded systems) where low overhead is
19 //config:         needed.
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 }