diff options
Diffstat (limited to 'kernel/file.c')
-rw-r--r-- | kernel/file.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/kernel/file.c b/kernel/file.c index 6f27f22..f330cf1 100644 --- a/kernel/file.c +++ b/kernel/file.c @@ -73,9 +73,9 @@ fileclose(struct file *f) f->type = FD_NONE; release(&ftable.lock); - if(ff.type == FD_PIPE) + if(ff.type == FD_PIPE){ pipeclose(ff.pipe, ff.writable); - else if(ff.type == FD_INODE){ + } else if(ff.type == FD_INODE || ff.type == FD_DEVICE){ begin_op(); iput(ff.ip); end_op(); @@ -90,7 +90,7 @@ filestat(struct file *f, uint64 addr) struct proc *p = myproc(); struct stat st; - if(f->type == FD_INODE){ + if(f->type == FD_INODE || f->type == FD_DEVICE){ ilock(f->ip); stati(f->ip, &st); iunlock(f->ip); @@ -113,6 +113,8 @@ fileread(struct file *f, uint64 addr, int n) if(f->type == FD_PIPE){ r = piperead(f->pipe, addr, n); + } else if(f->type == FD_DEVICE){ + r = devsw[f->major].read(1, addr, n); } else if(f->type == FD_INODE){ ilock(f->ip); if((r = readi(f->ip, 1, addr, f->off, n)) > 0) @@ -138,6 +140,8 @@ filewrite(struct file *f, uint64 addr, int n) if(f->type == FD_PIPE){ ret = pipewrite(f->pipe, addr, n); + } else if(f->type == FD_DEVICE){ + ret = devsw[f->major].write(1, addr, n); } else if(f->type == FD_INODE){ // write a few blocks at a time to avoid exceeding // the maximum log transaction size, including |