diff options
Diffstat (limited to 'libglusterfs/src')
-rw-r--r-- | libglusterfs/src/common-utils.c | 35 | ||||
-rw-r--r-- | libglusterfs/src/common-utils.h | 2 |
2 files changed, 10 insertions, 27 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 351eb4daaec..14a344958fd 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -4535,37 +4535,20 @@ gf_zero_fill_stat (struct iatt *buf) buf->ia_ctime = 0; } -/* This function checks if the input key is a virtual or on disk xattr. - * Its not simple to identify a virtual xattr as there is no common - * format used to identify virtual xattrs. One way is to list each of the - * xattrs in different categories and compare the input against every xattr - * in the list, this is very inefficient as there are 100s of xattrs. - * - * Currently the only consumer of this function is upcall and md-cache, - * hence tailoring this function to their needs; in their case its allowed - * to consider disk xattrs as virtual xattrs, but not vice versa, i.e. - * virtual xattrs should not be considered as on disk xattr. Hence, being - * conservative, we consider anything that starts from user.*, security.*, - * system.* as on disk xattrs. trusted.* and glusterfs.* cannot be considered - * as virtual xattrs as there are some on disk xattrs which start from - * glusterfs.* and trusted.* - * - * Hence, this function could return an on disk xattr as virtual xattr but - * never a virtual xattr as on disk xattr. - */ gf_boolean_t -is_virtual_xattr (const char *k) +gf_is_valid_xattr_namespace (char *key) { - gf_boolean_t ret = _gf_true; + static char *xattr_namespaces[] = {"trusted.", "security.", "system.", + "user.", NULL }; + int i = 0; - if ((strncmp (k, "user.", strlen ("user.")) == 0) || - (strncmp (k, "security.", strlen ("security.")) == 0) || - (strncmp (k, "system.", strlen ("system.")) == 0) || - (GF_POSIX_ACL_REQUEST (k))) { - ret = _gf_false; + for (i = 0; xattr_namespaces[i]; i++) { + if (strncmp (key, xattr_namespaces[i], + strlen (xattr_namespaces[i])) == 0) + return _gf_true; } - return ret; + return _gf_false; } ino_t diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index 286b70ea708..72613acba3b 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -853,7 +853,7 @@ void gf_zero_fill_stat (struct iatt *buf); gf_boolean_t -is_virtual_xattr (const char *k); +gf_is_valid_xattr_namespace (char *k); const char * gf_inode_type_to_str (ia_type_t type); |