aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/xattr.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2009-11-13 04:52:56 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2009-12-16 12:16:49 -0500
commit431547b3c4533b8c7fd150ab36980b9a3147797b (patch)
tree807ff2790f3c13c7c91ed2afd6d833032899482d /fs/gfs2/xattr.c
parentef26ca97e83052790940cbc444b01b0d17a813c1 (diff)
sanitize xattr handler prototypes
Add a flags argument to struct xattr_handler and pass it to all xattr handler methods. This allows using the same methods for multiple handlers, e.g. for the ACL methods which perform exactly the same action for the access and default ACLs, just using a different underlying attribute. With a little more groundwork it'll also allow sharing the methods for the regular user/trusted/secure handlers in extN, ocfs2 and jffs2 like it's already done for xfs in this patch. Also change the inode argument to the handlers to a dentry to allow using the handlers mechnism for filesystems that require it later, e.g. cifs. [with GFS2 bits updated by Steven Whitehouse <swhiteho@redhat.com>] Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: James Morris <jmorris@namei.org> Acked-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/gfs2/xattr.c')
-rw-r--r--fs/gfs2/xattr.c69
1 files changed, 26 insertions, 43 deletions
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
index 912f5cbc4740..8a04108e0c22 100644
--- a/fs/gfs2/xattr.c
+++ b/fs/gfs2/xattr.c
@@ -567,18 +567,17 @@ out:
567/** 567/**
568 * gfs2_xattr_get - Get a GFS2 extended attribute 568 * gfs2_xattr_get - Get a GFS2 extended attribute
569 * @inode: The inode 569 * @inode: The inode
570 * @type: The type of extended attribute
571 * @name: The name of the extended attribute 570 * @name: The name of the extended attribute
572 * @buffer: The buffer to write the result into 571 * @buffer: The buffer to write the result into
573 * @size: The size of the buffer 572 * @size: The size of the buffer
573 * @type: The type of extended attribute
574 * 574 *
575 * Returns: actual size of data on success, -errno on error 575 * Returns: actual size of data on success, -errno on error
576 */ 576 */
577 577static int gfs2_xattr_get(struct dentry *dentry, const char *name,
578int gfs2_xattr_get(struct inode *inode, int type, const char *name, 578 void *buffer, size_t size, int type)
579 void *buffer, size_t size)
580{ 579{
581 struct gfs2_inode *ip = GFS2_I(inode); 580 struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
582 struct gfs2_ea_location el; 581 struct gfs2_ea_location el;
583 int error; 582 int error;
584 583
@@ -1119,7 +1118,7 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el)
1119 1118
1120/** 1119/**
1121 * gfs2_xattr_remove - Remove a GFS2 extended attribute 1120 * gfs2_xattr_remove - Remove a GFS2 extended attribute
1122 * @inode: The inode 1121 * @ip: The inode
1123 * @type: The type of the extended attribute 1122 * @type: The type of the extended attribute
1124 * @name: The name of the extended attribute 1123 * @name: The name of the extended attribute
1125 * 1124 *
@@ -1130,9 +1129,8 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el)
1130 * Returns: 0, or errno on failure 1129 * Returns: 0, or errno on failure
1131 */ 1130 */
1132 1131
1133static int gfs2_xattr_remove(struct inode *inode, int type, const char *name) 1132static int gfs2_xattr_remove(struct gfs2_inode *ip, int type, const char *name)
1134{ 1133{
1135 struct gfs2_inode *ip = GFS2_I(inode);
1136 struct gfs2_ea_location el; 1134 struct gfs2_ea_location el;
1137 int error; 1135 int error;
1138 1136
@@ -1156,24 +1154,24 @@ static int gfs2_xattr_remove(struct inode *inode, int type, const char *name)
1156} 1154}
1157 1155
1158/** 1156/**
1159 * gfs2_xattr_set - Set (or remove) a GFS2 extended attribute 1157 * __gfs2_xattr_set - Set (or remove) a GFS2 extended attribute
1160 * @inode: The inode 1158 * @ip: The inode
1161 * @type: The type of the extended attribute
1162 * @name: The name of the extended attribute 1159 * @name: The name of the extended attribute
1163 * @value: The value of the extended attribute (NULL for remove) 1160 * @value: The value of the extended attribute (NULL for remove)
1164 * @size: The size of the @value argument 1161 * @size: The size of the @value argument
1165 * @flags: Create or Replace 1162 * @flags: Create or Replace
1163 * @type: The type of the extended attribute
1166 * 1164 *
1167 * See gfs2_xattr_remove() for details of the removal of xattrs. 1165 * See gfs2_xattr_remove() for details of the removal of xattrs.
1168 * 1166 *
1169 * Returns: 0 or errno on failure 1167 * Returns: 0 or errno on failure
1170 */ 1168 */
1171 1169
1172int gfs2_xattr_set(struct inode *inode, int type, const char *name, 1170int __gfs2_xattr_set(struct inode *inode, const char *name,
1173 const void *value, size_t size, int flags) 1171 const void *value, size_t size, int flags, int type)
1174{ 1172{
1175 struct gfs2_sbd *sdp = GFS2_SB(inode);
1176 struct gfs2_inode *ip = GFS2_I(inode); 1173 struct gfs2_inode *ip = GFS2_I(inode);
1174 struct gfs2_sbd *sdp = GFS2_SB(inode);
1177 struct gfs2_ea_location el; 1175 struct gfs2_ea_location el;
1178 unsigned int namel = strlen(name); 1176 unsigned int namel = strlen(name);
1179 int error; 1177 int error;
@@ -1184,7 +1182,7 @@ int gfs2_xattr_set(struct inode *inode, int type, const char *name,
1184 return -ERANGE; 1182 return -ERANGE;
1185 1183
1186 if (value == NULL) 1184 if (value == NULL)
1187 return gfs2_xattr_remove(inode, type, name); 1185 return gfs2_xattr_remove(ip, type, name);
1188 1186
1189 if (ea_check_size(sdp, namel, size)) 1187 if (ea_check_size(sdp, namel, size))
1190 return -ERANGE; 1188 return -ERANGE;
@@ -1224,6 +1222,13 @@ int gfs2_xattr_set(struct inode *inode, int type, const char *name,
1224 return error; 1222 return error;
1225} 1223}
1226 1224
1225static int gfs2_xattr_set(struct dentry *dentry, const char *name,
1226 const void *value, size_t size, int flags, int type)
1227{
1228 return __gfs2_xattr_set(dentry->d_inode, name, value,
1229 size, flags, type);
1230}
1231
1227static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip, 1232static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip,
1228 struct gfs2_ea_header *ea, char *data) 1233 struct gfs2_ea_header *ea, char *data)
1229{ 1234{
@@ -1529,40 +1534,18 @@ out_alloc:
1529 return error; 1534 return error;
1530} 1535}
1531 1536
1532static int gfs2_xattr_user_get(struct inode *inode, const char *name,
1533 void *buffer, size_t size)
1534{
1535 return gfs2_xattr_get(inode, GFS2_EATYPE_USR, name, buffer, size);
1536}
1537
1538static int gfs2_xattr_user_set(struct inode *inode, const char *name,
1539 const void *value, size_t size, int flags)
1540{
1541 return gfs2_xattr_set(inode, GFS2_EATYPE_USR, name, value, size, flags);
1542}
1543
1544static int gfs2_xattr_security_get(struct inode *inode, const char *name,
1545 void *buffer, size_t size)
1546{
1547 return gfs2_xattr_get(inode, GFS2_EATYPE_SECURITY, name, buffer, size);
1548}
1549
1550static int gfs2_xattr_security_set(struct inode *inode, const char *name,
1551 const void *value, size_t size, int flags)
1552{
1553 return gfs2_xattr_set(inode, GFS2_EATYPE_SECURITY, name, value, size, flags);
1554}
1555
1556static struct xattr_handler gfs2_xattr_user_handler = { 1537static struct xattr_handler gfs2_xattr_user_handler = {
1557 .prefix = XATTR_USER_PREFIX, 1538 .prefix = XATTR_USER_PREFIX,
1558 .get = gfs2_xattr_user_get, 1539 .flags = GFS2_EATYPE_USR,
1559 .set = gfs2_xattr_user_set, 1540 .get = gfs2_xattr_get,
1541 .set = gfs2_xattr_set,
1560}; 1542};
1561 1543
1562static struct xattr_handler gfs2_xattr_security_handler = { 1544static struct xattr_handler gfs2_xattr_security_handler = {
1563 .prefix = XATTR_SECURITY_PREFIX, 1545 .prefix = XATTR_SECURITY_PREFIX,
1564 .get = gfs2_xattr_security_get, 1546 .flags = GFS2_EATYPE_SECURITY,
1565 .set = gfs2_xattr_security_set, 1547 .get = gfs2_xattr_get,
1548 .set = gfs2_xattr_set,
1566}; 1549};
1567 1550
1568struct xattr_handler *gfs2_xattr_handlers[] = { 1551struct xattr_handler *gfs2_xattr_handlers[] = {