summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohit Mehta <mohit@vyatta.com>2011-05-16 16:25:04 -0700
committerMohit Mehta <mohit@vyatta.com>2011-05-16 16:25:04 -0700
commit86c421ea5216fa2ba80d860556a2ec82c8e4a566 (patch)
treeb57d26489dd1c42585cd8223be223cd9b279a124
parentb4fb99277cede6287684abd52dd839f5e6d86446 (diff)
parent42436ca83b2e416a019b1da208af5f71ba947234 (diff)
downloadvyatta-cfg-86c421ea5216fa2ba80d860556a2ec82c8e4a566.tar.gz
vyatta-cfg-86c421ea5216fa2ba80d860556a2ec82c8e4a566.zip
Merge branch 'napa' of git.vyatta.com:/git/vyatta-cfg into napa
-rw-r--r--debian/changelog6
-rw-r--r--src/cstore/unionfs/cstore-unionfs.cpp31
-rw-r--r--src/cstore/unionfs/cstore-unionfs.hpp1
3 files changed, 33 insertions, 5 deletions
diff --git a/debian/changelog b/debian/changelog
index 69f18fe..062aed4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+vyatta-cfg (0.18.104) unstable; urgency=low
+
+ * tweak directory handling for unionfs
+
+ -- An-Cheng Huang <ancheng@vyatta.com> Mon, 16 May 2011 15:26:27 -0700
+
vyatta-cfg (0.18.103) unstable; urgency=low
* close pipe fd before returning
diff --git a/src/cstore/unionfs/cstore-unionfs.cpp b/src/cstore/unionfs/cstore-unionfs.cpp
index ee24c46..6ccdbf2 100644
--- a/src/cstore/unionfs/cstore-unionfs.cpp
+++ b/src/cstore/unionfs/cstore-unionfs.cpp
@@ -659,9 +659,16 @@ UnionfsCstore::commitConfig(commit::PrioNode& node)
if (!do_umount(work_root)) {
return false;
}
- if (b_fs::remove_all(change_root.path_cstr()) < 1
- || b_fs::remove_all(active_root.path_cstr()) < 1) {
- output_internal("failed to remove existing directories\n");
+ if (b_fs::remove_all(change_root.path_cstr()) < 1) {
+ output_internal("failed to remove [%s]\n", change_root.path_cstr());
+ return false;
+ }
+ /* note: unionfs can't cope with whole directory being removed, so just
+ * remove the content.
+ */
+ if (!remove_dir_content(active_root.path_cstr())) {
+ output_internal("failed to remove [%s] content\n",
+ active_root.path_cstr());
return false;
}
try {
@@ -680,13 +687,11 @@ UnionfsCstore::commitConfig(commit::PrioNode& node)
if (!sync_dir(tmp_work_root, work_root, work_root)) {
return false;
}
-#if 0
if (b_fs::remove_all(tmp_work_root.path_cstr()) < 1
|| b_fs::remove_all(tmp_active_root.path_cstr()) < 1) {
output_user("failed to remove temp directories\n");
return false;
}
-#endif
// all done
return true;
}
@@ -1500,6 +1505,22 @@ UnionfsCstore::path_is_regular(const char *path)
return b_fs::is_regular(result);
}
+bool
+UnionfsCstore::remove_dir_content(const char *path)
+{
+ if (!path_is_directory(path)) {
+ return false;
+ }
+
+ b_fs::directory_iterator di(path);
+ for (; di != b_fs::directory_iterator(); ++di) {
+ if (b_fs::remove_all(di->path()) < 1) {
+ return false;
+ }
+ }
+ return true;
+}
+
} // end namespace unionfs
} // end namespace cstore
diff --git a/src/cstore/unionfs/cstore-unionfs.hpp b/src/cstore/unionfs/cstore-unionfs.hpp
index 8113d00..c7cd2d9 100644
--- a/src/cstore/unionfs/cstore-unionfs.hpp
+++ b/src/cstore/unionfs/cstore-unionfs.hpp
@@ -293,6 +293,7 @@ private:
bool path_is_regular(const FsPath& path) {
return path_is_regular(path.path_cstr());
};
+ bool remove_dir_content(const char *path);
};
} // end namespace unionfs