diff options
| -rw-r--r-- | libglusterfs/src/xlator.c | 39 | ||||
| -rw-r--r-- | libglusterfs/src/xlator.h | 2 | ||||
| -rw-r--r-- | xlators/features/gfid-access/src/gfid-access.c | 17 | 
3 files changed, 58 insertions, 0 deletions
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 7c8c3cdba36..9ce52407f9e 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -650,6 +650,45 @@ loc_gfid_utoa (loc_t *loc)  }  int +loc_copy_overload_parent (loc_t *dst, loc_t *src, inode_t *parent) +{ +        int ret = -1; + +        GF_VALIDATE_OR_GOTO ("xlator", dst, err); +        GF_VALIDATE_OR_GOTO ("xlator", src, err); +        GF_VALIDATE_OR_GOTO ("xlator", parent, err); + +        uuid_copy (dst->gfid, src->gfid); +        uuid_copy (dst->pargfid, parent->gfid); + +        if (src->inode) +                dst->inode = inode_ref (src->inode); + +        if (parent) +                dst->parent = inode_ref (parent); + +        if (src->path) { +                dst->path = gf_strdup (src->path); + +                if (!dst->path) +                        goto out; + +                if (src->name) +                        dst->name = strrchr (dst->path, '/'); +                if (dst->name) +                        dst->name++; +        } + +        ret = 0; +out: +        if (ret == -1) +                loc_wipe (dst); + +err: +        return ret; +} + +int  loc_copy (loc_t *dst, loc_t *src)  {          int ret = -1; diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index 2f3bc9d6fb2..1daa06ec2ed 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -937,6 +937,8 @@ xlator_t *xlator_search_by_name (xlator_t *any, const char *name);  void inode_destroy_notify (inode_t *inode, const char *xlname);  int loc_copy (loc_t *dst, loc_t *src); +int loc_copy_overload_parent (loc_t *dst, +                              loc_t *src, inode_t *parent);  #define loc_dup(src, dst) loc_copy(dst, src)  void loc_wipe (loc_t *loc);  int loc_path (loc_t *loc, const char *bname); diff --git a/xlators/features/gfid-access/src/gfid-access.c b/xlators/features/gfid-access/src/gfid-access.c index 25ef9369709..a2bcbb74b6b 100644 --- a/xlators/features/gfid-access/src/gfid-access.c +++ b/xlators/features/gfid-access/src/gfid-access.c @@ -762,7 +762,24 @@ ga_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)             but on gfid-path */          if (!((loc->parent && __is_gfid_access_dir (loc->parent->gfid)) ||                __is_gfid_access_dir (loc->pargfid))) { +                if (!loc->parent)                          goto wind; + +                ret = inode_ctx_get (loc->parent, this, &value); +                if (ret) +                        goto wind; + +                inode = (inode_t *) value; + +                ret = loc_copy_overload_parent (&tmp_loc, loc, inode); +                if (ret) +                        goto err; + +                STACK_WIND (frame, ga_lookup_cbk, FIRST_CHILD (this), +                            FIRST_CHILD (this)->fops->lookup, &tmp_loc, xdata); + +                loc_wipe (&tmp_loc); +                return 0;          }          /* make sure the 'basename' is actually a 'canonical-gfid',  | 
