Various squash4 fixes and LZO and XZ support.
* Makefile.util.def (libgrubmods.a): Add xzembed directory to cppflags. Add xzembed source files. * grub-core/Makefile.core.def (squash4): Add xzembed and minilzo flags. * grub-core/fs/squash4.c (grub_squash_super): New field compression. (grub_squash_inode): New subtype long_dir. (SQUASH_TYPE_LONG_DIR): New inode type. (COMPRESSION): New enum. (XZBUFSIZ): New const. (grub_squash_data): New fields blksz, decompress, xzdec, xzbuf. (read_chunk): Use data->decompress. (zlib_decompress): New function. (lzo_decompress): Likewise. (xz_decompress): Likewise. (squash_mount): Set new data fields. (grub_squash_iterate_dir): Handle long dir. (squash_unmount): Free xzdec and xzbuf. (grub_squash_open): Check ino type. (direct_read): Stylistic fixes. Use data->decompress. (grub_squash_read_data): Likewise. * grub-core/io/gzio.c (grub_gzio): Remove disk_input. (get_byte): Likewise. (grub_zlib_disk_read): Removed. * grub-core/lib/posix_wrap/sys/types.h (ssize_t): New type. (GRUB_POSIX_BOOL_DEFINED): New define. * grub-core/lib/posix_wrap/unistd.h: Include sys/types.h. * grub-core/lib/xzembed/xz.h: Addmissing includes. [!GRUB_POSIX_BOOL_DEFINED]: Define bool. * include/grub/deflate.h (grub_zlib_disk_read): Removed.
This commit is contained in:
parent
7a45a539db
commit
c029da8a89
9 changed files with 334 additions and 107 deletions
|
@ -41,7 +41,6 @@
|
|||
#include <grub/fs.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/deflate.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
@ -65,9 +64,6 @@ struct grub_gzio
|
|||
/* If input is in memory following fields are used instead of file. */
|
||||
grub_size_t mem_input_size, mem_input_off;
|
||||
grub_uint8_t *mem_input;
|
||||
grub_disk_addr_t disk_input_off;
|
||||
grub_disk_addr_t disk_input_start;
|
||||
grub_disk_t disk_input;
|
||||
/* The offset at which the data starts in the underlying file. */
|
||||
grub_off_t data_offset;
|
||||
/* The type of current block. */
|
||||
|
@ -388,18 +384,6 @@ get_byte (grub_gzio_t gzio)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (gzio->disk_input && (gzio->disk_input_off == gzio->data_offset
|
||||
|| gzio->inbuf_d == INBUFSIZ))
|
||||
{
|
||||
grub_disk_addr_t d = gzio->disk_input_start + gzio->disk_input_off;
|
||||
gzio->inbuf_d = 0;
|
||||
grub_disk_read (gzio->disk_input,
|
||||
d >> GRUB_DISK_SECTOR_BITS,
|
||||
d & (GRUB_DISK_SECTOR_SIZE - 1),
|
||||
INBUFSIZ, gzio->inbuf);
|
||||
gzio->disk_input_off += INBUFSIZ;
|
||||
}
|
||||
|
||||
if (gzio->file && (grub_file_tell (gzio->file)
|
||||
== (grub_off_t) gzio->data_offset
|
||||
|| gzio->inbuf_d == INBUFSIZ))
|
||||
|
@ -422,8 +406,6 @@ gzio_seek (grub_gzio_t gzio, grub_off_t off)
|
|||
else
|
||||
gzio->mem_input_off = off;
|
||||
}
|
||||
else if (gzio->disk_input)
|
||||
gzio->disk_input_off = off;
|
||||
else
|
||||
grub_file_seek (gzio->file, off);
|
||||
}
|
||||
|
@ -1314,34 +1296,6 @@ grub_zlib_decompress (char *inbuf, grub_size_t insize, grub_off_t off,
|
|||
return ret;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_zlib_disk_read (grub_disk_t disk, grub_disk_addr_t zlibstart,
|
||||
grub_off_t off, char *outbuf, grub_size_t outsize)
|
||||
{
|
||||
grub_gzio_t gzio = 0;
|
||||
grub_ssize_t ret;
|
||||
|
||||
gzio = grub_zalloc (sizeof (*gzio));
|
||||
if (! gzio)
|
||||
return -1;
|
||||
|
||||
gzio->disk_input_off = 0;
|
||||
gzio->disk_input_start = zlibstart;
|
||||
gzio->disk_input = disk;
|
||||
|
||||
if (!test_zlib_header (gzio))
|
||||
{
|
||||
grub_free (gzio);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = grub_gzio_read_real (gzio, off, outbuf, outsize);
|
||||
grub_free (gzio);
|
||||
|
||||
/* FIXME: Check Adler. */
|
||||
return ret < 0 ? grub_errno : GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct grub_fs grub_gzio_fs =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue