| plan 9 kernel history: overview | file list | diff list |
1991/0411/port/devdup.c (diff list | history)
| port/devdup.c on 1990/0227 | ||
| 1990/0227 | #include "u.h" #include "lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "errno.h" #include "devtab.h" int dupgen(Chan *c, Dirtab *tab, int ntab, int s, Dir *dp) { char buf[8]; Chan *f; static int perm[] = { 0400, 0200, 0600, 0 }; if(s >= NFD) return -1; if((f=u->fd[s]) == 0) return 0; sprint(buf, "%ld", s); | |
| 1990/11211 | devdir(c, (Qid){s, 0}, buf, 0, perm[f->mode&3], dp); | |
| 1990/0227 | return 1; } void dupinit(void) { } void dupreset(void) { } Chan * dupattach(char *spec) { return devattach('d', spec); } Chan * dupclone(Chan *c, Chan *nc) { return devclone(c, nc); } int dupwalk(Chan *c, char *name) { return devwalk(c, name, (Dirtab *)0, 0, dupgen); } void dupstat(Chan *c, char *db) { devstat(c, db, (Dirtab *)0, 0L, dupgen); } Chan * 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; } | |
| 1990/11211 | fdtochan(c->qid.path, openmode(omode)); /* error check only */ f = u->fd[c->qid.path]; | |
| 1990/0227 | close(c); incref(f); | |
| 1991/0320 | if(omode & OCEXEC) f->flag |= CCEXEC; | |
| 1990/0227 | return f; } void dupcreate(Chan *c, char *name, int omode, ulong perm) { | |
| 1990/11211 | error(Eperm); | |
| 1990/0227 | } void dupremove(Chan *c) { | |
| 1990/11211 | error(Eperm); | |
| 1990/0227 | } void dupwstat(Chan *c, char *dp) { | |
| 1990/11211 | error(Egreg); | |
| 1990/0227 | } void dupclose(Chan *c) { } long | |
| 1991/0411 | dupread(Chan *c, void *va, long n, ulong offset) | |
| 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); } long | |
| 1991/0411 | dupwrite(Chan *c, void *va, long n, ulong offset) | |
| 1990/0227 | { panic("dupwrite"); } | |