The determination of the CellServDB pathname is platform-dependent.
However, error reporting in the current code base assumes the CellServDB
location is platform-independent.
Add the pathname of the CellServDB file to the configuration directory
structure and set the new cellservDB member when opening the
configuration. Use this value when checking if the CellServDB has
changed and update the callers to use the cellservDB member when
reporting errors about the CellServDB file.
Change-Id: I5a3393fb9d4ae3c637d5a0d773598115314bfe1c
Reviewed-on: https://gerrit.openafs.org/13408
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
int
_afsconf_UpToDate(struct afsconf_dir *adir)
{
- char *cellservDB;
struct stat tstat;
int code;
time_t now = time(0);
}
adir->timeCheck = now;
- _afsconf_CellServDBPath(adir, &cellservDB);
- if (cellservDB == NULL)
+ if (adir->cellservDB == NULL)
return 0;
- code = stat(cellservDB, &tstat);
- free(cellservDB);
+ code = stat(adir->cellservDB, &tstat);
if (code < 0)
return 0; /* Can't throw the error, so just say we're not up to date */
int
_afsconf_Touch(struct afsconf_dir *adir)
{
- char *cellservDB;
int code;
#ifndef AFS_NT40_ENV
struct timeval tvp[2];
adir->timeRead = 0; /* just in case */
adir->timeCheck = 0;
- _afsconf_CellServDBPath(adir, &cellservDB);
- if (cellservDB == NULL)
+ if (adir->cellservDB == NULL)
return ENOMEM;
#ifdef AFS_NT40_ENV
- code = _utime(cellservDB, NULL);
+ code = _utime(adir->cellservDB, NULL);
#else
gettimeofday(&tvp[0], NULL);
tvp[1] = tvp[0];
- code = utimes(cellservDB, tvp);
+ code = utimes(adir->cellservDB, tvp);
#endif /* AFS_NT40_ENV */
- free(cellservDB);
return code;
}
afs_int32 i;
char tbuffer[256];
struct stat tstat;
- char *cellservDB;
#ifdef AFS_NT40_ENV
cm_enumCellRegistry_t enumCellRegistry = {0, 0};
/* now parse the individual lines */
curEntry = 0;
- _afsconf_CellServDBPath(adir, &cellservDB);
+ _afsconf_CellServDBPath(adir, &adir->cellservDB);
#ifdef AFS_NT40_ENV
if (_afsconf_IsClientConfigDirectory(adir->name))
enumCellRegistry.client = 1;
#endif /* AFS_NT40_ENV */
- if (!stat(cellservDB, &tstat)) {
+ if (!stat(adir->cellservDB, &tstat)) {
adir->timeRead = tstat.st_mtime;
} else {
adir->timeRead = 0;
}
- tf = fopen(cellservDB, "r");
+ tf = fopen(adir->cellservDB, "r");
if (!tf) {
return -1;
}
*bp = '\0';
fprintf(stderr,
"Can't properly parse host line \"%s\" in configuration file %s\n",
- tbuffer, cellservDB);
+ tbuffer, adir->cellservDB);
}
free(curEntry);
fclose(tf);
} else {
fprintf(stderr,
"Too many hosts for cell %s in configuration file %s\n",
- curEntry->cellInfo.name, cellservDB);
+ curEntry->cellInfo.name, adir->cellservDB);
}
}
}
fclose(tf); /* close the file now */
- free(cellservDB);
/* end the last partially-completed cell */
if (curEntry) {
/* free everything we can find */
if (adir->cellName)
free(adir->cellName);
+ if (adir->cellservDB)
+ free(adir->cellservDB);
for (td = adir->entries; td; td = nd) {
nd = td->next;
if (td->cellInfo.linkedCell)
struct afsconf_dir {
char *name; /* pointer to dir prefix */
char *cellName; /* cell name, if any, we're in */
+ char *cellservDB; /* pathname of the CellServDB file */
struct afsconf_entry *entries; /* list of cell entries */
struct opr_queue keyList; /* list of keys */
afs_int32 timeRead; /* time stamp of file last read */
}
/* write CellServDB */
- strcompose(tbuffer, 1024, apath, "/", AFSDIR_CELLSERVDB_FILE, (char *)NULL);
- tf = fopen(tbuffer, "w");
+ tf = fopen(adir->cellservDB, "w");
if (!tf) {
UNLOCK_GLOBAL_MUTEX;
return AFSCONF_NOTFOUND;
code = afsconf_GetCellInfo(acdir, cellName, AFSCONF_VLDBSERVICE, &info);
if (code) {
- afs_com_err(whoami, code, "; Can't find cell %s's hosts in %s/%s",
- cellName, confdir, AFSDIR_CELLSERVDB_FILE);
+ afs_com_err(whoami, code, "; Can't find cell %s's hosts in %s",
+ cellName, acdir->cellservDB);
ERROR(BC_NOCELLCONFIG);
}
code = afsconf_GetCellInfo(acdir, cellName, 0, &info);
if (code) {
- afs_com_err(whoami, code, "; Can't find cell %s's hosts in %s/%s",
- cellName, confdir, AFSDIR_CELLSERVDB_FILE);
+ afs_com_err(whoami, code, "; Can't find cell %s's hosts in %s",
+ cellName, acdir->cellservDB);
ERROR(BC_NOCELLCONFIG);
}
code = afsconf_GetCellInfo(tdir, cell, "afsprot", &info);
if (code) {
- fprintf(stderr, "libprot: Could not locate cell %s in %s/%s\n",
- cell, confDir, AFSDIR_CELLSERVDB_FILE);
+ fprintf(stderr, "libprot: Could not locate cell %s in %s\n",
+ cell, tdir->cellservDB);
return code;
}
}
code = afsconf_GetCellInfo(dir, cellName, serviceid, &info);
if (code) {
- fprintf(stderr, "%s: can't find cell %s's hosts in %s/%s\n",
- progname?progname:"<unknown>", cellName, confDir,
- AFSDIR_CELLSERVDB_FILE);
+ fprintf(stderr, "%s: can't find cell %s's hosts in %s\n",
+ progname?progname:"<unknown>", cellName, dir->cellservDB);
afsconf_Close(dir);
return code;
}
code = afsconf_GetCellInfo(tdir, cellstr, "afsprot", &info);
if (code) {
- ViceLog(0, ("hpr_Initialize: Could not locate cell %s in %s/%s\n",
- cellstr, tdir->name, AFSDIR_CELLSERVDB_FILE));
+ ViceLog(0, ("hpr_Initialize: Could not locate cell %s in %s\n",
+ cellstr, tdir->cellservDB));
afsconf_Close(tdir);
return code;
}