|
|
1.1 root 1: #include "u.h"
2: #include "../port/lib.h"
3: #include "mem.h"
4: #include "dat.h"
5: #include "fns.h"
6: #include "../port/error.h"
7:
8: #include "devtab.h"
9:
10:
11: int
12: dupgen(Chan *c, Dirtab *tab, int ntab, int s, Dir *dp)
13: {
14: char buf[8];
15: Fgrp *fgrp = u->p->fgrp;
16: Chan *f;
17: static int perm[] = { 0400, 0200, 0600, 0 };
18:
19: USED(tab);
20: USED(ntab);
21: if(s >= NFD)
22: return -1;
23: if((f=fgrp->fd[s]) == 0)
24: return 0;
25: sprint(buf, "%ld", s);
26: devdir(c, (Qid){s, 0}, buf, 0, eve, perm[f->mode&3], dp);
27: return 1;
28: }
29:
30: void
31: dupinit(void)
32: {
33: }
34:
35: void
36: dupreset(void)
37: {
38: }
39:
40: Chan *
41: dupattach(char *spec)
42: {
43: return devattach('d', spec);
44: }
45:
46: Chan *
47: dupclone(Chan *c, Chan *nc)
48: {
49: return devclone(c, nc);
50: }
51:
52: int
53: dupwalk(Chan *c, char *name)
54: {
55: return devwalk(c, name, (Dirtab *)0, 0, dupgen);
56: }
57:
58: void
59: dupstat(Chan *c, char *db)
60: {
61: devstat(c, db, (Dirtab *)0, 0L, dupgen);
62: }
63:
64: Chan *
65: dupopen(Chan *c, int omode)
66: {
67: Chan *f;
68:
69: if(c->qid.path == CHDIR){
70: if(omode != 0)
71: error(Eisdir);
72: c->mode = 0;
73: c->flag |= COPEN;
74: c->offset = 0;
75: return c;
76: }
77: fdtochan(c->qid.path, openmode(omode), 0, 0); /* error check only */
78: f = u->p->fgrp->fd[c->qid.path];
79: close(c);
80: incref(f);
81: if(omode & OCEXEC)
82: f->flag |= CCEXEC;
83: return f;
84: }
85:
86: void
87: dupcreate(Chan *c, char *name, int omode, ulong perm)
88: {
89: USED(c, name, omode, perm);
90: error(Eperm);
91: }
92:
93: void
94: dupremove(Chan *c)
95: {
96: USED(c);
97: error(Eperm);
98: }
99:
100: void
101: dupwstat(Chan *c, char *dp)
102: {
103: USED(c);
104: USED(dp);
105: error(Egreg);
106: }
107:
108: void
109: dupclose(Chan *c)
110: {
111: USED(c);
112: }
113:
114: long
115: dupread(Chan *c, void *va, long n, ulong offset)
116: {
117: char *a = va;
118:
119: USED(offset);
120: if(c->qid.path != CHDIR)
121: panic("dupread");
122: return devdirread(c, a, n, (Dirtab *)0, 0L, dupgen);
123: }
124:
125: long
126: dupwrite(Chan *c, void *va, long n, ulong offset)
127: {
128: USED(c, va, n, offset);
129: panic("dupwrite");
130: return 0; /* not reached */
131: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.