| plan 9 kernel history: overview | file list | diff list |
1991/1219/port/devsrv.c (diff list | history)
| 1991/1127/sys/src/9/port/devsrv.c:9,27 – 1991/1219/sys/src/9/port/devsrv.c:9,35 (short | long | prev | next) | ||
| 1990/0227 | ||
| 1991/0828 | typedef struct Srv Srv; struct Srv{ | |
| 1990/0227 |
| |
| 1991/0828 |
| |
| 1991/1219 | char name[NAMELEN]; char owner[NAMELEN]; ulong perm; Chan *chan; }; | |
| 1990/0227 | ||
| 1991/1219 | Lock srvlk; Srv *srv; | |
| 1991/0828 | int srvgen(Chan *c, Dirtab *tab, int ntab, int s, Dir *dp) { | |
| 1991/1219 | Srv *sp; | |
| 1991/0828 | if(s >= conf.nsrv) return -1; | |
| 1991/1219 | sp = &srv[s]; if(sp->chan == 0) | |
| 1991/0828 | return 0; | |
| 1991/1109 |
| |
| 1991/1219 | devdir(c, (Qid){s, 0}, sp->name, 0, sp->owner, sp->perm, dp); | |
| 1991/0828 | return 1; } | |
| 1991/1127/sys/src/9/port/devsrv.c:33,40 – 1991/1219/sys/src/9/port/devsrv.c:41,47 | ||
| 1990/0227 | void srvreset(void) { | |
| 1991/0828 |
| |
| 1991/1219 | srv = ialloc(conf.nsrv*sizeof(Srv), 0); | |
| 1990/0227 | } Chan * | |
| 1991/1127/sys/src/9/port/devsrv.c:74,85 – 1991/1219/sys/src/9/port/devsrv.c:81,92 | ||
| 1990/0227 | c->offset = 0; return c; } | |
| 1991/0828 |
| |
| 1991/1219 | lock(&srvlk); | |
| 1991/0828 | if(waserror()){ | |
| 1991/1219 | unlock(&srvlk); | |
| 1991/0828 | nexterror(); } | |
| 1991/1219 | f = srv[c->qid.path].chan; | |
| 1991/0828 | if(f == 0) | |
| 1990/11211 | error(Eshutdown); | |
| 1991/0828 | if(omode&OTRUNC) | |
| 1991/1127/sys/src/9/port/devsrv.c:88,94 – 1991/1219/sys/src/9/port/devsrv.c:95,101 | ||
| 1990/11211 | error(Eperm); | |
| 1990/0227 | close(c); incref(f); | |
| 1991/0828 |
| |
| 1991/1219 | unlock(&srvlk); | |
| 1991/0828 | poperror(); | |
| 1990/0227 | return f; } | |
| 1991/1127/sys/src/9/port/devsrv.c:97,124 – 1991/1219/sys/src/9/port/devsrv.c:104,138 | ||
| 1990/0227 | srvcreate(Chan *c, char *name, int omode, ulong perm) { | |
| 1991/0828 | int j, i; | |
| 1991/1219 | Srv *sp; | |
| 1990/0227 | ||
| 1991/0828 | if(omode != OWRITE) error(Eperm); | |
| 1991/1219 | lock(&srvlk); | |
| 1991/0828 | if(waserror()){ | |
| 1991/1219 | unlock(&srvlk); | |
| 1990/0227 | nexterror(); } | |
| 1991/0828 | j = -1; for(i=0; i<conf.nsrv; i++){ | |
| 1991/1219 | if(srv[i].chan == 0){ | |
| 1991/0828 | if(j == -1) j = i; | |
| 1991/1219 | } else if(strcmp(name, srv[i].name) == 0) | |
| 1990/11211 | error(Einuse); | |
| 1991/0828 | } if(j == -1) error(Enosrv); | |
| 1991/1219 | sp = &srv[j]; sp->chan = c; unlock(&srvlk); | |
| 1990/1002 | poperror(); | |
| 1991/0828 |
| |
| 1991/1219 | strncpy(sp->name, name, NAMELEN); strncpy(sp->owner, u->p->user, NAMELEN); sp->perm = perm&0777; | |
| 1991/0828 | c->qid.path = j; | |
| 1990/0227 | c->flag |= COPEN; | |
| 1991/0828 | c->mode = OWRITE; | |
| 1991/1127/sys/src/9/port/devsrv.c:131,148 – 1991/1219/sys/src/9/port/devsrv.c:145,163 | ||
| 1990/0227 | ||
| 1991/0828 | if(c->qid.path == CHDIR) | |
| 1990/11211 | error(Eperm); | |
| 1991/0828 |
| |
| 1991/1219 | lock(&srvlk); | |
| 1990/1110 | if(waserror()){ | |
| 1991/0828 |
| |
| 1991/1219 | unlock(&srvlk); | |
| 1990/0227 | nexterror(); } | |
| 1991/0828 |
| |
| 1991/1219 | f = srv[c->qid.path].chan; | |
| 1991/0828 | if(f == 0) error(Eshutdown); | |
| 1991/1219 | if(strcmp(srv[c->qid.path].name, "boot") == 0) | |
| 1991/0828 | error(Eperm); | |
| 1991/1219 | srv[c->qid.path].chan = 0; unlock(&srvlk); | |
| 1990/0227 | poperror(); | |
| 1991/0828 | close(f); | |
| 1990/0227 | } | |
| 1991/1127/sys/src/9/port/devsrv.c:175,181 – 1991/1219/sys/src/9/port/devsrv.c:190,196 | ||
| 1990/0227 | char buf[32]; | |
| 1991/0828 | i = c->qid.path; | |
| 1991/1219 | if(srv[i].chan != c) /* already been written to */ | |
| 1990/11211 | error(Egreg); | |
| 1990/1110 | if(n >= sizeof buf) | |
| 1990/11211 | error(Egreg); | |
| 1991/1127/sys/src/9/port/devsrv.c:185,192 – 1991/1219/sys/src/9/port/devsrv.c:200,207 | ||
| 1991/1127 | f = u->p->fgrp; lock(f); | |
| 1991/1011 | fdtochan(fd, -1, 0); /* error check only */ | |
| 1991/1127 |
| |
| 1991/0921 |
| |
| 1991/1219 | srv[i].chan = f->fd[fd]; incref(srv[i].chan); | |
| 1991/1127 | unlock(f); | |
| 1990/0227 | return n; } | |