Support zle compression on ZFS.
* grub-core/fs/zfs/zfs.c (zle_decompress): New function. (decomp_table): Add zle. * include/grub/zfs/zio.h (zio_compress): Add zle.
This commit is contained in:
parent
c7ba4f6984
commit
b632b404e0
3 changed files with 43 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2011-11-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Support zle compression on ZFS.
|
||||||
|
|
||||||
|
* grub-core/fs/zfs/zfs.c (zle_decompress): New function.
|
||||||
|
(decomp_table): Add zle.
|
||||||
|
* include/grub/zfs/zio.h (zio_compress): Add zle.
|
||||||
|
|
||||||
2011-11-05 Vladimir Serbinenko <phcoder@gmail.com>
|
2011-11-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Support BtrFS embedding.
|
Support BtrFS embedding.
|
||||||
|
|
|
@ -199,6 +199,39 @@ zlib_decompress (void *s, void *d,
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
zle_decompress (void *s, void *d,
|
||||||
|
grub_size_t slen, grub_size_t dlen)
|
||||||
|
{
|
||||||
|
grub_uint8_t *iptr, *optr;
|
||||||
|
grub_size_t clen;
|
||||||
|
for (iptr = s, optr = d; iptr < (grub_uint8_t *) s + slen
|
||||||
|
&& optr < (grub_uint8_t *) d + dlen;)
|
||||||
|
{
|
||||||
|
if (*iptr & 0x80)
|
||||||
|
clen = ((*iptr) & 0x7f) + 0x41;
|
||||||
|
else
|
||||||
|
clen = ((*iptr) & 0x3f) + 1;
|
||||||
|
if ((grub_ssize_t) clen > (grub_uint8_t *) d + dlen - optr)
|
||||||
|
clen = (grub_uint8_t *) d + dlen - optr;
|
||||||
|
if (*iptr & 0x40 || *iptr & 0x80)
|
||||||
|
{
|
||||||
|
grub_memset (optr, 0, clen);
|
||||||
|
iptr++;
|
||||||
|
optr += clen;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ((grub_ssize_t) clen > (grub_uint8_t *) s + slen - iptr - 1)
|
||||||
|
clen = (grub_uint8_t *) s + slen - iptr - 1;
|
||||||
|
grub_memcpy (optr, iptr + 1, clen);
|
||||||
|
optr += clen;
|
||||||
|
iptr += clen + 1;
|
||||||
|
}
|
||||||
|
if (optr < (grub_uint8_t *) d + dlen)
|
||||||
|
grub_memset (optr, 0, (grub_uint8_t *) d + dlen - optr);
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
static decomp_entry_t decomp_table[ZIO_COMPRESS_FUNCTIONS] = {
|
static decomp_entry_t decomp_table[ZIO_COMPRESS_FUNCTIONS] = {
|
||||||
{"inherit", NULL}, /* ZIO_COMPRESS_INHERIT */
|
{"inherit", NULL}, /* ZIO_COMPRESS_INHERIT */
|
||||||
{"on", lzjb_decompress}, /* ZIO_COMPRESS_ON */
|
{"on", lzjb_decompress}, /* ZIO_COMPRESS_ON */
|
||||||
|
@ -214,6 +247,7 @@ static decomp_entry_t decomp_table[ZIO_COMPRESS_FUNCTIONS] = {
|
||||||
{"gzip-7", zlib_decompress}, /* ZIO_COMPRESS_GZIP7 */
|
{"gzip-7", zlib_decompress}, /* ZIO_COMPRESS_GZIP7 */
|
||||||
{"gzip-8", zlib_decompress}, /* ZIO_COMPRESS_GZIP8 */
|
{"gzip-8", zlib_decompress}, /* ZIO_COMPRESS_GZIP8 */
|
||||||
{"gzip-9", zlib_decompress}, /* ZIO_COMPRESS_GZIP9 */
|
{"gzip-9", zlib_decompress}, /* ZIO_COMPRESS_GZIP9 */
|
||||||
|
{"zle", zle_decompress}, /* ZIO_COMPRESS_ZLE */
|
||||||
};
|
};
|
||||||
|
|
||||||
static grub_err_t zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian,
|
static grub_err_t zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian,
|
||||||
|
|
|
@ -86,6 +86,7 @@ enum zio_compress {
|
||||||
ZIO_COMPRESS_GZIP7,
|
ZIO_COMPRESS_GZIP7,
|
||||||
ZIO_COMPRESS_GZIP8,
|
ZIO_COMPRESS_GZIP8,
|
||||||
ZIO_COMPRESS_GZIP9,
|
ZIO_COMPRESS_GZIP9,
|
||||||
|
ZIO_COMPRESS_ZLE,
|
||||||
ZIO_COMPRESS_FUNCTIONS
|
ZIO_COMPRESS_FUNCTIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue