diff options
Diffstat (limited to 'xlators/features/bit-rot/src/stub/bit-rot-stub-helpers.c')
-rw-r--r-- | xlators/features/bit-rot/src/stub/bit-rot-stub-helpers.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub-helpers.c b/xlators/features/bit-rot/src/stub/bit-rot-stub-helpers.c index bf3e56a6c74..59588d04f5c 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub-helpers.c +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub-helpers.c @@ -224,8 +224,15 @@ out: static int br_stub_check_stub_directory (xlator_t *this, char *fullpath) { - int ret = 0; - struct stat st = {0,}; + int ret = 0; + struct stat st = {0,}; + char oldpath[PATH_MAX] = {0}; + br_stub_private_t *priv = NULL; + + priv = this->private; + + (void) snprintf (oldpath, PATH_MAX, + "%s/%s", priv->export, OLD_BR_STUB_QUARANTINE_DIR); ret = sys_stat (fullpath, &st); if (!ret && !S_ISDIR (st.st_mode)) @@ -233,7 +240,11 @@ br_stub_check_stub_directory (xlator_t *this, char *fullpath) if (ret) { if (errno != ENOENT) goto error_return; - ret = mkdir_p (fullpath, 0600, _gf_true); + ret = sys_stat (oldpath, &st); + if (ret) + ret = mkdir_p (fullpath, 0600, _gf_true); + else + ret = sys_rename (oldpath, fullpath); } if (ret) |