| plan 9 kernel history: overview | file list | diff list |
1993/0501/port/dev.c (diff list | history)
| 1993/0330/sys/src/9/port/dev.c:65,75 – 1993/0501/sys/src/9/port/dev.c:65,80 (short | long | prev | next) | ||
|
Convert to Brazil: add Path, up, format edits.
Directory mode back to 0700.
rsc Fri Mar 4 12:44:25 2005 | ||
| 1990/0227 | devattach(int tc, char *spec) { Chan *c; | |
| 1993/0501 | char buf[NAMELEN+4]; | |
| 1990/0227 | ||
| 1992/0711 | USED(spec); | |
| 1990/0227 | c = newchan(); | |
| 1990/11211 | c->qid = (Qid){CHDIR, 0}; | |
| 1990/0227 | c->type = devno(tc, 0); | |
| 1993/0501 | if(tc != 'M') { sprint(buf, "#%C%s", tc, spec); c->path = ptenter(&syspt, 0, buf); } | |
| 1990/0227 | return c; } | |
| 1993/0330/sys/src/9/port/dev.c:78,85 – 1993/0501/sys/src/9/port/dev.c:83,92 | ||
| 1990/0227 | { | |
| 1990/0329 | if(c->flag & COPEN) | |
| 1992/1217 | panic("clone of open file type %C\n", devchar[c->type]); | |
| 1993/0501 | ||
| 1990/0227 | if(nc == 0) nc = newchan(); | |
| 1993/0501 | ||
| 1990/0227 | nc->type = c->type; | |
| 1991/0421 | nc->dev = c->dev; | |
| 1990/0227 | nc->mode = c->mode; | |
| 1993/0330/sys/src/9/port/dev.c:91,96 – 1993/0501/sys/src/9/port/dev.c:98,105 | ||
| 1991/0421 | nc->aux = c->aux; | |
| 1990/0303 | nc->mchan = c->mchan; nc->mqid = c->mqid; | |
| 1993/0501 | nc->path = c->path; incref(nc->path); | |
| 1990/0227 | return nc; } | |
| 1993/0330/sys/src/9/port/dev.c:99,112 – 1993/0501/sys/src/9/port/dev.c:108,122 | ||
| 1990/0227 | { long i; Dir dir; | |
| 1993/0501 | Path *op; | |
| 1990/0227 | isdir(c); if(name[0]=='.' && name[1]==0) return 1; | |
| 1993/0501 | for(i=0;; i++) { | |
| 1990/0227 | switch((*gen)(c, tab, ntab, i, &dir)){ case -1: | |
| 1992/0111 |
| |
| 1993/0501 | strncpy(up->error, Enonexist, NAMELEN); | |
| 1990/0227 | return 0; case 0: continue; | |
| 1993/0330/sys/src/9/port/dev.c:113,123 – 1993/0501/sys/src/9/port/dev.c:123,137 | ||
| 1990/0227 | case 1: if(strcmp(name, dir.name) == 0){ c->qid = dir.qid; | |
| 1993/0501 | op = c->path; c->path = ptenter(&syspt, op, name); decref(op); | |
| 1990/0227 | return 1; } continue; } | |
| 1992/0520 |
| |
| 1993/0501 | } return 0; /* not reached */ | |
| 1991/0411 | } | |
| 1990/0227 | void | |
| 1993/0330/sys/src/9/port/dev.c:129,151 – 1993/0501/sys/src/9/port/dev.c:143,165 | ||
| 1993/0330 | for(i=0;; i++) | |
| 1990/0227 | switch((*gen)(c, tab, ntab, i, &dir)){ case -1: | |
| 1991/1206 |
| |
| 1990/0227 |
| |
| 1993/0501 | /* * given a channel, we cannot derive the directory name * that the channel was generated from since it was lost * by namec. */ | |
| 1990/11211 | if(c->qid.path & CHDIR){ | |
| 1993/0330 |
| |
| 1993/0501 | devdir(c, c->qid, c->path->elem, i*DIRLEN, eve, CHDIR|0700, &dir); | |
| 1990/0227 | convD2M(&dir, db); return; } | |
| 1992/1217 |
| |
| 1993/0330 |
| |
| 1993/0501 | print("%s %s: devstat %C %lux\n", up->text, up->user, devchar[c->type], c->qid.path); | |
| 1991/0626 | error(Enonexist); | |
| 1993/0330 | case 0: break; | |
| 1990/0227 | case 1: | |
| 1993/0330 |
| |
| 1993/0501 | if(eqqid(c->qid, dir.qid)) { | |
| 1993/0323 | if(c->flag&CMSG) dir.mode |= CHMOUNT; | |
| 1990/0227 | convD2M(&dir, db); | |
| 1993/0330/sys/src/9/port/dev.c:162,168 – 1993/0501/sys/src/9/port/dev.c:176,182 | ||
| 1990/0227 | Dir dir; k = c->offset/DIRLEN; | |
| 1990/0821 |
| |
| 1993/0501 | for(m=0; m<n; k++) { | |
| 1990/0227 | switch((*gen)(c, tab, ntab, k, &dir)){ case -1: | |
| 1990/0821 | return m; | |
| 1993/0330/sys/src/9/port/dev.c:177,182 – 1993/0501/sys/src/9/port/dev.c:191,198 | ||
| 1990/0227 | d += DIRLEN; break; } | |
| 1993/0501 | } | |
| 1990/0821 | return m; | |
| 1990/0227 | } | |
| 1993/0330/sys/src/9/port/dev.c:188,194 – 1993/0501/sys/src/9/port/dev.c:204,210 | ||
| 1991/1112 | ulong t, mode; | |
| 1990/0227 | static int access[] = { 0400, 0200, 0600, 0100 }; | |
| 1993/0501 | for(i=0;; i++) { | |
| 1990/0227 | switch((*gen)(c, tab, ntab, i, &dir)){ case -1: goto Return; | |
| 1993/0330/sys/src/9/port/dev.c:196,207 – 1993/0501/sys/src/9/port/dev.c:212,224 | ||
| 1990/0227 | break; case 1: | |
| 1991/1112 | if(eqqid(c->qid, dir.qid)) { | |
| 1993/0501 | if(strcmp(up->user, dir.uid) == 0) | |
| 1991/1112 | mode = dir.mode; | |
| 1991/1206 |
| |
| 1993/0501 | else if(strcmp(up->user, eve) == 0) | |
| 1991/1112 | mode = dir.mode<<3; else | |
| 1993/0501 | mode = dir.mode<<6; | |
| 1991/1112 | t = access[omode&3]; if((t & mode) == t) | |
| 1993/0330/sys/src/9/port/dev.c:210,216 – 1993/0501/sys/src/9/port/dev.c:227,234 | ||
| 1990/0227 | } break; } | |
| 1993/0501 | } Return: | |
| 1990/0227 | c->offset = 0; | |
| 1990/11211 | if((c->qid.path&CHDIR) && omode!=OREAD) error(Eperm); | |