summaryrefslogtreecommitdiffstats
path: root/xlators/features/changelog/lib
diff options
context:
space:
mode:
authorKotresh H R <khiremat@redhat.com>2014-08-01 14:08:56 +0530
committerVijay Bellur <vbellur@redhat.com>2014-08-01 17:23:57 -0700
commitd09f69e76f86e727ea9a3487f57a0d7fd7b5bcd7 (patch)
tree6384fca0cf285dd2d16bb5edec4fa27375861ba5 /xlators/features/changelog/lib
parentb12ee8fbaf8f720f9072ea6b62bb844232870e6e (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. Change-Id: Ief3f2b87deaf5da16c135b64be1be42e0a7647f3 BUG: 1125843 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>
Diffstat (limited to 'xlators/features/changelog/lib')
-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;