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 | |
| 13 | #define GFS2_EA_REC_LEN(ea) be32_to_cpu((ea)->ea_rec_len) |
| 14 | #define GFS2_EA_DATA_LEN(ea) be32_to_cpu((ea)->ea_data_len) |
| 15 | |
| 16 | #define GFS2_EA_SIZE(ea) \ |
| 17 | ALIGN(sizeof(struct gfs2_ea_header) + (ea)->ea_name_len + \ |
| 18 | ((GFS2_EA_IS_STUFFED(ea)) ? GFS2_EA_DATA_LEN(ea) : \ |
| 19 | (sizeof(uint64_t) * (ea)->ea_num_ptrs)), 8) |
| 20 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 21 | #define GFS2_EA_IS_STUFFED(ea) (!(ea)->ea_num_ptrs) |
| 22 | #define GFS2_EA_IS_LAST(ea) ((ea)->ea_flags & GFS2_EAFLAG_LAST) |
| 23 | |
| 24 | #define GFS2_EAREQ_SIZE_STUFFED(er) \ |
| 25 | ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + (er)->er_data_len, 8) |
| 26 | |
| 27 | #define GFS2_EAREQ_SIZE_UNSTUFFED(sdp, er) \ |
| 28 | ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + \ |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 29 | sizeof(uint64_t) * DIV_ROUND_UP((er)->er_data_len, (sdp)->sd_jbsize), 8) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 30 | |
| 31 | #define GFS2_EA2NAME(ea) ((char *)((struct gfs2_ea_header *)(ea) + 1)) |
| 32 | #define GFS2_EA2DATA(ea) (GFS2_EA2NAME(ea) + (ea)->ea_name_len) |
| 33 | |
| 34 | #define GFS2_EA2DATAPTRS(ea) \ |
| 35 | ((uint64_t *)(GFS2_EA2NAME(ea) + ALIGN((ea)->ea_name_len, 8))) |
| 36 | |
| 37 | #define GFS2_EA2NEXT(ea) \ |
| 38 | ((struct gfs2_ea_header *)((char *)(ea) + GFS2_EA_REC_LEN(ea))) |
| 39 | |
| 40 | #define GFS2_EA_BH2FIRST(bh) \ |
| 41 | ((struct gfs2_ea_header *)((bh)->b_data + sizeof(struct gfs2_meta_header))) |
| 42 | |
| 43 | #define GFS2_ERF_MODE 0x80000000 |
| 44 | |
| 45 | struct gfs2_ea_request { |
| 46 | char *er_name; |
| 47 | char *er_data; |
| 48 | unsigned int er_name_len; |
| 49 | unsigned int er_data_len; |
| 50 | unsigned int er_type; /* GFS2_EATYPE_... */ |
| 51 | int er_flags; |
| 52 | mode_t er_mode; |
| 53 | }; |
| 54 | |
| 55 | struct gfs2_ea_location { |
| 56 | struct buffer_head *el_bh; |
| 57 | struct gfs2_ea_header *el_ea; |
| 58 | struct gfs2_ea_header *el_prev; |
| 59 | }; |
| 60 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 61 | int gfs2_ea_get_i(struct gfs2_inode *ip, struct gfs2_ea_request *er); |
| 62 | int gfs2_ea_set_i(struct gfs2_inode *ip, struct gfs2_ea_request *er); |
| 63 | int gfs2_ea_remove_i(struct gfs2_inode *ip, struct gfs2_ea_request *er); |
| 64 | |
| 65 | int gfs2_ea_list(struct gfs2_inode *ip, struct gfs2_ea_request *er); |
| 66 | int gfs2_ea_get(struct gfs2_inode *ip, struct gfs2_ea_request *er); |
| 67 | int gfs2_ea_set(struct gfs2_inode *ip, struct gfs2_ea_request *er); |
| 68 | int gfs2_ea_remove(struct gfs2_inode *ip, struct gfs2_ea_request *er); |
| 69 | |
| 70 | int gfs2_ea_dealloc(struct gfs2_inode *ip); |
| 71 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 72 | /* Exported to acl.c */ |
| 73 | |
| 74 | int gfs2_ea_find(struct gfs2_inode *ip, |
| 75 | struct gfs2_ea_request *er, |
| 76 | struct gfs2_ea_location *el); |
| 77 | int gfs2_ea_get_copy(struct gfs2_inode *ip, |
| 78 | struct gfs2_ea_location *el, |
| 79 | char *data); |
| 80 | int gfs2_ea_acl_chmod(struct gfs2_inode *ip, struct gfs2_ea_location *el, |
| 81 | struct iattr *attr, char *data); |
| 82 | |
Ryan O'Hara | 639b6d7 | 2006-05-22 10:08:35 -0400 | [diff] [blame] | 83 | static inline unsigned int gfs2_ea_strlen(struct gfs2_ea_header *ea) |
| 84 | { |
| 85 | switch (ea->ea_type) { |
| 86 | case GFS2_EATYPE_USR: |
| 87 | return (5 + (ea->ea_name_len + 1)); |
| 88 | case GFS2_EATYPE_SYS: |
| 89 | return (7 + (ea->ea_name_len + 1)); |
| 90 | case GFS2_EATYPE_SECURITY: |
| 91 | return (9 + (ea->ea_name_len + 1)); |
| 92 | default: |
| 93 | return (0); |
| 94 | } |
| 95 | } |
| 96 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 97 | #endif /* __EATTR_DOT_H__ */ |