diff options
| author | Jiffin Tony Thottan <jthottan@redhat.com> | 2016-07-18 11:12:43 +0530 | 
|---|---|---|
| committer | Niels de Vos <ndevos@redhat.com> | 2016-08-05 00:51:28 -0700 | 
| commit | 903ff0cf9c4e870f17fd9cc8ef95321f39c9760c (patch) | |
| tree | a395940447cff04837cfc7943275313ffa41048c /xlators/features/trash/src | |
| parent | 15e83bedbef360fea0ff67eab4ac8a8a8dd17772 (diff) | |
xlator/trash : append '/' at the end in trash_notify_lookup_cbk
In the notify function in trash xlator, a lookup is performed
to obtain path of old trash directory. The result usually contains
path without '/' at the end. The trash xlator maintains expects
'/' at the end for the values such as 'old trash dir' and
'new trash dir'. Otherwise certian checks in the code will fail.
>Change-Id: I89e02e4b249314fb6536297f959865feee182c83
>BUG: 1357397
>Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
>Reviewed-on: http://review.gluster.org/14938
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: Anoop C S <anoopcs@redhat.com>
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
>Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
>(cherry picked from commit d90307c1b0245e0e6a39044a28819cde520a100c)
Change-Id: I89e02e4b249314fb6536297f959865feee182c83
BUG: 1358262
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
Reviewed-on: http://review.gluster.org/14965
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'xlators/features/trash/src')
| -rw-r--r-- | xlators/features/trash/src/trash.c | 15 | 
1 files changed, 10 insertions, 5 deletions
diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c index 025d2c2efc1..fd5507ff694 100644 --- a/xlators/features/trash/src/trash.c +++ b/xlators/features/trash/src/trash.c @@ -290,7 +290,7 @@ trash_notify_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,  {          data_t                 *data                  = NULL;          trash_private_t        *priv                  = NULL; -        int ret                                       = 0; +        int                    ret                    = 0;          priv = this->private;          GF_VALIDATE_OR_GOTO ("trash", priv, out); @@ -306,14 +306,19 @@ trash_notify_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                          goto out;                  }          } else { -                priv->oldtrash_dir = gf_strdup (data->data); +                priv->oldtrash_dir = GF_CALLOC (1, PATH_MAX, +                                                gf_common_mt_char);                  if (!priv->oldtrash_dir) {                          gf_log (this->name, GF_LOG_ERROR, "out of memory");                           ret = ENOMEM;                           goto out;                  } -                gf_log (this->name, GF_LOG_DEBUG, "old trash directory" -                                                  " path is %s", data->data); +                /* appending '/' if it is not present */ +                sprintf (priv->oldtrash_dir, "%s%c", data->data, +                         data->data[strlen(data->data) - 1] != '/' ? '/' : '\0' +                         ); +                gf_log (this->name, GF_LOG_DEBUG, "old trash directory path " +                                                  "is %s", priv->oldtrash_dir);          }  out: @@ -378,7 +383,7 @@ trash_internal_op_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                          struct iatt *buf, struct iatt *preparent,                          struct iatt *postparent, dict_t *xdata)  { -        if (op_ret != 0) +        if (op_ret != 0 && !(op_errno == EEXIST))                  gf_log (this->name, GF_LOG_ERROR, "mkdir failed for "                          "internal op directory : %s", strerror (op_errno));          return op_ret;  | 
