diff options
-rwxr-xr-x | lib/Vyatta/Config.pm | 23 | ||||
-rwxr-xr-x | lib/Vyatta/ConfigLoad.pm | 4 | ||||
-rw-r--r-- | perl_dmod/Cstore/Cstore.xs | 10 | ||||
-rw-r--r-- | src/cstore/cstore.cpp | 16 | ||||
-rw-r--r-- | src/cstore/cstore.hpp | 4 | ||||
-rw-r--r-- | src/cstore/unionfs/cstore-unionfs.cpp | 5 | ||||
-rw-r--r-- | src/cstore/unionfs/cstore-unionfs.hpp | 2 |
7 files changed, 55 insertions, 9 deletions
diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm index 8067e05..371fe32 100755 --- a/lib/Vyatta/Config.pm +++ b/lib/Vyatta/Config.pm @@ -53,8 +53,9 @@ sub get_path_comps { } ############################################################ -# low-level API functions that have been converted to use -# the cstore library. +# low-level API functions that use the cstore library directly. +# they are either new functions or old ones that have been +# converted to use cstore. ############################################################ ###### @@ -94,6 +95,24 @@ sub existsOrig { return; # note: this return is needed. } +## isDefault("path to node") +# Returns true if specified node is "default" in working config. +sub isDefault { + my ($self, $path) = @_; + return 1 + if ($self->{_cstore}->cfgPathDefault($self->get_path_comps($path), undef)); + return; # note: this return is needed. +} + +## isDefaultOrig("path to node") +# Returns true if specified node is "default" in active config. +sub isDefaultOrig { + my ($self, $path) = @_; + return 1 + if ($self->{_cstore}->cfgPathDefault($self->get_path_comps($path), 1)); + return; # note: this return is needed. +} + ## listNodes("level") # return array of all child nodes at "level" in working config. sub listNodes { diff --git a/lib/Vyatta/ConfigLoad.pm b/lib/Vyatta/ConfigLoad.pm index d3d7dbb..55ba76b 100755 --- a/lib/Vyatta/ConfigLoad.pm +++ b/lib/Vyatta/ConfigLoad.pm @@ -401,8 +401,8 @@ sub getConfigDiff { $file; } @{${$del}[0]}; - my ($is_multi, $is_text, $default) - = $active_cfg->parseTmpl(join ' ', @comps); + $active_cfg->setLevel(join ' ', @comps); + my ($is_multi, $is_text, $default) = $active_cfg->parseTmpl(); if (!defined($default)) { push @new_delete_list, $del; } diff --git a/perl_dmod/Cstore/Cstore.xs b/perl_dmod/Cstore/Cstore.xs index 5dd105e..f72a124 100644 --- a/perl_dmod/Cstore/Cstore.xs +++ b/perl_dmod/Cstore/Cstore.xs @@ -54,6 +54,16 @@ OUTPUT: RETVAL +bool +Cstore::cfgPathDefault(STRVEC *vref, bool active_cfg) +PREINIT: + vector<string> arg_strvec; +CODE: + RETVAL = THIS->cfgPathDefault(arg_strvec, active_cfg); +OUTPUT: + RETVAL + + STRVEC * Cstore::cfgPathGetChildNodes(STRVEC *vref, bool active_cfg) PREINIT: diff --git a/src/cstore/cstore.cpp b/src/cstore/cstore.cpp index e97ea2c..c829f6e 100644 --- a/src/cstore/cstore.cpp +++ b/src/cstore/cstore.cpp @@ -853,7 +853,7 @@ Cstore::setCfgPath(const vector<string>& path_comps) append_cfg_path(path_comps); pop_cfg_path(); // only do it if it's previously marked default - if (marked_display_default()) { + if (marked_display_default(false)) { ret = unmark_display_default(); /* XXX work around current commit's unionfs implementation problem. @@ -1448,6 +1448,20 @@ Cstore::cfgPathGetComment(const vector<string>& path_comps, string& comment, return ret; } +/* return whether specified path is "default". if a node is "default", it + * is currently not shown by the "show" command unless "-all" is specified. + * active_cfg: whether to observe active config. + */ +bool +Cstore::cfgPathDefault(const vector<string>& path_comps, bool active_cfg) +{ + SAVE_PATHS; + append_cfg_path(path_comps); + bool ret = marked_display_default(active_cfg); + RESTORE_PATHS; + return ret; +} + /* the following functions are observers of the "effective" config. * they can be used * (1) outside a config session (e.g., op mode, daemons, callbacks, etc.). diff --git a/src/cstore/cstore.hpp b/src/cstore/cstore.hpp index 1d4ffe2..1d8a295 100644 --- a/src/cstore/cstore.hpp +++ b/src/cstore/cstore.hpp @@ -172,6 +172,8 @@ public: vector<string>& values, bool active_cfg = false); bool cfgPathGetComment(const vector<string>& path_comps, string& comment, bool active_cfg = false); + bool cfgPathDefault(const vector<string>& path_comps, + bool active_cfg = false); /* observers for working AND active configs (at the same time). * MUST ONLY be used during config session. */ @@ -304,13 +306,13 @@ private: // observers for current work path virtual bool marked_changed() = 0; - virtual bool marked_display_default() = 0; // observers for current work path or active path virtual bool read_value_vec(vector<string>& vvec, bool active_cfg) = 0; virtual bool cfg_node_exists(bool active_cfg) = 0; virtual bool marked_deactivated(bool active_cfg) = 0; virtual bool get_comment(string& comment, bool active_cfg) = 0; + virtual bool marked_display_default(bool active_cfg) = 0; // observers during commit operation virtual bool marked_committed(const vtw_def& def, bool is_set) = 0; diff --git a/src/cstore/unionfs/cstore-unionfs.cpp b/src/cstore/unionfs/cstore-unionfs.cpp index 6e6e5de..3e94778 100644 --- a/src/cstore/unionfs/cstore-unionfs.cpp +++ b/src/cstore/unionfs/cstore-unionfs.cpp @@ -662,9 +662,10 @@ UnionfsCstore::unmark_display_default() } bool -UnionfsCstore::marked_display_default() +UnionfsCstore::marked_display_default(bool active_cfg) { - b_fs::path marker = get_work_path() / C_MARKER_DEF_VALUE; + b_fs::path marker = (active_cfg ? get_active_path() : get_work_path()) + / C_MARKER_DEF_VALUE; return b_fs::exists(marker); } diff --git a/src/cstore/unionfs/cstore-unionfs.hpp b/src/cstore/unionfs/cstore-unionfs.hpp index dd44d9a..8bec974 100644 --- a/src/cstore/unionfs/cstore-unionfs.hpp +++ b/src/cstore/unionfs/cstore-unionfs.hpp @@ -165,13 +165,13 @@ private: // observers for work path bool marked_changed(); - bool marked_display_default(); // observers for work path or active path bool cfg_node_exists(bool active_cfg); bool read_value_vec(vector<string>& vvec, bool active_cfg); bool marked_deactivated(bool active_cfg); bool get_comment(string& comment, bool active_cfg); + bool marked_display_default(bool active_cfg); // observers during commit operation bool marked_committed(const vtw_def& def, bool is_set); |