This is an automated email from the ASF dual-hosted git repository.
dragon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 6d5d870 Add infodir back to Layout and clean up some code
6d5d870 is described below
commit 6d5d870399ed772c47f5683b10533c306dc298b4
Author: Xavier Chi <[email protected]>
AuthorDate: Thu Jun 7 13:53:55 2018 -0500
Add infodir back to Layout and clean up some code
Although infodir is not used, it is better to add it back to keep the
consistency and at least have it stored somewhere to use.
---
cmd/traffic_layout/engine.cc | 11 ++++++-----
cmd/traffic_layout/engine.h | 2 +-
lib/ts/I_Layout.h | 1 +
lib/ts/Layout.cc | 4 +++-
lib/ts/runroot.cc | 12 ++++++------
lib/ts/runroot.h | 6 ++++--
6 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/cmd/traffic_layout/engine.cc b/cmd/traffic_layout/engine.cc
index 6d42a35..6055ac8 100644
--- a/cmd/traffic_layout/engine.cc
+++ b/cmd/traffic_layout/engine.cc
@@ -433,6 +433,7 @@ RunrootEngine::copy_runroot(const std::string
&original_root, const std::string
original_map["runtimedir"] = TS_BUILD_RUNTIMEDIR;
original_map["logdir"] = TS_BUILD_LOGDIR;
original_map["mandir"] = TS_BUILD_MANDIR;
+ original_map["infodir"] = TS_BUILD_INFODIR;
original_map["cachedir"] = TS_BUILD_CACHEDIR;
// copy each directory to the runroot path
@@ -455,8 +456,8 @@ RunrootEngine::copy_runroot(const std::string
&original_root, const std::string
path_map[it.first] = Layout::relative_to(".", join_path);
}
- // don't copy the prefix, mandir and localstatedir
- if (it.first != "exec_prefix" && it.first != "localstatedir" && it.first
!= "mandir") {
+ // don't copy the prefix, mandir, localstatedir and infodir
+ if (it.first != "exec_prefix" && it.first != "localstatedir" && it.first
!= "mandir" && it.first != "infodir") {
if (!copy_directory(old_path, new_path, it.first)) {
ink_warning("Unable to copy '%s' - %s", it.first.c_str(),
strerror(errno));
ink_notice("Creating '%s': %s", it.first.c_str(), new_path.c_str());
@@ -574,7 +575,7 @@ fix_runroot(RunrootMapType &path_map, RunrootMapType
&permission_map, RunrootMap
}
std::cout << "Read permission fixed for '" + name + "': " + path <<
std::endl;
}
- if (name == "localstatedir" || name == "logdir" || name == "runtimedir" ||
name == "cachedir") {
+ if (name == "logdir" || name == "runtimedir" || name == "cachedir") {
// write
if (permission[1] != '1') {
if (chmod(path.c_str(), stat_buffer.st_mode | read_permission |
write_permission) < 0) {
@@ -697,11 +698,11 @@ RunrootEngine::verify_runroot()
std::cout << name << ": \x1b[1m" + path_map[name] + "\x1b[0m" << std::endl;
// output read permission
- if (name == "includedir" || name == "sysconfdir" || name == "datadir") {
+ if (name == "localstatedir" || name == "includedir" || name ==
"sysconfdir" || name == "datadir") {
output_read_permission(permission);
}
// output write permission
- if (name == "localstatedir" || name == "logdir" || name == "runtimedir" ||
name == "cachedir") {
+ if (name == "logdir" || name == "runtimedir" || name == "cachedir") {
output_read_permission(permission);
output_write_permission(permission);
}
diff --git a/cmd/traffic_layout/engine.h b/cmd/traffic_layout/engine.h
index 241ba59..7144ac4 100644
--- a/cmd/traffic_layout/engine.h
+++ b/cmd/traffic_layout/engine.h
@@ -80,5 +80,5 @@ struct RunrootEngine {
"runtimedir", "logdir",
"cachedir"};
// map for yaml file emit
- std::unordered_map<std::string, std::string> path_map;
+ RunrootMapType path_map;
};
diff --git a/lib/ts/I_Layout.h b/lib/ts/I_Layout.h
index cf6d7f5..e35dd95 100644
--- a/lib/ts/I_Layout.h
+++ b/lib/ts/I_Layout.h
@@ -95,5 +95,6 @@ struct Layout {
std::string runtimedir;
std::string logdir;
std::string mandir;
+ std::string infodir;
std::string cachedir;
};
diff --git a/lib/ts/Layout.cc b/lib/ts/Layout.cc
index c34280a..4042e39 100644
--- a/lib/ts/Layout.cc
+++ b/lib/ts/Layout.cc
@@ -118,7 +118,7 @@ Layout::Layout(std::string_view const _prefix)
} else {
std::string path;
int len;
- std::unordered_map<std::string, std::string> dir_map = check_runroot();
+ RunrootMapType dir_map = check_runroot();
if (dir_map.size() != 0) {
prefix = dir_map["prefix"];
exec_prefix = dir_map["exec_prefix"];
@@ -133,6 +133,7 @@ Layout::Layout(std::string_view const _prefix)
runtimedir = dir_map["runtimedir"];
logdir = dir_map["logdir"];
mandir = dir_map["mandir"];
+ infodir = dir_map["infodir"];
cachedir = dir_map["cachedir"];
return;
}
@@ -164,6 +165,7 @@ Layout::Layout(std::string_view const _prefix)
runtimedir = layout_relative(prefix, TS_BUILD_RUNTIMEDIR);
logdir = layout_relative(prefix, TS_BUILD_LOGDIR);
mandir = layout_relative(prefix, TS_BUILD_MANDIR);
+ infodir = layout_relative(prefix, TS_BUILD_INFODIR);
cachedir = layout_relative(prefix, TS_BUILD_CACHEDIR);
}
diff --git a/lib/ts/runroot.cc b/lib/ts/runroot.cc
index ac85cd6..23e103a 100644
--- a/lib/ts/runroot.cc
+++ b/lib/ts/runroot.cc
@@ -33,7 +33,7 @@ Example: ./traffic_server --run-root=/path/to/sandbox
Need a yaml file in the sandbox with key value pairs of all directory
locations for other programs to use
Directories needed in the yaml file:
-prefix, exec_prefix, includedir, localstatedir, bindir, logdir, mandir,
sbindir, sysconfdir,
+prefix, exec_prefix, includedir, localstatedir, bindir, logdir, sbindir,
sysconfdir,
datadir, libexecdir, libdir, runtimedir, cachedir.
*/
@@ -207,7 +207,7 @@ runroot_map_default()
}
// return a map of all path in runroot_path.yml
-std::unordered_map<std::string, std::string>
+RunrootMapType
runroot_map(const std::string &prefix)
{
std::string yaml_path = Layout::relative_to(prefix, "runroot_path.yml");
@@ -215,11 +215,11 @@ runroot_map(const std::string &prefix)
file.open(yaml_path);
if (!file.good()) {
ink_warning("Bad path '%s', continue with default value", prefix.c_str());
- return std::unordered_map<std::string, std::string>{};
+ return RunrootMapType{};
}
std::ifstream yamlfile(yaml_path);
- std::unordered_map<std::string, std::string> map;
+ RunrootMapType map;
std::string str;
while (std::getline(yamlfile, str)) {
int pos = str.find(':');
@@ -238,11 +238,11 @@ runroot_map(const std::string &prefix)
// check for the using of runroot
// a map of all path will be returned
// if we do not use runroot, a empty map will be returned.
-std::unordered_map<std::string, std::string>
+RunrootMapType
check_runroot()
{
if (using_runroot.empty()) {
- return std::unordered_map<std::string, std::string>{};
+ return RunrootMapType{};
}
int len = using_runroot.size();
diff --git a/lib/ts/runroot.h b/lib/ts/runroot.h
index be3852a..96ba791 100644
--- a/lib/ts/runroot.h
+++ b/lib/ts/runroot.h
@@ -29,6 +29,8 @@
#include <string>
#include <unordered_map>
+typedef std::unordered_map<std::string, std::string> RunrootMapType;
+
std::string check_path(const std::string &path);
std::string check_parent_path(const std::string &path);
@@ -38,7 +40,7 @@ void runroot_handler(const char **argv, bool json = false);
// get a map from default layout
std::unordered_map<std::string, std::string> runroot_map_default();
// get runroot map from yaml path and prefix
-std::unordered_map<std::string, std::string> runroot_map(const std::string
&prefix);
+RunrootMapType runroot_map(const std::string &prefix);
// help check runroot for layout
-std::unordered_map<std::string, std::string> check_runroot();
+RunrootMapType check_runroot();
--
To stop receiving notification emails like this one, please contact
[email protected].