Newer
Older
#include "param.h"
#include "x86.h"
#include "mmu.h"
#include "proc.h"
#include "defs.h"
#include "fs.h"
#include "fsvar.h"
for(i = 0; i < NFILE; i++){
if(file[i].type == FD_CLOSED){
file[i].type = FD_NONE;
file[i].ref = 1;
if(f->type == FD_PIPE){
return pipe_write(f->pipe, addr, n);
} else if(f->type == FD_FILE) {
ilock(f->ip);
int r = writei(f->ip, addr, f->off, n);
if(f->type == FD_PIPE){
return pipe_read(f->pipe, addr, n);
} else if(f->type == FD_FILE){
ilock(f->ip);
int cc = readi(f->ip, addr, f->off, n);
f->ref = 0;
f->type = FD_CLOSED;
release(&file_table_lock);
if(dummy.type == FD_PIPE){
} else if(dummy.type == FD_FILE){
idecref(dummy.ip);
if(f->type == FD_FILE){
ilock(f->ip);
stati(f->ip, st);
iunlock(f->ip);
acquire(&file_table_lock);
if(f->ref < 1 || f->type == FD_CLOSED)