summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/inode.c7
-rw-r--r--libglusterfs/src/inode.h1
-rw-r--r--libglusterfs/src/xlator.c36
-rw-r--r--libglusterfs/src/xlator.h1
4 files changed, 42 insertions, 3 deletions
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
index 1db8297923a..c1a7efc0942 100644
--- a/libglusterfs/src/inode.c
+++ b/libglusterfs/src/inode.c
@@ -1095,8 +1095,9 @@ __inode_path (inode_t *inode, const char *name, char **bufp)
int len = 0;
char *buf = NULL;
- if (!inode) {
- gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found");
+ if (!inode || uuid_is_null (inode->gfid)) {
+ GF_ASSERT (0);
+ gf_log_callingfn (THIS->name, GF_LOG_WARNING, "invalid inode");
return -1;
}
@@ -1153,7 +1154,7 @@ __inode_path (inode_t *inode, const char *name, char **bufp)
if (!__is_root_gfid (itrav->gfid)) {
snprintf (&buf[i-GFID_STR_PFX_LEN], GFID_STR_PFX_LEN,
- "<gfid:%s>", uuid_utoa (itrav->gfid));
+ INODE_PATH_FMT, uuid_utoa (itrav->gfid));
buf[i-1] = '>';
}
diff --git a/libglusterfs/src/inode.h b/libglusterfs/src/inode.h
index f6401c5b9b1..7a296e0d23d 100644
--- a/libglusterfs/src/inode.h
+++ b/libglusterfs/src/inode.h
@@ -29,6 +29,7 @@
#include <sys/types.h>
#define DEFAULT_INODE_MEMPOOL_ENTRIES 32 * 1024
+#define INODE_PATH_FMT "<gfid:%s>"
struct _inode_table;
typedef struct _inode_table inode_table_t;
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index 1641a1909f6..16a931716f5 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -552,6 +552,42 @@ loc_wipe (loc_t *loc)
memset (loc, 0, sizeof (*loc));
}
+int
+loc_path (loc_t *loc, const char *bname)
+{
+ int ret = 0;
+
+ if (loc->path)
+ goto out;
+
+ ret = -1;
+
+ if (bname && !strlen (bname))
+ bname = NULL;
+
+ if (!bname)
+ goto inode_path;
+
+ if (loc->parent && !uuid_is_null (loc->parent->gfid)) {
+ ret = inode_path (loc->parent, bname, (char**)&loc->path);
+ } else if (!uuid_is_null (loc->pargfid)) {
+ ret = gf_asprintf ((char**)&loc->path, INODE_PATH_FMT"/%s",
+ uuid_utoa (loc->pargfid), bname);
+ }
+
+ if (loc->path)
+ goto out;
+
+inode_path:
+ if (loc->inode && !uuid_is_null (loc->inode->gfid)) {
+ ret = inode_path (loc->inode, NULL, (char **)&loc->path);
+ } else if (!uuid_is_null (loc->gfid)) {
+ ret = gf_asprintf ((char**)&loc->path, INODE_PATH_FMT,
+ uuid_utoa (loc->gfid));
+ }
+out:
+ return ret;
+}
int
loc_copy (loc_t *dst, loc_t *src)
diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h
index 2663b041a38..4c55e979f2f 100644
--- a/libglusterfs/src/xlator.h
+++ b/libglusterfs/src/xlator.h
@@ -876,6 +876,7 @@ void inode_destroy_notify (inode_t *inode, const char *xlname);
int loc_copy (loc_t *dst, loc_t *src);
#define loc_dup(src, dst) loc_copy(dst, src)
void loc_wipe (loc_t *loc);
+int loc_path (loc_t *loc, const char *bname);
int xlator_mem_acct_init (xlator_t *xl, int num_types);
int is_gf_log_command (xlator_t *trans, const char *name, char *value);
int glusterd_check_log_level (const char *value);