aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/compr.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2/compr.c')
-rw-r--r--fs/jffs2/compr.c144
1 files changed, 2 insertions, 142 deletions
diff --git a/fs/jffs2/compr.c b/fs/jffs2/compr.c
index 7001ba26c067..485d065de41f 100644
--- a/fs/jffs2/compr.c
+++ b/fs/jffs2/compr.c
@@ -1,16 +1,14 @@
1/* 1/*
2 * JFFS2 -- Journalling Flash File System, Version 2. 2 * JFFS2 -- Journalling Flash File System, Version 2.
3 * 3 *
4 * Copyright (C) 2001-2003 Red Hat, Inc. 4 * Copyright © 2001-2007 Red Hat, Inc.
5 * Created by Arjan van de Ven <arjanv@redhat.com> 5 * Created by Arjan van de Ven <arjanv@redhat.com>
6 * 6 *
7 * Copyright (C) 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 *
12 * $Id: compr.c,v 1.46 2005/11/07 11:14:38 gleixner Exp $
13 *
14 */ 12 */
15 13
16#include "compr.h" 14#include "compr.h"
@@ -268,144 +266,6 @@ int jffs2_unregister_compressor(struct jffs2_compressor *comp)
268 return 0; 266 return 0;
269} 267}
270 268
271#ifdef CONFIG_JFFS2_PROC
272
273#define JFFS2_STAT_BUF_SIZE 16000
274
275char *jffs2_list_compressors(void)
276{
277 struct jffs2_compressor *this;
278 char *buf, *act_buf;
279
280 act_buf = buf = kmalloc(JFFS2_STAT_BUF_SIZE,GFP_KERNEL);
281 list_for_each_entry(this, &jffs2_compressor_list, list) {
282 act_buf += sprintf(act_buf, "%10s priority:%d ", this->name, this->priority);
283 if ((this->disabled)||(!this->compress))
284 act_buf += sprintf(act_buf,"disabled");
285 else
286 act_buf += sprintf(act_buf,"enabled");
287 act_buf += sprintf(act_buf,"\n");
288 }
289 return buf;
290}
291
292char *jffs2_stats(void)
293{
294 struct jffs2_compressor *this;
295 char *buf, *act_buf;
296
297 act_buf = buf = kmalloc(JFFS2_STAT_BUF_SIZE,GFP_KERNEL);
298
299 act_buf += sprintf(act_buf,"JFFS2 compressor statistics:\n");
300 act_buf += sprintf(act_buf,"%10s ","none");
301 act_buf += sprintf(act_buf,"compr: %d blocks (%d) decompr: %d blocks\n", none_stat_compr_blocks,
302 none_stat_compr_size, none_stat_decompr_blocks);
303 spin_lock(&jffs2_compressor_list_lock);
304 list_for_each_entry(this, &jffs2_compressor_list, list) {
305 act_buf += sprintf(act_buf,"%10s ",this->name);
306 if ((this->disabled)||(!this->compress))
307 act_buf += sprintf(act_buf,"- ");
308 else
309 act_buf += sprintf(act_buf,"+ ");
310 act_buf += sprintf(act_buf,"compr: %d blocks (%d/%d) decompr: %d blocks ", this->stat_compr_blocks,
311 this->stat_compr_new_size, this->stat_compr_orig_size,
312 this->stat_decompr_blocks);
313 act_buf += sprintf(act_buf,"\n");
314 }
315 spin_unlock(&jffs2_compressor_list_lock);
316
317 return buf;
318}
319
320char *jffs2_get_compression_mode_name(void)
321{
322 switch (jffs2_compression_mode) {
323 case JFFS2_COMPR_MODE_NONE:
324 return "none";
325 case JFFS2_COMPR_MODE_PRIORITY:
326 return "priority";
327 case JFFS2_COMPR_MODE_SIZE:
328 return "size";
329 }
330 return "unkown";
331}
332
333int jffs2_set_compression_mode_name(const char *name)
334{
335 if (!strcmp("none",name)) {
336 jffs2_compression_mode = JFFS2_COMPR_MODE_NONE;
337 return 0;
338 }
339 if (!strcmp("priority",name)) {
340 jffs2_compression_mode = JFFS2_COMPR_MODE_PRIORITY;
341 return 0;
342 }
343 if (!strcmp("size",name)) {
344 jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE;
345 return 0;
346 }
347 return 1;
348}
349
350static int jffs2_compressor_Xable(const char *name, int disabled)
351{
352 struct jffs2_compressor *this;
353 spin_lock(&jffs2_compressor_list_lock);
354 list_for_each_entry(this, &jffs2_compressor_list, list) {
355 if (!strcmp(this->name, name)) {
356 this->disabled = disabled;
357 spin_unlock(&jffs2_compressor_list_lock);
358 return 0;
359 }
360 }
361 spin_unlock(&jffs2_compressor_list_lock);
362 printk(KERN_WARNING "JFFS2: compressor %s not found.\n",name);
363 return 1;
364}
365
366int jffs2_enable_compressor_name(const char *name)
367{
368 return jffs2_compressor_Xable(name, 0);
369}
370
371int jffs2_disable_compressor_name(const char *name)
372{
373 return jffs2_compressor_Xable(name, 1);
374}
375
376int jffs2_set_compressor_priority(const char *name, int priority)
377{
378 struct jffs2_compressor *this,*comp;
379 spin_lock(&jffs2_compressor_list_lock);
380 list_for_each_entry(this, &jffs2_compressor_list, list) {
381 if (!strcmp(this->name, name)) {
382 this->priority = priority;
383 comp = this;
384 goto reinsert;
385 }
386 }
387 spin_unlock(&jffs2_compressor_list_lock);
388 printk(KERN_WARNING "JFFS2: compressor %s not found.\n",name);
389 return 1;
390reinsert:
391 /* list is sorted in the order of priority, so if
392 we change it we have to reinsert it into the
393 good place */
394 list_del(&comp->list);
395 list_for_each_entry(this, &jffs2_compressor_list, list) {
396 if (this->priority < comp->priority) {
397 list_add(&comp->list, this->list.prev);
398 spin_unlock(&jffs2_compressor_list_lock);
399 return 0;
400 }
401 }
402 list_add_tail(&comp->list, &jffs2_compressor_list);
403 spin_unlock(&jffs2_compressor_list_lock);
404 return 0;
405}
406
407#endif
408
409void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig) 269void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig)
410{ 270{
411 if (orig != comprbuf) 271 if (orig != comprbuf)