Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_compressor.c
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | struct compressor { | ||||
void *priv; | void *priv; | ||||
void *arg; | void *arg; | ||||
}; | }; | ||||
SET_DECLARE(compressors, struct compressor_methods); | SET_DECLARE(compressors, struct compressor_methods); | ||||
#ifdef GZIO | #ifdef GZIO | ||||
#include <sys/gsb_crc32.h> | #include <contrib/zlib/zutil.h> | ||||
#include <sys/zutil.h> | |||||
struct gz_stream { | struct gz_stream { | ||||
uint8_t *gz_buffer; /* output buffer */ | uint8_t *gz_buffer; /* output buffer */ | ||||
size_t gz_bufsz; /* output buffer size */ | size_t gz_bufsz; /* output buffer size */ | ||||
off_t gz_off; /* offset into the output stream */ | off_t gz_off; /* offset into the output stream */ | ||||
uint32_t gz_crc; /* stream CRC32 */ | uint32_t gz_crc; /* stream CRC32 */ | ||||
z_stream gz_stream; /* zlib state */ | z_stream gz_stream; /* zlib state */ | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | gz_write(void *stream, void *data, size_t len, compressor_cb_t cb, | ||||
int error, zerror, zflag; | int error, zerror, zflag; | ||||
s = stream; | s = stream; | ||||
zflag = data == NULL ? Z_FINISH : Z_NO_FLUSH; | zflag = data == NULL ? Z_FINISH : Z_NO_FLUSH; | ||||
if (len > 0) { | if (len > 0) { | ||||
s->gz_stream.avail_in = len; | s->gz_stream.avail_in = len; | ||||
s->gz_stream.next_in = data; | s->gz_stream.next_in = data; | ||||
s->gz_crc = crc32_raw(data, len, s->gz_crc); | s->gz_crc = crc32(s->gz_crc, data, len); | ||||
} else | } else | ||||
s->gz_crc ^= ~0U; | s->gz_crc ^= ~0U; | ||||
ota_j.email.ne.jp: It doesn't look crc32_raw() and zlib's crc32() isn't inter-exchangeable.
I created and tested… | |||||
error = 0; | error = 0; | ||||
do { | do { | ||||
zerror = deflate(&s->gz_stream, zflag); | zerror = deflate(&s->gz_stream, zflag); | ||||
if (zerror != Z_OK && zerror != Z_STREAM_END) { | if (zerror != Z_OK && zerror != Z_STREAM_END) { | ||||
error = EIO; | error = EIO; | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 374 Lines • Show Last 20 Lines |
It doesn't look crc32_raw() and zlib's crc32() isn't inter-exchangeable.
I created and tested in D21408.