You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge branches 'x86/apic', 'x86/cpu', 'x86/fixmap', 'x86/mm', 'x86/sched', 'x86/setup-lzma', 'x86/signal' and 'x86/urgent' into x86/core
This commit is contained in:
+14
@@ -97,6 +97,20 @@ config LZO_COMPRESS
|
||||
config LZO_DECOMPRESS
|
||||
tristate
|
||||
|
||||
#
|
||||
# These all provide a common interface (hence the apparent duplication with
|
||||
# ZLIB_INFLATE; DECOMPRESS_GZIP is just a wrapper.)
|
||||
#
|
||||
config DECOMPRESS_GZIP
|
||||
select ZLIB_INFLATE
|
||||
tristate
|
||||
|
||||
config DECOMPRESS_BZIP2
|
||||
tristate
|
||||
|
||||
config DECOMPRESS_LZMA
|
||||
tristate
|
||||
|
||||
#
|
||||
# Generic allocator support is selected if needed
|
||||
#
|
||||
|
||||
+6
-1
@@ -11,7 +11,8 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
|
||||
rbtree.o radix-tree.o dump_stack.o \
|
||||
idr.o int_sqrt.o extable.o prio_tree.o \
|
||||
sha1.o irq_regs.o reciprocal_div.o argv_split.o \
|
||||
proportions.o prio_heap.o ratelimit.o show_mem.o is_single_threaded.o
|
||||
proportions.o prio_heap.o ratelimit.o show_mem.o \
|
||||
is_single_threaded.o decompress.o
|
||||
|
||||
lib-$(CONFIG_MMU) += ioremap.o
|
||||
lib-$(CONFIG_SMP) += cpumask.o
|
||||
@@ -65,6 +66,10 @@ obj-$(CONFIG_REED_SOLOMON) += reed_solomon/
|
||||
obj-$(CONFIG_LZO_COMPRESS) += lzo/
|
||||
obj-$(CONFIG_LZO_DECOMPRESS) += lzo/
|
||||
|
||||
lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o
|
||||
lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
|
||||
lib-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o
|
||||
|
||||
obj-$(CONFIG_TEXTSEARCH) += textsearch.o
|
||||
obj-$(CONFIG_TEXTSEARCH_KMP) += ts_kmp.o
|
||||
obj-$(CONFIG_TEXTSEARCH_BM) += ts_bm.o
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* decompress.c
|
||||
*
|
||||
* Detect the decompression method based on magic number
|
||||
*/
|
||||
|
||||
#include <linux/decompress/generic.h>
|
||||
|
||||
#include <linux/decompress/bunzip2.h>
|
||||
#include <linux/decompress/unlzma.h>
|
||||
#include <linux/decompress/inflate.h>
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#ifndef CONFIG_DECOMPRESS_GZIP
|
||||
# define gunzip NULL
|
||||
#endif
|
||||
#ifndef CONFIG_DECOMPRESS_BZIP2
|
||||
# define bunzip2 NULL
|
||||
#endif
|
||||
#ifndef CONFIG_DECOMPRESS_LZMA
|
||||
# define unlzma NULL
|
||||
#endif
|
||||
|
||||
static const struct compress_format {
|
||||
unsigned char magic[2];
|
||||
const char *name;
|
||||
decompress_fn decompressor;
|
||||
} compressed_formats[] = {
|
||||
{ {037, 0213}, "gzip", gunzip },
|
||||
{ {037, 0236}, "gzip", gunzip },
|
||||
{ {0x42, 0x5a}, "bzip2", bunzip2 },
|
||||
{ {0x5d, 0x00}, "lzma", unlzma },
|
||||
{ {0, 0}, NULL, NULL }
|
||||
};
|
||||
|
||||
decompress_fn decompress_method(const unsigned char *inbuf, int len,
|
||||
const char **name)
|
||||
{
|
||||
const struct compress_format *cf;
|
||||
|
||||
if (len < 2)
|
||||
return NULL; /* Need at least this much... */
|
||||
|
||||
for (cf = compressed_formats; cf->name; cf++) {
|
||||
if (!memcmp(inbuf, cf->magic, 2))
|
||||
break;
|
||||
|
||||
}
|
||||
if (name)
|
||||
*name = cf->name;
|
||||
return cf->decompressor;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,167 @@
|
||||
#ifdef STATIC
|
||||
/* Pre-boot environment: included */
|
||||
|
||||
/* prevent inclusion of _LINUX_KERNEL_H in pre-boot environment: lots
|
||||
* errors about console_printk etc... on ARM */
|
||||
#define _LINUX_KERNEL_H
|
||||
|
||||
#include "zlib_inflate/inftrees.c"
|
||||
#include "zlib_inflate/inffast.c"
|
||||
#include "zlib_inflate/inflate.c"
|
||||
|
||||
#else /* STATIC */
|
||||
/* initramfs et al: linked */
|
||||
|
||||
#include <linux/zutil.h>
|
||||
|
||||
#include "zlib_inflate/inftrees.h"
|
||||
#include "zlib_inflate/inffast.h"
|
||||
#include "zlib_inflate/inflate.h"
|
||||
|
||||
#include "zlib_inflate/infutil.h"
|
||||
|
||||
#endif /* STATIC */
|
||||
|
||||
#include <linux/decompress/mm.h>
|
||||
|
||||
#define INBUF_LEN (16*1024)
|
||||
|
||||
/* Included from initramfs et al code */
|
||||
STATIC int INIT gunzip(unsigned char *buf, int len,
|
||||
int(*fill)(void*, unsigned int),
|
||||
int(*flush)(void*, unsigned int),
|
||||
unsigned char *out_buf,
|
||||
int *pos,
|
||||
void(*error_fn)(char *x)) {
|
||||
u8 *zbuf;
|
||||
struct z_stream_s *strm;
|
||||
int rc;
|
||||
size_t out_len;
|
||||
|
||||
set_error_fn(error_fn);
|
||||
rc = -1;
|
||||
if (flush) {
|
||||
out_len = 0x8000; /* 32 K */
|
||||
out_buf = malloc(out_len);
|
||||
} else {
|
||||
out_len = 0x7fffffff; /* no limit */
|
||||
}
|
||||
if (!out_buf) {
|
||||
error("Out of memory while allocating output buffer");
|
||||
goto gunzip_nomem1;
|
||||
}
|
||||
|
||||
if (buf)
|
||||
zbuf = buf;
|
||||
else {
|
||||
zbuf = malloc(INBUF_LEN);
|
||||
len = 0;
|
||||
}
|
||||
if (!zbuf) {
|
||||
error("Out of memory while allocating input buffer");
|
||||
goto gunzip_nomem2;
|
||||
}
|
||||
|
||||
strm = malloc(sizeof(*strm));
|
||||
if (strm == NULL) {
|
||||
error("Out of memory while allocating z_stream");
|
||||
goto gunzip_nomem3;
|
||||
}
|
||||
|
||||
strm->workspace = malloc(flush ? zlib_inflate_workspacesize() :
|
||||
sizeof(struct inflate_state));
|
||||
if (strm->workspace == NULL) {
|
||||
error("Out of memory while allocating workspace");
|
||||
goto gunzip_nomem4;
|
||||
}
|
||||
|
||||
if (len == 0)
|
||||
len = fill(zbuf, INBUF_LEN);
|
||||
|
||||
/* verify the gzip header */
|
||||
if (len < 10 ||
|
||||
zbuf[0] != 0x1f || zbuf[1] != 0x8b || zbuf[2] != 0x08) {
|
||||
if (pos)
|
||||
*pos = 0;
|
||||
error("Not a gzip file");
|
||||
goto gunzip_5;
|
||||
}
|
||||
|
||||
/* skip over gzip header (1f,8b,08... 10 bytes total +
|
||||
* possible asciz filename)
|
||||
*/
|
||||
strm->next_in = zbuf + 10;
|
||||
/* skip over asciz filename */
|
||||
if (zbuf[3] & 0x8) {
|
||||
while (strm->next_in[0])
|
||||
strm->next_in++;
|
||||
strm->next_in++;
|
||||
}
|
||||
strm->avail_in = len - (strm->next_in - zbuf);
|
||||
|
||||
strm->next_out = out_buf;
|
||||
strm->avail_out = out_len;
|
||||
|
||||
rc = zlib_inflateInit2(strm, -MAX_WBITS);
|
||||
|
||||
if (!flush) {
|
||||
WS(strm)->inflate_state.wsize = 0;
|
||||
WS(strm)->inflate_state.window = NULL;
|
||||
}
|
||||
|
||||
while (rc == Z_OK) {
|
||||
if (strm->avail_in == 0) {
|
||||
/* TODO: handle case where both pos and fill are set */
|
||||
len = fill(zbuf, INBUF_LEN);
|
||||
if (len < 0) {
|
||||
rc = -1;
|
||||
error("read error");
|
||||
break;
|
||||
}
|
||||
strm->next_in = zbuf;
|
||||
strm->avail_in = len;
|
||||
}
|
||||
rc = zlib_inflate(strm, 0);
|
||||
|
||||
/* Write any data generated */
|
||||
if (flush && strm->next_out > out_buf) {
|
||||
int l = strm->next_out - out_buf;
|
||||
if (l != flush(out_buf, l)) {
|
||||
rc = -1;
|
||||
error("write error");
|
||||
break;
|
||||
}
|
||||
strm->next_out = out_buf;
|
||||
strm->avail_out = out_len;
|
||||
}
|
||||
|
||||
/* after Z_FINISH, only Z_STREAM_END is "we unpacked it all" */
|
||||
if (rc == Z_STREAM_END) {
|
||||
rc = 0;
|
||||
break;
|
||||
} else if (rc != Z_OK) {
|
||||
error("uncompression error");
|
||||
rc = -1;
|
||||
}
|
||||
}
|
||||
|
||||
zlib_inflateEnd(strm);
|
||||
if (pos)
|
||||
/* add + 8 to skip over trailer */
|
||||
*pos = strm->next_in - zbuf+8;
|
||||
|
||||
gunzip_5:
|
||||
free(strm->workspace);
|
||||
gunzip_nomem4:
|
||||
free(strm);
|
||||
gunzip_nomem3:
|
||||
if (!buf)
|
||||
free(zbuf);
|
||||
gunzip_nomem2:
|
||||
if (flush)
|
||||
free(out_buf);
|
||||
gunzip_nomem1:
|
||||
return rc; /* returns Z_OK (0) if successful */
|
||||
}
|
||||
|
||||
#define decompress gunzip
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,6 @@
|
||||
#ifndef INFLATE_H
|
||||
#define INFLATE_H
|
||||
|
||||
/* inflate.h -- internal inflate state definition
|
||||
* Copyright (C) 1995-2004 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
@@ -105,3 +108,4 @@ struct inflate_state {
|
||||
unsigned short work[288]; /* work area for code table building */
|
||||
code codes[ENOUGH]; /* space for code tables */
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef INFTREES_H
|
||||
#define INFTREES_H
|
||||
|
||||
/* inftrees.h -- header to use inftrees.c
|
||||
* Copyright (C) 1995-2005 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
@@ -53,3 +56,4 @@ typedef enum {
|
||||
extern int zlib_inflate_table (codetype type, unsigned short *lens,
|
||||
unsigned codes, code **table,
|
||||
unsigned *bits, unsigned short *work);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user