summaryrefslogtreecommitdiff
path: root/kernel/fs.c
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2020-08-10 13:05:17 -0400
committerGitHub <[email protected]>2020-08-10 13:05:17 -0400
commitc31d35d8031c88b7e1ea8657cc9806dfdd4c3ef9 (patch)
treea6c903e1c61c08f4cb87700c320752a737081dcb /kernel/fs.c
parent90eb90b5e203299427c3fde8c996a48835fc93cf (diff)
parentd8fe1773b26758c7c7b8f36724cd822555b33612 (diff)
downloadxv6-labs-c31d35d8031c88b7e1ea8657cc9806dfdd4c3ef9.tar.gz
xv6-labs-c31d35d8031c88b7e1ea8657cc9806dfdd4c3ef9.tar.bz2
xv6-labs-c31d35d8031c88b7e1ea8657cc9806dfdd4c3ef9.zip
Merge branch 'riscv' into riscv
Diffstat (limited to 'kernel/fs.c')
-rw-r--r--kernel/fs.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/kernel/fs.c b/kernel/fs.c
index 53586d5..ec68cd7 100644
--- a/kernel/fs.c
+++ b/kernel/fs.c
@@ -22,7 +22,6 @@
#include "file.h"
#define min(a, b) ((a) < (b) ? (a) : (b))
-static void itrunc(struct inode*);
// there should be one superblock per disk device, but we run with
// only one device
struct superblock sb;
@@ -406,11 +405,8 @@ bmap(struct inode *ip, uint bn)
}
// Truncate inode (discard contents).
-// Only called when the inode has no links
-// to it (no directory entries referring to it)
-// and has no in-memory reference to it (is
-// not an open file or current directory).
-static void
+// Caller must hold ip->lock.
+void
itrunc(struct inode *ip)
{
int i, j;
@@ -463,7 +459,7 @@ readi(struct inode *ip, int user_dst, uint64 dst, uint off, uint n)
struct buf *bp;
if(off > ip->size || off + n < off)
- return -1;
+ return 0;
if(off + n > ip->size)
n = ip->size - off;
@@ -476,7 +472,7 @@ readi(struct inode *ip, int user_dst, uint64 dst, uint off, uint n)
}
brelse(bp);
}
- return n;
+ return tot;
}
// Write data to inode.