TS-2401: Replace system_root_dir with Layout::prefix
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/fa100cff Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/fa100cff Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/fa100cff Branch: refs/heads/5.0.x Commit: fa100cffa77b33c723ad0236876477a3c054bac1 Parents: bb26f42 Author: James Peach <jpe...@apache.org> Authored: Wed Nov 27 14:50:48 2013 -0800 Committer: James Peach <jpe...@apache.org> Committed: Thu Dec 5 20:33:48 2013 -0800 ---------------------------------------------------------------------- example/app-template/app-template.cc | 8 +++----- iocore/hostdb/HostDB.cc | 2 +- lib/records/I_RecDefs.h | 1 - mgmt/Main.cc | 9 ++++----- proxy/InkAPI.cc | 2 +- proxy/Main.cc | 10 +++++----- proxy/logging/LogStandalone.cc | 1 - 7 files changed, 14 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa100cff/example/app-template/app-template.cc ---------------------------------------------------------------------- diff --git a/example/app-template/app-template.cc b/example/app-template/app-template.cc index d4d63cd..fefff13 100644 --- a/example/app-template/app-template.cc +++ b/example/app-template/app-template.cc @@ -53,7 +53,6 @@ int system_num_of_processors = ink_number_of_processors(); int system_num_of_net_threads = DEFAULT_NUMBER_OF_THREADS; int system_num_of_udp_threads = DEFAULT_NUMBER_OF_UDP_THREADS; -char system_root_dir[PATH_NAME_MAX + 1]; char system_runtime_dir[PATH_NAME_MAX + 1]; char system_config_directory[PATH_NAME_MAX + 1]; char system_log_dir[PATH_NAME_MAX + 1]; @@ -158,17 +157,16 @@ int main(int argc, char * argv[]) } // Get TS directories - ink_strlcpy(system_root_dir, Layout::get()->prefix, sizeof(system_root_dir)); ink_strlcpy(system_config_directory, Layout::get()->sysconfdir, sizeof(system_config_directory)); ink_strlcpy(system_runtime_dir, Layout::get()->runtimedir, sizeof(system_runtime_dir)); ink_strlcpy(system_log_dir, Layout::get()->logdir, sizeof(system_log_dir)); - if (system_root_dir[0] && (chdir(system_root_dir) < 0)) { - fprintf(stderr,"unable to change to root directory \"%s\" [%d '%s']\n", system_root_dir, errno, strerror(errno)); + if (chdir(Layout::get()->prefix) < 0) { + fprintf(stderr,"unable to change to root directory \"%s\" [%d '%s']\n", Layout::get()->prefix, errno, strerror(errno)); fprintf(stderr," please set correct path in env variable TS_ROOT \n"); _exit(1); } else { - printf("[tsapp] using root directory '%s'\n",system_root_dir); + printf("[tsapp] using root directory '%s'\n", Layou::get()->prefix); } // Diags http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa100cff/iocore/hostdb/HostDB.cc ---------------------------------------------------------------------- diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc index 0b114b4..0ffd5bc 100644 --- a/iocore/hostdb/HostDB.cc +++ b/iocore/hostdb/HostDB.cc @@ -391,7 +391,7 @@ HostDBCache::start(int flags) REC_ReadConfigInt32(storage_size, "proxy.config.hostdb.storage_size"); if (storage_path[0] != '/') { - Layout::relative_to(storage_path, PATH_NAME_MAX, system_root_dir, storage_path); + Layout::relative_to(storage_path, PATH_NAME_MAX, Layout::get()->prefix, storage_path); } Debug("hostdb", "Storage path is %s", storage_path); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa100cff/lib/records/I_RecDefs.h ---------------------------------------------------------------------- diff --git a/lib/records/I_RecDefs.h b/lib/records/I_RecDefs.h index 9a22613..4517357 100644 --- a/lib/records/I_RecDefs.h +++ b/lib/records/I_RecDefs.h @@ -177,7 +177,6 @@ typedef int (*RecRawStatSyncCb) (const char *name, RecDataT data_type, RecData * // System Defaults -extern char system_root_dir[PATH_NAME_MAX + 1]; extern char system_runtime_dir[PATH_NAME_MAX + 1]; extern char system_config_directory[PATH_NAME_MAX + 1]; extern char system_log_dir[PATH_NAME_MAX + 1]; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa100cff/mgmt/Main.cc ---------------------------------------------------------------------- diff --git a/mgmt/Main.cc b/mgmt/Main.cc index 59d697a..a48686b 100644 --- a/mgmt/Main.cc +++ b/mgmt/Main.cc @@ -78,7 +78,6 @@ static char action_tags[1024] = ""; static bool proxy_on = true; // TODO: Check if really need those -char system_root_dir[PATH_NAME_MAX + 1]; char system_runtime_dir[PATH_NAME_MAX + 1]; char system_config_directory[PATH_NAME_MAX + 1]; char system_log_dir[PATH_NAME_MAX + 1]; @@ -301,13 +300,14 @@ init_dirs() static void chdir_root() { + const char * prefix = Layout::get()->prefix; - if (system_root_dir[0] && (chdir(system_root_dir) < 0)) { - mgmt_elog(0, "unable to change to root directory \"%s\" [%d '%s']\n", system_root_dir, errno, strerror(errno)); + if (chdir(prefix) < 0) { + mgmt_elog(0, "unable to change to root directory \"%s\" [%d '%s']\n", prefix, errno, strerror(errno)); mgmt_elog(0, " please set correct path in env variable TS_ROOT \n"); exit(1); } else { - mgmt_log("[TrafficManager] using root directory '%s'\n",system_root_dir); + mgmt_log("[TrafficManager] using root directory '%s'\n", prefix); } } @@ -370,7 +370,6 @@ main(int argc, char **argv) { // Before accessing file system initialize Layout engine Layout::create(); - ink_strlcpy(system_root_dir, Layout::get()->prefix, sizeof(system_root_dir)); ink_strlcpy(mgmt_path, Layout::get()->sysconfdir, sizeof(mgmt_path)); // change the directory to the "root" directory http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa100cff/proxy/InkAPI.cc ---------------------------------------------------------------------- diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc index 4b533d7..1b4ce13 100644 --- a/proxy/InkAPI.cc +++ b/proxy/InkAPI.cc @@ -1705,7 +1705,7 @@ TShrtime() const char * TSInstallDirGet(void) { - return system_root_dir; + return Layout::get()->prefix; } const char * http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa100cff/proxy/Main.cc ---------------------------------------------------------------------- diff --git a/proxy/Main.cc b/proxy/Main.cc index 3cdd0f4..3b7e6ae 100644 --- a/proxy/Main.cc +++ b/proxy/Main.cc @@ -144,7 +144,6 @@ char cluster_host[MAXDNAME + 1] = DEFAULT_CLUSTER_HOST; static char command_string[512] = ""; int remote_management_flag = DEFAULT_REMOTE_MANAGEMENT_FLAG; -char system_root_dir[PATH_NAME_MAX + 1]; // Layout->prefix char system_runtime_dir[PATH_NAME_MAX + 1]; // Layout->runtimedir char system_config_directory[PATH_NAME_MAX + 1]; // Layout->sysconfdir char system_log_dir[PATH_NAME_MAX + 1]; // Layout->logdir @@ -1099,13 +1098,15 @@ run_RegressionTest() static void chdir_root() { - if (system_root_dir[0] && (chdir(system_root_dir) < 0)) { + const char * prefix = Layout::get()->prefix; + + if (chdir(prefix) < 0) { fprintf(stderr,"unable to change to root directory \"%s\" [%d '%s']\n", - system_root_dir, errno, strerror(errno)); + prefix, errno, strerror(errno)); fprintf(stderr," please set correct path in env variable TS_ROOT \n"); _exit(1); } else { - printf("[TrafficServer] using root directory '%s'\n", system_root_dir); + printf("[TrafficServer] using root directory '%s'\n", prefix); } } @@ -1291,7 +1292,6 @@ main(int /* argc ATS_UNUSED */, char **argv) // Before accessing file system initialize Layout engine Layout::create(); - ink_strlcpy(system_root_dir, Layout::get()->prefix, sizeof(system_root_dir)); chdir_root(); // change directory to the install root of traffic server. process_args(argument_descriptions, countof(argument_descriptions), argv); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa100cff/proxy/logging/LogStandalone.cc ---------------------------------------------------------------------- diff --git a/proxy/logging/LogStandalone.cc b/proxy/logging/LogStandalone.cc index 014baac..17fd687 100644 --- a/proxy/logging/LogStandalone.cc +++ b/proxy/logging/LogStandalone.cc @@ -56,7 +56,6 @@ int remote_management_flag = 0; int auto_clear_hostdb_flag = 0; char proxy_name[MAXDNAME + 1] = "unknown"; -char system_root_dir[PATH_NAME_MAX + 1] = ""; char system_config_directory[PATH_NAME_MAX + 1] = ""; char system_runtime_dir[PATH_NAME_MAX + 1] = ""; char system_log_dir[PATH_NAME_MAX + 1] = "";