A new field has been added to Ndb to mark the file as open. Reference: /n/patches.lsub.org/patch/ndbreopen Date: Mon Jul 2 18:34:10 CES 2012 Signed-off-by: esoriano@lsub.org --- /sys/src/libndb/ndbopen.c Thu Apr 12 12:26:24 2012 +++ /sys/src/libndb/ndbopen.c Mon Jul 2 17:58:33 2012 @@ -90,12 +90,13 @@ Dir *d; /* forget what we know about the open files */ - if(db->mtime){ + if(db->isopen){ _ndbcacheflush(db); hffree(db); close(Bfildes(&db->b)); Bterm(&db->b); db->mtime = 0; + db->isopen = 0; } /* try the open again */ @@ -111,6 +112,7 @@ db->qid = d->qid; db->mtime = d->mtime; db->length = d->length; + db->isopen = 1; Binits(&db->b, fd, OREAD, db->buf, sizeof(db->buf)); free(d); return 0; --- /sys/include/ndb.h Thu Apr 12 12:24:41 2012 +++ /sys/include/ndb.h Mon Jul 2 17:26:25 2012 @@ -33,6 +33,7 @@ Qid qid; /* qid of db file */ char file[128];/* path name of db file */ ulong length; /* length of db file */ + int isopen; /* true if the file is open */ int nohash; /* don't look for hash files */ Ndbhf *hf; /* open hash files */