Merge branch 'master' into next
Conflicts: drivers/ata/disk_drive.c Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
commit
e0f4fb2c98
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
|||
VERSION = 2011
|
||||
PATCHLEVEL = 10
|
||||
PATCHLEVEL = 11
|
||||
SUBLEVEL = 0
|
||||
EXTRAVERSION =
|
||||
NAME = Amissive Actinocutious Kiwi
|
||||
|
|
|
@ -103,8 +103,6 @@ static int loco_devices_init(void)
|
|||
armlinux_set_bootparams((void *)0x70000100);
|
||||
armlinux_set_architecture(MACH_TYPE_MX53_LOCO);
|
||||
|
||||
loco_fec_reset();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,13 +61,14 @@
|
|||
* Twrph1 = 1 (-> 20ns)
|
||||
* Cycle time = 80ns
|
||||
*/
|
||||
#define A9M2440_TACLS 1
|
||||
#define A9M2440_TWRPH0 3
|
||||
#define A9M2440_TWRPH1 1
|
||||
#define MINI2440_TACLS 1
|
||||
#define MINI2440_TWRPH0 3
|
||||
#define MINI2440_TWRPH1 1
|
||||
|
||||
/* needed in the generic NAND boot code only */
|
||||
#ifdef CONFIG_S3C24XX_NAND_BOOT
|
||||
# define BOARD_DEFAULT_NAND_TIMING CALC_NFCONF_TIMING(A9M2440_TACLS, A9M2440_TWRPH0, A9M2440_TWRPH1)
|
||||
# define BOARD_DEFAULT_NAND_TIMING \
|
||||
CALC_NFCONF_TIMING(MINI2440_TACLS, MINI2440_TWRPH0, MINI2440_TWRPH1)
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
@ -45,7 +45,8 @@
|
|||
#include <mach/fb.h>
|
||||
|
||||
static struct s3c24x0_nand_platform_data nand_info = {
|
||||
.nand_timing = CALC_NFCONF_TIMING(A9M2440_TACLS, A9M2440_TWRPH0, A9M2440_TWRPH1),
|
||||
.nand_timing = CALC_NFCONF_TIMING(MINI2440_TACLS, MINI2440_TWRPH0,
|
||||
MINI2440_TWRPH1),
|
||||
.flash_bbt = 1, /* same as the kernel */
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CONFIG_ARCH_IMX=y
|
||||
CONFIG_CACHE_L2X0=y
|
||||
CONFIG_ARCH_IMX_EXTERNAL_BOOT=y
|
||||
CONFIG_ARCH_IMX35=y
|
||||
CONFIG_MACH_PCM043=y
|
||||
CONFIG_IMX_CLKO=y
|
||||
|
|
|
@ -95,7 +95,7 @@ void imx_nand_set_layout(int writesize, int datawidth)
|
|||
FMCR = fmcr;
|
||||
}
|
||||
|
||||
#elif defined CONFIG_ARCH_IMX51
|
||||
#elif defined CONFIG_ARCH_IMX51 || defined CONFIG_ARCH_IMX53
|
||||
|
||||
void imx_nand_set_layout(int writesize, int datawidth)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef _ASM_NIOS_UNALIGNED_H
|
||||
#define _ASM_NIOS_UNALIGNED_H
|
||||
|
||||
#include <linux/unaligned/le_byteshift.h>
|
||||
#include <linux/unaligned/be_byteshift.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
/*
|
||||
* Select endianness
|
||||
*/
|
||||
|
||||
#define get_unaligned __get_unaligned_le
|
||||
#define put_unaligned __put_unaligned_le
|
||||
|
||||
#endif /* _ASM_NIOS_UNALIGNED_H */
|
|
@ -44,6 +44,7 @@ protected_mode_jump:
|
|||
|
||||
/* Transition to 32-bit flat mode */
|
||||
data32 ljmp $__BOOT_CS, $in_pm32
|
||||
.size protected_mode_jump, .-protected_mode_jump
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
|
@ -83,5 +84,5 @@ in_pm32:
|
|||
|
||||
jmp uboot_entry
|
||||
|
||||
.size protected_mode_jump, .-protected_mode_jump
|
||||
.size in_pm32, .-in_pm32
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ typedef unsigned short u16;
|
|||
|
||||
typedef unsigned int u32;
|
||||
|
||||
typedef unsigned long long u64;
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* __ASM_X86_TYPES_H */
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef _ASM_X86_UNALIGNED_H
|
||||
#define _ASM_X86_UNALIGNED_H
|
||||
|
||||
/*
|
||||
* The x86 can do unaligned accesses itself.
|
||||
*/
|
||||
|
||||
#include <linux/unaligned/access_ok.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#define get_unaligned __get_unaligned_le
|
||||
#define put_unaligned __put_unaligned_le
|
||||
|
||||
#endif /* _ASM_X86_UNALIGNED_H */
|
|
@ -72,6 +72,7 @@ real_to_prot:
|
|||
|
||||
/* jump to relocation, flush prefetch queue, and reload %cs */
|
||||
DATA32 ljmp $__BOOT_CS, $return_to_flatmode
|
||||
.size real_to_prot, .-real_to_prot
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
.section .boot.text.return_to_flatmode, "ax"
|
||||
|
@ -102,8 +103,7 @@ return_to_flatmode:
|
|||
/* flag we returned happy here */
|
||||
xorl %eax, %eax
|
||||
ret
|
||||
|
||||
.size real_to_prot, .-real_to_prot
|
||||
.size return_to_flatmode, .-return_to_flatmode
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
|
@ -140,13 +140,16 @@ prot_to_real:
|
|||
|
||||
/* at last, also limit the code segment to 16 bit */
|
||||
ljmp $__REAL_CS, $return_to_realmode
|
||||
.size prot_to_real, .-prot_to_real
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
.section .boot.text.return_to_realmode, "ax"
|
||||
return_to_realmode:
|
||||
.globl return_to_realmode
|
||||
.type return_to_realmode, @function
|
||||
.code16
|
||||
|
||||
return_to_realmode:
|
||||
/* disable protected mode */
|
||||
movl %cr0, %eax
|
||||
andl $(~0x00000001), %eax
|
||||
|
@ -176,5 +179,5 @@ enter_realmode:
|
|||
/* return on realmode stack! */
|
||||
DATA32 ret
|
||||
|
||||
.size prot_to_real, .-prot_to_real
|
||||
.size return_to_realmode, .-return_to_realmode
|
||||
|
||||
|
|
|
@ -45,10 +45,13 @@ static int do_mkdir(struct command *cmdtp, int argc, char *argv[])
|
|||
return COMMAND_ERROR_USAGE;
|
||||
|
||||
while (optind < argc) {
|
||||
if (parent)
|
||||
if (parent) {
|
||||
ret = make_directory(argv[optind]);
|
||||
else
|
||||
if (ret == -EEXIST)
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = mkdir(argv[optind], 0);
|
||||
}
|
||||
if (ret) {
|
||||
printf("could not create %s: %s\n", argv[optind], errno_str());
|
||||
return 1;
|
||||
|
|
|
@ -40,7 +40,7 @@ static int do_mount(struct command *cmdtp, int argc, char *argv[])
|
|||
entry = mtab_next_entry(entry);
|
||||
if (entry) {
|
||||
printf("%s on %s type %s\n",
|
||||
entry->parent_device ? entry->parent_device->name : "none",
|
||||
entry->parent_device ? dev_name(entry->parent_device) : "none",
|
||||
entry->path,
|
||||
entry->dev->name);
|
||||
}
|
||||
|
|
|
@ -292,27 +292,32 @@ int fputc(int fd, char c)
|
|||
}
|
||||
EXPORT_SYMBOL(fputc);
|
||||
|
||||
void console_puts(unsigned int ch, const char *str)
|
||||
int console_puts(unsigned int ch, const char *str)
|
||||
{
|
||||
const char *s = str;
|
||||
int n = 0;
|
||||
|
||||
while (*s) {
|
||||
if (*s == '\n')
|
||||
if (*s == '\n') {
|
||||
console_putc(ch, '\r');
|
||||
n++;
|
||||
}
|
||||
console_putc(ch, *s);
|
||||
n++;
|
||||
s++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
EXPORT_SYMBOL(console_puts);
|
||||
|
||||
int fputs(int fd, const char *s)
|
||||
{
|
||||
if (fd == 1)
|
||||
puts(s);
|
||||
return puts(s);
|
||||
else if (fd == 2)
|
||||
eputs(s);
|
||||
return eputs(s);
|
||||
else
|
||||
return write(fd, s, strlen(s));
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(fputs);
|
||||
|
||||
|
@ -327,7 +332,7 @@ void console_flush(void)
|
|||
}
|
||||
EXPORT_SYMBOL(console_flush);
|
||||
|
||||
void fprintf (int file, const char *fmt, ...)
|
||||
int fprintf(int file, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
uint i;
|
||||
|
@ -342,7 +347,7 @@ void fprintf (int file, const char *fmt, ...)
|
|||
va_end (args);
|
||||
|
||||
/* Print the string */
|
||||
fputs (file, printbuffer);
|
||||
return fputs(file, printbuffer);
|
||||
}
|
||||
EXPORT_SYMBOL(fprintf);
|
||||
|
||||
|
|
|
@ -247,8 +247,7 @@ int export(const char *varname)
|
|||
if (val) {
|
||||
setenv_raw(context->global, varname, val);
|
||||
setenv_raw(context->local, varname, NULL);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(export);
|
||||
|
|
|
@ -42,13 +42,12 @@ int password(unsigned char *passwd, size_t length, int flags, int timeout)
|
|||
unsigned char *buf = passwd;
|
||||
int pos = 0;
|
||||
unsigned char ch;
|
||||
uint64_t start, second;
|
||||
uint64_t start;
|
||||
|
||||
if (!passwd)
|
||||
return -EINVAL;
|
||||
|
||||
start = get_time_ns();
|
||||
second = start;
|
||||
|
||||
do {
|
||||
if (tstc()) {
|
||||
|
|
|
@ -778,10 +778,12 @@ static int m25p_probe(struct device_d *dev)
|
|||
m25p80_ops.write = m25p80_write;
|
||||
|
||||
/* prefer "small sector" erase if possible */
|
||||
if (info->flags & SECT_4K)
|
||||
if (info->flags & SECT_4K) {
|
||||
flash->erase_opcode = OPCODE_BE_4K;
|
||||
else
|
||||
flash->erasesize = 4096;
|
||||
} else {
|
||||
flash->erase_opcode = OPCODE_SE;
|
||||
}
|
||||
|
||||
flash->page_size = info->page_size;
|
||||
|
||||
|
|
|
@ -72,6 +72,8 @@ static int s3c24x0_serial_init_port(struct console_device *cdev)
|
|||
writew(0x0245, base + UCON);
|
||||
|
||||
#ifdef CONFIG_DRIVER_SERIAL_S3C24X0_AUTOSYNC
|
||||
writeb(0x10, base + UMCON); /* enable auto flow control */
|
||||
#else
|
||||
writeb(0x01, base + UMCON); /* RTS up */
|
||||
#endif
|
||||
|
||||
|
|
|
@ -190,6 +190,7 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
|
|||
struct spi_transfer *t = NULL;
|
||||
unsigned int bits = spi->bits_per_word;
|
||||
|
||||
mesg->actual_length = 0;
|
||||
ret = master->setup(spi);
|
||||
if (ret < 0) {
|
||||
dev_dbg(master->dev, "transfer: master setup failed\n");
|
||||
|
@ -210,6 +211,7 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
|
|||
u32 tx_val;
|
||||
int i = 0, rx_val;
|
||||
|
||||
mesg->actual_length += t->len;
|
||||
if (bits <= 8) {
|
||||
const u8 *txbuf = t->tx_buf;
|
||||
u8 *rxbuf = t->rx_buf;
|
||||
|
|
|
@ -7,3 +7,7 @@ config USB_EHCI_OMAP
|
|||
|
||||
config USB_OHCI
|
||||
bool "OHCI driver"
|
||||
|
||||
config USB_OHCI_AT91
|
||||
depends on ARCH_AT91
|
||||
bool "AT91 OHCI driver"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
obj-$(CONFIG_USB_EHCI) += ehci-hcd.o
|
||||
obj-$(CONFIG_USB_EHCI_OMAP) += ehci-omap.o
|
||||
obj-$(CONFIG_USB_OHCI) += ohci-hcd.o
|
||||
obj-$(CONFIG_ARCH_AT91) += ohci-at91.o
|
||||
obj-$(CONFIG_USB_OHCI_AT91) += ohci-at91.o
|
||||
|
|
|
@ -714,7 +714,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
|
|||
goto unknown;
|
||||
}
|
||||
/* unblock posted writes */
|
||||
ehci_readl(&ehci->hcor->or_usbcmd);
|
||||
(void) ehci_readl(&ehci->hcor->or_usbcmd);
|
||||
break;
|
||||
case USB_REQ_CLEAR_FEATURE | ((USB_DIR_OUT | USB_RT_PORT) << 8):
|
||||
reg = ehci_readl(status_reg);
|
||||
|
@ -743,7 +743,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
|
|||
}
|
||||
ehci_writel(status_reg, reg);
|
||||
/* unblock posted write */
|
||||
ehci_readl(&ehci->hcor->or_usbcmd);
|
||||
(void) ehci_readl(&ehci->hcor->or_usbcmd);
|
||||
break;
|
||||
default:
|
||||
debug("Unknown request\n");
|
||||
|
|
|
@ -354,6 +354,8 @@ static int fat_stat(struct device_d *dev, const char *filename, struct stat *s)
|
|||
FILINFO finfo;
|
||||
int ret;
|
||||
|
||||
memset(&finfo, 0, sizeof(FILINFO));
|
||||
|
||||
ret = f_stat(&priv->fat, filename, &finfo);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
7
fs/fs.c
7
fs/fs.c
|
@ -743,6 +743,7 @@ int mount(const char *device, const char *fsname, const char *_path)
|
|||
struct mtab_entry *entry;
|
||||
struct fs_device_d *fsdev;
|
||||
struct device_d *dev, *parent_device = NULL;
|
||||
struct cdev *cdev = NULL;
|
||||
int ret;
|
||||
char *path = normalise_path(_path);
|
||||
|
||||
|
@ -808,6 +809,12 @@ int mount(const char *device, const char *fsname, const char *_path)
|
|||
goto out2;
|
||||
}
|
||||
|
||||
if (!strncmp(device, "/dev/", 5)) {
|
||||
cdev = cdev_by_name(device + 5);
|
||||
if(cdev)
|
||||
parent_device = cdev->dev;
|
||||
}
|
||||
|
||||
if (parent_device)
|
||||
dev_add_child(parent_device, &fsdev->dev);
|
||||
|
||||
|
|
|
@ -17,12 +17,12 @@ int tstc(void);
|
|||
/* stdout */
|
||||
void console_putc(unsigned int ch, const char c);
|
||||
int getc(void);
|
||||
void console_puts(unsigned int ch, const char *s);
|
||||
int console_puts(unsigned int ch, const char *s);
|
||||
void console_flush(void);
|
||||
|
||||
static inline void puts(const char *s)
|
||||
static inline int puts(const char *s)
|
||||
{
|
||||
console_puts(CONSOLE_STDOUT, s);
|
||||
return console_puts(CONSOLE_STDOUT, s);
|
||||
}
|
||||
|
||||
static inline void putchar(char c)
|
||||
|
@ -54,7 +54,7 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
|
|||
#define stderr 2
|
||||
#define MAX_FILES 128
|
||||
|
||||
void fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
|
||||
int fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
|
||||
int fputs(int file, const char *s);
|
||||
int fputc(int file, const char c);
|
||||
int ftstc(int file);
|
||||
|
|
|
@ -46,14 +46,25 @@ static const unsigned char lzop_magic[] = {
|
|||
|
||||
#define LZO_BLOCK_SIZE (256*1024l)
|
||||
#define HEADER_HAS_FILTER 0x00000800L
|
||||
#define HEADER_SIZE_MIN (9 + 7 + 4 + 8 + 1 + 4)
|
||||
#define HEADER_SIZE_MAX (9 + 7 + 1 + 8 + 8 + 4 + 1 + 255 + 4)
|
||||
|
||||
static inline int parse_header(u8 *input, u8 *skip)
|
||||
static inline int parse_header(u8 *input, int *skip, int in_len)
|
||||
{
|
||||
int l;
|
||||
u8 *parse = input;
|
||||
u8 *end = input + in_len;
|
||||
u8 level = 0;
|
||||
u16 version;
|
||||
|
||||
/*
|
||||
* Check that there's enough input to possibly have a valid header.
|
||||
* Then it is possible to parse several fields until the minimum
|
||||
* size may have been used.
|
||||
*/
|
||||
if (in_len < HEADER_SIZE_MIN)
|
||||
return 0;
|
||||
|
||||
/* read magic: 9 first bits */
|
||||
for (l = 0; l < 9; l++) {
|
||||
if (*parse++ != lzop_magic[l])
|
||||
|
@ -71,6 +82,15 @@ static inline int parse_header(u8 *input, u8 *skip)
|
|||
else
|
||||
parse += 4; /* flags */
|
||||
|
||||
/*
|
||||
* At least mode, mtime_low, filename length, and checksum must
|
||||
* be left to be parsed. If also mtime_high is present, it's OK
|
||||
* because the next input buffer check is after reading the
|
||||
* filename length.
|
||||
*/
|
||||
if (end - parse < 8 + 1 + 4)
|
||||
return 0;
|
||||
|
||||
/* skip mode and mtime_low */
|
||||
parse += 8;
|
||||
if (version >= 0x0940)
|
||||
|
@ -78,108 +98,191 @@ static inline int parse_header(u8 *input, u8 *skip)
|
|||
|
||||
l = *parse++;
|
||||
/* don't care about the file name, and skip checksum */
|
||||
if (end - parse < l + 4)
|
||||
return 0;
|
||||
parse += l + 4;
|
||||
|
||||
*skip = parse - input;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int __unlzo(int *dest_len,
|
||||
int (*fill) (void *, unsigned int),
|
||||
int (*flush) (void *, unsigned int))
|
||||
static inline int __unlzo(u8 *input, int in_len,
|
||||
int (*fill) (void *, unsigned int),
|
||||
int (*flush) (void *, unsigned int),
|
||||
u8 *output, int *posp,
|
||||
void (*error) (char *x))
|
||||
{
|
||||
u8 skip = 0, r = 0;
|
||||
u8 r = 0;
|
||||
int skip = 0;
|
||||
u32 src_len, dst_len;
|
||||
size_t tmp;
|
||||
u8 *in_buf, *in_buf_save, *out_buf, *out_buf_save;
|
||||
int obytes_processed = 0;
|
||||
u8 *in_buf, *in_buf_save, *out_buf;
|
||||
int ret = -1;
|
||||
|
||||
out_buf = xmalloc(LZO_BLOCK_SIZE);
|
||||
in_buf = xmalloc(lzo1x_worst_compress(LZO_BLOCK_SIZE));
|
||||
if (output) {
|
||||
out_buf = output;
|
||||
} else if (!flush) {
|
||||
error("NULL output pointer and no flush function provided");
|
||||
goto exit;
|
||||
} else {
|
||||
out_buf = malloc(LZO_BLOCK_SIZE);
|
||||
if (!out_buf) {
|
||||
error("Could not allocate output buffer");
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (input && fill) {
|
||||
error("Both input pointer and fill function provided, don't know what to do");
|
||||
goto exit_1;
|
||||
} else if (input) {
|
||||
in_buf = input;
|
||||
} else if (!fill) {
|
||||
error("NULL input pointer and missing fill function");
|
||||
goto exit_1;
|
||||
} else {
|
||||
in_buf = malloc(lzo1x_worst_compress(LZO_BLOCK_SIZE));
|
||||
if (!in_buf) {
|
||||
error("Could not allocate input buffer");
|
||||
goto exit_1;
|
||||
}
|
||||
}
|
||||
in_buf_save = in_buf;
|
||||
out_buf_save = out_buf;
|
||||
|
||||
ret = fill(in_buf, lzo1x_worst_compress(LZO_BLOCK_SIZE));
|
||||
if (ret < 0)
|
||||
goto exit_free;
|
||||
if (posp)
|
||||
*posp = 0;
|
||||
|
||||
if (!parse_header(in_buf, &skip))
|
||||
return -EINVAL;
|
||||
if (fill) {
|
||||
/*
|
||||
* Start from in_buf + HEADER_SIZE_MAX to make it possible
|
||||
* to use memcpy() to copy the unused data to the beginning
|
||||
* of the buffer. This way memmove() isn't needed which
|
||||
* is missing from pre-boot environments of most archs.
|
||||
*/
|
||||
in_buf += HEADER_SIZE_MAX;
|
||||
in_len = fill(in_buf, HEADER_SIZE_MAX);
|
||||
}
|
||||
|
||||
if (!parse_header(in_buf, &skip, in_len)) {
|
||||
error("invalid header");
|
||||
goto exit_2;
|
||||
}
|
||||
in_buf += skip;
|
||||
in_len -= skip;
|
||||
|
||||
if (fill) {
|
||||
/* Move the unused data to the beginning of the buffer. */
|
||||
memcpy(in_buf_save, in_buf, in_len);
|
||||
in_buf = in_buf_save;
|
||||
}
|
||||
|
||||
if (posp)
|
||||
*posp = skip;
|
||||
|
||||
for (;;) {
|
||||
/* read uncompressed block size */
|
||||
if (fill && in_len < 4) {
|
||||
skip = fill(in_buf + in_len, 4 - in_len);
|
||||
if (skip > 0)
|
||||
in_len += skip;
|
||||
}
|
||||
if (in_len < 4) {
|
||||
error("file corrupted");
|
||||
goto exit_2;
|
||||
}
|
||||
dst_len = get_unaligned_be32(in_buf);
|
||||
in_buf += 4;
|
||||
in_len -= 4;
|
||||
|
||||
/* exit if last block */
|
||||
if (dst_len == 0)
|
||||
if (dst_len == 0) {
|
||||
if (posp)
|
||||
*posp += 4;
|
||||
break;
|
||||
}
|
||||
|
||||
if (dst_len > LZO_BLOCK_SIZE) {
|
||||
printf("dest len longer than block size");
|
||||
goto exit_free;
|
||||
error("dest len longer than block size");
|
||||
goto exit_2;
|
||||
}
|
||||
|
||||
/* read compressed block size, and skip block checksum info */
|
||||
if (fill && in_len < 8) {
|
||||
skip = fill(in_buf + in_len, 8 - in_len);
|
||||
if (skip > 0)
|
||||
in_len += skip;
|
||||
}
|
||||
if (in_len < 8) {
|
||||
error("file corrupted");
|
||||
goto exit_2;
|
||||
}
|
||||
src_len = get_unaligned_be32(in_buf);
|
||||
in_buf += 8;
|
||||
in_len -= 8;
|
||||
|
||||
if (src_len <= 0 || src_len > dst_len) {
|
||||
printf("file corrupted");
|
||||
goto exit_free;
|
||||
error("file corrupted");
|
||||
goto exit_2;
|
||||
}
|
||||
|
||||
/* decompress */
|
||||
if (fill && in_len < src_len) {
|
||||
skip = fill(in_buf + in_len, src_len - in_len);
|
||||
if (skip > 0)
|
||||
in_len += skip;
|
||||
}
|
||||
if (in_len < src_len) {
|
||||
error("file corrupted");
|
||||
goto exit_2;
|
||||
}
|
||||
tmp = dst_len;
|
||||
|
||||
/* When the input data is not compressed at all,
|
||||
* lzo1x_decompress_safe will fail, so call memcpy()
|
||||
* instead */
|
||||
if (unlikely(dst_len == src_len)) {
|
||||
if (src_len != dst_len) {
|
||||
printf("Compressed data violation");
|
||||
goto exit_free;
|
||||
}
|
||||
out_buf = in_buf;
|
||||
} else {
|
||||
if (unlikely(dst_len == src_len))
|
||||
memcpy(out_buf, in_buf, src_len);
|
||||
else {
|
||||
r = lzo1x_decompress_safe((u8 *) in_buf, src_len,
|
||||
out_buf, &tmp);
|
||||
|
||||
if (r != LZO_E_OK || dst_len != tmp) {
|
||||
printf("Compressed data violation");
|
||||
goto exit_free;
|
||||
error("Compressed data violation");
|
||||
goto exit_2;
|
||||
}
|
||||
}
|
||||
|
||||
ret = flush(out_buf, dst_len);
|
||||
if (ret < 0)
|
||||
goto exit_free;
|
||||
|
||||
out_buf = in_buf + src_len;
|
||||
in_buf = in_buf_save;
|
||||
ret = fill(in_buf, lzo1x_worst_compress(LZO_BLOCK_SIZE));
|
||||
if (ret < 0)
|
||||
goto exit_free;
|
||||
|
||||
if (ret == 0)
|
||||
in_buf = out_buf;
|
||||
|
||||
out_buf = out_buf_save;
|
||||
|
||||
obytes_processed += dst_len;
|
||||
if (flush && flush(out_buf, dst_len) != dst_len)
|
||||
goto exit_2;
|
||||
if (output)
|
||||
out_buf += dst_len;
|
||||
if (posp)
|
||||
*posp += src_len + 12;
|
||||
|
||||
in_buf += src_len;
|
||||
in_len -= src_len;
|
||||
if (fill) {
|
||||
/*
|
||||
* If there happens to still be unused data left in
|
||||
* in_buf, move it to the beginning of the buffer.
|
||||
* Use a loop to avoid memmove() dependency.
|
||||
*/
|
||||
if (in_len > 0)
|
||||
for (skip = 0; skip < in_len; ++skip)
|
||||
in_buf_save[skip] = in_buf[skip];
|
||||
in_buf = in_buf_save;
|
||||
}
|
||||
}
|
||||
|
||||
exit_free:
|
||||
free(in_buf);
|
||||
free(out_buf);
|
||||
|
||||
*dest_len = obytes_processed;
|
||||
return 0;
|
||||
ret = 0;
|
||||
exit_2:
|
||||
if (!input)
|
||||
free(in_buf_save);
|
||||
exit_1:
|
||||
if (!output)
|
||||
free(out_buf);
|
||||
exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int in_fd;
|
||||
|
@ -195,9 +298,14 @@ static int unlzo_flush(void *buf, unsigned int len)
|
|||
return write(out_fd, buf, len);
|
||||
}
|
||||
|
||||
static void unlzo_error(char *s)
|
||||
{
|
||||
printf("%s\n", s);
|
||||
}
|
||||
|
||||
int unlzo(int _in_fd, int _out_fd, int *dest_len)
|
||||
{
|
||||
in_fd = _in_fd;
|
||||
out_fd = _out_fd;
|
||||
return __unlzo(dest_len, unlzo_fill, unlzo_flush);
|
||||
return __unlzo(NULL, 0, unlzo_fill, unlzo_flush, NULL, NULL, unlzo_error);
|
||||
}
|
||||
|
|
|
@ -67,6 +67,8 @@ int read_key(void)
|
|||
esc[i] = getc();
|
||||
if (esc[i++] == '~')
|
||||
break;
|
||||
if (i == ARRAY_SIZE(esc))
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
esc[i] = 0;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
setupmbr
|
Loading…
Reference in New Issue