updated on Sun Jan 15 16:02:00 UTC 2012
[aur-mirror.git] / util-linux-ng-aes / util-linux-ng-nilfs2.patch
blob3ac215b0ce6d00c49d218574aada853cd1c38a49
1 From b44b8600d4096de8203c1fb0702bbc95ee51017f Mon Sep 17 00:00:00 2001
2 From: Jiro SEKIBA <jir@unicus.jp>
3 Date: Tue, 13 Jul 2010 09:12:56 +0200
4 Subject: [PATCH] libblkid: add nilfs2 filesystem superblock probe
6 This patch implements nilfs2_idinfo to proble nilfs2 partition.
7 The patch probes uuid, label, version and verify crc check sum of
8 superblock.
10 Signed-off-by: Jiro SEKIBA <jir@unicus.jp>
11 Signed-off-by: Karel Zak <kzak@redhat.com>
12 ---
13 shlibs/blkid/src/superblocks/Makefile.am | 1 +
14 shlibs/blkid/src/superblocks/nilfs.c | 120 ++++++++++++++++++++++++++++
15 shlibs/blkid/src/superblocks/superblocks.c | 1 +
16 shlibs/blkid/src/superblocks/superblocks.h | 1 +
17 4 files changed, 123 insertions(+), 0 deletions(-)
18 create mode 100644 shlibs/blkid/src/superblocks/nilfs.c
20 diff --git a/shlibs/blkid/src/superblocks/Makefile.am b/shlibs/blkid/src/superblocks/Makefile.am
21 index 39b074b..1501fab 100644
22 --- a/shlibs/blkid/src/superblocks/Makefile.am
23 +++ b/shlibs/blkid/src/superblocks/Makefile.am
24 @@ -47,4 +47,5 @@ libblkid_superblocks_la_SOURCES = \
25 drbd.c \
26 vmfs.c \
27 befs.c \
28 + nilfs.c \
29 exfat.c
30 diff --git a/shlibs/blkid/src/superblocks/nilfs.c b/shlibs/blkid/src/superblocks/nilfs.c
31 new file mode 100644
32 index 0000000..c7aba35
33 --- /dev/null
34 +++ b/shlibs/blkid/src/superblocks/nilfs.c
35 @@ -0,0 +1,120 @@
36 +/*
37 + * Copyright (C) 2010 by Jiro SEKIBA <jir@unicus.jp>
38 + *
39 + * This file may be redistributed under the terms of the
40 + * GNU Lesser General Public License
41 + */
42 +#include <stddef.h>
43 +#include <string.h>
45 +#include "superblocks.h"
46 +#include "crc32.h"
48 +struct nilfs_super_block {
49 + uint32_t s_rev_level;
50 + uint16_t s_minor_rev_level;
51 + uint16_t s_magic;
53 + uint16_t s_bytes;
55 + uint16_t s_flags;
56 + uint32_t s_crc_seed;
57 + uint32_t s_sum;
59 + uint32_t s_log_block_size;
61 + uint64_t s_nsegments;
62 + uint64_t s_dev_size;
63 + uint64_t s_first_data_block;
64 + uint32_t s_blocks_per_segment;
65 + uint32_t s_r_segments_percentage;
67 + uint64_t s_last_cno;
68 + uint64_t s_last_pseg;
69 + uint64_t s_last_seq;
70 + uint64_t s_free_blocks_count;
72 + uint64_t s_ctime;
74 + uint64_t s_mtime;
75 + uint64_t s_wtime;
76 + uint16_t s_mnt_count;
77 + uint16_t s_max_mnt_count;
78 + uint16_t s_state;
79 + uint16_t s_errors;
80 + uint64_t s_lastcheck;
82 + uint32_t s_checkinterval;
83 + uint32_t s_creator_os;
84 + uint16_t s_def_resuid;
85 + uint16_t s_def_resgid;
86 + uint32_t s_first_ino;
88 + uint16_t s_inode_size;
89 + uint16_t s_dat_entry_size;
90 + uint16_t s_checkpoint_size;
91 + uint16_t s_segment_usage_size;
93 + uint8_t s_uuid[16];
94 + char s_volume_name[80];
96 + uint32_t s_c_interval;
97 + uint32_t s_c_block_max;
98 + uint32_t s_reserved[192];
99 +};
101 +/* nilfs2 magic string */
102 +#define NILFS_SB_MAGIC "\x34\x34"
103 +/* nilfs2 super block offset */
104 +#define NILFS_SB_OFF 0x400
105 +/* nilfs2 super block offset in kB */
106 +#define NILFS_SB_KBOFF (NILFS_SB_OFF >> 10)
107 +/* nilfs2 magic string offset within super block */
108 +#define NILFS_MAG_OFF 6
110 +static int probe_nilfs2(blkid_probe pr, const struct blkid_idmag *mag)
112 + struct nilfs_super_block *sb;
113 + static unsigned char sum[4];
114 + const int sumoff = offsetof(struct nilfs_super_block, s_sum);
115 + size_t bytes;
116 + uint32_t crc;
118 + sb = blkid_probe_get_sb(pr, mag, struct nilfs_super_block);
119 + if (!sb)
120 + return -1;
122 + bytes = le32_to_cpu(sb->s_bytes);
123 + crc = crc32(le32_to_cpu(sb->s_crc_seed), (unsigned char *)sb, sumoff);
124 + crc = crc32(crc, sum, 4);
125 + crc = crc32(crc, (unsigned char *)sb + sumoff + 4, bytes - sumoff - 4);
127 + if (crc != le32_to_cpu(sb->s_sum))
128 + return -1;
130 + if (strlen(sb->s_volume_name))
131 + blkid_probe_set_label(pr, (unsigned char *) sb->s_volume_name,
132 + sizeof(sb->s_volume_name));
134 + blkid_probe_set_uuid(pr, sb->s_uuid);
135 + blkid_probe_sprintf_version(pr, "%u", le32_to_cpu(sb->s_rev_level));
137 + return 0;
140 +const struct blkid_idinfo nilfs2_idinfo =
142 + .name = "nilfs",
143 + .usage = BLKID_USAGE_FILESYSTEM,
144 + .probefunc = probe_nilfs2,
145 + .magics =
148 + .magic = NILFS_SB_MAGIC,
149 + .len = 2,
150 + .kboff = NILFS_SB_KBOFF,
151 + .sboff = NILFS_MAG_OFF
152 + },
153 + { NULL }
156 diff --git a/shlibs/blkid/src/superblocks/superblocks.c b/shlibs/blkid/src/superblocks/superblocks.c
157 index b80c10b..3d66d98 100644
158 --- a/shlibs/blkid/src/superblocks/superblocks.c
159 +++ b/shlibs/blkid/src/superblocks/superblocks.c
160 @@ -140,6 +140,7 @@ static const struct blkid_idinfo *idinfos[] =
161 &bfs_idinfo,
162 &vmfs_fs_idinfo,
163 &befs_idinfo,
164 + &nilfs2_idinfo,
165 &exfat_idinfo
168 diff --git a/shlibs/blkid/src/superblocks/superblocks.h b/shlibs/blkid/src/superblocks/superblocks.h
169 index 74cb974..a79d7cb 100644
170 --- a/shlibs/blkid/src/superblocks/superblocks.h
171 +++ b/shlibs/blkid/src/superblocks/superblocks.h
172 @@ -65,6 +65,7 @@ extern const struct blkid_idinfo vmfs_volume_idinfo;
173 extern const struct blkid_idinfo vmfs_fs_idinfo;
174 extern const struct blkid_idinfo drbd_idinfo;
175 extern const struct blkid_idinfo befs_idinfo;
176 +extern const struct blkid_idinfo nilfs2_idinfo;
177 extern const struct blkid_idinfo exfat_idinfo;
181 1.7.2.1
182 From 67bb0074eec2b154d15bd3dd77b482c3d6125761 Mon Sep 17 00:00:00 2001
183 From: Jiro SEKIBA <jir@unicus.jp>
184 Date: Tue, 13 Jul 2010 09:14:08 +0200
185 Subject: [PATCH] tests: add nilfs2 test for libblkid
187 Signed-off-by: Jiro SEKIBA <jir@unicus.jp>
188 Signed-off-by: Karel Zak <kzak@redhat.com>
190 tests/expected/blkid/low-probe-nilfs2 | 7 +++++++
191 tests/ts/blkid/images-fs/nilfs2.img.bz2 | Bin 0 -> 795 bytes
192 2 files changed, 7 insertions(+), 0 deletions(-)
193 create mode 100644 tests/expected/blkid/low-probe-nilfs2
194 create mode 100644 tests/ts/blkid/images-fs/nilfs2.img.bz2
196 diff --git a/tests/expected/blkid/low-probe-nilfs2 b/tests/expected/blkid/low-probe-nilfs2
197 new file mode 100644
198 index 0000000..bfd8fcd
199 --- /dev/null
200 +++ b/tests/expected/blkid/low-probe-nilfs2
201 @@ -0,0 +1,7 @@
202 +ID_FS_LABEL=test-nilfs2
203 +ID_FS_LABEL_ENC=test-nilfs2
204 +ID_FS_TYPE=nilfs
205 +ID_FS_USAGE=filesystem
206 +ID_FS_UUID=524025fb-6d31-40e6-baad-1db36cfdf806
207 +ID_FS_UUID_ENC=524025fb-6d31-40e6-baad-1db36cfdf806
208 +ID_FS_VERSION=2
209 diff --git a/tests/ts/blkid/images-fs/nilfs2.img.bz2 b/tests/ts/blkid/images-fs/nilfs2.img.bz2
210 new file mode 100644
211 index 0000000000000000000000000000000000000000..a9762eb1ace9f1999aaad3c40f1d836668d856ac
212 GIT binary patch
213 literal 795
214 zcmZ>Y%CIzaj8qGbG`Ml9n}H$iKM?$BcJi+ANKl`nz?|O0@_@lbK*y;^z=e@R;iM8v
215 z^#R6D2YV7HdVE!LUvc5DPv^n~3?@drY>Er`xpEzs%?rp}D3rOt`HEDABm)D32?GP;
216 z0!EREipv^IOn^)V240{j^Q<Hzqs++;Mp8zSMhpyWZZoCW1WqjeK1)#Iz#6seeHv~(
217 zmxJ_T@69=2^IA3QjKnD|>vorkjN+>MH*4-%s37X<)*F#v)Rf{P;KEe-N=h(9AxK5r
218 zNaB>=<>ixS2R?swwRU~FskVY@0E2@ILyiK&T}MB??Mn}*D~htZ3cdTZRH0!*OIOhp
219 zuF1Yi0SZB_TmsB4k61&aUN!_Ugm_J068*5`gF*w#0teARmnpo_kuT2~GOf!|DtB62
220 z!)T++5$eFKB*GXf;<I9F!NQM?v;8`}*7b6px{&k4S4E)bP}5GYFDbo;*GrVLFkN9@
221 z@@Z9sSb~JGco?eycMA(Q^Ph&Ju|ft>1p%^G=UuLqkPtM9ycck)X|u7g*QFMo>QK!;
222 zURQKH*iWxuZsIwzh@rOT!@1{s7L*D22$pQI7i2k@S1M-~SA2Zm@7XFsJ@fXR;7eg<
223 zQ4&<W_Vc7f@7p(fvkiM$nYo*^O$-78_-wK~RVMkbV1D8JQ`OC<q49;V$o`^l=O3L4
224 zcH6Z3#E!YsGG`s)RMF~EOO1d3>aY{zarw_8qLWfhCp?&^`$6=_69yh&WHm7`bFf@V
225 z(PE04u!6IgDET?h6*ny4n=k(V{?{W7DhkUTSQr9X7>p_oxG=CVFtI2!vN$jZD6(v3
226 z;O=l+m1w{)gHeLB;X+0N+bk2QBw&h}z@#bCHj{nH7h4xLj+2u!PE3DPVsFhCSH8Sp
227 zT}DV?fa{Ns2bOWHVhs!t%xc}wps|W$-`>x&rn$fKjBA>})U}{HMs?HV9M&t-a)KVS
228 zYg}FWIQh_-FYD!hutchUy`86XxmogM<nBjObNPCsG{5_M%3n}$Xkh3NkUdt<dS{}a
229 Lh>ElVLy7|cD)2Ck
231 literal 0
232 HcmV?d00001
235 1.7.2.1
236 From 1326e1dfa5c1d06ff7521b8c8162452799164239 Mon Sep 17 00:00:00 2001
237 From: Jiro SEKIBA <jir@unicus.jp>
238 Date: Thu, 15 Jul 2010 13:40:27 +0900
239 Subject: [PATCH] libblkid: fix typo filesystem name nilfs to nilfs2
241 The correct filesystem name is nilfs2, not nilfs.
243 Signed-off-by: Jiro SEKIBA <jir@unicus.jp>
245 shlibs/blkid/src/superblocks/nilfs.c | 2 +-
246 tests/expected/blkid/low-probe-nilfs2 | 2 +-
247 2 files changed, 2 insertions(+), 2 deletions(-)
249 diff --git a/shlibs/blkid/src/superblocks/nilfs.c b/shlibs/blkid/src/superblocks/nilfs.c
250 index c7aba35..bf16918 100644
251 --- a/shlibs/blkid/src/superblocks/nilfs.c
252 +++ b/shlibs/blkid/src/superblocks/nilfs.c
253 @@ -104,7 +104,7 @@ static int probe_nilfs2(blkid_probe pr, const struct blkid_idmag *mag)
255 const struct blkid_idinfo nilfs2_idinfo =
257 - .name = "nilfs",
258 + .name = "nilfs2",
259 .usage = BLKID_USAGE_FILESYSTEM,
260 .probefunc = probe_nilfs2,
261 .magics =
262 diff --git a/tests/expected/blkid/low-probe-nilfs2 b/tests/expected/blkid/low-probe-nilfs2
263 index bfd8fcd..c6c9cab 100644
264 --- a/tests/expected/blkid/low-probe-nilfs2
265 +++ b/tests/expected/blkid/low-probe-nilfs2
266 @@ -1,6 +1,6 @@
267 ID_FS_LABEL=test-nilfs2
268 ID_FS_LABEL_ENC=test-nilfs2
269 -ID_FS_TYPE=nilfs
270 +ID_FS_TYPE=nilfs2
271 ID_FS_USAGE=filesystem
272 ID_FS_UUID=524025fb-6d31-40e6-baad-1db36cfdf806
273 ID_FS_UUID_ENC=524025fb-6d31-40e6-baad-1db36cfdf806
275 1.7.2.1