diff options
author | rsc <rsc> | 2007-08-27 14:35:09 +0000 |
---|---|---|
committer | rsc <rsc> | 2007-08-27 14:35:09 +0000 |
commit | 1ccff18b2404e18fc889901f85b72777193c0b3f (patch) | |
tree | d941f80dbef7df236c522eeee8bbf8b8c27b8663 | |
parent | 7895178df374a1a89c193e5c83a37a35243aadc2 (diff) | |
download | xv6-labs-1ccff18b2404e18fc889901f85b72777193c0b3f.tar.gz xv6-labs-1ccff18b2404e18fc889901f85b72777193c0b3f.tar.bz2 xv6-labs-1ccff18b2404e18fc889901f85b72777193c0b3f.zip |
fileincref -> filedup (consistent with idup)
-rw-r--r-- | defs.h | 2 | ||||
-rw-r--r-- | file.c | 7 | ||||
-rw-r--r-- | proc.c | 7 | ||||
-rw-r--r-- | sysfile.c | 2 |
4 files changed, 9 insertions, 9 deletions
@@ -28,7 +28,7 @@ int exec(char*, char**); // file.c struct file* filealloc(void); void fileclose(struct file*); -void fileincref(struct file*); +struct file* filedup(struct file*); void fileinit(void); int fileread(struct file*, char*, int n); int filestat(struct file*, struct stat*); @@ -41,14 +41,15 @@ filealloc(void) } // Increment ref count for file f. -void -fileincref(struct file *f) +struct file* +filedup(struct file *f) { acquire(&file_table_lock); if(f->ref < 1 || f->type == FD_CLOSED) - panic("fileincref"); + panic("filedup"); f->ref++; release(&file_table_lock); + return f; } // Read from file f. Addr is kernel address. @@ -129,10 +129,9 @@ copyproc(struct proc *p) } memmove(np->mem, p->mem, np->sz); - for(i = 0; i < NOFILE; i++){ - if((np->ofile[i] = p->ofile[i]) != 0) - fileincref(np->ofile[i]); - } + for(i = 0; i < NOFILE; i++) + if(p->ofile[i]) + np->ofile[i] = filedup(p->ofile[i]); np->cwd = idup(p->cwd); } @@ -83,7 +83,7 @@ sys_dup(void) return -1; if((fd=fdalloc(f)) < 0) return -1; - fileincref(f); + filedup(f); return fd; } |