diff options
author | Frans Kaashoek <[email protected]> | 2020-09-24 13:18:54 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2020-10-03 16:36:20 -0400 |
commit | 675060882480c21915629750a5a504d9da445ba3 (patch) | |
tree | 49de72d59eace518575770f894d9d637ae7667cd /kernel/fs.c | |
parent | 8c67f96b72b052083f1ac538141a4a16ca0e1b5c (diff) | |
download | xv6-labs-675060882480c21915629750a5a504d9da445ba3.tar.gz xv6-labs-675060882480c21915629750a5a504d9da445ba3.tar.bz2 xv6-labs-675060882480c21915629750a5a504d9da445ba3.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/fs.c')
-rw-r--r-- | kernel/fs.c | 2 |
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); |