summaryrefslogtreecommitdiff
path: root/sys/src/9/port
diff options
context:
space:
mode:
authorJacob Moody <moody@posixcafe.org>2022-06-15 06:42:05 +0000
committerJacob Moody <moody@posixcafe.org>2022-06-15 06:42:05 +0000
commitc12022fd8c434860accb237b9bad9bd7cd9ed2db (patch)
treef3651ec0e98313f83a3dce393a53910e1953f359 /sys/src/9/port
parentc7c0ff5db6137662e435d66338cfa4e68c64598e (diff)
skel(3) → skelfs(4)
The original intention was to put devskel in to the kernel to detach what it provides from devsrv. That is not a good reason, just move it to userspace. auth/box has been changed to exec skelfs instead of relying on '#z'.
Diffstat (limited to 'sys/src/9/port')
-rw-r--r--sys/src/9/port/devskel.c239
1 files changed, 0 insertions, 239 deletions
diff --git a/sys/src/9/port/devskel.c b/sys/src/9/port/devskel.c
deleted file mode 100644
index 90aa2dae6..000000000
--- a/sys/src/9/port/devskel.c
+++ /dev/null
@@ -1,239 +0,0 @@
-#include "u.h"
-#include "../port/lib.h"
-#include "mem.h"
-#include "dat.h"
-#include "fns.h"
-#include "../port/error.h"
-
-#include "netif.h"
-
-typedef struct Skel Skel;
-struct Skel {
- RWlock;
- int ref;
- char name[KNAMELEN];
- char mode;
-};
-
-struct
-{
- QLock;
- ulong path;
-} skelalloc;
-
-enum{
- Qroot,
- Qdir,
- Qskel,
-};
-
-static Chan*
-skelattach(char *spec)
-{
- Chan *c;
- Skel *f;
- uvlong path;
-
- c = devattach('z', spec);
-
- f = mallocz(sizeof *f, 1);
- if(f == nil)
- exhausted("memory");
- if(waserror()){
- free(f);
- nexterror();
- }
-
- if(spec == nil)
- f->mode = 'f';
- else
- f->mode = spec[0];
-
- eqlock(&skelalloc);
- path = skelalloc.path++;
- qunlock(&skelalloc);
-
- poperror();
- mkqid(&c->qid, NETQID(path, Qroot), path, QTDIR);
- f->ref = 1;
- c->aux = f;
- return c;
-}
-
-static int
-step(Chan *c, Dir *dp, int direction)
-{
- Skel *f;
- Qid qid;
- ulong perm;
- int path;
- char *name;
-
- perm = 0555|DMDIR;
- path = NETTYPE(c->qid.path);
- f = c->aux;
- rlock(f);
- if(waserror()){
- runlock(f);
- return -1;
- }
- name = f->name;
-
- path += direction;
- if(!f->name[0] && path > Qroot)
- error(Enonexist);
-
- switch(path){
- case Qroot-1:
- case Qroot:
- mkqid(&qid, Qroot, 0, QTDIR);
- name = "#z";
- break;
- case Qdir:
- mkqid(&qid, Qdir, 0, QTDIR);
- break;
- case Qskel:
- switch(f->mode){
- case 'd':
- mkqid(&qid, Qskel, 0, QTDIR);
- break;
- case 'f':
- default:
- mkqid(&qid, Qskel, 0, QTFILE);
- perm = 0666;
- break;
- }
- break;
- default:
- error(Enonexist);
- }
-
- qid.vers = NETID(c->qid.path);
- qid.path = NETQID(qid.vers, qid.path);
- devdir(c, qid, name, 0, eve, perm, dp);
- runlock(f);
- poperror();
- return 1;
-}
-
-
-static int
-skelgen(Chan *c, char *name, Dirtab*, int, int s, Dir *dp)
-{
- Skel *f;
-
- switch(s){
- case DEVDOTDOT:
- break;
- case 0:
- s++;
- break;
- default:
- return -1;
- }
- f = c->aux;
- if(name && NETTYPE(c->qid.path) == Qroot){
- wlock(f);
- if(!f->name[0] && f->mode != 'e')
- utfecpy(f->name, &f->name[sizeof f->name-1], name);
- wunlock(f);
- }
-
- return step(c, dp, s);
-}
-
-static Walkqid*
-skelwalk(Chan *c, Chan *nc, char **name, int nname)
-{
- Walkqid *wq;
- Skel *f;
-
- wq = devwalk(c, nc, name, nname, nil, 0, skelgen);
- if(wq == nil || wq->clone == nil)
- return wq;
-
- f = c->aux;
- wlock(f);
- if(f->ref <= 0)
- panic("devskel ref");
- f->ref++;
- wunlock(f);
- return wq;
-}
-
-static Chan*
-skelopen(Chan *c, int omode)
-{
- if(!(c->qid.type & QTDIR))
- error(Eperm);
- if(omode != OREAD)
- error(Ebadarg);
-
- c->mode = omode;
- c->flag |= COPEN;
- c->offset = 0;
- return c;
-}
-
-static void
-skelclose(Chan *c)
-{
- Skel *f;
-
- f = c->aux;
- wlock(f);
- f->ref--;
- if(f->ref == 0){
- wunlock(f);
- free(f);
- } else
- wunlock(f);
-}
-
-static long
-skelread(Chan *c, void *va, long n, vlong)
-{
- return devdirread(c, va, n, nil, 0, skelgen);
-}
-
-static long
-skelwrite(Chan*, void*, long, vlong)
-{
- error(Ebadusefd);
- return -1;
-}
-
-static int
-skelstat(Chan *c, uchar *db, int n)
-{
- Dir dir;
-
- if(step(c, &dir, 0) < 0)
- error(Enonexist);
-
- n = convD2M(&dir, db, n);
- if(n < BIT16SZ)
- error(Eshortstat);
- return n;
-}
-
-Dev skeldevtab = {
- 'z',
- "skel",
-
- devreset,
- devinit,
- devshutdown,
- skelattach,
- skelwalk,
- skelstat,
- skelopen,
- devcreate,
- skelclose,
- skelread,
- devbread,
- skelwrite,
- devbwrite,
- devremove,
- devwstat,
-};