When either_copyin/out fails, return an error from write/read
Add a test to check that read/write return an error
This commit is contained in:
parent
e23d53f27f
commit
05074badc4
2 changed files with 50 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue