diff options
author | jhb <jhb@FreeBSD.org> | 2004-01-21 20:12:23 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2004-01-21 20:12:23 +0000 |
commit | fffc52fe7a3393e38603b6d028c721e38a1d1cc3 (patch) | |
tree | ef59111118b96cb170e58b13a12c868718248613 /lib/libstand/splitfs.c | |
parent | c6b7068a7d44e6082f3cba1e19415d67838013ac (diff) | |
download | FreeBSD-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/splitfs.c')
-rw-r--r-- | lib/libstand/splitfs.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/libstand/splitfs.c b/lib/libstand/splitfs.c index 8792464..35593ad 100644 --- a/lib/libstand/splitfs.c +++ b/lib/libstand/splitfs.c @@ -250,6 +250,9 @@ splitfs_seek(struct open_file *f, off_t offset, int where) case SEEK_END: panic("splitfs_seek: SEEK_END not supported"); break; + default: + errno = EINVAL; + return (-1); } if (seek_by > 0) { @@ -261,8 +264,10 @@ splitfs_seek(struct open_file *f, off_t offset, int where) void *tmp; tmp = malloc(SEEK_BUF); - if (tmp == NULL) + if (tmp == NULL) { + errno = ENOMEM; return (-1); + } nread = 0; for (; seek_by > 0; seek_by -= nread) { @@ -283,8 +288,10 @@ splitfs_seek(struct open_file *f, off_t offset, int where) if (sf->file_pos + seek_by < 0) panic("splitfs_seek: can't seek past the beginning of the slice"); new_pos = lseek(sf->curfd, seek_by, SEEK_CUR); - if (new_pos < 0) + if (new_pos < 0) { + errno = EINVAL; return (-1); + } sf->tot_pos += new_pos - sf->file_pos; sf->file_pos = new_pos; } |