| plan 9 kernel history: overview | file list | diff list |
2002/0202/port/devcap.c (diff list | history)
| 2001/0527/sys/src/9/port/devcap.c:251,256 – 2002/0109/sys/src/9/port/devcap.c:251,257 (short | long) | ||
|
Add devshutdown.
rsc Fri Mar 4 12:44:25 2005 | ||
| 2001/0527 | devreset, devinit, | |
| 2002/0109 | devshutdown, | |
| 2001/0527 | capattach, capwalk, capstat, | |
| 2002/0109/sys/src/9/port/devcap.c:192,198 – 2002/0202/sys/src/9/port/devcap.c:192,198 (short | long) | ||
| 2001/0527 | Caphash *p; char *cp; uchar hash[Hashlen]; | |
| 2002/0202 | char *key, *from, *to; | |
| 2001/0527 | char err[256]; switch((ulong)c->qid.path){ | |
| 2002/0109/sys/src/9/port/devcap.c:214,235 – 2002/0202/sys/src/9/port/devcap.c:214,245 | ||
| 2001/0527 | memmove(cp, va, n); cp[n] = 0; | |
| 2002/0202 | from = cp; key = strrchr(cp, '@'); | |
| 2001/0527 | if(key == nil) error(Eshort); *key++ = 0; | |
| 2002/0202 | hmac_sha1((uchar*)from, strlen(from), (uchar*)key, strlen(key), hash, nil); | |
| 2001/0527 | p = remcap(hash); if(p == nil){ | |
| 2002/0202 | snprint(err, sizeof err, "invalid capability %s@%s", from, key); | |
| 2001/0527 | error(err); } | |
| 2002/0202 | /* if a from user is supplied, make sure it matches */ to = strchr(from, '@'); if(to == nil){ to = from; } else { *to++ = 0; if(strcmp(from, up->user) != 0) error("capability must match user"); } | |
| 2001/0527 | /* set user id */ | |
| 2002/0202 | kstrdup(&up->user, to); | |
| 2001/0527 | up->basepri = PriNormal; free(p); | |
| 2002/0202/sys/src/9/port/devcap.c:89,94 – 2002/0622/sys/src/9/port/devcap.c:89,96 (short | long) | ||
| 2001/0527 | qlock(&capalloc); switch((ulong)c->qid.path){ case Qhash: | |
| 2002/0622 | if(!iseve()) error(Eperm); | |
| 2001/0527 | if(capalloc.opens > 0){ qunlock(&capalloc); error("exclusive use"); | |
| 2002/0622/sys/src/9/port/devcap.c:29,35 – 2002/0623/sys/src/9/port/devcap.c:29,34 (short | long) | ||
| 2001/0527 | struct { QLock; | |
| 2002/0622/sys/src/9/port/devcap.c:41,53 – 2002/0623/sys/src/9/port/devcap.c:40,53 | ||
| 2001/0527 | Quse, }; | |
| 2002/0623 | /* caphash must be last */ | |
| 2001/0527 | Dirtab capdir[] = { ".", {Qdir,0,QTDIR}, 0, DMDIR|0500, | |
| 2002/0623 | "caphash", {Qhash}, 0, 0200, | |
| 2001/0527 | }; | |
| 2002/0623 | int ncapdir = nelem(capdir); | |
| 2001/0527 | static Chan* capattach(char *spec) | |
| 2002/0622/sys/src/9/port/devcap.c:58,70 – 2002/0623/sys/src/9/port/devcap.c:58,80 | ||
| 2001/0527 | static Walkqid* capwalk(Chan *c, Chan *nc, char **name, int nname) { | |
| 2002/0623 | return devwalk(c, nc, name, nname, capdir, ncapdir, devgen); | |
| 2001/0527 | } | |
| 2002/0623 | static void capremove(Chan *c) { if(iseve() && c->qid.path == Qhash) ncapdir = nelem(capdir)-1; else error(Eperm); } | |
| 2001/0527 | static int capstat(Chan *c, uchar *db, int n) { | |
| 2002/0623 | return devstat(c, db, n, capdir, ncapdir, devgen); | |
| 2001/0527 | } /* | |
| 2002/0622/sys/src/9/port/devcap.c:86,105 – 2002/0623/sys/src/9/port/devcap.c:96,108 | ||
| 2001/0527 | qunlock(&capalloc); nexterror(); } | |
| 2002/0622 | if(!iseve()) error(Eperm); | |
| 2001/0527 |
| |
| 2002/0622/sys/src/9/port/devcap.c:164,177 – 2002/0623/sys/src/9/port/devcap.c:167,174 | ||
| 2001/0527 | } static void | |
| 2002/0623 | capclose(Chan*) | |
| 2001/0527 | { | |
| 2002/0622/sys/src/9/port/devcap.c:179,185 – 2002/0623/sys/src/9/port/devcap.c:176,182 | ||
| 2001/0527 | { switch((ulong)c->qid.path){ case Qdir: | |
| 2002/0623 | return devdirread(c, va, n, capdir, ncapdir, devgen); | |
| 2001/0527 | default: error(Eperm); | |
| 2002/0622/sys/src/9/port/devcap.c:258,279 – 2002/0623/sys/src/9/port/devcap.c:255,276 | ||
| 2001/0527 | } Dev capdevtab = { | |
| 2002/0623 | .dc= L'¤', .name= "cap", | |
| 2001/0527 |
| |
| 2002/0109 |
| |
| 2001/0527 |
| |
| 2002/0623 | .reset= devreset, .init= devinit, .shutdown= devshutdown, .attach= capattach, .walk= capwalk, .stat= capstat, .open= capopen, .create= devcreate, .close= capclose, .read= capread, .bread= devbread, .write= capwrite, .bwrite= devbwrite, .remove= capremove, .wstat= devwstat, | |
| 2001/0527 | }; | |
| 2002/0623/sys/src/9/port/devcap.c:92,101 – 2002/0907/sys/src/9/port/devcap.c:92,97 (short | long) | ||
| 2001/0527 | return c; } | |
| 2002/0622 | if(!iseve()) | |
| 2002/0623/sys/src/9/port/devcap.c:102,108 – 2002/0907/sys/src/9/port/devcap.c:98,103 | ||
| 2002/0622 | error(Eperm); | |
| 2001/0527 | break; } | |
| 2002/0907/sys/src/9/port/devcap.c:250,271 – 2003/0218/sys/src/9/port/devcap.c:250,271 (short | long) | ||
| 2001/0527 | } Dev capdevtab = { | |
| 2002/0623 |
| |
| 2003/0218 | L'¤', "cap", | |
| 2001/0527 | ||
| 2002/0623 |
| |
| 2003/0218 | devreset, devinit, devshutdown, capattach, capwalk, capstat, capopen, devcreate, capclose, capread, devbread, capwrite, devbwrite, capremove, devwstat | |
| 2001/0527 | }; | |
| 2003/0218/sys/src/9/port/devcap.c:105,110 – 2003/0222/sys/src/9/port/devcap.c:105,122 (short | long) | ||
| 2001/0527 | return c; } | |
| 2003/0222 | static char* hashstr(uchar *hash) { static char buf[256]; int i; for(i = 0; i < Hashlen; i++) sprint(buf+2*i, "%2.2ux", hash[i]); buf[2*Hashlen] = 0; return buf; } | |
| 2001/0527 | static Caphash* remcap(uchar *hash) { | |