summaryrefslogtreecommitdiff
path: root/src/cstore/unionfs/cstore-unionfs.cpp
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2010-08-20 19:15:21 -0700
committerAn-Cheng Huang <ancheng@vyatta.com>2010-08-20 19:15:21 -0700
commite29b420868b312a1e3eaf52300002d3ba548481c (patch)
tree8b827888ac57bb2128d8b5394a99703bb0e2ec96 /src/cstore/unionfs/cstore-unionfs.cpp
parentf92d4eab7ef7411e5ec70768cbb26fdaa5f48541 (diff)
downloadvyatta-cfg-e29b420868b312a1e3eaf52300002d3ba548481c.tar.gz
vyatta-cfg-e29b420868b312a1e3eaf52300002d3ba548481c.zip
don't remove the workaround yet
* need to move changed status handling into the library.
Diffstat (limited to 'src/cstore/unionfs/cstore-unionfs.cpp')
-rw-r--r--src/cstore/unionfs/cstore-unionfs.cpp47
1 files changed, 37 insertions, 10 deletions
diff --git a/src/cstore/unionfs/cstore-unionfs.cpp b/src/cstore/unionfs/cstore-unionfs.cpp
index 46611ed..7f14483 100644
--- a/src/cstore/unionfs/cstore-unionfs.cpp
+++ b/src/cstore/unionfs/cstore-unionfs.cpp
@@ -780,16 +780,33 @@ UnionfsCstore::unmark_changed_with_descendants()
bool
UnionfsCstore::mark_changed()
{
- b_fs::path marker = get_work_path() / C_MARKER_CHANGED;
- if (b_fs_exists(marker)) {
- // already marked. treat as success.
+ if (!mutable_cfg_path.has_parent_path()) {
+ /* at root, mark changed. root marker is needed by the original
+ * implementation as an indication of whether the whole config
+ * has changed.
+ */
+ b_fs::path marker = get_work_path() / C_MARKER_CHANGED;
+ if (b_fs_exists(marker)) {
+ // already marked. treat as success.
+ return true;
+ }
+ if (!create_file(marker.file_string())) {
+ output_internal("failed to mark changed [%s]\n",
+ get_work_path().file_string().c_str());
+ return false;
+ }
return true;
}
- if (!create_file(marker.file_string())) {
- output_internal("failed to mark changed [%s]\n",
- get_work_path().file_string().c_str());
- return false;
- }
+
+ /* XXX not at root => nop for now.
+ * we should be marking changed here. however, as commit is still
+ * using its own unionfs implementation, it will not understand the
+ * markers and therefore will not perform the necessary cleanup when
+ * it's done.
+ *
+ * for now, don't mark anything besides root. the query function
+ * will use unionfs-specific implementation (changes-only dir).
+ */
return true;
}
@@ -866,8 +883,18 @@ UnionfsCstore::get_comment(string& comment, bool active_cfg)
bool
UnionfsCstore::marked_changed()
{
- b_fs::path marker = get_work_path() / C_MARKER_CHANGED;
- return b_fs_exists(marker);
+ /* this function is only called by cfgPathChanged() in base class.
+ *
+ * XXX currently just use the changes_only dir for this query.
+ * see explanation in mark_changed().
+ *
+ * this implementation relies on the fact that cfgPathChanged()
+ * includes deleted/added nodes (including deactivated/activated
+ * nodes since it's NOT deactivate-aware). if that is not the case,
+ * result will be different between deleted nodes (NOT IN
+ * changes_only) and deactivated nodes (IN changes_only).
+ */
+ return b_fs_exists(get_change_path());
}
/* XXX currently "committed marking" is done inside commit.