summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;