diff options
author | rtm <rtm> | 2006-07-27 21:10:00 +0000 |
---|---|---|
committer | rtm <rtm> | 2006-07-27 21:10:00 +0000 |
commit | c59361f1430ec485596d1bf5d43339af0b5a2705 (patch) | |
tree | 1cb1898c928857c94f2927f74fdb0e2cd3772793 /fs.c | |
parent | 54a4b00346575f3e2da1c9aeb023aaba4412a31d (diff) | |
download | xv6-labs-c59361f1430ec485596d1bf5d43339af0b5a2705.tar.gz xv6-labs-c59361f1430ec485596d1bf5d43339af0b5a2705.tar.bz2 xv6-labs-c59361f1430ec485596d1bf5d43339af0b5a2705.zip |
primitive exec
Diffstat (limited to 'fs.c')
-rw-r--r-- | fs.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -133,6 +133,29 @@ bmap(struct inode *ip, uint bn) return x; } +#define min(a, b) ((a) < (b) ? (a) : (b)) + +int +readi(struct inode *ip, void *xdst, uint off, uint n) +{ + char *dst = (char *) xdst; + uint target = n, n1; + struct buf *bp; + + while(n > 0 && off < ip->size){ + bp = bread(ip->dev, bmap(ip, off / 512)); + n1 = min(n, ip->size - off); + n1 = min(n1, 512 - (off % 512)); + memmove(dst, bp->data + (off % 512), n1); + n -= n1; + off += n1; + dst += n1; + brelse(bp); + } + + return target - n; +} + struct inode * namei(char *path) { |