diff options
-rw-r--r-- | xlators/storage/posix/src/posix.c | 23 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix.h | 1 |
2 files changed, 24 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 0205c52758d..1772fc3ad3f 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -2195,6 +2195,7 @@ int32_t posix_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name) { + struct posix_private *priv = NULL; int32_t op_ret = -1; int32_t op_errno = ENOENT; int32_t list_offset = 0; @@ -2217,6 +2218,8 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, SET_FS_ID (frame->root->uid, frame->root->gid); MAKE_REAL_PATH (real_path, this, loc->path); + priv = this->private; + if (loc->inode && S_ISDIR(loc->inode->st_mode) && name && ZR_FILE_CONTENT_REQUEST(name)) { ret = get_file_contents (this, real_path, name, @@ -2237,6 +2240,20 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, goto out; } + if (loc->inode && S_ISREG (loc->inode->st_mode) && name && + (strcmp (name, "trusted.glusterfs.location") == 0)) { + ret = dict_set_static_ptr (dict, + "trusted.glusterfs.location", + priv->hostname); + if (ret < 0) { + gf_log (this->name, GF_LOG_WARNING, + "could not set hostname (%s) in dictionary", + priv->hostname); + } + goto done; + } + + size = sys_llistxattr (real_path, NULL, 0); if (size == -1) { op_errno = errno; @@ -3901,6 +3918,12 @@ init (xlator_t *this) _private->base_path = strdup (dir_data->data); _private->base_path_length = strlen (_private->base_path); + ret = gethostname (_private->hostname, 256); + if (ret < 0) { + gf_log (this->name, GF_LOG_WARNING, + "could not find hostname (%s)", strerror (errno)); + } + { /* Stats related variables */ gettimeofday (&_private->init_time, NULL); diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h index ed6b46430dd..15829db18a8 100644 --- a/xlators/storage/posix/src/posix.h +++ b/xlators/storage/posix/src/posix.h @@ -65,6 +65,7 @@ struct posix_private { char *base_path; int32_t base_path_length; + char hostname[256]; /* Statistics, provides activity of the server */ struct xlator_stats stats; |