support for xz compression
PATCH 1/1 support for xz compression
Hello,
New version with various fixes, most noticable : seek support, respect not easly seekable flag, BCJ support.
This patch depends on 04_transparentio.diff from previous post.
Commenst and testing are welcome.
Signature · 2 lines
Szymon K. Janc [email protected] // GG: 1383435
=== modified file 'include/grub/crypto.h'
grub/crypto.h +2 -0
@@ -243,10 +243,12 @@extern gcry_md_spec_t _gcry_digest_spec_sha1;extern gcry_md_spec_t _gcry_digest_spec_sha256;extern gcry_md_spec_t _gcry_digest_spec_sha512; +extern gcry_md_spec_t _gcry_digest_spec_crc32;#define GRUB_MD_MD5 ((const gcry_md_spec_t *) &_gcry_digest_spec_md5)#define GRUB_MD_SHA1 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha1)#define GRUB_MD_SHA256 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha256)#define GRUB_MD_SHA512 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha512) +#define GRUB_MD_CRC32 ((const gcry_md_spec_t *) &_gcry_digest_spec_crc32)/* Implement PKCS#5 PBKDF2 as per RFC 2898. The PRF to use is HMAC variant of digest supplied by MD. Inputs are the password P of length PLEN,
=== modified file 'lib/posix_wrap/sys/types.h'
posix_wrap/sys/types.h +7 -2
@@ -23,10 +23,15 @@typedef grub_size_t size_t ;typedef int bool ; -static const bool true =1 ; -static const bool false =0 ; +#define true 1 +#define false 0#define ULONG_MAX GRUB_ULONG_MAX#define UCHAR_MAX 0xff +typedef grub_uint8_t uint8_t ; +typedef grub_uint16_t uint16_t ; +typedef grub_uint32_t uint32_t ; +typedef grub_uint64_t uint64_t ; +#endif
=== modified file 'conf/common.rmk'
common.rmk +6 -1
@@ -727,7 +727,7 @@ # Misc. -pkglib_MODULES += gzio.mod elf.mod +pkglib_MODULES += gzio.mod xzio.mod elf.mod # For elf.mod. elf_mod_SOURCES = kern/elf.c
@@ -739,6 +739,11 @@ gzio_mod_CFLAGS = $(COMMON_CFLAGS) gzio_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For xzio.mod. +xzio_mod_SOURCES = io/xzio.c lib/xzembed/xz_dec_bcj.c lib/xzembed/xz_dec_lzma2.c lib/xzembed/xz_dec_stream.c +xzio_mod_CFLAGS = $(COMMON_CFLAGS) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed +xzio_mod_LDFLAGS = $(COMMON_LDFLAGS) + # On Yeeloong it's part of kernel ifneq ($(platform), yeeloong) # For bufio.mod.
=== modified file 'include/grub/file.h'
grub/file.h +2 -1
@@ -55,7 +55,8 @@/* IO filter priorities. */ typedef enum { -GRUB_IOFILTER_PRIO_GZIO =0 +GRUB_IOFILTER_PRIO_GZIO =0 , +GRUB_IOFILTER_PRIO_XZIO =1 }grub_io_filter_prio_t ;
=== added file 'io/xzio.c'
xzio.c +373 -0
373 lines not on this page · raw message
=== added directory 'lib/xzembed'
=== added file 'lib/xzembed/xz.h'
xzembed/xz.h +180 -0
180 lines not on this page · raw message
=== added file 'lib/xzembed/xz_config.h'
xzembed/xz_config.h +141 -0
141 lines not on this page · raw message
=== added file 'lib/xzembed/xz_dec_bcj.c'
xzembed/xz_dec_bcj.c +569 -0
569 lines not on this page · raw message
=== added file 'lib/xzembed/xz_dec_lzma2.c'
xzembed/xz_dec_lzma2.c +1168 -0
1,168 lines not on this page · raw message
=== added file 'lib/xzembed/xz_dec_stream.c'
xzembed/xz_dec_stream.c +854 -0
512 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== added file 'lib/xzembed/xz_lzma2.h'
xzembed/xz_lzma2.h +236 -0
236 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== added file 'lib/xzembed/xz_private.h'
xzembed/xz_private.h +96 -0
96 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== added file 'lib/xzembed/xz_stream.h'
xzembed/xz_stream.h +53 -0
53 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Dnia czwartek 08 kwiecień 2010 o 23:55:28 Szymon Janc napisał(a):
Quoted 4 lines
Hello,
New version with various fixes, most noticable : seek support, respect not easly seekable flag, BCJ support.
Attached is a small fix for xzio read to act in grub way, not posix like.
Signature · 2 lines
Szymon K. Janc [email protected] // GG: 1383435
=== modified file 'io/xzio.c'
xzio.c +7 -8
@@ -245,8 +245,6 @@int offset_lock;grub_uint8_t current_offset; - xzio->buf.out_size = len >=XZBUFSIZ ?XZBUFSIZ : len; -/* If seek backward need to reset decoder and start from beginning of file. TODO Possible improvement by jumping blocks. */ if (file->offset < xzio->saved_offset)
@@ -259,18 +257,19 @@grub_file_seek (xzio->file,0 ); } - offset_lock = (file->offset == xzio->saved_offset) ?1 :0 ; - current_offset = xzio->saved_offset; - -while (len >= xzio->buf.out_size) +while (len >0 ) { + xzio->buf.out_size = len >=XZBUFSIZ ?XZBUFSIZ : len; + + offset_lock = (file->offset == xzio->saved_offset) ?1 :0 ; + current_offset = xzio->saved_offset; +/* Feed input. */ if (xzio->buf.in_pos == xzio->buf.in_size) { readret =grub_file_read (xzio->file, xzio->inbuf,XZBUFSIZ );if (readret <0 )return -1 ; - xzio->buf.in_size = readret; xzio->buf.in_pos =0 ; }
@@ -317,7 +316,7 @@ } xzio->buf.out_pos =0 ; -if (xzret ==XZ_STREAM_END )/* Stream end, EOF. */ +if (xzret ==XZ_STREAM_END )/* Stream end, EOF. */ break ; }
Dnia niedziela 11 kwiecień 2010 o 21:30:17 Szymon Janc napisał(a):
Quoted 1 line
Attached is a small fix for xzio read to act in grub way, not posix like.
Attached patch fix a nasty seek bug introduced by previous fix. If You are brave enough to test xzio don't forget to apply this fix.
Signature · 2 lines
Szymon K. Janc [email protected] // GG: 1383435
=== modified file 'io/xzio.c'
xzio.c +5 -5
@@ -243,7 +243,7 @@enum xz_ret xzret;grub_xzio_t xzio = file->data;int offset_lock; -grub_uint8_t current_offset; +grub_off_t current_offset;/* If seek backward need to reset decoder and start from beginning of file. TODO Possible improvement by jumping blocks. */
@@ -257,13 +257,13 @@grub_file_seek (xzio->file,0 ); } + offset_lock = (file->offset == xzio->saved_offset) ?1 :0 ; + current_offset = xzio->saved_offset; +while (len >0 ) { xzio->buf.out_size = len >=XZBUFSIZ ?XZBUFSIZ : len; - offset_lock = (file->offset == xzio->saved_offset) ?1 :0 ; - current_offset = xzio->saved_offset; -/* Feed input. */ if (xzio->buf.in_pos == xzio->buf.in_size) {
@@ -298,7 +298,7 @@ }else { -grub_uint8_t new_offset = current_offset + xzio->buf.out_pos; +grub_off_t new_offset = current_offset + xzio->buf.out_pos;if (file->offset > new_offset) current_offset = new_offset;
Quoted 10 lines · Szymon Janc
Hello,
New version with various fixes, most noticable : seek support, respect not easly seekable flag, BCJ support.
This patch depends on 04_transparentio.diff from previous post.
Commenst and testing are welcome.
Merged together with few followup patches and my bugfixing. Thanks
Quoted 7 lines
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko