From d09f69e76f86e727ea9a3487f57a0d7fd7b5bcd7 Mon Sep 17 00:00:00 2001 From: Kotresh H R Date: Fri, 1 Aug 2014 14:08:56 +0530 Subject: geo-rep/libgfchangelog: Create working dir during changelog_register if not present. Earlier, xysnc's register was being called first, which was creating working directory before calling changelog_register. Now it is history crawl first. Hence working directory would not have been created. Create it in gf_changelog_register itself if it is not already created. Change-Id: Ief3f2b87deaf5da16c135b64be1be42e0a7647f3 BUG: 1125843 Signed-off-by: Kotresh H R Reviewed-on: http://review.gluster.org/8399 Tested-by: Gluster Build System Reviewed-by: Aravinda VK Reviewed-by: Vijay Bellur --- xlators/features/changelog/lib/src/gf-changelog.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'xlators/features/changelog/lib') diff --git a/xlators/features/changelog/lib/src/gf-changelog.c b/xlators/features/changelog/lib/src/gf-changelog.c index 482a59aa805..5586580a748 100644 --- a/xlators/features/changelog/lib/src/gf-changelog.c +++ b/xlators/features/changelog/lib/src/gf-changelog.c @@ -440,12 +440,13 @@ int gf_changelog_register (char *brick_path, char *scratch_dir, char *log_file, int log_level, int max_reconnects) { - int i = 0; - int ret = -1; - int errn = 0; - xlator_t *this = NULL; - gf_changelog_t *gfc = NULL; - char hist_scratch_dir[PATH_MAX] = {0,}; + int i = 0; + int ret = -1; + int errn = 0; + xlator_t *this = NULL; + gf_changelog_t *gfc = NULL; + char hist_scratch_dir[PATH_MAX] = {0,}; + struct stat buf = {0,}; this = THIS; if (!this->ctx) @@ -463,6 +464,14 @@ gf_changelog_register (char *brick_path, char *scratch_dir, gfc->gfc_dir = NULL; gfc->gfc_fd = gfc->gfc_sockfd = -1; + if (stat (scratch_dir, &buf) && errno == ENOENT) { + ret = mkdir_p (scratch_dir, 0600, _gf_false); + if (ret) { + errn = errno; + goto cleanup; + } + } + gfc->gfc_working_dir = realpath (scratch_dir, NULL); if (!gfc->gfc_working_dir) { errn = errno; -- cgit