]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/bcm64/devgen.c
bcm64: use exclusive monitor on nrdy to wake up idlehands()
[plan9front.git] / sys / src / 9 / bcm64 / devgen.c
1 #include        "u.h"
2 #include        "../port/lib.h"
3 #include        "mem.h"
4 #include        "dat.h"
5 #include        "fns.h"
6 #include        "../port/error.h"
7
8 /*
9  * the zeroth element of the table MUST be the directory itself for ..
10 */
11 int
12 devgen(Chan *c, char *name, Dirtab *tab, int ntab, int i, Dir *dp)
13 {
14         if(tab == 0)
15                 return -1;
16         if(i == DEVDOTDOT){
17                 /* nothing */
18         }else if(name){
19                 for(i=1; i<ntab; i++)
20                         if(strcmp(tab[i].name, name) == 0)
21                                 break;
22                 if(i==ntab)
23                         return -1;
24                 tab += i;
25         }else{
26                 /* skip over the first element, that for . itself */
27                 i++;
28                 if(i >= ntab)
29                         return -1;
30                 tab += i;
31         }
32         devdir(c, tab->qid, tab->name, tab->length, eve, tab->perm, dp);
33         return 1;
34 }