summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2009-07-17 22:09:17 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-07-20 14:28:49 -0700
commit5be3c142978257032bd11ad420382859fc204702 (patch)
tree45378ec787c8b9d89713585763c6ff9a4564f441 /xlators/storage/posix
parent2105226253d4fe8cca2e31de76960ddc1a47a8c3 (diff)
posix getxattr supports new key 'trusted.glusterfs.location'
which can be used to get the file location by 'hostname' of the machine where file resides. Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 131 (provide a way to get the file location in clustered storage) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=131
Diffstat (limited to 'xlators/storage/posix')
-rw-r--r--xlators/storage/posix/src/posix.c23
-rw-r--r--xlators/storage/posix/src/posix.h1
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;