diff options
-rw-r--r-- | util-linux/volume_id/get_devname.c | 6 | ||||
-rw-r--r-- | util-linux/volume_id/ubifs.c | 125 | ||||
-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, 135 insertions, 1 deletions
diff --git a/util-linux/volume_id/get_devname.c b/util-linux/volume_id/get_devname.c index 6b97df113..b64d28ceb 100644 --- a/util-linux/volume_id/get_devname.c +++ b/util-linux/volume_id/get_devname.c | |||
@@ -107,7 +107,11 @@ uuidcache_check_device(const char *device, | |||
107 | int depth UNUSED_PARAM) | 107 | int depth UNUSED_PARAM) |
108 | { | 108 | { |
109 | /* note: this check rejects links to devices, among other nodes */ | 109 | /* note: this check rejects links to devices, among other nodes */ |
110 | if (!S_ISBLK(statbuf->st_mode)) | 110 | if (!S_ISBLK(statbuf->st_mode) |
111 | #if ENABLE_FEATURE_VOLUMEID_UBIFS | ||
112 | && !(S_ISCHR(statbuf->st_mode) && strncmp(bb_basename(device), "ubi", 3) == 0) | ||
113 | #endif | ||
114 | ) | ||
111 | return TRUE; | 115 | return TRUE; |
112 | 116 | ||
113 | /* Users report that mucking with floppies (especially non-present | 117 | /* Users report that mucking with floppies (especially non-present |
diff --git a/util-linux/volume_id/ubifs.c b/util-linux/volume_id/ubifs.c new file mode 100644 index 000000000..13604ec35 --- /dev/null +++ b/util-linux/volume_id/ubifs.c | |||
@@ -0,0 +1,125 @@ | |||
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_UBIFS) += ubifs.o | ||
10 | |||
11 | //config: | ||
12 | //config:config FEATURE_VOLUMEID_UBIFS | ||
13 | //config: bool "UBIFS filesystem" | ||
14 | //config: default y | ||
15 | //config: depends on VOLUMEID | ||
16 | //config: help | ||
17 | //config: UBIFS (Unsorted Block Image File System) is a file | ||
18 | //config: system for use with raw flash memory media. | ||
19 | //config: | ||
20 | |||
21 | #include "volume_id_internal.h" | ||
22 | |||
23 | #define UBIFS_NODE_MAGIC 0x06101831 | ||
24 | |||
25 | /* | ||
26 | * struct ubifs_ch - common header node. | ||
27 | * @magic: UBIFS node magic number (%UBIFS_NODE_MAGIC) | ||
28 | * @crc: CRC-32 checksum of the node header | ||
29 | * @sqnum: sequence number | ||
30 | * @len: full node length | ||
31 | * @node_type: node type | ||
32 | * @group_type: node group type | ||
33 | * @padding: reserved for future, zeroes | ||
34 | * | ||
35 | * Every UBIFS node starts with this common part. If the node has a key, the | ||
36 | * key always goes next. | ||
37 | */ | ||
38 | struct ubifs_ch { | ||
39 | uint32_t magic; | ||
40 | uint32_t crc; | ||
41 | uint64_t sqnum; | ||
42 | uint32_t len; | ||
43 | uint8_t node_type; | ||
44 | uint8_t group_type; | ||
45 | uint8_t padding[2]; | ||
46 | } PACKED; | ||
47 | |||
48 | /* | ||
49 | * struct ubifs_sb_node - superblock node. | ||
50 | * @ch: common header | ||
51 | * @padding: reserved for future, zeroes | ||
52 | * @key_hash: type of hash function used in keys | ||
53 | * @key_fmt: format of the key | ||
54 | * @flags: file-system flags (%UBIFS_FLG_BIGLPT, etc) | ||
55 | * @min_io_size: minimal input/output unit size | ||
56 | * @leb_size: logical eraseblock size in bytes | ||
57 | * @leb_cnt: count of LEBs used by file-system | ||
58 | * @max_leb_cnt: maximum count of LEBs used by file-system | ||
59 | * @max_bud_bytes: maximum amount of data stored in buds | ||
60 | * @log_lebs: log size in logical eraseblocks | ||
61 | * @lpt_lebs: number of LEBs used for lprops table | ||
62 | * @orph_lebs: number of LEBs used for recording orphans | ||
63 | * @jhead_cnt: count of journal heads | ||
64 | * @fanout: tree fanout (max. number of links per indexing node) | ||
65 | * @lsave_cnt: number of LEB numbers in LPT's save table | ||
66 | * @fmt_version: UBIFS on-flash format version | ||
67 | * @default_compr: default compression algorithm (%UBIFS_COMPR_LZO, etc) | ||
68 | * @padding1: reserved for future, zeroes | ||
69 | * @rp_uid: reserve pool UID | ||
70 | * @rp_gid: reserve pool GID | ||
71 | * @rp_size: size of the reserved pool in bytes | ||
72 | * @padding2: reserved for future, zeroes | ||
73 | * @time_gran: time granularity in nanoseconds | ||
74 | * @uuid: UUID generated when the file system image was created | ||
75 | * @ro_compat_version: UBIFS R/O compatibility version | ||
76 | */ | ||
77 | struct ubifs_sb_node { | ||
78 | struct ubifs_ch ch; | ||
79 | uint8_t padding[2]; | ||
80 | uint8_t key_hash; | ||
81 | uint8_t key_fmt; | ||
82 | uint32_t flags; | ||
83 | uint32_t min_io_size; | ||
84 | uint32_t leb_size; | ||
85 | uint32_t leb_cnt; | ||
86 | uint32_t max_leb_cnt; | ||
87 | uint64_t max_bud_bytes; | ||
88 | uint32_t log_lebs; | ||
89 | uint32_t lpt_lebs; | ||
90 | uint32_t orph_lebs; | ||
91 | uint32_t jhead_cnt; | ||
92 | uint32_t fanout; | ||
93 | uint32_t lsave_cnt; | ||
94 | uint32_t fmt_version; | ||
95 | uint16_t default_compr; | ||
96 | uint8_t padding1[2]; | ||
97 | uint32_t rp_uid; | ||
98 | uint32_t rp_gid; | ||
99 | uint64_t rp_size; | ||
100 | uint32_t time_gran; | ||
101 | uint8_t uuid[16]; | ||
102 | uint32_t ro_compat_version; | ||
103 | /* | ||
104 | uint8_t padding2[3968]; | ||
105 | */ | ||
106 | } PACKED; | ||
107 | |||
108 | int FAST_FUNC volume_id_probe_ubifs(struct volume_id *id /*,uint64_t off*/) | ||
109 | { | ||
110 | #define off ((uint64_t)0) | ||
111 | struct ubifs_sb_node *sb; | ||
112 | |||
113 | dbg("UBIFS: probing at offset 0x%llx", (unsigned long long) off); | ||
114 | sb = volume_id_get_buffer(id, off, sizeof(struct ubifs_sb_node)); | ||
115 | if (!sb) | ||
116 | return -1; | ||
117 | |||
118 | if (le32_to_cpu(sb->ch.magic) != UBIFS_NODE_MAGIC) | ||
119 | return -1; | ||
120 | |||
121 | IF_FEATURE_BLKID_TYPE(id->type = "ubifs";) | ||
122 | volume_id_set_uuid(id, sb->uuid, UUID_DCE); | ||
123 | |||
124 | return 0; | ||
125 | } | ||
diff --git a/util-linux/volume_id/volume_id.c b/util-linux/volume_id/volume_id.c index 3f71e0084..5bb95994b 100644 --- a/util-linux/volume_id/volume_id.c +++ b/util-linux/volume_id/volume_id.c | |||
@@ -168,6 +168,9 @@ static const probe_fptr fs2[] = { | |||
168 | #if ENABLE_FEATURE_VOLUMEID_OCFS2 | 168 | #if ENABLE_FEATURE_VOLUMEID_OCFS2 |
169 | volume_id_probe_ocfs2, | 169 | volume_id_probe_ocfs2, |
170 | #endif | 170 | #endif |
171 | #if ENABLE_FEATURE_VOLUMEID_UBIFS | ||
172 | volume_id_probe_ubifs, | ||
173 | #endif | ||
171 | }; | 174 | }; |
172 | 175 | ||
173 | int FAST_FUNC volume_id_probe_all(struct volume_id *id, /*uint64_t off,*/ uint64_t size) | 176 | int FAST_FUNC volume_id_probe_all(struct volume_id *id, /*uint64_t off,*/ uint64_t size) |
diff --git a/util-linux/volume_id/volume_id_internal.h b/util-linux/volume_id/volume_id_internal.h index 3061ac4d5..759a832e6 100644 --- a/util-linux/volume_id/volume_id_internal.h +++ b/util-linux/volume_id/volume_id_internal.h | |||
@@ -221,4 +221,6 @@ int FAST_FUNC volume_id_probe_udf(struct volume_id *id /*,uint64_t off*/); | |||
221 | 221 | ||
222 | int FAST_FUNC volume_id_probe_xfs(struct volume_id *id /*,uint64_t off*/); | 222 | int FAST_FUNC volume_id_probe_xfs(struct volume_id *id /*,uint64_t off*/); |
223 | 223 | ||
224 | int FAST_FUNC volume_id_probe_ubifs(struct volume_id *id /*,uint64_t off*/); | ||
225 | |||
224 | POP_SAVED_FUNCTION_VISIBILITY | 226 | POP_SAVED_FUNCTION_VISIBILITY |