summaryrefslogtreecommitdiff
path: root/src/cstore/unionfs/cstore-unionfs.cpp
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2010-08-20 13:29:49 -0700
committerAn-Cheng Huang <ancheng@vyatta.com>2010-08-20 13:29:49 -0700
commitcbd1770462b2325372f90ef9200110dc66245377 (patch)
tree0bc0e2e3cb08576d20acc727d9a4e4521ea01428 /src/cstore/unionfs/cstore-unionfs.cpp
parent6c98b67a95f4bc35a801720dcca8460a75dcaed7 (diff)
downloadvyatta-cfg-cbd1770462b2325372f90ef9200110dc66245377.tar.gz
vyatta-cfg-cbd1770462b2325372f90ef9200110dc66245377.zip
handle "changed" status properly
* original backend implementation uses unionfs-specific "changes only" dir to determine "changed" status. this breaks when it involves deactivated nodes. * new library design uses explicit per-node "changed" marker. however, since previously "commit" only handles a root "changed" marker, the new library could not implement this scheme and used a workaround instead. * now add API functions for "commit" to properly clean up "changed" markers. * modify "commit" to use these API functions and remove the workaround from the new library.
Diffstat (limited to 'src/cstore/unionfs/cstore-unionfs.cpp')
-rw-r--r--src/cstore/unionfs/cstore-unionfs.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/cstore/unionfs/cstore-unionfs.cpp b/src/cstore/unionfs/cstore-unionfs.cpp
index 860d553..7f14483 100644
--- a/src/cstore/unionfs/cstore-unionfs.cpp
+++ b/src/cstore/unionfs/cstore-unionfs.cpp
@@ -749,6 +749,34 @@ UnionfsCstore::unmark_deactivated_descendants()
return ret;
}
+/* remove all "changed" markers under the current work path. this is used,
+ * e.g., at the end of "commit" to reset a subtree.
+ */
+bool
+UnionfsCstore::unmark_changed_with_descendants()
+{
+ try {
+ vector<b_fs::path> markers;
+ b_fs::recursive_directory_iterator di(get_work_path());
+ for (; di != b_fs::recursive_directory_iterator(); ++di) {
+ if (!b_fs_is_regular(di->path())
+ || di->path().filename() != C_MARKER_CHANGED) {
+ // not marker
+ continue;
+ }
+ markers.push_back(di->path());
+ }
+ for (size_t i = 0; i < markers.size(); i++) {
+ b_fs::remove(markers[i]);
+ }
+ } catch (...) {
+ output_internal("failed to unmark changed with descendants [%s]\n",
+ get_work_path().file_string().c_str());
+ return false;
+ }
+ return true;
+}
+
bool
UnionfsCstore::mark_changed()
{