/* * dump any cached information, forget the hash tables, and reopen a single file */ int ndbreopen(struct ndb *db) { int fd; struct dir *d; /* forget what we know about the open files */ if(db->isopen){ _ndbcacheflush(db); hffree(db); fclose(db->b); db->mtime = 0; db->isopen = 0; } /* try the open again */ db->b = fopen(db->file, "r"); if(! db->b) return -1; #if 0 d = dirfstat(fd); if(d == NULL){ close(fd); return -1; } db->qid = d->qid; db->mtime = d->mtime; db->length = d->length; free(d); #endif db->isopen = 1; return 0; }
/* * close the database files */ void ndbclose(struct ndb *db) { struct ndb *nextdb; for(; db; db = nextdb){ nextdb = db->next; _ndbcacheflush(db); hffree(db); fclose(db->b); free(db); } }
/* * close the database files */ void ndbclose(Ndb *db) { Ndb *nextdb; for(; db; db = nextdb){ nextdb = db->next; _ndbcacheflush(db); hffree(db); close(Bfildes(&db->b)); Bterm(&db->b); free(db); } }
/* * dump any cached information, forget the hash tables, and reopen a single file */ int ndbreopen(struct ndb *db) { int fd; struct dir *d; /* forget what we know about the open files */ if(db->isopen){ _ndbcacheflush(db); hffree(db); fclose(db->b); db->mtime = 0; db->isopen = 0; } /* try the open again */ db->b = fopen(db->file, "r"); if(! db->b) { return -1; } #if 0 d = dirfstat(fd); if(d == NULL){ close(fd); return -1; } db->qid.path = d->qid.path; db->mtime = d->mtime; db->length = d->length; free(d); #else struct stat s; /* we opened it, this WILL work */ stat(db->file, &s); db->qid.path = s.st_ino; db->mtime = s.st_mtime + 1; db->length = s.st_size; #endif db->isopen = 1; return 0; }
/* * dump any cached information, forget the hash tables, and reopen a single file */ int ndbreopen(Ndb *db) { int fd; Dir *d; /* forget what we know about the open files */ if(db->mtime){ _ndbcacheflush(db); hffree(db); close(Bfildes(&db->b)); Bterm(&db->b); db->mtime = 0; } /* try the open again */ fd = open(db->file, OREAD); if(fd < 0) return -1; d = dirfstat(fd); if(d == nil){ close(fd); return -1; } /* no hashfile for /net/ndb (avoids deadlock in cs) */ if(d->type == 'I') db->nohash = 1; db->qid = d->qid; db->mtime = d->mtime; db->length = d->length; Binits(&db->b, fd, OREAD, db->buf, sizeof(db->buf)); free(d); return 0; }