diff options
Diffstat (limited to 'fs/gfs2/xattr.c')
| -rw-r--r-- | fs/gfs2/xattr.c | 74 |
1 files changed, 45 insertions, 29 deletions
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c index 8a0f8ef6ee27..912f5cbc4740 100644 --- a/fs/gfs2/xattr.c +++ b/fs/gfs2/xattr.c | |||
| @@ -186,8 +186,8 @@ static int ea_find_i(struct gfs2_inode *ip, struct buffer_head *bh, | |||
| 186 | return 0; | 186 | return 0; |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | int gfs2_ea_find(struct gfs2_inode *ip, int type, const char *name, | 189 | static int gfs2_ea_find(struct gfs2_inode *ip, int type, const char *name, |
| 190 | struct gfs2_ea_location *el) | 190 | struct gfs2_ea_location *el) |
| 191 | { | 191 | { |
| 192 | struct ea_find ef; | 192 | struct ea_find ef; |
| 193 | int error; | 193 | int error; |
| @@ -516,8 +516,8 @@ out: | |||
| 516 | return error; | 516 | return error; |
| 517 | } | 517 | } |
| 518 | 518 | ||
| 519 | int gfs2_ea_get_copy(struct gfs2_inode *ip, struct gfs2_ea_location *el, | 519 | static int gfs2_ea_get_copy(struct gfs2_inode *ip, struct gfs2_ea_location *el, |
| 520 | char *data, size_t size) | 520 | char *data, size_t size) |
| 521 | { | 521 | { |
| 522 | int ret; | 522 | int ret; |
| 523 | size_t len = GFS2_EA_DATA_LEN(el->el_ea); | 523 | size_t len = GFS2_EA_DATA_LEN(el->el_ea); |
| @@ -534,6 +534,36 @@ int gfs2_ea_get_copy(struct gfs2_inode *ip, struct gfs2_ea_location *el, | |||
| 534 | return len; | 534 | return len; |
| 535 | } | 535 | } |
| 536 | 536 | ||
| 537 | int gfs2_xattr_acl_get(struct gfs2_inode *ip, const char *name, char **ppdata) | ||
| 538 | { | ||
| 539 | struct gfs2_ea_location el; | ||
| 540 | int error; | ||
| 541 | int len; | ||
| 542 | char *data; | ||
| 543 | |||
| 544 | error = gfs2_ea_find(ip, GFS2_EATYPE_SYS, name, &el); | ||
| 545 | if (error) | ||
| 546 | return error; | ||
| 547 | if (!el.el_ea) | ||
| 548 | goto out; | ||
| 549 | if (!GFS2_EA_DATA_LEN(el.el_ea)) | ||
| 550 | goto out; | ||
| 551 | |||
| 552 | len = GFS2_EA_DATA_LEN(el.el_ea); | ||
| 553 | data = kmalloc(len, GFP_NOFS); | ||
| 554 | error = -ENOMEM; | ||
| 555 | if (data == NULL) | ||
| 556 | goto out; | ||
| 557 | |||
| 558 | error = gfs2_ea_get_copy(ip, &el, data, len); | ||
| 559 | if (error == 0) | ||
| 560 | error = len; | ||
| 561 | *ppdata = data; | ||
| 562 | out: | ||
| 563 | brelse(el.el_bh); | ||
| 564 | return error; | ||
| 565 | } | ||
| 566 | |||
| 537 | /** | 567 | /** |
| 538 | * gfs2_xattr_get - Get a GFS2 extended attribute | 568 | * gfs2_xattr_get - Get a GFS2 extended attribute |
| 539 | * @inode: The inode | 569 | * @inode: The inode |
| @@ -1259,22 +1289,26 @@ fail: | |||
| 1259 | return error; | 1289 | return error; |
| 1260 | } | 1290 | } |
| 1261 | 1291 | ||
| 1262 | int gfs2_ea_acl_chmod(struct gfs2_inode *ip, struct gfs2_ea_location *el, | 1292 | int gfs2_xattr_acl_chmod(struct gfs2_inode *ip, struct iattr *attr, char *data) |
| 1263 | struct iattr *attr, char *data) | ||
| 1264 | { | 1293 | { |
| 1294 | struct gfs2_ea_location el; | ||
| 1265 | struct buffer_head *dibh; | 1295 | struct buffer_head *dibh; |
| 1266 | int error; | 1296 | int error; |
| 1267 | 1297 | ||
| 1268 | if (GFS2_EA_IS_STUFFED(el->el_ea)) { | 1298 | error = gfs2_ea_find(ip, GFS2_EATYPE_SYS, GFS2_POSIX_ACL_ACCESS, &el); |
| 1299 | if (error) | ||
| 1300 | return error; | ||
| 1301 | |||
| 1302 | if (GFS2_EA_IS_STUFFED(el.el_ea)) { | ||
| 1269 | error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + RES_EATTR, 0); | 1303 | error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + RES_EATTR, 0); |
| 1270 | if (error) | 1304 | if (error) |
| 1271 | return error; | 1305 | return error; |
| 1272 | 1306 | ||
| 1273 | gfs2_trans_add_bh(ip->i_gl, el->el_bh, 1); | 1307 | gfs2_trans_add_bh(ip->i_gl, el.el_bh, 1); |
| 1274 | memcpy(GFS2_EA2DATA(el->el_ea), data, | 1308 | memcpy(GFS2_EA2DATA(el.el_ea), data, |
| 1275 | GFS2_EA_DATA_LEN(el->el_ea)); | 1309 | GFS2_EA_DATA_LEN(el.el_ea)); |
| 1276 | } else | 1310 | } else |
| 1277 | error = ea_acl_chmod_unstuffed(ip, el->el_ea, data); | 1311 | error = ea_acl_chmod_unstuffed(ip, el.el_ea, data); |
| 1278 | 1312 | ||
| 1279 | if (error) | 1313 | if (error) |
| 1280 | return error; | 1314 | return error; |
| @@ -1507,18 +1541,6 @@ static int gfs2_xattr_user_set(struct inode *inode, const char *name, | |||
| 1507 | return gfs2_xattr_set(inode, GFS2_EATYPE_USR, name, value, size, flags); | 1541 | return gfs2_xattr_set(inode, GFS2_EATYPE_USR, name, value, size, flags); |
| 1508 | } | 1542 | } |
| 1509 | 1543 | ||
| 1510 | static int gfs2_xattr_system_get(struct inode *inode, const char *name, | ||
| 1511 | void *buffer, size_t size) | ||
| 1512 | { | ||
| 1513 | return gfs2_xattr_get(inode, GFS2_EATYPE_SYS, name, buffer, size); | ||
| 1514 | } | ||
| 1515 | |||
| 1516 | static int gfs2_xattr_system_set(struct inode *inode, const char *name, | ||
| 1517 | const void *value, size_t size, int flags) | ||
| 1518 | { | ||
| 1519 | return gfs2_xattr_set(inode, GFS2_EATYPE_SYS, name, value, size, flags); | ||
| 1520 | } | ||
| 1521 | |||
| 1522 | static int gfs2_xattr_security_get(struct inode *inode, const char *name, | 1544 | static int gfs2_xattr_security_get(struct inode *inode, const char *name, |
| 1523 | void *buffer, size_t size) | 1545 | void *buffer, size_t size) |
| 1524 | { | 1546 | { |
| @@ -1543,12 +1565,6 @@ static struct xattr_handler gfs2_xattr_security_handler = { | |||
| 1543 | .set = gfs2_xattr_security_set, | 1565 | .set = gfs2_xattr_security_set, |
| 1544 | }; | 1566 | }; |
| 1545 | 1567 | ||
| 1546 | static struct xattr_handler gfs2_xattr_system_handler = { | ||
| 1547 | .prefix = XATTR_SYSTEM_PREFIX, | ||
| 1548 | .get = gfs2_xattr_system_get, | ||
| 1549 | .set = gfs2_xattr_system_set, | ||
| 1550 | }; | ||
| 1551 | |||
| 1552 | struct xattr_handler *gfs2_xattr_handlers[] = { | 1568 | struct xattr_handler *gfs2_xattr_handlers[] = { |
| 1553 | &gfs2_xattr_user_handler, | 1569 | &gfs2_xattr_user_handler, |
| 1554 | &gfs2_xattr_security_handler, | 1570 | &gfs2_xattr_security_handler, |
