aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2')
-rw-r--r--fs/jffs2/background.c4
-rw-r--r--fs/jffs2/compr.c381
-rw-r--r--fs/jffs2/compr.h44
-rw-r--r--fs/jffs2/compr_rtime.c2
-rw-r--r--fs/jffs2/compr_rubin.c4
-rw-r--r--fs/jffs2/compr_zlib.c6
-rw-r--r--fs/jffs2/dir.c4
-rw-r--r--fs/jffs2/erase.c4
-rw-r--r--fs/jffs2/gc.c4
-rw-r--r--fs/jffs2/nodelist.h2
-rw-r--r--fs/jffs2/nodemgmt.c2
-rw-r--r--fs/jffs2/readinode.c6
-rw-r--r--fs/jffs2/scan.c2
-rw-r--r--fs/jffs2/security.c6
-rw-r--r--fs/jffs2/summary.c8
-rw-r--r--fs/jffs2/summary.h6
-rw-r--r--fs/jffs2/wbuf.c4
-rw-r--r--fs/jffs2/xattr.h2
-rw-r--r--fs/jffs2/xattr_user.c4
19 files changed, 248 insertions, 247 deletions
diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c
index 39bd6c7a9b62..8754b2742112 100644
--- a/fs/jffs2/background.c
+++ b/fs/jffs2/background.c
@@ -23,8 +23,8 @@ static int jffs2_garbage_collect_thread(void *);
23void jffs2_garbage_collect_trigger(struct jffs2_sb_info *c) 23void jffs2_garbage_collect_trigger(struct jffs2_sb_info *c)
24{ 24{
25 spin_lock(&c->erase_completion_lock); 25 spin_lock(&c->erase_completion_lock);
26 if (c->gc_task && jffs2_thread_should_wake(c)) 26 if (c->gc_task && jffs2_thread_should_wake(c))
27 send_sig(SIGHUP, c->gc_task, 1); 27 send_sig(SIGHUP, c->gc_task, 1);
28 spin_unlock(&c->erase_completion_lock); 28 spin_unlock(&c->erase_completion_lock);
29} 29}
30 30
diff --git a/fs/jffs2/compr.c b/fs/jffs2/compr.c
index 485d065de41f..d90ca05e4992 100644
--- a/fs/jffs2/compr.c
+++ b/fs/jffs2/compr.c
@@ -5,7 +5,7 @@
5 * Created by Arjan van de Ven <arjanv@redhat.com> 5 * Created by Arjan van de Ven <arjanv@redhat.com>
6 * 6 *
7 * Copyright © 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>, 7 * Copyright © 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>,
8 * University of Szeged, Hungary 8 * University of Szeged, Hungary
9 * 9 *
10 * For licensing information, see the file 'LICENCE' in this directory. 10 * For licensing information, see the file 'LICENCE' in this directory.
11 * 11 *
@@ -43,121 +43,122 @@ static uint32_t none_stat_compr_blocks=0,none_stat_decompr_blocks=0,none_stat_co
43 * *datalen accordingly to show the amount of data which were compressed. 43 * *datalen accordingly to show the amount of data which were compressed.
44 */ 44 */
45uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 45uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
46 unsigned char *data_in, unsigned char **cpage_out, 46 unsigned char *data_in, unsigned char **cpage_out,
47 uint32_t *datalen, uint32_t *cdatalen) 47 uint32_t *datalen, uint32_t *cdatalen)
48{ 48{
49 int ret = JFFS2_COMPR_NONE; 49 int ret = JFFS2_COMPR_NONE;
50 int compr_ret; 50 int compr_ret;
51 struct jffs2_compressor *this, *best=NULL; 51 struct jffs2_compressor *this, *best=NULL;
52 unsigned char *output_buf = NULL, *tmp_buf; 52 unsigned char *output_buf = NULL, *tmp_buf;
53 uint32_t orig_slen, orig_dlen; 53 uint32_t orig_slen, orig_dlen;
54 uint32_t best_slen=0, best_dlen=0; 54 uint32_t best_slen=0, best_dlen=0;
55 55
56 switch (jffs2_compression_mode) { 56 switch (jffs2_compression_mode) {
57 case JFFS2_COMPR_MODE_NONE: 57 case JFFS2_COMPR_MODE_NONE:
58 break; 58 break;
59 case JFFS2_COMPR_MODE_PRIORITY: 59 case JFFS2_COMPR_MODE_PRIORITY:
60 output_buf = kmalloc(*cdatalen,GFP_KERNEL); 60 output_buf = kmalloc(*cdatalen,GFP_KERNEL);
61 if (!output_buf) { 61 if (!output_buf) {
62 printk(KERN_WARNING "JFFS2: No memory for compressor allocation. Compression failed.\n"); 62 printk(KERN_WARNING "JFFS2: No memory for compressor allocation. Compression failed.\n");
63 goto out; 63 goto out;
64 } 64 }
65 orig_slen = *datalen; 65 orig_slen = *datalen;
66 orig_dlen = *cdatalen; 66 orig_dlen = *cdatalen;
67 spin_lock(&jffs2_compressor_list_lock); 67 spin_lock(&jffs2_compressor_list_lock);
68 list_for_each_entry(this, &jffs2_compressor_list, list) { 68 list_for_each_entry(this, &jffs2_compressor_list, list) {
69 /* Skip decompress-only backwards-compatibility and disabled modules */ 69 /* Skip decompress-only backwards-compatibility and disabled modules */
70 if ((!this->compress)||(this->disabled)) 70 if ((!this->compress)||(this->disabled))
71 continue; 71 continue;
72 72
73 this->usecount++; 73 this->usecount++;
74 spin_unlock(&jffs2_compressor_list_lock); 74 spin_unlock(&jffs2_compressor_list_lock);
75 *datalen = orig_slen; 75 *datalen = orig_slen;
76 *cdatalen = orig_dlen; 76 *cdatalen = orig_dlen;
77 compr_ret = this->compress(data_in, output_buf, datalen, cdatalen, NULL); 77 compr_ret = this->compress(data_in, output_buf, datalen, cdatalen, NULL);
78 spin_lock(&jffs2_compressor_list_lock); 78 spin_lock(&jffs2_compressor_list_lock);
79 this->usecount--; 79 this->usecount--;
80 if (!compr_ret) { 80 if (!compr_ret) {
81 ret = this->compr; 81 ret = this->compr;
82 this->stat_compr_blocks++; 82 this->stat_compr_blocks++;
83 this->stat_compr_orig_size += *datalen; 83 this->stat_compr_orig_size += *datalen;
84 this->stat_compr_new_size += *cdatalen; 84 this->stat_compr_new_size += *cdatalen;
85 break; 85 break;
86 } 86 }
87 } 87 }
88 spin_unlock(&jffs2_compressor_list_lock); 88 spin_unlock(&jffs2_compressor_list_lock);
89 if (ret == JFFS2_COMPR_NONE) kfree(output_buf); 89 if (ret == JFFS2_COMPR_NONE)
90 break; 90 kfree(output_buf);
91 case JFFS2_COMPR_MODE_SIZE: 91 break;
92 orig_slen = *datalen; 92 case JFFS2_COMPR_MODE_SIZE:
93 orig_dlen = *cdatalen; 93 orig_slen = *datalen;
94 spin_lock(&jffs2_compressor_list_lock); 94 orig_dlen = *cdatalen;
95 list_for_each_entry(this, &jffs2_compressor_list, list) { 95 spin_lock(&jffs2_compressor_list_lock);
96 /* Skip decompress-only backwards-compatibility and disabled modules */ 96 list_for_each_entry(this, &jffs2_compressor_list, list) {
97 if ((!this->compress)||(this->disabled)) 97 /* Skip decompress-only backwards-compatibility and disabled modules */
98 continue; 98 if ((!this->compress)||(this->disabled))
99 /* Allocating memory for output buffer if necessary */ 99 continue;
100 if ((this->compr_buf_size<orig_dlen)&&(this->compr_buf)) { 100 /* Allocating memory for output buffer if necessary */
101 spin_unlock(&jffs2_compressor_list_lock); 101 if ((this->compr_buf_size<orig_dlen)&&(this->compr_buf)) {
102 kfree(this->compr_buf); 102 spin_unlock(&jffs2_compressor_list_lock);
103 spin_lock(&jffs2_compressor_list_lock); 103 kfree(this->compr_buf);
104 this->compr_buf_size=0; 104 spin_lock(&jffs2_compressor_list_lock);
105 this->compr_buf=NULL; 105 this->compr_buf_size=0;
106 } 106 this->compr_buf=NULL;
107 if (!this->compr_buf) { 107 }
108 spin_unlock(&jffs2_compressor_list_lock); 108 if (!this->compr_buf) {
109 tmp_buf = kmalloc(orig_dlen,GFP_KERNEL); 109 spin_unlock(&jffs2_compressor_list_lock);
110 spin_lock(&jffs2_compressor_list_lock); 110 tmp_buf = kmalloc(orig_dlen,GFP_KERNEL);
111 if (!tmp_buf) { 111 spin_lock(&jffs2_compressor_list_lock);
112 printk(KERN_WARNING "JFFS2: No memory for compressor allocation. (%d bytes)\n",orig_dlen); 112 if (!tmp_buf) {
113 continue; 113 printk(KERN_WARNING "JFFS2: No memory for compressor allocation. (%d bytes)\n",orig_dlen);
114 } 114 continue;
115 else { 115 }
116 this->compr_buf = tmp_buf; 116 else {
117 this->compr_buf_size = orig_dlen; 117 this->compr_buf = tmp_buf;
118 } 118 this->compr_buf_size = orig_dlen;
119 } 119 }
120 this->usecount++; 120 }
121 spin_unlock(&jffs2_compressor_list_lock); 121 this->usecount++;
122 *datalen = orig_slen; 122 spin_unlock(&jffs2_compressor_list_lock);
123 *cdatalen = orig_dlen; 123 *datalen = orig_slen;
124 compr_ret = this->compress(data_in, this->compr_buf, datalen, cdatalen, NULL); 124 *cdatalen = orig_dlen;
125 spin_lock(&jffs2_compressor_list_lock); 125 compr_ret = this->compress(data_in, this->compr_buf, datalen, cdatalen, NULL);
126 this->usecount--; 126 spin_lock(&jffs2_compressor_list_lock);
127 if (!compr_ret) { 127 this->usecount--;
128 if ((!best_dlen)||(best_dlen>*cdatalen)) { 128 if (!compr_ret) {
129 best_dlen = *cdatalen; 129 if ((!best_dlen)||(best_dlen>*cdatalen)) {
130 best_slen = *datalen; 130 best_dlen = *cdatalen;
131 best = this; 131 best_slen = *datalen;
132 } 132 best = this;
133 } 133 }
134 } 134 }
135 if (best_dlen) { 135 }
136 *cdatalen = best_dlen; 136 if (best_dlen) {
137 *datalen = best_slen; 137 *cdatalen = best_dlen;
138 output_buf = best->compr_buf; 138 *datalen = best_slen;
139 best->compr_buf = NULL; 139 output_buf = best->compr_buf;
140 best->compr_buf_size = 0; 140 best->compr_buf = NULL;
141 best->stat_compr_blocks++; 141 best->compr_buf_size = 0;
142 best->stat_compr_orig_size += best_slen; 142 best->stat_compr_blocks++;
143 best->stat_compr_new_size += best_dlen; 143 best->stat_compr_orig_size += best_slen;
144 ret = best->compr; 144 best->stat_compr_new_size += best_dlen;
145 } 145 ret = best->compr;
146 spin_unlock(&jffs2_compressor_list_lock); 146 }
147 break; 147 spin_unlock(&jffs2_compressor_list_lock);
148 default: 148 break;
149 printk(KERN_ERR "JFFS2: unknow compression mode.\n"); 149 default:
150 } 150 printk(KERN_ERR "JFFS2: unknow compression mode.\n");
151 }
151 out: 152 out:
152 if (ret == JFFS2_COMPR_NONE) { 153 if (ret == JFFS2_COMPR_NONE) {
153 *cpage_out = data_in; 154 *cpage_out = data_in;
154 *datalen = *cdatalen; 155 *datalen = *cdatalen;
155 none_stat_compr_blocks++; 156 none_stat_compr_blocks++;
156 none_stat_compr_size += *datalen; 157 none_stat_compr_size += *datalen;
157 } 158 }
158 else { 159 else {
159 *cpage_out = output_buf; 160 *cpage_out = output_buf;
160 } 161 }
161 return ret; 162 return ret;
162} 163}
163 164
@@ -165,8 +166,8 @@ int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
165 uint16_t comprtype, unsigned char *cdata_in, 166 uint16_t comprtype, unsigned char *cdata_in,
166 unsigned char *data_out, uint32_t cdatalen, uint32_t datalen) 167 unsigned char *data_out, uint32_t cdatalen, uint32_t datalen)
167{ 168{
168 struct jffs2_compressor *this; 169 struct jffs2_compressor *this;
169 int ret; 170 int ret;
170 171
171 /* Older code had a bug where it would write non-zero 'usercompr' 172 /* Older code had a bug where it would write non-zero 'usercompr'
172 fields. Deal with it. */ 173 fields. Deal with it. */
@@ -177,32 +178,32 @@ int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
177 case JFFS2_COMPR_NONE: 178 case JFFS2_COMPR_NONE:
178 /* This should be special-cased elsewhere, but we might as well deal with it */ 179 /* This should be special-cased elsewhere, but we might as well deal with it */
179 memcpy(data_out, cdata_in, datalen); 180 memcpy(data_out, cdata_in, datalen);
180 none_stat_decompr_blocks++; 181 none_stat_decompr_blocks++;
181 break; 182 break;
182 case JFFS2_COMPR_ZERO: 183 case JFFS2_COMPR_ZERO:
183 memset(data_out, 0, datalen); 184 memset(data_out, 0, datalen);
184 break; 185 break;
185 default: 186 default:
186 spin_lock(&jffs2_compressor_list_lock); 187 spin_lock(&jffs2_compressor_list_lock);
187 list_for_each_entry(this, &jffs2_compressor_list, list) { 188 list_for_each_entry(this, &jffs2_compressor_list, list) {
188 if (comprtype == this->compr) { 189 if (comprtype == this->compr) {
189 this->usecount++; 190 this->usecount++;
190 spin_unlock(&jffs2_compressor_list_lock); 191 spin_unlock(&jffs2_compressor_list_lock);
191 ret = this->decompress(cdata_in, data_out, cdatalen, datalen, NULL); 192 ret = this->decompress(cdata_in, data_out, cdatalen, datalen, NULL);
192 spin_lock(&jffs2_compressor_list_lock); 193 spin_lock(&jffs2_compressor_list_lock);
193 if (ret) { 194 if (ret) {
194 printk(KERN_WARNING "Decompressor \"%s\" returned %d\n", this->name, ret); 195 printk(KERN_WARNING "Decompressor \"%s\" returned %d\n", this->name, ret);
195 } 196 }
196 else { 197 else {
197 this->stat_decompr_blocks++; 198 this->stat_decompr_blocks++;
198 } 199 }
199 this->usecount--; 200 this->usecount--;
200 spin_unlock(&jffs2_compressor_list_lock); 201 spin_unlock(&jffs2_compressor_list_lock);
201 return ret; 202 return ret;
202 } 203 }
203 } 204 }
204 printk(KERN_WARNING "JFFS2 compression type 0x%02x not available.\n", comprtype); 205 printk(KERN_WARNING "JFFS2 compression type 0x%02x not available.\n", comprtype);
205 spin_unlock(&jffs2_compressor_list_lock); 206 spin_unlock(&jffs2_compressor_list_lock);
206 return -EIO; 207 return -EIO;
207 } 208 }
208 return 0; 209 return 0;
@@ -210,108 +211,108 @@ int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
210 211
211int jffs2_register_compressor(struct jffs2_compressor *comp) 212int jffs2_register_compressor(struct jffs2_compressor *comp)
212{ 213{
213 struct jffs2_compressor *this; 214 struct jffs2_compressor *this;
214 215
215 if (!comp->name) { 216 if (!comp->name) {
216 printk(KERN_WARNING "NULL compressor name at registering JFFS2 compressor. Failed.\n"); 217 printk(KERN_WARNING "NULL compressor name at registering JFFS2 compressor. Failed.\n");
217 return -1; 218 return -1;
218 } 219 }
219 comp->compr_buf_size=0; 220 comp->compr_buf_size=0;
220 comp->compr_buf=NULL; 221 comp->compr_buf=NULL;
221 comp->usecount=0; 222 comp->usecount=0;
222 comp->stat_compr_orig_size=0; 223 comp->stat_compr_orig_size=0;
223 comp->stat_compr_new_size=0; 224 comp->stat_compr_new_size=0;
224 comp->stat_compr_blocks=0; 225 comp->stat_compr_blocks=0;
225 comp->stat_decompr_blocks=0; 226 comp->stat_decompr_blocks=0;
226 D1(printk(KERN_DEBUG "Registering JFFS2 compressor \"%s\"\n", comp->name)); 227 D1(printk(KERN_DEBUG "Registering JFFS2 compressor \"%s\"\n", comp->name));
227 228
228 spin_lock(&jffs2_compressor_list_lock); 229 spin_lock(&jffs2_compressor_list_lock);
229 230
230 list_for_each_entry(this, &jffs2_compressor_list, list) { 231 list_for_each_entry(this, &jffs2_compressor_list, list) {
231 if (this->priority < comp->priority) { 232 if (this->priority < comp->priority) {
232 list_add(&comp->list, this->list.prev); 233 list_add(&comp->list, this->list.prev);
233 goto out; 234 goto out;
234 } 235 }
235 } 236 }
236 list_add_tail(&comp->list, &jffs2_compressor_list); 237 list_add_tail(&comp->list, &jffs2_compressor_list);
237out: 238out:
238 D2(list_for_each_entry(this, &jffs2_compressor_list, list) { 239 D2(list_for_each_entry(this, &jffs2_compressor_list, list) {
239 printk(KERN_DEBUG "Compressor \"%s\", prio %d\n", this->name, this->priority); 240 printk(KERN_DEBUG "Compressor \"%s\", prio %d\n", this->name, this->priority);
240 }) 241 })
241 242
242 spin_unlock(&jffs2_compressor_list_lock); 243 spin_unlock(&jffs2_compressor_list_lock);
243 244
244 return 0; 245 return 0;
245} 246}
246 247
247int jffs2_unregister_compressor(struct jffs2_compressor *comp) 248int jffs2_unregister_compressor(struct jffs2_compressor *comp)
248{ 249{
249 D2(struct jffs2_compressor *this;) 250 D2(struct jffs2_compressor *this;)
250 251
251 D1(printk(KERN_DEBUG "Unregistering JFFS2 compressor \"%s\"\n", comp->name)); 252 D1(printk(KERN_DEBUG "Unregistering JFFS2 compressor \"%s\"\n", comp->name));
252 253
253 spin_lock(&jffs2_compressor_list_lock); 254 spin_lock(&jffs2_compressor_list_lock);
254 255
255 if (comp->usecount) { 256 if (comp->usecount) {
256 spin_unlock(&jffs2_compressor_list_lock); 257 spin_unlock(&jffs2_compressor_list_lock);
257 printk(KERN_WARNING "JFFS2: Compressor modul is in use. Unregister failed.\n"); 258 printk(KERN_WARNING "JFFS2: Compressor modul is in use. Unregister failed.\n");
258 return -1; 259 return -1;
259 } 260 }
260 list_del(&comp->list); 261 list_del(&comp->list);
261 262
262 D2(list_for_each_entry(this, &jffs2_compressor_list, list) { 263 D2(list_for_each_entry(this, &jffs2_compressor_list, list) {
263 printk(KERN_DEBUG "Compressor \"%s\", prio %d\n", this->name, this->priority); 264 printk(KERN_DEBUG "Compressor \"%s\", prio %d\n", this->name, this->priority);
264 }) 265 })
265 spin_unlock(&jffs2_compressor_list_lock); 266 spin_unlock(&jffs2_compressor_list_lock);
266 return 0; 267 return 0;
267} 268}
268 269
269void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig) 270void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig)
270{ 271{
271 if (orig != comprbuf) 272 if (orig != comprbuf)
272 kfree(comprbuf); 273 kfree(comprbuf);
273} 274}
274 275
275int __init jffs2_compressors_init(void) 276int __init jffs2_compressors_init(void)
276{ 277{
277/* Registering compressors */ 278/* Registering compressors */
278#ifdef CONFIG_JFFS2_ZLIB 279#ifdef CONFIG_JFFS2_ZLIB
279 jffs2_zlib_init(); 280 jffs2_zlib_init();
280#endif 281#endif
281#ifdef CONFIG_JFFS2_RTIME 282#ifdef CONFIG_JFFS2_RTIME
282 jffs2_rtime_init(); 283 jffs2_rtime_init();
283#endif 284#endif
284#ifdef CONFIG_JFFS2_RUBIN 285#ifdef CONFIG_JFFS2_RUBIN
285 jffs2_rubinmips_init(); 286 jffs2_rubinmips_init();
286 jffs2_dynrubin_init(); 287 jffs2_dynrubin_init();
287#endif 288#endif
288/* Setting default compression mode */ 289/* Setting default compression mode */
289#ifdef CONFIG_JFFS2_CMODE_NONE 290#ifdef CONFIG_JFFS2_CMODE_NONE
290 jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; 291 jffs2_compression_mode = JFFS2_COMPR_MODE_NONE;
291 D1(printk(KERN_INFO "JFFS2: default compression mode: none\n");) 292 D1(printk(KERN_INFO "JFFS2: default compression mode: none\n");)
292#else 293#else
293#ifdef CONFIG_JFFS2_CMODE_SIZE 294#ifdef CONFIG_JFFS2_CMODE_SIZE
294 jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE; 295 jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE;
295 D1(printk(KERN_INFO "JFFS2: default compression mode: size\n");) 296 D1(printk(KERN_INFO "JFFS2: default compression mode: size\n");)
296#else 297#else
297 D1(printk(KERN_INFO "JFFS2: default compression mode: priority\n");) 298 D1(printk(KERN_INFO "JFFS2: default compression mode: priority\n");)
298#endif 299#endif
299#endif 300#endif
300 return 0; 301 return 0;
301} 302}
302 303
303int jffs2_compressors_exit(void) 304int jffs2_compressors_exit(void)
304{ 305{
305/* Unregistering compressors */ 306/* Unregistering compressors */
306#ifdef CONFIG_JFFS2_RUBIN 307#ifdef CONFIG_JFFS2_RUBIN
307 jffs2_dynrubin_exit(); 308 jffs2_dynrubin_exit();
308 jffs2_rubinmips_exit(); 309 jffs2_rubinmips_exit();
309#endif 310#endif
310#ifdef CONFIG_JFFS2_RTIME 311#ifdef CONFIG_JFFS2_RTIME
311 jffs2_rtime_exit(); 312 jffs2_rtime_exit();
312#endif 313#endif
313#ifdef CONFIG_JFFS2_ZLIB 314#ifdef CONFIG_JFFS2_ZLIB
314 jffs2_zlib_exit(); 315 jffs2_zlib_exit();
315#endif 316#endif
316 return 0; 317 return 0;
317} 318}
diff --git a/fs/jffs2/compr.h b/fs/jffs2/compr.h
index 68cc7010dbdf..1070275da58f 100644
--- a/fs/jffs2/compr.h
+++ b/fs/jffs2/compr.h
@@ -2,7 +2,7 @@
2 * JFFS2 -- Journalling Flash File System, Version 2. 2 * JFFS2 -- Journalling Flash File System, Version 2.
3 * 3 *
4 * Copyright © 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>, 4 * Copyright © 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>,
5 * University of Szeged, Hungary 5 * University of Szeged, Hungary
6 * 6 *
7 * For licensing information, see the file 'LICENCE' in this directory. 7 * For licensing information, see the file 'LICENCE' in this directory.
8 * 8 *
@@ -32,29 +32,29 @@
32#define JFFS2_ZLIB_PRIORITY 60 32#define JFFS2_ZLIB_PRIORITY 60
33 33
34#define JFFS2_RUBINMIPS_DISABLED /* RUBINs will be used only */ 34#define JFFS2_RUBINMIPS_DISABLED /* RUBINs will be used only */
35#define JFFS2_DYNRUBIN_DISABLED /* for decompression */ 35#define JFFS2_DYNRUBIN_DISABLED /* for decompression */
36 36
37#define JFFS2_COMPR_MODE_NONE 0 37#define JFFS2_COMPR_MODE_NONE 0
38#define JFFS2_COMPR_MODE_PRIORITY 1 38#define JFFS2_COMPR_MODE_PRIORITY 1
39#define JFFS2_COMPR_MODE_SIZE 2 39#define JFFS2_COMPR_MODE_SIZE 2
40 40
41struct jffs2_compressor { 41struct jffs2_compressor {
42 struct list_head list; 42 struct list_head list;
43 int priority; /* used by prirority comr. mode */ 43 int priority; /* used by prirority comr. mode */
44 char *name; 44 char *name;
45 char compr; /* JFFS2_COMPR_XXX */ 45 char compr; /* JFFS2_COMPR_XXX */
46 int (*compress)(unsigned char *data_in, unsigned char *cpage_out, 46 int (*compress)(unsigned char *data_in, unsigned char *cpage_out,
47 uint32_t *srclen, uint32_t *destlen, void *model); 47 uint32_t *srclen, uint32_t *destlen, void *model);
48 int (*decompress)(unsigned char *cdata_in, unsigned char *data_out, 48 int (*decompress)(unsigned char *cdata_in, unsigned char *data_out,
49 uint32_t cdatalen, uint32_t datalen, void *model); 49 uint32_t cdatalen, uint32_t datalen, void *model);
50 int usecount; 50 int usecount;
51 int disabled; /* if seted the compressor won't compress */ 51 int disabled; /* if set the compressor won't compress */
52 unsigned char *compr_buf; /* used by size compr. mode */ 52 unsigned char *compr_buf; /* used by size compr. mode */
53 uint32_t compr_buf_size; /* used by size compr. mode */ 53 uint32_t compr_buf_size; /* used by size compr. mode */
54 uint32_t stat_compr_orig_size; 54 uint32_t stat_compr_orig_size;
55 uint32_t stat_compr_new_size; 55 uint32_t stat_compr_new_size;
56 uint32_t stat_compr_blocks; 56 uint32_t stat_compr_blocks;
57 uint32_t stat_decompr_blocks; 57 uint32_t stat_decompr_blocks;
58}; 58};
59 59
60int jffs2_register_compressor(struct jffs2_compressor *comp); 60int jffs2_register_compressor(struct jffs2_compressor *comp);
@@ -64,12 +64,12 @@ int jffs2_compressors_init(void);
64int jffs2_compressors_exit(void); 64int jffs2_compressors_exit(void);
65 65
66uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 66uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
67 unsigned char *data_in, unsigned char **cpage_out, 67 unsigned char *data_in, unsigned char **cpage_out,
68 uint32_t *datalen, uint32_t *cdatalen); 68 uint32_t *datalen, uint32_t *cdatalen);
69 69
70int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 70int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
71 uint16_t comprtype, unsigned char *cdata_in, 71 uint16_t comprtype, unsigned char *cdata_in,
72 unsigned char *data_out, uint32_t cdatalen, uint32_t datalen); 72 unsigned char *data_out, uint32_t cdatalen, uint32_t datalen);
73 73
74void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig); 74void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig);
75 75
diff --git a/fs/jffs2/compr_rtime.c b/fs/jffs2/compr_rtime.c
index 0d0bfd2e4e0d..546d1538d076 100644
--- a/fs/jffs2/compr_rtime.c
+++ b/fs/jffs2/compr_rtime.c
@@ -104,7 +104,7 @@ static int jffs2_rtime_decompress(unsigned char *data_in,
104 } 104 }
105 } 105 }
106 } 106 }
107 return 0; 107 return 0;
108} 108}
109 109
110static struct jffs2_compressor jffs2_rtime_comp = { 110static struct jffs2_compressor jffs2_rtime_comp = {
diff --git a/fs/jffs2/compr_rubin.c b/fs/jffs2/compr_rubin.c
index ea0431e047d5..c73fa89b5f8a 100644
--- a/fs/jffs2/compr_rubin.c
+++ b/fs/jffs2/compr_rubin.c
@@ -384,7 +384,7 @@ static int jffs2_rubinmips_decompress(unsigned char *data_in,
384 void *model) 384 void *model)
385{ 385{
386 rubin_do_decompress(BIT_DIVIDER_MIPS, bits_mips, data_in, cpage_out, sourcelen, dstlen); 386 rubin_do_decompress(BIT_DIVIDER_MIPS, bits_mips, data_in, cpage_out, sourcelen, dstlen);
387 return 0; 387 return 0;
388} 388}
389 389
390static int jffs2_dynrubin_decompress(unsigned char *data_in, 390static int jffs2_dynrubin_decompress(unsigned char *data_in,
@@ -399,7 +399,7 @@ static int jffs2_dynrubin_decompress(unsigned char *data_in,
399 bits[c] = data_in[c]; 399 bits[c] = data_in[c];
400 400
401 rubin_do_decompress(256, bits, data_in+8, cpage_out, sourcelen-8, dstlen); 401 rubin_do_decompress(256, bits, data_in+8, cpage_out, sourcelen-8, dstlen);
402 return 0; 402 return 0;
403} 403}
404 404
405static struct jffs2_compressor jffs2_rubinmips_comp = { 405static struct jffs2_compressor jffs2_rubinmips_comp = {
diff --git a/fs/jffs2/compr_zlib.c b/fs/jffs2/compr_zlib.c
index 2b87fccc1557..cfd301a5edfc 100644
--- a/fs/jffs2/compr_zlib.c
+++ b/fs/jffs2/compr_zlib.c
@@ -181,7 +181,7 @@ static int jffs2_zlib_decompress(unsigned char *data_in,
181 } 181 }
182 zlib_inflateEnd(&inf_strm); 182 zlib_inflateEnd(&inf_strm);
183 mutex_unlock(&inflate_mutex); 183 mutex_unlock(&inflate_mutex);
184 return 0; 184 return 0;
185} 185}
186 186
187static struct jffs2_compressor jffs2_zlib_comp = { 187static struct jffs2_compressor jffs2_zlib_comp = {
@@ -203,11 +203,11 @@ int __init jffs2_zlib_init(void)
203 203
204 ret = alloc_workspaces(); 204 ret = alloc_workspaces();
205 if (ret) 205 if (ret)
206 return ret; 206 return ret;
207 207
208 ret = jffs2_register_compressor(&jffs2_zlib_comp); 208 ret = jffs2_register_compressor(&jffs2_zlib_comp);
209 if (ret) 209 if (ret)
210 free_workspaces(); 210 free_workspaces();
211 211
212 return ret; 212 return ret;
213} 213}
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index c1dfca310dd6..d293a1fad6d6 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -32,7 +32,7 @@ static int jffs2_mkdir (struct inode *,struct dentry *,int);
32static int jffs2_rmdir (struct inode *,struct dentry *); 32static int jffs2_rmdir (struct inode *,struct dentry *);
33static int jffs2_mknod (struct inode *,struct dentry *,int,dev_t); 33static int jffs2_mknod (struct inode *,struct dentry *,int,dev_t);
34static int jffs2_rename (struct inode *, struct dentry *, 34static int jffs2_rename (struct inode *, struct dentry *,
35 struct inode *, struct dentry *); 35 struct inode *, struct dentry *);
36 36
37const struct file_operations jffs2_dir_operations = 37const struct file_operations jffs2_dir_operations =
38{ 38{
@@ -770,7 +770,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
770} 770}
771 771
772static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, 772static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
773 struct inode *new_dir_i, struct dentry *new_dentry) 773 struct inode *new_dir_i, struct dentry *new_dentry)
774{ 774{
775 int ret; 775 int ret;
776 struct jffs2_sb_info *c = JFFS2_SB_INFO(old_dir_i->i_sb); 776 struct jffs2_sb_info *c = JFFS2_SB_INFO(old_dir_i->i_sb);
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index f81148ae3101..efd83f33a806 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -38,8 +38,8 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
38#ifdef __ECOS 38#ifdef __ECOS
39 ret = jffs2_flash_erase(c, jeb); 39 ret = jffs2_flash_erase(c, jeb);
40 if (!ret) { 40 if (!ret) {
41 jffs2_erase_succeeded(c, jeb); 41 jffs2_erase_succeeded(c, jeb);
42 return; 42 return;
43 } 43 }
44 bad_offset = jeb->offset; 44 bad_offset = jeb->offset;
45#else /* Linux */ 45#else /* Linux */
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c
index 2d99e06ab223..eded819df235 100644
--- a/fs/jffs2/gc.c
+++ b/fs/jffs2/gc.c
@@ -556,7 +556,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
556 556
557 node = kmalloc(rawlen, GFP_KERNEL); 557 node = kmalloc(rawlen, GFP_KERNEL);
558 if (!node) 558 if (!node)
559 return -ENOMEM; 559 return -ENOMEM;
560 560
561 ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (char *)node); 561 ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (char *)node);
562 if (!ret && retlen != rawlen) 562 if (!ret && retlen != rawlen)
@@ -624,7 +624,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
624 624
625 if (ret || (retlen != rawlen)) { 625 if (ret || (retlen != rawlen)) {
626 printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n", 626 printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n",
627 rawlen, phys_ofs, ret, retlen); 627 rawlen, phys_ofs, ret, retlen);
628 if (retlen) { 628 if (retlen) {
629 jffs2_add_physical_node_ref(c, phys_ofs | REF_OBSOLETE, rawlen, NULL); 629 jffs2_add_physical_node_ref(c, phys_ofs | REF_OBSOLETE, rawlen, NULL);
630 } else { 630 } else {
diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h
index bc5509fe577b..ec1aae9e695e 100644
--- a/fs/jffs2/nodelist.h
+++ b/fs/jffs2/nodelist.h
@@ -127,7 +127,7 @@ static inline struct jffs2_inode_cache *jffs2_raw_ref_to_ic(struct jffs2_raw_nod
127 return ((struct jffs2_inode_cache *)raw); 127 return ((struct jffs2_inode_cache *)raw);
128} 128}
129 129
130 /* flash_offset & 3 always has to be zero, because nodes are 130 /* flash_offset & 3 always has to be zero, because nodes are
131 always aligned at 4 bytes. So we have a couple of extra bits 131 always aligned at 4 bytes. So we have a couple of extra bits
132 to play with, which indicate the node's status; see below: */ 132 to play with, which indicate the node's status; see below: */
133#define REF_UNCHECKED 0 /* We haven't yet checked the CRC or built its inode */ 133#define REF_UNCHECKED 0 /* We haven't yet checked the CRC or built its inode */
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c
index 9c3a3bba6dcf..5b49bff364b4 100644
--- a/fs/jffs2/nodemgmt.c
+++ b/fs/jffs2/nodemgmt.c
@@ -154,7 +154,7 @@ int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize,
154 while(ret == -EAGAIN) { 154 while(ret == -EAGAIN) {
155 ret = jffs2_do_reserve_space(c, minsize, len, sumsize); 155 ret = jffs2_do_reserve_space(c, minsize, len, sumsize);
156 if (ret) { 156 if (ret) {
157 D1(printk(KERN_DEBUG "jffs2_reserve_space_gc: looping, ret is %d\n", ret)); 157 D1(printk(KERN_DEBUG "jffs2_reserve_space_gc: looping, ret is %d\n", ret));
158 } 158 }
159 } 159 }
160 spin_unlock(&c->erase_completion_lock); 160 spin_unlock(&c->erase_completion_lock);
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index b5baa356fed2..8d4319c56b17 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -211,7 +211,7 @@ static void jffs2_kill_tn(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info *
211 * ordering. 211 * ordering.
212 * 212 *
213 * Returns 0 if the node was handled (including marking it obsolete) 213 * Returns 0 if the node was handled (including marking it obsolete)
214 * < 0 an if error occurred 214 * < 0 an if error occurred
215 */ 215 */
216static int jffs2_add_tn_to_tree(struct jffs2_sb_info *c, 216static int jffs2_add_tn_to_tree(struct jffs2_sb_info *c,
217 struct jffs2_readinode_info *rii, 217 struct jffs2_readinode_info *rii,
@@ -862,8 +862,8 @@ static inline int read_unknown(struct jffs2_sb_info *c, struct jffs2_raw_node_re
862 JFFS2_ERROR("REF_UNCHECKED but unknown node at %#08x\n", 862 JFFS2_ERROR("REF_UNCHECKED but unknown node at %#08x\n",
863 ref_offset(ref)); 863 ref_offset(ref));
864 JFFS2_ERROR("Node is {%04x,%04x,%08x,%08x}. Please report this error.\n", 864 JFFS2_ERROR("Node is {%04x,%04x,%08x,%08x}. Please report this error.\n",
865 je16_to_cpu(un->magic), je16_to_cpu(un->nodetype), 865 je16_to_cpu(un->magic), je16_to_cpu(un->nodetype),
866 je32_to_cpu(un->totlen), je32_to_cpu(un->hdr_crc)); 866 je32_to_cpu(un->totlen), je32_to_cpu(un->hdr_crc));
867 jffs2_mark_node_obsolete(c, ref); 867 jffs2_mark_node_obsolete(c, ref);
868 return 0; 868 return 0;
869 } 869 }
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index 6c75cd433342..59dd408e5432 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -863,7 +863,7 @@ scan_more:
863 switch (je16_to_cpu(node->nodetype) & JFFS2_COMPAT_MASK) { 863 switch (je16_to_cpu(node->nodetype) & JFFS2_COMPAT_MASK) {
864 case JFFS2_FEATURE_ROCOMPAT: 864 case JFFS2_FEATURE_ROCOMPAT:
865 printk(KERN_NOTICE "Read-only compatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs); 865 printk(KERN_NOTICE "Read-only compatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs);
866 c->flags |= JFFS2_SB_FLAG_RO; 866 c->flags |= JFFS2_SB_FLAG_RO;
867 if (!(jffs2_is_readonly(c))) 867 if (!(jffs2_is_readonly(c)))
868 return -EROFS; 868 return -EROFS;
869 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) 869 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen)))))
diff --git a/fs/jffs2/security.c b/fs/jffs2/security.c
index bc9f6ba10823..02c39c64ecb3 100644
--- a/fs/jffs2/security.c
+++ b/fs/jffs2/security.c
@@ -38,9 +38,9 @@ int jffs2_init_security(struct inode *inode, struct inode *dir)
38 } 38 }
39 rc = do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY, name, value, len, 0); 39 rc = do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY, name, value, len, 0);
40 40
41 kfree(name); 41 kfree(name);
42 kfree(value); 42 kfree(value);
43 return rc; 43 return rc;
44} 44}
45 45
46/* ---- XATTR Handler for "security.*" ----------------- */ 46/* ---- XATTR Handler for "security.*" ----------------- */
diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c
index d828b296392a..2a77d3f93029 100644
--- a/fs/jffs2/summary.c
+++ b/fs/jffs2/summary.c
@@ -2,10 +2,10 @@
2 * JFFS2 -- Journalling Flash File System, Version 2. 2 * JFFS2 -- Journalling Flash File System, Version 2.
3 * 3 *
4 * Copyright © 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>, 4 * Copyright © 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>,
5 * Zoltan Sogor <weth@inf.u-szeged.hu>, 5 * Zoltan Sogor <weth@inf.u-szeged.hu>,
6 * Patrik Kluba <pajko@halom.u-szeged.hu>, 6 * Patrik Kluba <pajko@halom.u-szeged.hu>,
7 * University of Szeged, Hungary 7 * University of Szeged, Hungary
8 * 2006 KaiGai Kohei <kaigai@ak.jp.nec.com> 8 * 2006 KaiGai Kohei <kaigai@ak.jp.nec.com>
9 * 9 *
10 * For licensing information, see the file 'LICENCE' in this directory. 10 * For licensing information, see the file 'LICENCE' in this directory.
11 * 11 *
diff --git a/fs/jffs2/summary.h b/fs/jffs2/summary.h
index 0c6669e21390..8bf34f2fa5ce 100644
--- a/fs/jffs2/summary.h
+++ b/fs/jffs2/summary.h
@@ -2,9 +2,9 @@
2 * JFFS2 -- Journalling Flash File System, Version 2. 2 * JFFS2 -- Journalling Flash File System, Version 2.
3 * 3 *
4 * Copyright © 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>, 4 * Copyright © 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>,
5 * Zoltan Sogor <weth@inf.u-szeged.hu>, 5 * Zoltan Sogor <weth@inf.u-szeged.hu>,
6 * Patrik Kluba <pajko@halom.u-szeged.hu>, 6 * Patrik Kluba <pajko@halom.u-szeged.hu>,
7 * University of Szeged, Hungary 7 * University of Szeged, Hungary
8 * 8 *
9 * For licensing information, see the file 'LICENCE' in this directory. 9 * For licensing information, see the file 'LICENCE' in this directory.
10 * 10 *
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index 91d1d0f1c66c..64f8d7add7e8 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -1021,8 +1021,8 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c,
1021/* 1021/*
1022 * Check for a valid cleanmarker. 1022 * Check for a valid cleanmarker.
1023 * Returns: 0 if a valid cleanmarker was found 1023 * Returns: 0 if a valid cleanmarker was found
1024 * 1 if no cleanmarker was found 1024 * 1 if no cleanmarker was found
1025 * negative error code if an error occurred 1025 * negative error code if an error occurred
1026 */ 1026 */
1027int jffs2_check_nand_cleanmarker(struct jffs2_sb_info *c, 1027int jffs2_check_nand_cleanmarker(struct jffs2_sb_info *c,
1028 struct jffs2_eraseblock *jeb) 1028 struct jffs2_eraseblock *jeb)
diff --git a/fs/jffs2/xattr.h b/fs/jffs2/xattr.h
index 3b0ff2925937..6e3b5ddfb7ab 100644
--- a/fs/jffs2/xattr.h
+++ b/fs/jffs2/xattr.h
@@ -75,7 +75,7 @@ extern void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c);
75extern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c); 75extern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c);
76 76
77extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c, 77extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
78 uint32_t xid, uint32_t version); 78 uint32_t xid, uint32_t version);
79 79
80extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); 80extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
81extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); 81extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
diff --git a/fs/jffs2/xattr_user.c b/fs/jffs2/xattr_user.c
index 40942bc516bb..8bbeab90ada1 100644
--- a/fs/jffs2/xattr_user.c
+++ b/fs/jffs2/xattr_user.c
@@ -17,7 +17,7 @@
17#include "nodelist.h" 17#include "nodelist.h"
18 18
19static int jffs2_user_getxattr(struct inode *inode, const char *name, 19static int jffs2_user_getxattr(struct inode *inode, const char *name,
20 void *buffer, size_t size) 20 void *buffer, size_t size)
21{ 21{
22 if (!strcmp(name, "")) 22 if (!strcmp(name, ""))
23 return -EINVAL; 23 return -EINVAL;
@@ -25,7 +25,7 @@ static int jffs2_user_getxattr(struct inode *inode, const char *name,
25} 25}
26 26
27static int jffs2_user_setxattr(struct inode *inode, const char *name, const void *buffer, 27static int jffs2_user_setxattr(struct inode *inode, const char *name, const void *buffer,
28 size_t size, int flags) 28 size_t size, int flags)
29{ 29{
30 if (!strcmp(name, "")) 30 if (!strcmp(name, ""))
31 return -EINVAL; 31 return -EINVAL;