| plan 9 kernel history: overview | file list | diff list |
1991/0910/port/devroot.c (diff list | history)
| 1991/0910/sys/src/9/port/devroot.c:1,186 – 1991/0913/sys/src/9/port/devroot.c:1,172 (short | long | prev | next) | ||
| 1990/0227 | #include "u.h" #include "lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "errno.h" #include "devtab.h" enum{ Qdir, Qbin, Qboot, | |
| 1991/0214 | Qcfs, | |
| 1991/0613 |
| |
| 1990/0227 | Qdev, Qenv, | |
| 1991/0910 | Qkfs, | |
| 1990/0227 | Qproc, }; | |
| 1991/0214 | extern long cfslen; | |
| 1991/0216 | extern ulong cfscode[]; | |
| 1991/0910 | extern long kfslen; extern ulong kfscode[]; | |
| 1991/0613 |
| |
| 1991/0214 | ||
| 1990/0227 | Dirtab rootdir[]={ | |
| 1990/11211 | "bin", {Qbin|CHDIR}, 0, 0700, "boot", {Qboot}, 0, 0700, "dev", {Qdev|CHDIR}, 0, 0700, "env", {Qenv|CHDIR}, 0, 0700, "proc", {Qproc|CHDIR}, 0, 0700, | |
| 1990/0227 | }; #define NROOT (sizeof rootdir/sizeof(Dirtab)) | |
| 1991/0615 | Dirtab rootpdir[]={ "cfs", {Qcfs}, 0, 0700, | |
| 1991/0910 | "kfs", {Qkfs}, 0, 0700, | |
| 1991/0615 | }; Dirtab *rootmap[sizeof rootpdir/sizeof(Dirtab)]; | |
| 1991/0214 | int nroot; | |
| 1990/0227 | ||
| 1991/0615 | int rootgen(Chan *c, Dirtab *tab, int ntab, int i, Dir *dp) { if(tab==0 || i>=ntab) return -1; if(i < NROOT) tab += i; else tab = rootmap[i - NROOT]; devdir(c, tab->qid, tab->name, tab->length, tab->perm, dp); return 1; } | |
| 1990/0227 | void rootreset(void) { | |
| 1991/0615 | int i; i = 0; if(cfslen) rootmap[i++] = &rootpdir[0]; | |
| 1991/0910 | if(kfslen) | |
| 1991/0913 | rootmap[i++] = &rootpdir[1]; | |
| 1991/0615 | nroot = NROOT + i; | |
| 1990/0227 | } void rootinit(void) { } Chan* rootattach(char *spec) { return devattach('/', spec); } Chan* rootclone(Chan *c, Chan *nc) { return devclone(c, nc); } int rootwalk(Chan *c, char *name) { | |
| 1991/0615 | return devwalk(c, name, rootdir, nroot, rootgen); | |
| 1990/0227 | } void rootstat(Chan *c, char *dp) { | |
| 1991/0615 | devstat(c, dp, rootdir, nroot, rootgen); | |
| 1990/0227 | } Chan* rootopen(Chan *c, int omode) { | |
| 1991/0615 | return devopen(c, omode, rootdir, nroot, rootgen); | |
| 1990/0227 | } void rootcreate(Chan *c, char *name, int omode, ulong perm) { | |
| 1990/11211 | error(Eperm); | |
| 1990/0227 | } /* * sysremove() knows this is a nop */ void rootclose(Chan *c) { } #include "boot.h" long | |
| 1991/0411 | rootread(Chan *c, void *buf, long n, ulong offset) | |
| 1990/0227 | { | |
| 1990/11211 | switch(c->qid.path & ~CHDIR){ | |
| 1990/0227 | case Qdir: | |
| 1991/0615 | return devdirread(c, buf, n, rootdir, nroot, rootgen); | |
| 1990/0227 | case Qboot: /* boot */ | |
| 1991/0411 | if(offset >= sizeof bootcode) | |
| 1990/0227 | return 0; | |
| 1991/0411 | if(offset+n > sizeof bootcode) n = sizeof bootcode - offset; memmove(buf, ((char*)bootcode)+offset, n); | |
| 1991/0214 | return n; | |
| 1991/0312 | case Qcfs: /* cfs */ | |
| 1991/0411 | if(offset >= cfslen) | |
| 1991/0214 | return 0; | |
| 1991/0411 | if(offset+n > cfslen) n = cfslen - offset; memmove(buf, ((char*)cfscode)+offset, n); | |
| 1991/0910 | return n; case Qkfs: /* kfs */ if(offset >= kfslen) return 0; if(offset+n > kfslen) n = kfslen - offset; memmove(buf, ((char*)kfscode)+offset, n); | |
| 1991/0613 |
| |
| 1990/0227 | return n; case Qdev: return 0; } | |
| 1990/11211 | error(Egreg); | |
| 1990/0227 | return 0; } long | |
| 1991/0411 | rootwrite(Chan *c, void *buf, long n, ulong offset) | |
| 1990/0227 | { | |
| 1990/11211 | error(Egreg); | |
| 1990/0227 | } void rootremove(Chan *c) { | |
| 1990/11211 | error(Eperm); | |
| 1990/0227 | } void rootwstat(Chan *c, char *dp) { | |
| 1990/11211 | error(Eperm); | |
| 1990/0227 | } | |