Removed some development remarks

and implemented skipping of zisofs headers larger than 16 bytes.
This commit is contained in:
Thomas Schmitt 2009-04-15 13:22:20 +02:00
parent 00802a1934
commit d87e5721db
6 changed files with 26 additions and 56 deletions

View File

@ -243,9 +243,6 @@ int extf_stream_open_flag(IsoStream *stream, int flag)
return ret; return ret;
} }
stream_open = 1; stream_open = 1;
/* >>> ??? should one replace non-blocking read() by select () ? */
/* Make filter outlet non-blocking */ /* Make filter outlet non-blocking */
ret = fcntl(recv_pipe[0], F_GETFL); ret = fcntl(recv_pipe[0], F_GETFL);
if (ret != -1) { if (ret != -1) {
@ -401,9 +398,6 @@ int extf_stream_read(IsoStream *stream, void *buf, size_t desired)
while (1) { while (1) {
if (running->in_eof && !blocking) { if (running->in_eof && !blocking) {
/* >>> ??? should one replace non-blocking read() by select () ? */
/* Make filter outlet blocking */ /* Make filter outlet blocking */
ret = fcntl(running->recv_fd, F_GETFL); ret = fcntl(running->recv_fd, F_GETFL);
if (ret != -1) { if (ret != -1) {
@ -415,9 +409,6 @@ int extf_stream_read(IsoStream *stream, void *buf, size_t desired)
/* Try to read desired amount from filter */; /* Try to read desired amount from filter */;
while (1) { while (1) {
/* >>> ??? should one replace non-blocking read() by select () ? */
ret = read(running->recv_fd, ((char *) buf) + fill, ret = read(running->recv_fd, ((char *) buf) + fill,
desired - fill); desired - fill);
if (ret < 0) { if (ret < 0) {
@ -436,9 +427,6 @@ int extf_stream_read(IsoStream *stream, void *buf, size_t desired)
} }
if (running->in_eof) { if (running->in_eof) {
/* >>> ??? should one replace non-blocking read() by select () ? */
usleep(1000); /* just in case it is still non-blocking */ usleep(1000); /* just in case it is still non-blocking */
continue; continue;
} }
@ -476,10 +464,8 @@ int extf_stream_read(IsoStream *stream, void *buf, size_t desired)
#ifdef Libisofs_external_filters_selecT #ifdef Libisofs_external_filters_selecT
/* >>> ??? should one replace non-blocking read() /* This select() based waiting saves 10 % CPU load but
by select () ? */ needs 50 % more real time */
/* This saves 10 % CPU load but needs 50 % more real time*/
ret = extf_wait_for_io(running->recv_fd, running->send_fd, ret = extf_wait_for_io(running->recv_fd, running->send_fd,
100000, 0); 100000, 0);

View File

@ -138,7 +138,10 @@ static off_t gunzip_ref_count = 0;
#ifdef Libisofs_with_zliB #ifdef Libisofs_with_zliB
/* Parameter for deflateInit2() , see <zlib.h> */ /* Parameter for deflateInit2() , see <zlib.h> */
/* >>> ??? get this from zisofs.c ziso_compression_level ? */ /* ??? get this from zisofs.c ziso_compression_level ?
* ??? have an own global parameter API ?
* For now level 6 seems to be a fine compromise between speed and size.
*/
static int gzip_compression_level = 6; static int gzip_compression_level = 6;
#endif /* Libisofs_with_zliB */ #endif /* Libisofs_with_zliB */
@ -359,10 +362,8 @@ int gzip_stream_convert(IsoStream *stream, void *buf, size_t desired, int flag)
return (rng->error_ret = ret); return (rng->error_ret = ret);
if (ret == 0) { if (ret == 0) {
if (flag & 2) { if (flag & 2) {
/* Early input EOF */
/* >>> ??? what to do on (early) input EOF ? */; return (rng->error_ret = ISO_ZLIB_EARLY_EOF);
return (rng->error_ret = ISO_ZLIB_COMPR_ERR);
} else { } else {
/* Tell zlib by the next call that it is over */ /* Tell zlib by the next call that it is over */
rng->do_flush = Z_FINISH; rng->do_flush = Z_FINISH;

View File

@ -507,12 +507,8 @@ int ziso_stream_uncompress(IsoStream *stream, void *buf, size_t desired)
size_t fill = 0; size_t fill = 0;
char *cbuf = buf; char *cbuf = buf;
uLongf buf_len; uLongf buf_len;
#ifndef NIX
uint32_t uncompressed_size; uint32_t uncompressed_size;
#else char waste_word[4];
char zisofs_head[16];
#endif
if (stream == NULL) { if (stream == NULL) {
return ISO_NULL_POINTER; return ISO_NULL_POINTER;
@ -530,8 +526,6 @@ int ziso_stream_uncompress(IsoStream *stream, void *buf, size_t desired)
while (1) { while (1) {
if (rng->state == 0) { if (rng->state == 0) {
/* Reading file header */ /* Reading file header */
#ifndef NIX
ret = ziso_parse_zisofs_head(data->orig, &header_size, &bs_log2, ret = ziso_parse_zisofs_head(data->orig, &header_size, &bs_log2,
&uncompressed_size, 0); &uncompressed_size, 0);
if (ret < 0) if (ret < 0)
@ -539,34 +533,15 @@ int ziso_stream_uncompress(IsoStream *stream, void *buf, size_t desired)
nstd->header_size_div4 = header_size; nstd->header_size_div4 = header_size;
header_size *= 4; header_size *= 4;
data->size = uncompressed_size; data->size = uncompressed_size;
#else
ret = iso_stream_read(data->orig, zisofs_head, 16);
if (ret < 0)
return (rng->error_ret = ret);
header_size = ((unsigned char *) zisofs_head)[12] * 4;
bs_log2 = ((unsigned char *) zisofs_head)[13];
if (ret != 16 || memcmp(zisofs_head, zisofs_magic, 8) != 0 ||
header_size < 16 || bs_log2 < 15 || bs_log2 > 17) {
return (rng->error_ret = ISO_ZISOFS_WRONG_INPUT);
}
data->size = iso_read_lsb(((uint8_t *) zisofs_head) + 8, 4);
nstd->header_size_div4 = header_size / 4;
#endif /* NIX */
nstd->block_size_log2 = bs_log2; nstd->block_size_log2 = bs_log2;
rng->block_size = 1 << bs_log2; rng->block_size = 1 << bs_log2;
if (header_size > 16) { for (i = 16; i < header_size; i += 4) {
/* Skip surplus header bytes */ /* Skip surplus header words */
ret = iso_stream_read(data->orig, waste_word, 4);
/* >>> This must be a loop if (ret < 0)
ret = iso_stream_read(data->orig, zisofs_head, header_size-16); return (rng->error_ret = ret);
if (ret < 0) if (ret != 4)
return (rng->error_ret = ret); return (rng->error_ret = ISO_ZISOFS_WRONG_INPUT);
if (ret != header_size - 16)
*/
return (rng->error_ret = ISO_ZISOFS_WRONG_INPUT);
} }
if (desired == 0) { if (desired == 0) {

View File

@ -4729,6 +4729,10 @@ int iso_local_set_attrs(char *disk_path, size_t num_attrs, char **names,
(FAILURE, HIGH, -350) */ (FAILURE, HIGH, -350) */
#define ISO_ZISOFS_PARAM_LOCK 0xE830FEA2 #define ISO_ZISOFS_PARAM_LOCK 0xE830FEA2
/* ts A90415 */
/** Premature EOF of zlib input stream (FAILURE, HIGH, -351) */
#define ISO_ZLIB_EARLY_EOF 0xE830FEA1
/* --------------------------- Filters in General -------------------------- */ /* --------------------------- Filters in General -------------------------- */

View File

@ -261,6 +261,8 @@ const char *iso_error_to_msg(int errcode)
return "Input stream is not in zisofs format"; return "Input stream is not in zisofs format";
case ISO_ZISOFS_PARAM_LOCK: case ISO_ZISOFS_PARAM_LOCK:
return "Cannot set global zisofs parameters while filters exist"; return "Cannot set global zisofs parameters while filters exist";
case ISO_ZLIB_EARLY_EOF:
return "Premature EOF of zlib input stream";
default: default:
return "Unknown error"; return "Unknown error";
} }

View File

@ -827,11 +827,13 @@ int add_zf_field(Ecma119Image *t, Ecma119Node *n, struct susp_info *info,
It gets copied and It gets copied and
the last stream is a ziso stream, the last stream is a ziso stream,
or it had a ZF entry and is unfiltered or it had a ZF entry and is unfiltered
>>> or its last stream delivers a zisofs file header or it has a zf xinfo record (because its last stream delivered a
zisofs file header when inquired)
or it stays uncopied and or it stays uncopied and
the first filter is an osiz stream, the first filter is an osiz stream,
or it had a ZF entry or it had a ZF entry
>>> or its first stream delivers a zisofs file header or it has a zf xinfo record (because its first stream delivered a
zisofs file header when inquired)
*/ */
if (t->appendable && file->from_old_session) if (t->appendable && file->from_old_session)