summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKotresh H R <khiremat@redhat.com>2014-08-01 14:08:56 +0530
committerVijay Bellur <vbellur@redhat.com>2014-09-08 10:42:25 -0700
commit010c82b0027300e45cc8db5d29ad87d39b290147 (patch)
treedd323c037ed6941d9c8abda1f9988089c7db7bd6
parentfca81b1300e2afdf3eb7cb75428657a31e92bc00 (diff)
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. BUG: 1138952 Change-Id: Ie39b9fd8c1ef7385f76a9b67d0acc3c1c2fd2bb2 Signed-off-by: Kotresh H R <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/8399 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Aravinda VK <avishwan@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com> Reviewed-on: http://review.gluster.org/8640
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog.c21
1 files changed, 15 insertions, 6 deletions
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;