| plan 9 kernel history: overview | file list | diff list |
1991/0411/port/devroot.c (diff list | history)
| 1991/0411/sys/src/9/port/devroot.c:1,139 – 1991/0419/sys/src/9/port/devroot.c:1,145 (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, | |
| 1990/0227 | Qdev, Qenv, Qproc, }; | |
| 1991/0214 | extern long cfslen; | |
| 1991/0216 | extern ulong cfscode[]; | |
| 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, | |
| 1991/0214 | "cfs", {Qcfs}, 0, 0700, | |
| 1990/0227 | }; #define NROOT (sizeof rootdir/sizeof(Dirtab)) | |
| 1991/0214 | int nroot; | |
| 1990/0227 | void rootreset(void) { | |
| 1991/0214 | nroot = (cfslen > 0) ? NROOT : NROOT-1; | |
| 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/0214 | return devwalk(c, name, rootdir, nroot, devgen); | |
| 1990/0227 | } | |
| 1991/0419 | Chan* rootclwalk(Chan *c, char *name) { return devclwalk(c, name); } | |
| 1990/0227 | void rootstat(Chan *c, char *dp) { | |
| 1991/0214 | devstat(c, dp, rootdir, nroot, devgen); | |
| 1990/0227 | } Chan* rootopen(Chan *c, int omode) { | |
| 1991/0214 | return devopen(c, omode, rootdir, nroot, devgen); | |
| 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/0214 | return devdirread(c, buf, n, rootdir, nroot, devgen); | |
| 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); | |
| 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 | } | |