summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/util-linux-ng/util-linux-ng-nilfs2.patch
blob: 3ac215b0ce6d00c49d218574aada853cd1c38a49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
From b44b8600d4096de8203c1fb0702bbc95ee51017f Mon Sep 17 00:00:00 2001
From: Jiro SEKIBA <jir@unicus.jp>
Date: Tue, 13 Jul 2010 09:12:56 +0200
Subject: [PATCH] libblkid: add nilfs2 filesystem superblock probe

This patch implements nilfs2_idinfo to proble nilfs2 partition.
The patch probes uuid, label, version and verify crc check sum of
superblock.

Signed-off-by: Jiro SEKIBA <jir@unicus.jp>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
 shlibs/blkid/src/superblocks/Makefile.am   |    1 +
 shlibs/blkid/src/superblocks/nilfs.c       |  120 ++++++++++++++++++++++++++++
 shlibs/blkid/src/superblocks/superblocks.c |    1 +
 shlibs/blkid/src/superblocks/superblocks.h |    1 +
 4 files changed, 123 insertions(+), 0 deletions(-)
 create mode 100644 shlibs/blkid/src/superblocks/nilfs.c

diff --git a/shlibs/blkid/src/superblocks/Makefile.am b/shlibs/blkid/src/superblocks/Makefile.am
index 39b074b..1501fab 100644
--- a/shlibs/blkid/src/superblocks/Makefile.am
+++ b/shlibs/blkid/src/superblocks/Makefile.am
@@ -47,4 +47,5 @@ libblkid_superblocks_la_SOURCES = \
 			drbd.c \
 			vmfs.c \
 			befs.c \
+			nilfs.c \
 			exfat.c
diff --git a/shlibs/blkid/src/superblocks/nilfs.c b/shlibs/blkid/src/superblocks/nilfs.c
new file mode 100644
index 0000000..c7aba35
--- /dev/null
+++ b/shlibs/blkid/src/superblocks/nilfs.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2010 by Jiro SEKIBA <jir@unicus.jp>
+ *
+ * This file may be redistributed under the terms of the
+ * GNU Lesser General Public License
+ */
+#include <stddef.h>
+#include <string.h>
+
+#include "superblocks.h"
+#include "crc32.h"
+
+struct nilfs_super_block {
+	uint32_t	s_rev_level;
+	uint16_t	s_minor_rev_level;
+	uint16_t	s_magic;
+
+	uint16_t	s_bytes;
+
+	uint16_t	s_flags;
+	uint32_t	s_crc_seed;
+	uint32_t	s_sum;
+
+	uint32_t	s_log_block_size;
+
+	uint64_t	s_nsegments;
+	uint64_t	s_dev_size;
+	uint64_t	s_first_data_block;
+	uint32_t	s_blocks_per_segment;
+	uint32_t	s_r_segments_percentage;
+
+	uint64_t	s_last_cno;
+	uint64_t	s_last_pseg;
+	uint64_t	s_last_seq;
+	uint64_t	s_free_blocks_count;
+
+	uint64_t	s_ctime;
+
+	uint64_t	s_mtime;
+	uint64_t	s_wtime;
+	uint16_t	s_mnt_count;
+	uint16_t	s_max_mnt_count;
+	uint16_t	s_state;
+	uint16_t	s_errors;
+	uint64_t	s_lastcheck;
+
+	uint32_t	s_checkinterval;
+	uint32_t	s_creator_os;
+	uint16_t	s_def_resuid;
+	uint16_t	s_def_resgid;
+	uint32_t	s_first_ino;
+
+	uint16_t	s_inode_size;
+	uint16_t	s_dat_entry_size;
+	uint16_t	s_checkpoint_size;
+	uint16_t	s_segment_usage_size;
+
+	uint8_t		s_uuid[16];
+	char		s_volume_name[80];
+
+	uint32_t	s_c_interval;
+	uint32_t	s_c_block_max;
+	uint32_t	s_reserved[192];
+};
+
+/* nilfs2 magic string */
+#define NILFS_SB_MAGIC		"\x34\x34"
+/* nilfs2 super block offset */
+#define NILFS_SB_OFF		0x400
+/* nilfs2 super block offset in kB */
+#define NILFS_SB_KBOFF		(NILFS_SB_OFF >> 10)
+/* nilfs2 magic string offset within super block */
+#define NILFS_MAG_OFF		6
+
+static int probe_nilfs2(blkid_probe pr, const struct blkid_idmag *mag)
+{
+	struct nilfs_super_block *sb;
+	static unsigned char sum[4];
+	const int sumoff = offsetof(struct nilfs_super_block, s_sum);
+	size_t bytes;
+	uint32_t crc;
+
+	sb = blkid_probe_get_sb(pr, mag, struct nilfs_super_block);
+	if (!sb)
+		return -1;
+
+	bytes = le32_to_cpu(sb->s_bytes);
+	crc = crc32(le32_to_cpu(sb->s_crc_seed), (unsigned char *)sb, sumoff);
+	crc = crc32(crc, sum, 4);
+	crc = crc32(crc, (unsigned char *)sb + sumoff + 4, bytes - sumoff - 4);
+
+	if (crc != le32_to_cpu(sb->s_sum))
+		return -1;
+
+	if (strlen(sb->s_volume_name))
+		blkid_probe_set_label(pr, (unsigned char *) sb->s_volume_name,
+				      sizeof(sb->s_volume_name));
+
+	blkid_probe_set_uuid(pr, sb->s_uuid);
+	blkid_probe_sprintf_version(pr, "%u", le32_to_cpu(sb->s_rev_level));
+
+	return 0;
+}
+
+const struct blkid_idinfo nilfs2_idinfo =
+{
+	.name		= "nilfs",
+	.usage		= BLKID_USAGE_FILESYSTEM,
+	.probefunc	= probe_nilfs2,
+	.magics		=
+	{
+		{
+			.magic = NILFS_SB_MAGIC,
+			.len = 2,
+			.kboff = NILFS_SB_KBOFF,
+			.sboff = NILFS_MAG_OFF
+		},
+		{ NULL }
+	}
+};
diff --git a/shlibs/blkid/src/superblocks/superblocks.c b/shlibs/blkid/src/superblocks/superblocks.c
index b80c10b..3d66d98 100644
--- a/shlibs/blkid/src/superblocks/superblocks.c
+++ b/shlibs/blkid/src/superblocks/superblocks.c
@@ -140,6 +140,7 @@ static const struct blkid_idinfo *idinfos[] =
 	&bfs_idinfo,
 	&vmfs_fs_idinfo,
 	&befs_idinfo,
+	&nilfs2_idinfo,
 	&exfat_idinfo
 };
 
diff --git a/shlibs/blkid/src/superblocks/superblocks.h b/shlibs/blkid/src/superblocks/superblocks.h
index 74cb974..a79d7cb 100644
--- a/shlibs/blkid/src/superblocks/superblocks.h
+++ b/shlibs/blkid/src/superblocks/superblocks.h
@@ -65,6 +65,7 @@ extern const struct blkid_idinfo vmfs_volume_idinfo;
 extern const struct blkid_idinfo vmfs_fs_idinfo;
 extern const struct blkid_idinfo drbd_idinfo;
 extern const struct blkid_idinfo befs_idinfo;
+extern const struct blkid_idinfo nilfs2_idinfo;
 extern const struct blkid_idinfo exfat_idinfo;
 
 /*
-- 
1.7.2.1
From 67bb0074eec2b154d15bd3dd77b482c3d6125761 Mon Sep 17 00:00:00 2001
From: Jiro SEKIBA <jir@unicus.jp>
Date: Tue, 13 Jul 2010 09:14:08 +0200
Subject: [PATCH] tests: add nilfs2 test for libblkid

Signed-off-by: Jiro SEKIBA <jir@unicus.jp>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
 tests/expected/blkid/low-probe-nilfs2   |    7 +++++++
 tests/ts/blkid/images-fs/nilfs2.img.bz2 |  Bin 0 -> 795 bytes
 2 files changed, 7 insertions(+), 0 deletions(-)
 create mode 100644 tests/expected/blkid/low-probe-nilfs2
 create mode 100644 tests/ts/blkid/images-fs/nilfs2.img.bz2

diff --git a/tests/expected/blkid/low-probe-nilfs2 b/tests/expected/blkid/low-probe-nilfs2
new file mode 100644
index 0000000..bfd8fcd
--- /dev/null
+++ b/tests/expected/blkid/low-probe-nilfs2
@@ -0,0 +1,7 @@
+ID_FS_LABEL=test-nilfs2
+ID_FS_LABEL_ENC=test-nilfs2
+ID_FS_TYPE=nilfs
+ID_FS_USAGE=filesystem
+ID_FS_UUID=524025fb-6d31-40e6-baad-1db36cfdf806
+ID_FS_UUID_ENC=524025fb-6d31-40e6-baad-1db36cfdf806
+ID_FS_VERSION=2
diff --git a/tests/ts/blkid/images-fs/nilfs2.img.bz2 b/tests/ts/blkid/images-fs/nilfs2.img.bz2
new file mode 100644
index 0000000000000000000000000000000000000000..a9762eb1ace9f1999aaad3c40f1d836668d856ac
GIT binary patch
literal 795
zcmZ>Y%CIzaj8qGbG`Ml9n}H$iKM?$BcJi+ANKl`nz?|O0@_@lbK*y;^z=e@R;iM8v
z^#R6D2YV7HdVE!LUvc5DPv^n~3?@drY>Er`xpEzs%?rp}D3rOt`HEDABm)D32?GP;
z0!EREipv^IOn^)V240{j^Q<Hzqs++;Mp8zSMhpyWZZoCW1WqjeK1)#Iz#6seeHv~(
zmxJ_T@69=2^IA3QjKnD|>vorkjN+>MH*4-%s37X<)*F#v)Rf{P;KEe-N=h(9AxK5r
zNaB>=<>ixS2R?swwRU~FskVY@0E2@ILyiK&T}MB??Mn}*D~htZ3cdTZRH0!*OIOhp
zuF1Yi0SZB_TmsB4k61&aUN!_Ugm_J068*5`gF*w#0teARmnpo_kuT2~GOf!|DtB62
z!)T++5$eFKB*GXf;<I9F!NQM?v;8`}*7b6px{&k4S4E)bP}5GYFDbo;*GrVLFkN9@
z@@Z9sSb~JGco?eycMA(Q^Ph&Ju|ft>1p%^G=UuLqkPtM9ycck)X|u7g*QFMo>QK!;
zURQKH*iWxuZsIwzh@rOT!@1{s7L*D22$pQI7i2k@S1M-~SA2Zm@7XFsJ@fXR;7eg<
zQ4&<W_Vc7f@7p(fvkiM$nYo*^O$-78_-wK~RVMkbV1D8JQ`OC<q49;V$o`^l=O3L4
zcH6Z3#E!YsGG`s)RMF~EOO1d3>aY{zarw_8qLWfhCp?&^`$6=_69yh&WHm7`bFf@V
z(PE04u!6IgDET?h6*ny4n=k(V{?{W7DhkUTSQr9X7>p_oxG=CVFtI2!vN$jZD6(v3
z;O=l+m1w{)gHeLB;X+0N+bk2QBw&h}z@#bCHj{nH7h4xLj+2u!PE3DPVsFhCSH8Sp
zT}DV?fa{Ns2bOWHVhs!t%xc}wps|W$-`>x&rn$fKjBA>})U}{HMs?HV9M&t-a)KVS
zYg}FWIQh_-FYD!hutchUy`86XxmogM<nBjObNPCsG{5_M%3n}$Xkh3NkUdt<dS{}a
Lh>ElVLy7|cD)2Ck

literal 0
HcmV?d00001

-- 
1.7.2.1
From 1326e1dfa5c1d06ff7521b8c8162452799164239 Mon Sep 17 00:00:00 2001
From: Jiro SEKIBA <jir@unicus.jp>
Date: Thu, 15 Jul 2010 13:40:27 +0900
Subject: [PATCH] libblkid: fix typo filesystem name nilfs to nilfs2

The correct filesystem name is nilfs2, not nilfs.

Signed-off-by: Jiro SEKIBA <jir@unicus.jp>
---
 shlibs/blkid/src/superblocks/nilfs.c  |    2 +-
 tests/expected/blkid/low-probe-nilfs2 |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/shlibs/blkid/src/superblocks/nilfs.c b/shlibs/blkid/src/superblocks/nilfs.c
index c7aba35..bf16918 100644
--- a/shlibs/blkid/src/superblocks/nilfs.c
+++ b/shlibs/blkid/src/superblocks/nilfs.c
@@ -104,7 +104,7 @@ static int probe_nilfs2(blkid_probe pr, const struct blkid_idmag *mag)
 
 const struct blkid_idinfo nilfs2_idinfo =
 {
-	.name		= "nilfs",
+	.name		= "nilfs2",
 	.usage		= BLKID_USAGE_FILESYSTEM,
 	.probefunc	= probe_nilfs2,
 	.magics		=
diff --git a/tests/expected/blkid/low-probe-nilfs2 b/tests/expected/blkid/low-probe-nilfs2
index bfd8fcd..c6c9cab 100644
--- a/tests/expected/blkid/low-probe-nilfs2
+++ b/tests/expected/blkid/low-probe-nilfs2
@@ -1,6 +1,6 @@
 ID_FS_LABEL=test-nilfs2
 ID_FS_LABEL_ENC=test-nilfs2
-ID_FS_TYPE=nilfs
+ID_FS_TYPE=nilfs2
 ID_FS_USAGE=filesystem
 ID_FS_UUID=524025fb-6d31-40e6-baad-1db36cfdf806
 ID_FS_UUID_ENC=524025fb-6d31-40e6-baad-1db36cfdf806
-- 
1.7.2.1