diff options
author | jhb <jhb@FreeBSD.org> | 2009-12-23 21:11:03 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2009-12-23 21:11:03 +0000 |
commit | 0ea3a0b2ea0093f6d6b4fad9d2bc4f0936782b36 (patch) | |
tree | e174efd43e9768c6bc8811d84679a834b8d97b6f /lib/libstand/gzipfs.c | |
parent | bc3808fc3374b7ecada1180fb886eba250b07fdc (diff) | |
download | FreeBSD-src-0ea3a0b2ea0093f6d6b4fad9d2bc4f0936782b36.zip FreeBSD-src-0ea3a0b2ea0093f6d6b4fad9d2bc4f0936782b36.tar.gz |
Fix a bug in gzipfs that prevented lseek() from working and add lseek()
support to bzip2fs. This fixes problems with loading compressed amd64
kernel modules containing debug symbols.
Submitted by: David Naylor naylor.b.david (gmail)
MFC after: 1 week
Diffstat (limited to 'lib/libstand/gzipfs.c')
-rw-r--r-- | lib/libstand/gzipfs.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/libstand/gzipfs.c b/lib/libstand/gzipfs.c index 4f40a4a..9ff7985 100644 --- a/lib/libstand/gzipfs.c +++ b/lib/libstand/gzipfs.c @@ -212,10 +212,9 @@ zf_open(const char *fname, struct open_file *f) bzero(zf, sizeof(struct z_file)); zf->zf_rawfd = rawfd; - /* Verify that the file is gzipped (XXX why do this afterwards?) */ + /* Verify that the file is gzipped */ if (check_header(zf)) { close(zf->zf_rawfd); - inflateEnd(&(zf->zf_zstream)); free(zf); return(EFTYPE); } @@ -261,7 +260,7 @@ zf_read(struct open_file *f, void *buf, size_t size, size_t *resid) if (zf->zf_zstream.avail_in == 0) { /* oops, unexpected EOF */ printf("zf_read: unexpected EOF\n"); if (zf->zf_zstream.avail_out == size) - return (EIO); + return(EIO); break; } @@ -286,12 +285,13 @@ zf_rewind(struct open_file *f) struct z_file *zf = (struct z_file *)f->f_fsdata; if (lseek(zf->zf_rawfd, zf->zf_dataoffset, SEEK_SET) == -1) - return -1; + return(-1); zf->zf_zstream.avail_in = 0; zf->zf_zstream.next_in = NULL; + zf->zf_endseen = 0; (void)inflateReset(&zf->zf_zstream); - return 0; + return(0); } static off_t @@ -312,12 +312,12 @@ zf_seek(struct open_file *f, off_t offset, int where) target = -1; default: errno = EINVAL; - return (-1); + return(-1); } /* rewind if required */ if (target < zf->zf_zstream.total_out && zf_rewind(f) != 0) - return -1; + return(-1); /* skip forwards if required */ while (target > zf->zf_zstream.total_out) { @@ -327,7 +327,7 @@ zf_seek(struct open_file *f, off_t offset, int where) return(-1); } /* This is where we are (be honest if we overshot) */ - return (zf->zf_zstream.total_out); + return(zf->zf_zstream.total_out); } |