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
|
From b864c387e8f16273aad1453d6457d847e29c3d25 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Wed, 22 Sep 2010 22:32:56 -0400
Subject: [PATCH] mtd-utils: clean up zlib.h usage a bit
Hide zlib's crc32 in compr_zlib.c and mkfs.ubifs/compr.c.
jffs2reader.c and mkfs.jffs2.c don't actually use zlib, so punt the
include from the file.
mkfs.jffs2.c is implicitly using crc32 from zlib.h instead of the
local mtd_crc32, so fix the local usage. otherwise we get warnings
about undefined crc32 because the file was redirecting the prototype.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
compr_zlib.c | 2 ++
jffs2reader.c | 1 -
mkfs.jffs2.c | 49 +++++++++++++++++++++++--------------------------
mkfs.ubifs/compr.c | 1 +
4 files changed, 26 insertions(+), 27 deletions(-)
diff --git a/compr_zlib.c b/compr_zlib.c
index 400b18a..db4811d 100644
--- a/compr_zlib.c
+++ b/compr_zlib.c
@@ -33,7 +33,9 @@
*/
#include <stdint.h>
+#define crc32 __zlib_crc32
#include <zlib.h>
+#undef crc32
#include <stdio.h>
#include <asm/types.h>
#include <linux/jffs2.h>
diff --git a/jffs2reader.c b/jffs2reader.c
index cde1d06..0ad7207 100644
--- a/jffs2reader.c
+++ b/jffs2reader.c
@@ -75,7 +75,6 @@ BUGS:
#include <sys/stat.h>
#include <sys/param.h>
#include <dirent.h>
-#include <zlib.h>
#include <linux/jffs2.h>
#define SCRATCH_SIZE (5*1024*1024)
diff --git a/mkfs.jffs2.c b/mkfs.jffs2.c
index ebfdb50..5c18eb1 100644
--- a/mkfs.jffs2.c
+++ b/mkfs.jffs2.c
@@ -69,9 +69,6 @@
#include <sys/acl.h>
#endif
#include <byteswap.h>
-#define crc32 __zlib_crc32
-#include <zlib.h>
-#undef crc32
#include <crc32.h>
#include "rbtree.h"
@@ -798,7 +795,7 @@ static void write_dirent(struct filesystem_entry *e)
rd.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
rd.nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT);
rd.totlen = cpu_to_je32(sizeof(rd) + strlen(name));
- rd.hdr_crc = cpu_to_je32(crc32(0, &rd,
+ rd.hdr_crc = cpu_to_je32(mtd_crc32(0, &rd,
sizeof(struct jffs2_unknown_node) - 4));
rd.pino = cpu_to_je32((e->parent) ? e->parent->ino : 1);
rd.version = cpu_to_je32(version++);
@@ -808,8 +805,8 @@ static void write_dirent(struct filesystem_entry *e)
rd.type = IFTODT(statbuf->st_mode);
//rd.unused[0] = 0;
//rd.unused[1] = 0;
- rd.node_crc = cpu_to_je32(crc32(0, &rd, sizeof(rd) - 8));
- rd.name_crc = cpu_to_je32(crc32(0, name, strlen(name)));
+ rd.node_crc = cpu_to_je32(mtd_crc32(0, &rd, sizeof(rd) - 8));
+ rd.name_crc = cpu_to_je32(mtd_crc32(0, name, strlen(name)));
pad_block_if_less_than(sizeof(rd) + rd.nsize);
full_write(out_fd, &rd, sizeof(rd));
@@ -895,15 +892,15 @@ static unsigned int write_regular_file(struct filesystem_entry *e)
}
ri.totlen = cpu_to_je32(sizeof(ri) + space);
- ri.hdr_crc = cpu_to_je32(crc32(0,
+ ri.hdr_crc = cpu_to_je32(mtd_crc32(0,
&ri, sizeof(struct jffs2_unknown_node) - 4));
ri.version = cpu_to_je32(++ver);
ri.offset = cpu_to_je32(offset);
ri.csize = cpu_to_je32(space);
ri.dsize = cpu_to_je32(dsize);
- ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri) - 8));
- ri.data_crc = cpu_to_je32(crc32(0, wbuf, space));
+ ri.node_crc = cpu_to_je32(mtd_crc32(0, &ri, sizeof(ri) - 8));
+ ri.data_crc = cpu_to_je32(mtd_crc32(0, wbuf, space));
full_write(out_fd, &ri, sizeof(ri));
totcomp += sizeof(ri);
@@ -928,11 +925,11 @@ static unsigned int write_regular_file(struct filesystem_entry *e)
ri.version = cpu_to_je32(++ver);
ri.totlen = cpu_to_je32(sizeof(ri));
- ri.hdr_crc = cpu_to_je32(crc32(0,
+ ri.hdr_crc = cpu_to_je32(mtd_crc32(0,
&ri, sizeof(struct jffs2_unknown_node) - 4));
ri.csize = cpu_to_je32(0);
ri.dsize = cpu_to_je32(0);
- ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri) - 8));
+ ri.node_crc = cpu_to_je32(mtd_crc32(0, &ri, sizeof(ri) - 8));
full_write(out_fd, &ri, sizeof(ri));
padword();
@@ -967,7 +964,7 @@ static void write_symlink(struct filesystem_entry *e)
ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
ri.nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE);
ri.totlen = cpu_to_je32(sizeof(ri) + len);
- ri.hdr_crc = cpu_to_je32(crc32(0,
+ ri.hdr_crc = cpu_to_je32(mtd_crc32(0,
&ri, sizeof(struct jffs2_unknown_node) - 4));
ri.ino = cpu_to_je32(e->ino);
@@ -981,8 +978,8 @@ static void write_symlink(struct filesystem_entry *e)
ri.version = cpu_to_je32(1);
ri.csize = cpu_to_je32(len);
ri.dsize = cpu_to_je32(len);
- ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri) - 8));
- ri.data_crc = cpu_to_je32(crc32(0, e->link, len));
+ ri.node_crc = cpu_to_je32(mtd_crc32(0, &ri, sizeof(ri) - 8));
+ ri.data_crc = cpu_to_je32(mtd_crc32(0, e->link, len));
pad_block_if_less_than(sizeof(ri) + len);
full_write(out_fd, &ri, sizeof(ri));
@@ -1009,7 +1006,7 @@ static void write_pipe(struct filesystem_entry *e)
ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
ri.nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE);
ri.totlen = cpu_to_je32(sizeof(ri));
- ri.hdr_crc = cpu_to_je32(crc32(0,
+ ri.hdr_crc = cpu_to_je32(mtd_crc32(0,
&ri, sizeof(struct jffs2_unknown_node) - 4));
ri.ino = cpu_to_je32(e->ino);
@@ -1023,7 +1020,7 @@ static void write_pipe(struct filesystem_entry *e)
ri.version = cpu_to_je32(1);
ri.csize = cpu_to_je32(0);
ri.dsize = cpu_to_je32(0);
- ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri) - 8));
+ ri.node_crc = cpu_to_je32(mtd_crc32(0, &ri, sizeof(ri) - 8));
ri.data_crc = cpu_to_je32(0);
pad_block_if_less_than(sizeof(ri));
@@ -1049,7 +1046,7 @@ static void write_special_file(struct filesystem_entry *e)
ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
ri.nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE);
ri.totlen = cpu_to_je32(sizeof(ri) + sizeof(kdev));
- ri.hdr_crc = cpu_to_je32(crc32(0,
+ ri.hdr_crc = cpu_to_je32(mtd_crc32(0,
&ri, sizeof(struct jffs2_unknown_node) - 4));
ri.ino = cpu_to_je32(e->ino);
@@ -1063,8 +1060,8 @@ static void write_special_file(struct filesystem_entry *e)
ri.version = cpu_to_je32(1);
ri.csize = cpu_to_je32(sizeof(kdev));
ri.dsize = cpu_to_je32(sizeof(kdev));
- ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri) - 8));
- ri.data_crc = cpu_to_je32(crc32(0, &kdev, sizeof(kdev)));
+ ri.node_crc = cpu_to_je32(mtd_crc32(0, &ri, sizeof(ri) - 8));
+ ri.data_crc = cpu_to_je32(mtd_crc32(0, &kdev, sizeof(kdev)));
pad_block_if_less_than(sizeof(ri) + sizeof(kdev));
full_write(out_fd, &ri, sizeof(ri));
@@ -1177,15 +1174,15 @@ static xattr_entry_t *create_xattr_entry(int xprefix, char *xname, char *xvalue,
rx.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
rx.nodetype = cpu_to_je16(JFFS2_NODETYPE_XATTR);
rx.totlen = cpu_to_je32(PAD(sizeof(rx) + xe->name_len + 1 + xe->value_len));
- rx.hdr_crc = cpu_to_je32(crc32(0, &rx, sizeof(struct jffs2_unknown_node) - 4));
+ rx.hdr_crc = cpu_to_je32(mtd_crc32(0, &rx, sizeof(struct jffs2_unknown_node) - 4));
rx.xid = cpu_to_je32(xe->xid);
rx.version = cpu_to_je32(1); /* initial version */
rx.xprefix = xprefix;
rx.name_len = xe->name_len;
rx.value_len = cpu_to_je16(xe->value_len);
- rx.data_crc = cpu_to_je32(crc32(0, xe->xname, xe->name_len + 1 + xe->value_len));
- rx.node_crc = cpu_to_je32(crc32(0, &rx, sizeof(rx) - 4));
+ rx.data_crc = cpu_to_je32(mtd_crc32(0, xe->xname, xe->name_len + 1 + xe->value_len));
+ rx.node_crc = cpu_to_je32(mtd_crc32(0, &rx, sizeof(rx) - 4));
pad_block_if_less_than(sizeof(rx) + xe->name_len + 1 + xe->value_len);
full_write(out_fd, &rx, sizeof(rx));
@@ -1211,7 +1208,7 @@ static xattr_entry_t *find_xattr_entry(int xprefix, char *xname, char *xvalue, i
formalize_posix_acl(xvalue, &value_len);
name_len = strlen(xname);
- index = (crc32(0, xname, name_len) ^ crc32(0, xvalue, value_len)) % XATTRENTRY_HASHSIZE;
+ index = (mtd_crc32(0, xname, name_len) ^ mtd_crc32(0, xvalue, value_len)) % XATTRENTRY_HASHSIZE;
for (xe = xentry_hash[index]; xe; xe = xe->next) {
if (xe->xprefix == xprefix
&& xe->value_len == value_len
@@ -1291,11 +1288,11 @@ static void write_xattr_entry(struct filesystem_entry *e)
ref.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
ref.nodetype = cpu_to_je16(JFFS2_NODETYPE_XREF);
ref.totlen = cpu_to_je32(sizeof(ref));
- ref.hdr_crc = cpu_to_je32(crc32(0, &ref, sizeof(struct jffs2_unknown_node) - 4));
+ ref.hdr_crc = cpu_to_je32(mtd_crc32(0, &ref, sizeof(struct jffs2_unknown_node) - 4));
ref.ino = cpu_to_je32(e->ino);
ref.xid = cpu_to_je32(xe->xid);
ref.xseqno = cpu_to_je32(highest_xseqno += 2);
- ref.node_crc = cpu_to_je32(crc32(0, &ref, sizeof(ref) - 4));
+ ref.node_crc = cpu_to_je32(mtd_crc32(0, &ref, sizeof(ref) - 4));
pad_block_if_less_than(sizeof(ref));
full_write(out_fd, &ref, sizeof(ref));
@@ -1423,7 +1420,7 @@ static void create_target_filesystem(struct filesystem_entry *root)
cleanmarker.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
cleanmarker.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER);
cleanmarker.totlen = cpu_to_je32(cleanmarker_size);
- cleanmarker.hdr_crc = cpu_to_je32(crc32(0, &cleanmarker, sizeof(struct jffs2_unknown_node)-4));
+ cleanmarker.hdr_crc = cpu_to_je32(mtd_crc32(0, &cleanmarker, sizeof(struct jffs2_unknown_node)-4));
if (ino == 0)
ino = 1;
diff --git a/mkfs.ubifs/compr.c b/mkfs.ubifs/compr.c
index 7f084c5..4152b6a 100644
--- a/mkfs.ubifs/compr.c
+++ b/mkfs.ubifs/compr.c
@@ -29,6 +29,7 @@
#define crc32 __zlib_crc32
#include <zlib.h>
+#undef crc32
#include "compr.h"
#include "ubifs-media.h"
--
1.7.1
|