From dec4700c663975896f3aad1b4e59257263b4f4ac Mon Sep 17 00:00:00 2001 From: Aravinda VK Date: Mon, 10 Nov 2014 12:41:49 +0530 Subject: features/changelog: Cleanup .processing and .current directory On changelog_register cleanup .processing, .history/.processing, .current and .history/.current from the working directory. Moved glusterd_recursive_rmdir and glusterd_for_each_entry to common place(libglusterfs) and renamed as recursive_rmdir and GF_FOR_EACH_ENTRY_IN_DIR respectively BUG: 1162057 Change-Id: I1f98468a344cead039026762a805437b2f9e507b Signed-off-by: Aravinda VK Reviewed-on: http://review.gluster.org/9082 Tested-by: Gluster Build System Reviewed-by: Venky Shankar Tested-by: Venky Shankar --- xlators/features/changelog/lib/src/gf-changelog.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'xlators/features/changelog') diff --git a/xlators/features/changelog/lib/src/gf-changelog.c b/xlators/features/changelog/lib/src/gf-changelog.c index f3f6ffbe976..a2257a66930 100644 --- a/xlators/features/changelog/lib/src/gf-changelog.c +++ b/xlators/features/changelog/lib/src/gf-changelog.c @@ -108,10 +108,22 @@ gf_changelog_open_dirs (gf_changelog_t *gfc) DIR *dir = NULL; int tracker_fd = 0; char tracker_path[PATH_MAX] = {0,}; + xlator_t *this = NULL; + + this = THIS; + GF_ASSERT (this); (void) snprintf (gfc->gfc_current_dir, PATH_MAX, "%s/"GF_CHANGELOG_CURRENT_DIR"/", gfc->gfc_working_dir); + + ret = recursive_rmdir (gfc->gfc_current_dir); + if (ret) + gf_log (this->name, GF_LOG_ERROR, + "Failed to rmdir: %s, err: %s", + gfc->gfc_current_dir, strerror (errno)); + goto out; + ret = mkdir_p (gfc->gfc_current_dir, 0600, _gf_false); if (ret) goto out; @@ -119,6 +131,7 @@ gf_changelog_open_dirs (gf_changelog_t *gfc) (void) snprintf (gfc->gfc_processed_dir, PATH_MAX, "%s/"GF_CHANGELOG_PROCESSED_DIR"/", gfc->gfc_working_dir); + ret = mkdir_p (gfc->gfc_processed_dir, 0600, _gf_false); if (ret) goto out; @@ -126,6 +139,14 @@ gf_changelog_open_dirs (gf_changelog_t *gfc) (void) snprintf (gfc->gfc_processing_dir, PATH_MAX, "%s/"GF_CHANGELOG_PROCESSING_DIR"/", gfc->gfc_working_dir); + + ret = recursive_rmdir (gfc->gfc_processing_dir); + if (ret) + gf_log (this->name, GF_LOG_ERROR, + "Failed to rmdir: %s, err: %s", + gfc->gfc_processing_dir, strerror (errno)); + goto out; + ret = mkdir_p (gfc->gfc_processing_dir, 0600, _gf_false); if (ret) goto out; -- cgit