diff -r -u arla-0.35.4pre8-dist/arlad/dynroot.c arla-0.35.4pre8/arlad/dynroot.c --- arla-0.35.4pre8-dist/arlad/dynroot.c Mon May 28 17:19:20 2001 +++ arla-0.35.4pre8/arlad/dynroot.c Tue Jun 12 16:20:24 2001 @@ -53,7 +53,6 @@ static int32_t dynrootcell = 0; /* this is the dynroocell */ static Bool dynroot_enable = 0; /* is dynroot enabled ? */ -static unsigned long last_celldb_version = 0; /* last version of celldb */ /* * Magic glue wrt afsvnode# @@ -97,6 +96,32 @@ } /* + * Create an entry for a new cell in the root dynamically + * on the fly + */ + +int +dynroot_create_entry_dynamically (const char *cellname, FCacheEntry *cacheentry) +{ + cell_entry *cellentry; + AFSFid newfid; + int ret; + + if ((cellentry = cell_add_dynroot(cellname)) == NULL) + return -1; + + newfid = cacheentry->fid.fid; + newfid.Vnode = cellnum2afs (cellentry->id); + + ret = adir_creat (cacheentry, cellentry->name, newfid); + if (ret) + return ret; + break_callback(cacheentry); + + return 0; +} + +/* * create the dynroot root directory in `fbuf', return number * of entries in `len'. */ @@ -256,12 +281,16 @@ int ret, fd, rootnode; size_t len; fbuf dir; + static unsigned long last_celldb_version = 0; /* last version of celldb */ + unsigned long l; rootnode = entry->fid.fid.Vnode == DYNROOT_ROOTDIR ? 1 : 0; + l = last_celldb_version; + last_celldb_version = cell_get_version(); if (entry->flags.attrp && entry->flags.datap && - (!rootnode || last_celldb_version == cell_get_version())) + (!rootnode || last_celldb_version == l)) return 0; fd = fcache_open_file (entry, O_RDWR); @@ -341,6 +370,24 @@ if (dynroot_enable && entry->fid.Cell == dynrootcell && entry->fid.fid.Volume == DYNROOT_ROOTVOLUME) + return TRUE; + + return FALSE; +} + +/* + * returns TRUE if `entry' is _the_ top dynroot entry (/afs) + */ + +Bool +dynroot_is_top_dynrootp (FCacheEntry *entry) +{ + assert (entry); + + if (dynroot_enable && + entry->fid.Cell == dynrootcell && + entry->fid.fid.Volume == DYNROOT_ROOTVOLUME && + entry->fid.fid.Vnode == DYNROOT_ROOTDIR) return TRUE; return FALSE; diff -r -u arla-0.35.4pre8-dist/arlad/dynroot.h arla-0.35.4pre8/arlad/dynroot.h --- arla-0.35.4pre8-dist/arlad/dynroot.h Mon May 28 17:19:20 2001 +++ arla-0.35.4pre8/arlad/dynroot.h Sun Jun 10 17:43:20 2001 @@ -37,6 +37,8 @@ #define DYNROOT_DEFAULT 0 +int dynroot_create_entry_dynamically (const char *cellname, FCacheEntry *cacheentry); + int dynroot_fetch_vldbN (nvldbentry *entry); Bool dynroot_isvolumep (int cell, const char *volume); @@ -47,6 +49,8 @@ Bool dynroot_is_dynrootp (FCacheEntry *entry); +Bool dynroot_is_top_dynrootp (FCacheEntry *entry); + Bool dynroot_enablep (void); Bool dynroot_setenable (Bool enable); @@ -54,3 +58,4 @@ int32_t dynroot_cellid (void); int32_t dynroot_volumeid (void); + diff -r -u arla-0.35.4pre8-dist/arlad/inter.c arla-0.35.4pre8/arlad/inter.c --- arla-0.35.4pre8-dist/arlad/inter.c Tue Jun 5 03:27:05 2001 +++ arla-0.35.4pre8/arlad/inter.c Sun Jun 10 17:42:59 2001 @@ -599,6 +599,12 @@ } error = adir_lookup (entry, name, res); + if (error && dynroot_is_top_dynrootp (entry)) { + arla_warnx(ADEBCM, "cm_lookup(): Creating dynamic entry for %s", name); + error = dynroot_create_entry_dynamically(name, entry); + if (!error) + error = adir_lookup (entry, name, res); + } if (error) { fcache_release(entry); ret.res = -1; diff -r -u arla-0.35.4pre8-dist/arlad/volcache.c arla-0.35.4pre8/arlad/volcache.c --- arla-0.35.4pre8-dist/arlad/volcache.c Sun Mar 4 06:11:19 2001 +++ arla-0.35.4pre8/arlad/volcache.c Tue Jun 12 17:15:42 2001 @@ -588,7 +588,11 @@ "Cannot find any db servers in cell %d(%s) while " "getting data for volume `%s'", cell, cell_num2name(cell), name); - assert (cell_is_sanep (cell)); + /* haba: cellnums cached in xfs */ + /* Instead of asserting on cell existence, try to recycle */ + /* the entry and let that code assert if that is not possible */ + recycle_entry(e); + /* assert (cell_is_sanep (cell)); */ return ENOENT; } diff -r -u arla-0.35.4pre8-dist/lib/ko/ko.h arla-0.35.4pre8/lib/ko/ko.h --- arla-0.35.4pre8-dist/lib/ko/ko.h Mon May 7 00:40:49 2001 +++ arla-0.35.4pre8/lib/ko/ko.h Tue Jun 12 14:40:44 2001 @@ -96,6 +96,7 @@ cell_entry *cell_get_by_id (int32_t cell); cell_entry *cell_new (const char *name); cell_entry *cell_new_dynamic (const char *name); +cell_entry *cell_add_dynroot(const char *cellname); Bool cell_dynroot (const cell_entry *c); Bool cell_issuid (const cell_entry *c); Bool cell_issuid_by_num (int32_t cell); diff -r -u arla-0.35.4pre8-dist/lib/ko/kocell.c arla-0.35.4pre8/lib/ko/kocell.c --- arla-0.35.4pre8-dist/lib/ko/kocell.c Mon May 7 00:40:50 2001 +++ arla-0.35.4pre8/lib/ko/kocell.c Tue Jun 12 14:41:41 2001 @@ -418,6 +418,7 @@ hashtabadd (cellnumhtab, c); c->timeout = 0; celldb_version++; + log_log (cell_log, CDEBERR, "Inserted cell %s with id %d", name, c->id); return c; } @@ -432,6 +433,9 @@ FILE *f; c = cell_new (name); + + return c; /* haba does not believe in changing CellServDB on the fly */ + if (c == NULL) return NULL; c->expl = "dynamically added cell"; @@ -649,14 +653,24 @@ { return parse_simple_file (filename, addsuidcell); } - /* - * + * Just as cell_add_dynroot but ignores return */ static void add_dynroot(const char *cellname) { + cell_add_dynroot(cellname); +} + +/* + * Adds cell to cell cache and sets its dynroot flag. + * returns NULL on error, otherwise cell_entry struct. + */ + +cell_entry * +cell_add_dynroot(const char *cellname) +{ cell_entry *e; e = cell_get_by_name (cellname); @@ -667,6 +681,7 @@ e->flags |= DYNROOT_CELL; dynrootdb_in_use = 1; } + return e; } static int