/* * JFFS2 -- Journalling Flash File System, Version 2. * * Copyright © 2007 Nokia Corporation. All rights reserved. * Copyright © 2004-2010 David Woodhouse * * Created by Richard Purdie * * For licensing information, see the file 'LICENCE' in this directory. * */ #include #include #include #include #include #include "compr.h" static void *lzo_mem; static void *lzo_compress_buf; static DEFINE_MUTEX(deflate_mutex); /* for lzo_mem and lzo_compress_buf */ static void free_workspace(void) { vfree(lzo_mem); vfree(lzo_compress_buf); } static int __init alloc_workspace(void) { lzo_mem = vmalloc(LZO1X_MEM_COMPRESS); lzo_compress_buf = vmalloc(lzo1x_worst_compress(PAGE_SIZE)); if (!lzo_mem || !lzo_compress_buf) { free_workspace(); return -ENOMEM; } return 0; } static int jffs2_lzo_compress(unsigned char *data_in, unsigned char *cpage_out, uint32_t *sourcelen, uint32_t *dstlen) { size_t compress_size; int ret; mutex_lock(&deflate_mutex); ret = lzo1x_1_compress(data_in, *sourcelen, lzo_compress_buf, &compress_size, lzo_mem); if (ret != LZO_E_OK) goto fail; if (compress_size > *dstlen) goto fail; memcpy(cpage_out, lzo_compress_buf, compress_size); mutex_unlock(&deflate_mutex); *dstlen = compress_size; return 0; fail: mutex_unlock(&deflate_mutex); return -1; } static int jffs2_lzo_decompress(unsigned char *data_in, unsigned char *cpage_out, uint32_t srclen, uint32_t destlen) { size_t dl = destlen; int ret; ret = lzo1x_decompress_safe(data_in, srclen, cpage_out, &dl); if (ret != LZO_E_OK || dl != destlen) return -1; return 0; } static struct jffs2_compressor jffs2_lzo_comp = { .priority = JFFS2_LZO_PRIORITY, .name = "lzo", .compr = JFFS2_COMPR_LZO, .compress = &jffs2_lzo_compress, .decompress = &jffs2_lzo_decompress, .disabled = 0, }; int __init jffs2_lzo_init(void) { int ret; ret = alloc_workspace(); if (ret < 0) return ret; ret = jffs2_register_compressor(&jffs2_lzo_comp); if (ret) free_workspace(); return ret; } void jffs2_lzo_exit(void) { jffs2_unregister_compressor(&jffs2_lzo_comp); free_workspace(); } /a>
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-12-12 20:50:02 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-12 20:50:02 -0800
commite34bac726d27056081d0250c0e173e4b155aa340 (patch)
tree85607d0b3b185380fb3267866020c6a4372b9298 /Documentation/filesystems/sharedsubtree.txt
parentfe6bce8d30a86c693bf7cfbf4759cbafd121289f (diff)
parent39a0e975c37dee93fa1b8ea5f7eacd1c4c8a586e (diff)
Merge branch 'akpm' (patches from Andrew)
Merge updates from Andrew Morton: - various misc bits - most of MM (quite a lot of MM material is awaiting the merge of linux-next dependencies) - kasan - printk updates - procfs updates - MAINTAINERS - /lib updates - checkpatch updates * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (123 commits) init: reduce rootwait polling interval time to 5ms binfmt_elf: use vmalloc() for allocation of vma_filesz checkpatch: don't emit unified-diff error for rename-only patches checkpatch: don't check c99 types like uint8_t under tools checkpatch: avoid multiple line dereferences checkpatch: don't check .pl files, improve absolute path commit log test scripts/checkpatch.pl: fix spelling checkpatch: don't try to get maintained status when --no-tree is given lib/ida: document locking requirements a bit better lib/rbtree.c: fix typo in comment of ____rb_erase_color lib/Kconfig.debug: make CONFIG_STRICT_DEVMEM depend on CONFIG_DEVMEM MAINTAINERS: add drm and drm/i915 irc channels MAINTAINERS: add "C:" for URI for chat where developers hang out MAINTAINERS: add drm and drm/i915 bug filing info MAINTAINERS: add "B:" for URI where to file bugs get_maintainer: look for arbitrary letter prefixes in sections printk: add Kconfig option to set default console loglevel printk/sound: handle more message headers printk/btrfs: handle more message headers printk/kdb: handle more message headers ...
Diffstat (limited to 'Documentation/filesystems/sharedsubtree.txt')