2 #include "../port/lib.h"
6 #include "../port/error.h"
8 /* Qid is (2*fd + (file is ctl))+1 */
11 dupgen(Chan *c, char *, Dirtab*, int, int s, Dir *dp)
13 Fgrp *fgrp = up->fgrp;
15 static int perm[] = { 0400, 0200, 0600, 0 };
20 devdir(c, c->qid, ".", 0, eve, DMDIR|0555, dp);
28 if((f=fgrp->fd[s/2]) == nil)
32 sprint(up->genbuf, "%dctl", s/2);
35 sprint(up->genbuf, "%d", s/2);
37 mkqid(&q, s+1, 0, QTFILE);
38 devdir(c, q, up->genbuf, 0, eve, p, dp);
45 return devattach('d', spec);
49 dupwalk(Chan *c, Chan *nc, char **name, int nname)
51 return devwalk(c, nc, name, nname, (Dirtab *)0, 0, dupgen);
55 dupstat(Chan *c, uchar *db, int n)
57 return devstat(c, db, n, (Dirtab *)0, 0L, dupgen);
61 dupopen(Chan *c, int omode)
66 if(c->qid.type & QTDIR){
74 if(c->qid.type & QTAUTH)
76 twicefd = c->qid.path - 1;
81 f->mode = openmode(omode);
86 f = fdtochan(fd, openmode(omode), 0, 1);
100 dupread(Chan *c, void *va, long n, vlong offset)
106 if(c->qid.type == QTDIR)
107 return devdirread(c, a, n, (Dirtab *)0, 0L, dupgen);
108 twicefd = c->qid.path - 1;
111 c = fdtochan(fd, -1, 0, 1);
112 procfdprint(c, fd, 0, buf, sizeof buf);
114 return readstr((ulong)offset, va, n, buf);
121 dupwrite(Chan*, void*, long, vlong)
124 return 0; /* not reached */