| plan 9 kernel history: overview | file list | diff list |
1998/0319/port/devdup.c (diff list | history)
| port/devdup.c on 1990/0227 | ||
| 1990/0227 | #include "u.h" | |
| 1992/0321 | #include "../port/lib.h" | |
| 1990/0227 | #include "mem.h" #include "dat.h" #include "fns.h" | |
| 1992/0111 | #include "../port/error.h" | |
| 1990/0227 | ||
| 1997/0327 | static int | |
| 1995/0804 | dupgen(Chan *c, Dirtab*, int, int s, Dir *dp) | |
| 1990/0227 | { char buf[8]; | |
| 1993/0501 | Fgrp *fgrp = up->fgrp; | |
| 1990/0227 | Chan *f; static int perm[] = { 0400, 0200, 0600, 0 }; | |
| 1997/0606 | if(s > fgrp->maxfd) | |
| 1990/0227 | return -1; | |
| 1991/0705 | if((f=fgrp->fd[s]) == 0) | |
| 1990/0227 | return 0; sprint(buf, "%ld", s); | |
| 1991/1109 | devdir(c, (Qid){s, 0}, buf, 0, eve, perm[f->mode&3], dp); | |
| 1990/0227 | return 1; } | |
| 1997/0327 | static Chan* | |
| 1990/0227 | dupattach(char *spec) { return devattach('d', spec); } | |
| 1997/0327 | static int | |
| 1990/0227 | dupwalk(Chan *c, char *name) { return devwalk(c, name, (Dirtab *)0, 0, dupgen); } | |
| 1997/0327 | static void | |
| 1990/0227 | dupstat(Chan *c, char *db) { | |
| 1991/0426 | devstat(c, db, (Dirtab *)0, 0L, dupgen); | |
| 1990/0227 | } | |
| 1997/0327 | static Chan* | |
| 1990/0227 | dupopen(Chan *c, int omode) { Chan *f; | |
| 1990/11211 | if(c->qid.path == CHDIR){ | |
| 1990/0227 | if(omode != 0) | |
| 1990/11211 | error(Eisdir); | |
| 1990/0227 | c->mode = 0; c->flag |= COPEN; c->offset = 0; return c; } | |
| 1992/0825 | fdtochan(c->qid.path, openmode(omode), 0, 0); /* error check only */ | |
| 1993/0501 | f = up->fgrp->fd[c->qid.path]; | |
| 1997/0327 | cclose(c); | |
| 1990/0227 | incref(f); | |
| 1991/0320 | if(omode & OCEXEC) f->flag |= CCEXEC; | |
| 1990/0227 | return f; } | |
| 1997/0327 | static void | |
| 1995/0804 | dupclose(Chan*) | |
| 1990/0227 | { } | |
| 1997/0327 | static long | |
| 1998/0319 | dupread(Chan *c, void *va, long n, vlong) | |
| 1990/0227 | { char *a = va; | |
| 1990/11211 | if(c->qid.path != CHDIR) | |
| 1990/0227 | panic("dupread"); return devdirread(c, a, n, (Dirtab *)0, 0L, dupgen); } | |
| 1997/0327 | static long | |
| 1998/0319 | dupwrite(Chan*, void*, long, vlong) | |
| 1990/0227 | { panic("dupwrite"); | |
| 1992/0520 | return 0; /* not reached */ | |
| 1995/0108 | } | |
| 1997/0327 | Dev dupdevtab = { | |
| 1997/0408 | 'd', "dup", | |
| 1997/0327 | devreset, devinit, dupattach, devclone, dupwalk, dupstat, dupopen, devcreate, dupclose, dupread, devbread, dupwrite, devbwrite, devremove, devwstat, }; | |