summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2020-09-24 13:18:54 -0400
committerFrans Kaashoek <[email protected]>2020-09-24 13:18:54 -0400
commit05074badc447ce9532824924bfc41a003579beb0 (patch)
tree536abf013ae27109a5c2c4f0c5876702856f48f9 /kernel
parente23d53f27f6e187732a92a2b4705639d1c260f05 (diff)
downloadxv6-labs-05074badc447ce9532824924bfc41a003579beb0.tar.gz
xv6-labs-05074badc447ce9532824924bfc41a003579beb0.tar.bz2
xv6-labs-05074badc447ce9532824924bfc41a003579beb0.zip
When either_copyin/out fails, return an error from write/read
Add a test to check that read/write return an error
Diffstat (limited to 'kernel')
-rw-r--r--kernel/fs.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/fs.c b/kernel/fs.c
index ec68cd7..848b2c9 100644
--- a/kernel/fs.c
+++ b/kernel/fs.c
@@ -468,6 +468,7 @@ readi(struct inode *ip, int user_dst, uint64 dst, uint off, uint n)
m = min(n - tot, BSIZE - off%BSIZE);
if(either_copyout(user_dst, dst, bp->data + (off % BSIZE), m) == -1) {
brelse(bp);
+ tot = -1;
break;
}
brelse(bp);
@@ -495,6 +496,7 @@ writei(struct inode *ip, int user_src, uint64 src, uint off, uint n)
m = min(n - tot, BSIZE - off%BSIZE);
if(either_copyin(bp->data + (off % BSIZE), user_src, src, m) == -1) {
brelse(bp);
+ n = -1;
break;
}
log_write(bp);