summaryrefslogtreecommitdiffstats
path: root/lib/libstand/bzipfs.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2004-01-21 20:12:23 +0000
committerjhb <jhb@FreeBSD.org>2004-01-21 20:12:23 +0000
commitfffc52fe7a3393e38603b6d028c721e38a1d1cc3 (patch)
treeef59111118b96cb170e58b13a12c868718248613 /lib/libstand/bzipfs.c
parentc6b7068a7d44e6082f3cba1e19415d67838013ac (diff)
downloadFreeBSD-src-fffc52fe7a3393e38603b6d028c721e38a1d1cc3.zip
FreeBSD-src-fffc52fe7a3393e38603b6d028c721e38a1d1cc3.tar.gz
Clean up error handling in libstand filesystem code to be more consistent:
- bzipfs and gzipfs now properly return errno values directly from their read routines rather than returning -1. - missing errno values on error returns for the seek routines on almost all filesystems were added. - fstat() now returns -1 if an error occurs rather than ignoring it. - nfs's readdir() routine now reports valid errno values if an error or EOF occurs rather than EPERM (It was just returning 0 for success and 1 for failure). - nullfs used the wrong semantics for every function besides close() and seek(). Getting it right for close() appears to be an accident at that. - read() for buffered files no longer returns 0 (EOF) if an error occurs, but returns -1 instead.
Diffstat (limited to 'lib/libstand/bzipfs.c')
-rw-r--r--lib/libstand/bzipfs.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/libstand/bzipfs.c b/lib/libstand/bzipfs.c
index c0a8d9b..7f89b33 100644
--- a/lib/libstand/bzipfs.c
+++ b/lib/libstand/bzipfs.c
@@ -223,10 +223,12 @@ bzf_read(struct open_file *f, void *buf, size_t size, size_t *resid)
while (bzf->bzf_bzstream.avail_out) {
if ((bzf->bzf_bzstream.avail_in == 0) && (bzf_fill(bzf) == -1)) {
printf("bzf_read: fill error\n");
- return(-1);
+ return(EIO);
}
if (bzf->bzf_bzstream.avail_in == 0) { /* oops, unexpected EOF */
printf("bzf_read: unexpected EOF\n");
+ if (bzf->bzf_bzstream.avail_out == size)
+ return (EIO);
break;
}
@@ -236,8 +238,7 @@ bzf_read(struct open_file *f, void *buf, size_t size, size_t *resid)
}
if (error != BZ_OK) { /* argh, decompression error */
printf("bzf_read: BZ2_bzDecompress returned %d\n", error);
- errno = EIO;
- return(-1);
+ return(EIO);
}
}
if (resid != NULL)
@@ -259,8 +260,11 @@ bzf_seek(struct open_file *f, off_t offset, int where)
case SEEK_CUR:
target = offset + bzf->bzf_bzstream.total_out_lo32;
break;
- default:
+ case SEEK_END:
target = -1;
+ default:
+ errno = EINVAL;
+ return (-1);
}
/* Can we get there from here? */
@@ -271,7 +275,9 @@ bzf_seek(struct open_file *f, off_t offset, int where)
/* skip forwards if required */
while (target > bzf->bzf_bzstream.total_out_lo32) {
- if (bzf_read(f, discard, min(sizeof(discard), target - bzf->bzf_bzstream.total_out_lo32), NULL) == -1)
+ errno = bzf_read(f, discard, min(sizeof(discard),
+ target - bzf->bzf_bzstream.total_out_lo32), NULL);
+ if (errno)
return(-1);
}
/* This is where we are (be honest if we overshot) */
OpenPOWER on IntegriCloud