?? compr.c
字號(hào):
list_for_each_entry(this, &jffs2_compressor_list, list) { if (this->priority < comp->priority) { list_add(&comp->list, this->list.prev); goto out; } } list_add_tail(&comp->list, &jffs2_compressor_list);out: D2(list_for_each_entry(this, &jffs2_compressor_list, list) { printk(KERN_DEBUG "Compressor \"%s\", prio %d\n", this->name, this->priority); }) spin_unlock(&jffs2_compressor_list_lock); return 0;}int jffs2_unregister_compressor(struct jffs2_compressor *comp){ D2(struct jffs2_compressor *this;) D1(printk(KERN_DEBUG "Unregistering JFFS2 compressor \"%s\"\n", comp->name)); spin_lock(&jffs2_compressor_list_lock); if (comp->usecount) { spin_unlock(&jffs2_compressor_list_lock); printk(KERN_WARNING "JFFS2: Compressor modul is in use. Unregister failed.\n"); return -1; } list_del(&comp->list); D2(list_for_each_entry(this, &jffs2_compressor_list, list) { printk(KERN_DEBUG "Compressor \"%s\", prio %d\n", this->name, this->priority); }) spin_unlock(&jffs2_compressor_list_lock); return 0;}#ifdef CONFIG_JFFS2_PROC#define JFFS2_STAT_BUF_SIZE 16000char *jffs2_list_compressors(void){ struct jffs2_compressor *this; char *buf, *act_buf; act_buf = buf = kmalloc(JFFS2_STAT_BUF_SIZE,GFP_KERNEL); list_for_each_entry(this, &jffs2_compressor_list, list) { act_buf += sprintf(act_buf, "%10s priority:%d ", this->name, this->priority); if ((this->disabled)||(!this->compress)) act_buf += sprintf(act_buf,"disabled"); else act_buf += sprintf(act_buf,"enabled"); act_buf += sprintf(act_buf,"\n"); } return buf;}char *jffs2_stats(void){ struct jffs2_compressor *this; char *buf, *act_buf; act_buf = buf = kmalloc(JFFS2_STAT_BUF_SIZE,GFP_KERNEL); act_buf += sprintf(act_buf,"JFFS2 compressor statistics:\n"); act_buf += sprintf(act_buf,"%10s ","none"); act_buf += sprintf(act_buf,"compr: %d blocks (%d) decompr: %d blocks\n", none_stat_compr_blocks, none_stat_compr_size, none_stat_decompr_blocks); spin_lock(&jffs2_compressor_list_lock); list_for_each_entry(this, &jffs2_compressor_list, list) { act_buf += sprintf(act_buf,"%10s ",this->name); if ((this->disabled)||(!this->compress)) act_buf += sprintf(act_buf,"- "); else act_buf += sprintf(act_buf,"+ "); act_buf += sprintf(act_buf,"compr: %d blocks (%d/%d) decompr: %d blocks ", this->stat_compr_blocks, this->stat_compr_new_size, this->stat_compr_orig_size, this->stat_decompr_blocks); act_buf += sprintf(act_buf,"\n"); } spin_unlock(&jffs2_compressor_list_lock); return buf;}char *jffs2_get_compression_mode_name(void) { switch (jffs2_compression_mode) { case JFFS2_COMPR_MODE_NONE: return "none"; case JFFS2_COMPR_MODE_PRIORITY: return "priority"; case JFFS2_COMPR_MODE_SIZE: return "size"; } return "unkown";}int jffs2_set_compression_mode_name(const char *name) { if (!strcmp("none",name)) { jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; return 0; } if (!strcmp("priority",name)) { jffs2_compression_mode = JFFS2_COMPR_MODE_PRIORITY; return 0; } if (!strcmp("size",name)) { jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE; return 0; } return 1;}static int jffs2_compressor_Xable(const char *name, int disabled){ struct jffs2_compressor *this; spin_lock(&jffs2_compressor_list_lock); list_for_each_entry(this, &jffs2_compressor_list, list) { if (!strcmp(this->name, name)) { this->disabled = disabled; spin_unlock(&jffs2_compressor_list_lock); return 0; } } spin_unlock(&jffs2_compressor_list_lock); printk(KERN_WARNING "JFFS2: compressor %s not found.\n",name); return 1;}int jffs2_enable_compressor_name(const char *name){ return jffs2_compressor_Xable(name, 0);}int jffs2_disable_compressor_name(const char *name){ return jffs2_compressor_Xable(name, 1);}int jffs2_set_compressor_priority(const char *name, int priority){ struct jffs2_compressor *this,*comp; spin_lock(&jffs2_compressor_list_lock); list_for_each_entry(this, &jffs2_compressor_list, list) { if (!strcmp(this->name, name)) { this->priority = priority; comp = this; goto reinsert; } } spin_unlock(&jffs2_compressor_list_lock); printk(KERN_WARNING "JFFS2: compressor %s not found.\n",name); return 1;reinsert: /* list is sorted in the order of priority, so if we change it we have to reinsert it into the good place */ list_del(&comp->list); list_for_each_entry(this, &jffs2_compressor_list, list) { if (this->priority < comp->priority) { list_add(&comp->list, this->list.prev); spin_unlock(&jffs2_compressor_list_lock); return 0; } } list_add_tail(&comp->list, &jffs2_compressor_list); spin_unlock(&jffs2_compressor_list_lock); return 0;}#endifvoid jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig){ if (orig != comprbuf) kfree(comprbuf);}int jffs2_compressors_init(void) {/* Registering compressors */#ifdef CONFIG_JFFS2_ZLIB jffs2_zlib_init();#endif#ifdef CONFIG_JFFS2_RTIME jffs2_rtime_init();#endif#ifdef CONFIG_JFFS2_RUBIN jffs2_rubinmips_init(); jffs2_dynrubin_init();#endif#ifdef CONFIG_JFFS2_LZARI jffs2_lzari_init();#endif#ifdef CONFIG_JFFS2_LZO jffs2_lzo_init();#endif/* Setting default compression mode */#ifdef CONFIG_JFFS2_CMODE_NONE jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; D1(printk(KERN_INFO "JFFS2: default compression mode: none\n");)#else#ifdef CONFIG_JFFS2_CMODE_SIZE jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE; D1(printk(KERN_INFO "JFFS2: default compression mode: size\n");)#else D1(printk(KERN_INFO "JFFS2: default compression mode: priority\n");)#endif#endif return 0;}int jffs2_compressors_exit(void) {/* Unregistering compressors */#ifdef CONFIG_JFFS2_LZO jffs2_lzo_exit();#endif#ifdef CONFIG_JFFS2_LZARI jffs2_lzari_exit();#endif#ifdef CONFIG_JFFS2_RUBIN jffs2_dynrubin_exit(); jffs2_rubinmips_exit();#endif#ifdef CONFIG_JFFS2_RTIME jffs2_rtime_exit();#endif#ifdef CONFIG_JFFS2_ZLIB jffs2_zlib_exit();#endif return 0;}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -