David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
Steven Whitehouse | 3a8a9a1 | 2006-05-18 15:09:15 -0400 | [diff] [blame] | 3 | * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 4 | * |
| 5 | * This copyrighted material is made available to anyone wishing to use, |
| 6 | * modify, copy, or redistribute it subject to the terms and conditions |
Steven Whitehouse | e9fc2aa | 2006-09-01 11:05:15 -0400 | [diff] [blame] | 7 | * of the GNU General Public License version 2. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef __EATTR_DOT_H__ |
| 11 | #define __EATTR_DOT_H__ |
| 12 | |
Steven Whitehouse | f2f7ba5 | 2006-09-05 10:39:21 -0400 | [diff] [blame] | 13 | struct gfs2_inode; |
| 14 | struct iattr; |
| 15 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 16 | #define GFS2_EA_REC_LEN(ea) be32_to_cpu((ea)->ea_rec_len) |
| 17 | #define GFS2_EA_DATA_LEN(ea) be32_to_cpu((ea)->ea_data_len) |
| 18 | |
| 19 | #define GFS2_EA_SIZE(ea) \ |
| 20 | ALIGN(sizeof(struct gfs2_ea_header) + (ea)->ea_name_len + \ |
| 21 | ((GFS2_EA_IS_STUFFED(ea)) ? GFS2_EA_DATA_LEN(ea) : \ |
Steven Whitehouse | 86d0063 | 2009-09-14 09:50:57 +0100 | [diff] [blame] | 22 | (sizeof(__be64) * (ea)->ea_num_ptrs)), 8) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 23 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 24 | #define GFS2_EA_IS_STUFFED(ea) (!(ea)->ea_num_ptrs) |
| 25 | #define GFS2_EA_IS_LAST(ea) ((ea)->ea_flags & GFS2_EAFLAG_LAST) |
| 26 | |
| 27 | #define GFS2_EAREQ_SIZE_STUFFED(er) \ |
| 28 | ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + (er)->er_data_len, 8) |
| 29 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 30 | #define GFS2_EA2NAME(ea) ((char *)((struct gfs2_ea_header *)(ea) + 1)) |
| 31 | #define GFS2_EA2DATA(ea) (GFS2_EA2NAME(ea) + (ea)->ea_name_len) |
| 32 | |
| 33 | #define GFS2_EA2DATAPTRS(ea) \ |
Al Viro | b44b84d | 2006-10-14 10:46:30 -0400 | [diff] [blame] | 34 | ((__be64 *)(GFS2_EA2NAME(ea) + ALIGN((ea)->ea_name_len, 8))) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 35 | |
| 36 | #define GFS2_EA2NEXT(ea) \ |
| 37 | ((struct gfs2_ea_header *)((char *)(ea) + GFS2_EA_REC_LEN(ea))) |
| 38 | |
| 39 | #define GFS2_EA_BH2FIRST(bh) \ |
| 40 | ((struct gfs2_ea_header *)((bh)->b_data + sizeof(struct gfs2_meta_header))) |
| 41 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 42 | struct gfs2_ea_request { |
Steven Whitehouse | cca195c | 2006-09-05 13:15:18 -0400 | [diff] [blame] | 43 | const char *er_name; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 44 | char *er_data; |
| 45 | unsigned int er_name_len; |
| 46 | unsigned int er_data_len; |
| 47 | unsigned int er_type; /* GFS2_EATYPE_... */ |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | struct gfs2_ea_location { |
| 51 | struct buffer_head *el_bh; |
| 52 | struct gfs2_ea_header *el_ea; |
| 53 | struct gfs2_ea_header *el_prev; |
| 54 | }; |
| 55 | |
Christoph Hellwig | 431547b | 2009-11-13 09:52:56 +0000 | [diff] [blame] | 56 | extern int __gfs2_xattr_set(struct inode *inode, const char *name, |
| 57 | const void *value, size_t size, |
| 58 | int flags, int type); |
Steven Whitehouse | 40b78a3 | 2009-08-26 18:41:32 +0100 | [diff] [blame] | 59 | extern ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size); |
| 60 | extern int gfs2_ea_dealloc(struct gfs2_inode *ip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 61 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 62 | /* Exported to acl.c */ |
| 63 | |
Steven Whitehouse | 479c427 | 2009-10-02 12:00:00 +0100 | [diff] [blame] | 64 | extern int gfs2_xattr_acl_get(struct gfs2_inode *ip, const char *name, char **data); |
Ryan O'Hara | 639b6d7 | 2006-05-22 10:08:35 -0400 | [diff] [blame] | 65 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 66 | #endif /* __EATTR_DOT_H__ */ |