8 static Ndb* doopen(char*);
9 static void hffree(Ndb*);
11 static char *deffile = "/lib/ndb/local";
14 * the database entry in 'file' indicates the list of files
15 * that makeup the database. Open each one and search in
21 Ndb *db, *first, *last;
31 t = ndbsearch(db, &s, "database", "");
35 for(nt = t; nt; nt = nt->entry){
36 if(strcmp(nt->attr, "file") != 0)
38 if(strcmp(nt->val, file) == 0){
39 /* default file can be reordered in the list */
42 if(strcmp(first->file, file) == 0){
69 db = (Ndb*)malloc(sizeof(Ndb));
72 memset(db, 0, sizeof(Ndb));
73 strncpy(db->file, file, sizeof(db->file)-1);
75 if(ndbreopen(db) < 0){
84 * dump any cached information, forget the hash tables, and reopen a single file
92 /* forget what we know about the open files */
96 close(Bfildes(&db->b));
101 /* try the open again */
102 fd = open(db->file, OREAD);
111 /* no hashfile for /net/ndb (avoids deadlock in cs) */
116 db->mtime = d->mtime;
117 db->length = d->length;
118 Binits(&db->b, fd, OREAD, db->buf, sizeof(db->buf));
124 * close the database files
131 for(; db; db = nextdb){
135 close(Bfildes(&db->b));
142 * free the hash files belonging to a db
149 for(hf = db->hf; hf; hf = next){
158 * return true if any part of the database has changed
166 for(ndb = db; ndb != nil; ndb = ndb->next){
167 d = dirfstat(Bfildes(&ndb->b));
170 if(ndb->qid.path != d->qid.path
171 || ndb->qid.vers != d->qid.vers){