
jread, jwrite and jwritev had a potential bug that a return value of 0 could
extend the file or leave the file pointer in an incorrect position. This patch
fixes it.


---

 cur-root/unix.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff -puN unix.c~jread_advance unix.c
--- cur/unix.c~jread_advance	2004-09-05 23:36:31.506675464 -0300
+++ cur-root/unix.c	2004-09-05 23:38:44.351479984 -0300
@@ -31,9 +31,9 @@ ssize_t jread(struct jfs *fs, void *buf,
 	rv = spread(fs->fd, buf, count, pos);
 	plockf(fs->fd, F_UNLOCK, pos, count);
 
-	if (rv >= 0) {
+	if (rv > 0) {
 		/* if success, advance the file pointer */
-		lseek(fs->fd, count, SEEK_CUR);
+		lseek(fs->fd, rv, SEEK_CUR);
 	}
 
 	pthread_mutex_unlock(&(fs->lock));
@@ -92,9 +92,9 @@ ssize_t jwrite(struct jfs *fs, const voi
 
 	rv = jtrans_commit(&ts);
 
-	if (rv >= 0) {
+	if (rv > 0) {
 		/* if success, advance the file pointer */
-		lseek(fs->fd, count, SEEK_CUR);
+		lseek(fs->fd, rv, SEEK_CUR);
 	}
 
 	pthread_mutex_unlock(&(fs->lock));
@@ -143,9 +143,9 @@ ssize_t jwritev(struct jfs *fs, const st
 
 	rv = jtrans_commit(&ts);
 
-	if (rv >= 0) {
+	if (rv > 0) {
 		/* if success, advance the file pointer */
-		lseek(fs->fd, sum, SEEK_CUR);
+		lseek(fs->fd, rv, SEEK_CUR);
 	}
 
 	pthread_mutex_unlock(&(fs->lock));
_

