summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Jepp <tom@tomjepp.co.uk>2015-12-16 21:15:39 +0000
committerThomas Jepp <tom@tomjepp.co.uk>2015-12-16 21:15:39 +0000
commitcb788b1cba70caee3b7d1a6716a4074e3acaff0e (patch)
tree079a5b384c86b0b1e9a83a8f104d9fb60f611447 /src
parentae41f9478892be200ecc45e2d831712136aac058 (diff)
downloadvyatta-cfg-cb788b1cba70caee3b7d1a6716a4074e3acaff0e.tar.gz
vyatta-cfg-cb788b1cba70caee3b7d1a6716a4074e3acaff0e.zip
More fixes to cstore-unionfs & cli_shell_api.
Diffstat (limited to 'src')
-rw-r--r--src/cli_shell_api.cpp73
-rw-r--r--src/cstore/unionfs/cstore-unionfs.cpp21
-rw-r--r--src/cstore/unionfs/cstore-unionfs.hpp6
3 files changed, 49 insertions, 51 deletions
diff --git a/src/cli_shell_api.cpp b/src/cli_shell_api.cpp
index 8a38a63..0439ccf 100644
--- a/src/cli_shell_api.cpp
+++ b/src/cli_shell_api.cpp
@@ -641,52 +641,52 @@ static OpT ops[] = {
2, "Must specify command and at least one component", true),
OP(getEditLevelStr, 0, "No argument expected", -1, NULL, true),
- OP(markSessionUnsaved, 0, "No argument expected", -1, NULL, false),
- OP(unmarkSessionUnsaved, 0, "No argument expected", -1, NULL, false),
- OP(sessionUnsaved, 0, "No argument expected", -1, NULL, false),
- OP(sessionChanged, 0, "No argument expected", -1, NULL, false),
+ OP(markSessionUnsaved, 0, "No argument expected", -1, NULL, NULL),
+ OP(unmarkSessionUnsaved, 0, "No argument expected", -1, NULL, NULL),
+ OP(sessionUnsaved, 0, "No argument expected", -1, NULL, NULL),
+ OP(sessionChanged, 0, "No argument expected", -1, NULL, NULL),
- OP(teardownSession, 0, "No argument expected", -1, NULL, false),
- OP(setupSession, 0, "No argument expected", -1, NULL, false),
- OP(inSession, 0, "No argument expected", -1, NULL, false),
+ OP(teardownSession, 0, "No argument expected", -1, NULL, NULL),
+ OP(setupSession, 0, "No argument expected", -1, NULL, NULL),
+ OP(inSession, 0, "No argument expected", -1, NULL, NULL),
- OP(exists, -1, NULL, 1, "Must specify config path", false),
- OP(existsActive, -1, NULL, 1, "Must specify config path", false),
- OP(existsEffective, -1, NULL, 1, "Must specify config path", false),
+ OP(exists, -1, NULL, 1, "Must specify config path", NULL),
+ OP(existsActive, -1, NULL, 1, "Must specify config path", NULL),
+ OP(existsEffective, -1, NULL, 1, "Must specify config path", NULL),
- OP(listNodes, -1, NULL, -1, NULL, false),
- OP(listActiveNodes, -1, NULL, -1, NULL, false),
- OP(listEffectiveNodes, -1, NULL, 1, "Must specify config path", false),
+ OP(listNodes, -1, NULL, -1, NULL, NULL),
+ OP(listActiveNodes, -1, NULL, -1, NULL, NULL),
+ OP(listEffectiveNodes, -1, NULL, 1, "Must specify config path", NULL),
- OP(isMulti, -1, NULL, 1, "Must specify config path", false),
- OP(isTag, -1, NULL, 1, "Must specify config path", false),
- OP(isLeaf, -1, NULL, 1, "Must specify config path", false),
- OP(isValue, -1, NULL, 1, "Must specify config path", false),
- OP(getNodeType, -1, NULL, 1, "Must specify config path", false),
+ OP(isMulti, -1, NULL, 1, "Must specify config path", NULL),
+ OP(isTag, -1, NULL, 1, "Must specify config path", NULL),
+ OP(isLeaf, -1, NULL, 1, "Must specify config path", NULL),
+ OP(isValue, -1, NULL, 1, "Must specify config path", NULL),
+ OP(getNodeType, -1, NULL, 1, "Must specify config path", NULL),
- OP(returnValue, -1, NULL, 1, "Must specify config path", false),
- OP(returnActiveValue, -1, NULL, 1, "Must specify config path", false),
- OP(returnEffectiveValue, -1, NULL, 1, "Must specify config path", false),
+ OP(returnValue, -1, NULL, 1, "Must specify config path", NULL),
+ OP(returnActiveValue, -1, NULL, 1, "Must specify config path", NULL),
+ OP(returnEffectiveValue, -1, NULL, 1, "Must specify config path", NULL),
- OP(returnValues, -1, NULL, 1, "Must specify config path", false),
- OP(returnActiveValues, -1, NULL, 1, "Must specify config path", false),
- OP(returnEffectiveValues, -1, NULL, 1, "Must specify config path", false),
+ OP(returnValues, -1, NULL, 1, "Must specify config path", NULL),
+ OP(returnActiveValues, -1, NULL, 1, "Must specify config path", NULL),
+ OP(returnEffectiveValues, -1, NULL, 1, "Must specify config path", NULL),
- OP(validateTmplPath, -1, NULL, 1, "Must specify config path", false),
- OP(validateTmplValPath, -1, NULL, 1, "Must specify config path", false),
+ OP(validateTmplPath, -1, NULL, 1, "Must specify config path", NULL),
+ OP(validateTmplValPath, -1, NULL, 1, "Must specify config path", NULL),
OP(showCfg, -1, NULL, -1, NULL, true),
OP(showConfig, -1, NULL, -1, NULL, true),
- OP(loadFile, 1, "Must specify config file", -1, NULL, false),
+ OP(loadFile, 1, "Must specify config file", -1, NULL, NULL),
- OP(getPreCommitHookDir, 0, "No argument expected", -1, NULL, false),
- OP(getPostCommitHookDir, 0, "No argument expected", -1, NULL, false),
+ OP(getPreCommitHookDir, 0, "No argument expected", -1, NULL, NULL),
+ OP(getPostCommitHookDir, 0, "No argument expected", -1, NULL, NULL),
- OP(cfExists, -1, NULL, 2, "Must specify config file and path", false),
- OP(cfReturnValue, -1, NULL, 2, "Must specify config file and path", false),
- OP(cfReturnValues, -1, NULL, 2, "Must specify config file and path", false),
+ OP(cfExists, -1, NULL, 2, "Must specify config file and path", NULL),
+ OP(cfReturnValue, -1, NULL, 2, "Must specify config file and path", NULL),
+ OP(cfReturnValues, -1, NULL, 2, "Must specify config file and path", NULL),
- {NULL, -1, NULL, -1, NULL, false, NULL}
+ {NULL, -1, NULL, -1, NULL, NULL, NULL}
};
#define OP_exact_args ops[op_idx].op_exact_args
#define OP_min_args ops[op_idx].op_min_args
@@ -716,12 +716,6 @@ struct option options[] = {
int
main(int argc, char **argv)
{
- fprintf(stderr, "DEBUG %s", argv[0]);
- for (int i = 1; i < argc; i++) {
- fprintf(stderr, " '%s'", argv[i]); // DEBUG
- }
- fprintf(stderr, "\n"); // DEBUG
-
// handle options first
int c = 0;
while ((c = getopt_long(argc, argv, "", options, NULL)) != -1) {
@@ -774,3 +768,4 @@ main(int argc, char **argv)
exit(0);
}
+
diff --git a/src/cstore/unionfs/cstore-unionfs.cpp b/src/cstore/unionfs/cstore-unionfs.cpp
index 1324d79..858a204 100644
--- a/src/cstore/unionfs/cstore-unionfs.cpp
+++ b/src/cstore/unionfs/cstore-unionfs.cpp
@@ -393,7 +393,7 @@ UnionfsCstore::setupSession()
try {
b_fs::directory_iterator di(work_base.path_cstr());
for (; di != b_fs::directory_iterator(); ++di) {
- old_config = di->path().c_str();
+ old_config = di->path().string().c_str();
if (path_is_directory(old_config)) {
directories.push_back(old_config);
}
@@ -1211,12 +1211,12 @@ UnionfsCstore::unmark_deactivated_descendants()
vector<b_fs::path> markers;
b_fs::recursive_directory_iterator di(get_work_path().path_cstr());
for (; di != b_fs::recursive_directory_iterator(); ++di) {
- if (!path_is_regular(di->path().c_str())
+ if (!path_is_regular(di->path().string().c_str())
|| di->path().filename() != C_MARKER_DEACTIVATE) {
// not marker
continue;
}
- const char *ppath = di->path().parent_path().c_str();
+ const char *ppath = di->path().parent_path().string().c_str();
if (strcmp(ppath, get_work_path().path_cstr()) == 0) {
// don't unmark the node itself
continue;
@@ -1279,7 +1279,7 @@ UnionfsCstore::unmark_changed_with_descendants()
vector<b_fs::path> markers;
b_fs::recursive_directory_iterator di(get_work_path().path_cstr());
for (; di != b_fs::recursive_directory_iterator(); ++di) {
- if (!path_is_regular(di->path().c_str())
+ if (!path_is_regular(di->path().string().c_str())
|| di->path().filename() != C_MARKER_CHANGED) {
// not marker
continue;
@@ -1338,7 +1338,7 @@ UnionfsCstore::discard_changes(unsigned long long& num_removed)
// iterate through all entries in change root
b_fs::directory_iterator di(change_root.path_cstr());
for (; di != b_fs::directory_iterator(); ++di) {
- if (path_is_directory(di->path().c_str())) {
+ if (path_is_directory(di->path().string().c_str())) {
directories.push_back(di->path());
} else {
files.push_back(di->path());
@@ -1471,10 +1471,10 @@ UnionfsCstore::check_dir_entries(const FsPath& root, vector<string> *cnodes,
try {
b_fs::directory_iterator di(root.path_cstr());
for (; di != b_fs::directory_iterator(); ++di) {
- string cname = di->path().filename().c_str();
+ string cname = di->path().filename().string();
if (filter_nodes) {
// must be directory
- if (!path_is_directory(di->path().c_str())) {
+ if (!path_is_directory(di->path().string().c_str())) {
continue;
}
// name cannot start with "."
@@ -1573,14 +1573,14 @@ UnionfsCstore::recursive_copy_dir(const FsPath& src, const FsPath& dst,
b_fs::recursive_directory_iterator di(src_str);
for (; di != b_fs::recursive_directory_iterator(); ++di) {
- const char *oname = di->path().c_str();
+ const char *oname = di->path().string().c_str();
string nname = oname;
nname.replace(0, src_str.length(), dst_str);
if (path_is_directory(oname)) {
b_fs::create_directory(nname);
} else {
if (filter_dot_entries) {
- string of = di->path().filename().c_str();
+ string of = di->path().filename().string();
if (!of.empty() && of.at(0) == '.') {
// filter dot files (with exceptions)
if (of != C_COMMENT_FILE) {
@@ -1688,7 +1688,7 @@ UnionfsCstore::do_umount(const FsPath& mdir)
const char *fusermount_path, *fusermount_prog;
const char *fusermount_umount;
- fusermount_path = "/usr/bin/fusermount";
+ fusermount_path = "/bin/fusermount";
fusermount_prog = "fusermount";
fusermount_umount = "-u";
@@ -1776,3 +1776,4 @@ UnionfsCstore::remove_dir_content(const char *path)
} // end namespace unionfs
} // end namespace cstore
+
diff --git a/src/cstore/unionfs/cstore-unionfs.hpp b/src/cstore/unionfs/cstore-unionfs.hpp
index 95c2b63..1196ae9 100644
--- a/src/cstore/unionfs/cstore-unionfs.hpp
+++ b/src/cstore/unionfs/cstore-unionfs.hpp
@@ -34,6 +34,7 @@
namespace commit {
class PrioNode;
}
+using namespace boost::filesystem;
namespace cstore { // begin namespace cstore
namespace unionfs { // begin namespace unionfs
@@ -291,8 +292,8 @@ private:
// boost fs operations wrappers
bool b_fs_get_file_status(const char *path, b_fs::file_status& fs) {
b_s::error_code ec;
- b_s::error_code* p_ec = &ec;
- fs = b_fs::detail::status(path, p_ec);
+ file_status s = status(path, ec);
+ fs = s;
return (!ec);
};
bool path_exists(const char *path);
@@ -315,3 +316,4 @@ private:
#endif /* _CSTORE_UNIONFS_H_ */
+