changelog shortlog tags branches changeset file revisions annotate raw help

Mercurial > hg > plan9front / sys/src/9/bcm64/devgen.c

revision 7199: ba62683c0e2d
     1.1new file mode 100644
     1.2--- /dev/null
     1.3+++ b/sys/src/9/bcm64/devgen.c
     1.4@@ -0,0 +1,34 @@
     1.5+#include	"u.h"
     1.6+#include	"../port/lib.h"
     1.7+#include	"mem.h"
     1.8+#include	"dat.h"
     1.9+#include	"fns.h"
    1.10+#include	"../port/error.h"
    1.11+
    1.12+/*
    1.13+ * the zeroth element of the table MUST be the directory itself for ..
    1.14+*/
    1.15+int
    1.16+devgen(Chan *c, char *name, Dirtab *tab, int ntab, int i, Dir *dp)
    1.17+{
    1.18+	if(tab == 0)
    1.19+		return -1;
    1.20+	if(i == DEVDOTDOT){
    1.21+		/* nothing */
    1.22+	}else if(name){
    1.23+		for(i=1; i<ntab; i++)
    1.24+			if(strcmp(tab[i].name, name) == 0)
    1.25+				break;
    1.26+		if(i==ntab)
    1.27+			return -1;
    1.28+		tab += i;
    1.29+	}else{
    1.30+		/* skip over the first element, that for . itself */
    1.31+		i++;
    1.32+		if(i >= ntab)
    1.33+			return -1;
    1.34+		tab += i;
    1.35+	}
    1.36+	devdir(c, tab->qid, tab->name, tab->length, eve, tab->perm, dp);
    1.37+	return 1;
    1.38+}