summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorrsc <rsc>2007-08-24 20:54:23 +0000
committerrsc <rsc>2007-08-24 20:54:23 +0000
commit07090dd705df557cba5ce4ea46b2a274876343a5 (patch)
tree4e4c4415c702ff4c041e101ab3c7173fd636d9d0 /file.c
parentfa1b34106ad99cf8021227b4c1e62353ae4d0fda (diff)
downloadxv6-labs-07090dd705df557cba5ce4ea46b2a274876343a5.tar.gz
xv6-labs-07090dd705df557cba5ce4ea46b2a274876343a5.tar.bz2
xv6-labs-07090dd705df557cba5ce4ea46b2a274876343a5.zip
Remove struct uinode.
Remove type arg to mknod (assume T_DEV).
Diffstat (limited to 'file.c')
-rw-r--r--file.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/file.c b/file.c
index 981d474..297fd1c 100644
--- a/file.c
+++ b/file.c
@@ -56,17 +56,16 @@ int
fileread(struct file *f, char *addr, int n)
{
int r;
- struct inode *ip;
if(f->readable == 0)
return -1;
if(f->type == FD_PIPE)
return pipe_read(f->pipe, addr, n);
if(f->type == FD_INODE){
- ip = ilock(f->ip);
- if((r = readi(ip, addr, f->off, n)) > 0)
+ ilock(f->ip);
+ if((r = readi(f->ip, addr, f->off, n)) > 0)
f->off += r;
- iunlock(ip);
+ iunlock(f->ip);
return r;
}
panic("fileread");
@@ -77,17 +76,16 @@ int
filewrite(struct file *f, char *addr, int n)
{
int r;
- struct inode *ip;
if(f->writable == 0)
return -1;
if(f->type == FD_PIPE)
return pipe_write(f->pipe, addr, n);
if(f->type == FD_INODE){
- ip = ilock(f->ip);
- if((r = writei(ip, addr, f->off, n)) > 0)
+ ilock(f->ip);
+ if((r = writei(f->ip, addr, f->off, n)) > 0)
f->off += r;
- iunlock(ip);
+ iunlock(f->ip);
return r;
}
panic("filewrite");
@@ -97,12 +95,10 @@ filewrite(struct file *f, char *addr, int n)
int
filestat(struct file *f, struct stat *st)
{
- struct inode *ip;
-
if(f->type == FD_INODE){
- ip = ilock(f->ip);
- stati(ip, st);
- iunlock(ip);
+ ilock(f->ip);
+ stati(f->ip, st);
+ iunlock(f->ip);
return 0;
}
return -1;