f 28 file.c struct file *f;
f 31 file.c for(f = ftable.file; f < ftable.file + NFILE; f++){
f 32 file.c if(f->ref == 0){
f 33 file.c f->ref = 1;
f 35 file.c return f;
f 44 file.c filedup(struct file *f)
f 47 file.c if(f->ref < 1)
f 49 file.c f->ref++;
f 51 file.c return f;
f 56 file.c fileclose(struct file *f)
f 61 file.c if(f->ref < 1)
f 63 file.c if(--f->ref > 0){
f 67 file.c ff = *f;
f 68 file.c f->ref = 0;
f 69 file.c f->type = FD_NONE;
f 83 file.c filestat(struct file *f, struct stat *st)
f 85 file.c if(f->type == FD_INODE){
f 86 file.c ilock(f->ip);
f 87 file.c stati(f->ip, st);
f 88 file.c iunlock(f->ip);
f 96 file.c fileread(struct file *f, char *addr, int n)
f 100 file.c if(f->readable == 0)
f 102 file.c if(f->type == FD_PIPE)
f 103 file.c return piperead(f->pipe, addr, n);
f 104 file.c if(f->type == FD_INODE){
f 105 file.c ilock(f->ip);
f 106 file.c if((r = readi(f->ip, addr, f->off, n)) > 0)
f 107 file.c f->off += r;
f 108 file.c iunlock(f->ip);
f 117 file.c filewrite(struct file *f, char *addr, int n)
f 121 file.c if(f->writable == 0)
f 123 file.c if(f->type == FD_PIPE)
f 124 file.c return pipewrite(f->pipe, addr, n);
f 125 file.c if(f->type == FD_INODE){
f 140 file.c ilock(f->ip);
f 141 file.c if ((r = writei(f->ip, addr + i, f->off, n1)) > 0)
f 142 file.c f->off += r;
f 143 file.c iunlock(f->ip);
f 23 sysfile.c struct file *f;
f 27 sysfile.c if(fd < 0 || fd >= NOFILE || (f=proc->ofile[fd]) == 0)
f 32 sysfile.c *pf = f;
f 39 sysfile.c fdalloc(struct file *f)
f 45 sysfile.c proc->ofile[fd] = f;
f 55 sysfile.c struct file *f;
f 58 sysfile.c if(argfd(0, 0, &f) < 0)
f 60 sysfile.c if((fd=fdalloc(f)) < 0)
f 62 sysfile.c filedup(f);
f 69 sysfile.c struct file *f;
f 73 sysfile.c if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0)
f 75 sysfile.c return fileread(f, p, n);
f 81 sysfile.c struct file *f;
f 85 sysfile.c if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0)
f 87 sysfile.c return filewrite(f, p, n);
f 94 sysfile.c struct file *f;
f 96 sysfile.c if(argfd(0, &fd, &f) < 0)
f 99 sysfile.c fileclose(f);
f 106 sysfile.c struct file *f;
f 109 sysfile.c if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0)
f 111 sysfile.c return filestat(f, st);
f 288 sysfile.c struct file *f;
f 315 sysfile.c if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){
f 316 sysfile.c if(f)
f 317 sysfile.c fileclose(f);
f 325 sysfile.c f->type = FD_INODE;
f 326 sysfile.c f->ip = ip;
f 327 sysfile.c f->off = 0;
f 328 sysfile.c f->readable = !(omode & O_WRONLY);
f 329 sysfile.c f->writable = (omode & O_WRONLY) || (omode & O_RDWR);