summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2012-02-20 19:48:07 +0530
committerVijay Bellur <vijay@gluster.com>2012-02-20 10:05:38 -0800
commitdfc88bf3727fb33e2fc273bd7f24401e0209f39e (patch)
tree77f44f80fc6cc208e460286fd019531daeae5974
parentd349334fc0b3b069875b2724a5a46dfeb84289e4 (diff)
storage/posix: Add xattr for gfid2path
Change-Id: I1fe987d255bf50e8433043749b482b67554a0ac3 BUG: 763820 Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Reviewed-on: http://review.gluster.com/2774 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r--libglusterfs/src/glusterfs.h1
-rw-r--r--xlators/storage/posix/src/posix.c19
2 files changed, 20 insertions, 0 deletions
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index f961fd5937e..076833d2352 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -94,6 +94,7 @@
#define GLUSTERFS_ENTRYLK_COUNT "glusterfs.entrylk-count"
#define GLUSTERFS_POSIXLK_COUNT "glusterfs.posixlk-count"
#define QUOTA_SIZE_KEY "trusted.glusterfs.quota.size"
+#define GFID_TO_PATH_KEY "glusterfs.gfid2path"
/* Index xlator related */
#define GF_XATTROP_INDEX_GFID "glusterfs.xattrop_index_gfid"
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 5849626b03c..deaf2e772ef 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -2393,6 +2393,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
dict_t * dict = NULL;
char * file_contents = NULL;
int ret = -1;
+ char * path = NULL;
DECLARE_OLD_FS_ID_VAR;
@@ -2456,6 +2457,24 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
goto done;
}
+ if (loc->inode && name &&
+ (strcmp (name, GFID_TO_PATH_KEY) == 0)) {
+ ret = inode_path (loc->inode, NULL, &path);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING, "%s: could not get "
+ "inode path", uuid_utoa (loc->inode->gfid));
+ goto done;
+ }
+
+ ret = dict_set_dynstr (dict, GFID_TO_PATH_KEY, path);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "could not set value (%s) in dictionary",
+ host_buf);
+ }
+ goto done;
+ }
+
if (name) {
strcpy (key, name);