/* * uncompress.c * * (C) Copyright 1999 Linus Torvalds * * cramfs interfaces to the uncompression library. There's really just * three entrypoints: * * - cramfs_uncompress_init() - called to initialize the thing. * - cramfs_uncompress_exit() - tell me when you're done * - cramfs_uncompress_block() - uncompress a block. * * NOTE NOTE NOTE! The uncompression is entirely single-threaded. We * only have one stream, and we'll initialize it only once even if it * then is used by multiple filesystems. */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include #include #include #include #include "internal.h" static z_stream stream; static int initialized; /* Returns length of decompressed data. */ int cramfs_uncompress_block(void *dst, int dstlen, void *src, int srclen) { int err; stream.next_in = src; stream.avail_in = srclen; stream.next_out = dst; stream.avail_out = dstlen; err = zlib_inflateReset(&stream); if (err != Z_OK) { pr_err("zlib_inflateReset error %d\n", err); zlib_inflateEnd(&stream); zlib_inflateInit(&stream); } err = zlib_inflate(&stream, Z_FINISH); if (err != Z_STREAM_END) goto err; return stream.total_out; err: pr_err("Error %d while decompressing!\n", err); pr_err("%p(%d)->%p(%d)\n", src, srclen, dst, dstlen); return -EIO; } int cramfs_uncompress_init(void) { if (!initialized++) { stream.workspace = vmalloc(zlib_inflate_workspacesize()); if (!stream.workspace) { initialized = 0; return -ENOMEM; } stream.next_in = NULL; stream.avail_in = 0; zlib_inflateInit(&stream); } return 0; } void cramfs_uncompress_exit(void) { if (!--initialized) { zlib_inflateEnd(&stream); vfree(stream.workspace); } } 4/nl_policy.c?h=nds-private-remove'>logtreecommitdiff
2
AgeCommit message (Expand)AuthorFilesLines
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-30 15:47:19 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-30 15:47:19 -0800
commitf9a42e0d58cf0fe3d902e63d4582f2ea4cd2bb8b (patch)
tree4078d3ae27d4ebb85bdcd4d84e9b9a4d059f22bb /net/irda/ircomm
parent751321b3dd5040dc5be19bd23f985e80c914621a (diff)
parent54791b276b4000b307339f269d3bf7db877d536f (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
Pull sparc fixes from David Miller: "Several small bug fixes and tidies, along with a fix for non-resumable memory errors triggered by userspace" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc: sparc64: Handle PIO & MEM non-resumable errors. sparc64: Zero pages on allocation for mondo and error queues. sparc: Fixed typo in sstate.c. Replaced panicing with panicking sparc: use symbolic names for tsb indexing
Diffstat (limited to 'net/irda/ircomm')