From 3b45a13a74936ed5f0e19a2766072fbd25c27022 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Wed, 27 Jun 2012 10:51:37 +0100 Subject: [PATCH] viced: Make the config directory path global Store the location of the configuration directory in a global variable, rather than hardcoding it in multiple locations in the file. This makes it easier to write unit tests for portions of the fileserver, and is a step towards producing a fileserver that can be run from within the test suite. Change-Id: I0ee1d9bed084472b1e29b9c559a8726f867f91e4 Reviewed-on: http://gerrit.openafs.org/7585 Reviewed-by: Jeffrey Altman Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/viced/host.c | 7 +++++-- src/viced/viced.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/viced/host.c b/src/viced/host.c index 6eadd5b25..87f12b32a 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -61,6 +61,7 @@ extern int LogLevel; extern struct afsconf_dir *confDir; /* config dir object */ extern int lwps; /* the max number of server threads */ extern afsUUID FS_HostUUID; +extern char *FS_configPath; afsUUID nulluuid; int CEs = 0; /* active clients */ @@ -266,9 +267,11 @@ hpr_Initialize(struct ubik_client **uclient) afs_int32 i; char cellstr[64]; - tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH); + tdir = afsconf_Open(FS_configPath); if (!tdir) { - ViceLog(0, ("hpr_Initialize: Could not open configuration directory: %s", AFSDIR_SERVER_ETC_DIRPATH)); + ViceLog(0, + ("hpr_Initialize: Could not open configuration directory: %s", + FS_configPath)); return -1; } diff --git a/src/viced/viced.c b/src/viced/viced.c index 9a406e4fc..982aad2c2 100644 --- a/src/viced/viced.c +++ b/src/viced/viced.c @@ -180,6 +180,7 @@ pthread_key_t viced_uclient_key; #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */ char FS_HostName[128] = "localhost"; +char *FS_configPath = NULL; afs_uint32 FS_HostAddr_NBO; afs_uint32 FS_HostAddr_HBO; afs_uint32 FS_HostAddrs[ADDRSPERSITE], FS_HostAddr_cnt = 0, FS_registered = 0; @@ -1835,10 +1836,12 @@ main(int argc, char *argv[]) exit(1); } #endif - confDir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH); + FS_configPath = strdup(AFSDIR_SERVER_ETC_DIRPATH); + + confDir = afsconf_Open(FS_configPath); if (!confDir) { fprintf(stderr, "Unable to open config directory %s\n", - AFSDIR_SERVER_ETC_DIRPATH); + FS_configPath); exit(-1); } -- 2.39.5