| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 |  * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc. | 
 | 3 |  * All Rights Reserved. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 |  * | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 5 |  * This program is free software; you can redistribute it and/or | 
 | 6 |  * modify it under the terms of the GNU General Public License as | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 |  * published by the Free Software Foundation. | 
 | 8 |  * | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 9 |  * This program is distributed in the hope that it would be useful, | 
 | 10 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 | 11 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
 | 12 |  * GNU General Public License for more details. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 |  * | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 14 |  * You should have received a copy of the GNU General Public License | 
 | 15 |  * along with this program; if not, write the Free Software Foundation, | 
 | 16 |  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 |  */ | 
 | 18 | #ifndef __XFS_ATTR_SF_H__ | 
 | 19 | #define	__XFS_ATTR_SF_H__ | 
 | 20 |  | 
 | 21 | /* | 
 | 22 |  * Attribute storage when stored inside the inode. | 
 | 23 |  * | 
 | 24 |  * Small attribute lists are packed as tightly as possible so as | 
 | 25 |  * to fit into the literal area of the inode. | 
 | 26 |  */ | 
 | 27 |  | 
 | 28 | struct xfs_inode; | 
 | 29 |  | 
 | 30 | /* | 
 | 31 |  * Entries are packed toward the top as tight as possible. | 
 | 32 |  */ | 
 | 33 | typedef struct xfs_attr_shortform { | 
 | 34 | 	struct xfs_attr_sf_hdr {	/* constant-structure header block */ | 
| Nathan Scott | 3b244aa | 2006-03-17 17:29:25 +1100 | [diff] [blame] | 35 | 		__be16	totsize;	/* total bytes in shortform list */ | 
 | 36 | 		__u8	count;	/* count of active entries */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | 	} hdr; | 
 | 38 | 	struct xfs_attr_sf_entry { | 
 | 39 | 		__uint8_t namelen;	/* actual length of name (no NULL) */ | 
 | 40 | 		__uint8_t valuelen;	/* actual length of value (no NULL) */ | 
 | 41 | 		__uint8_t flags;	/* flags bits (see xfs_attr_leaf.h) */ | 
 | 42 | 		__uint8_t nameval[1];	/* name & value bytes concatenated */ | 
 | 43 | 	} list[1];			/* variable sized array */ | 
 | 44 | } xfs_attr_shortform_t; | 
 | 45 | typedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t; | 
 | 46 | typedef struct xfs_attr_sf_entry xfs_attr_sf_entry_t; | 
 | 47 |  | 
 | 48 | /* | 
 | 49 |  * We generate this then sort it, attr_list() must return things in hash-order. | 
 | 50 |  */ | 
 | 51 | typedef struct xfs_attr_sf_sort { | 
 | 52 | 	__uint8_t	entno;		/* entry number in original list */ | 
 | 53 | 	__uint8_t	namelen;	/* length of name value (no null) */ | 
 | 54 | 	__uint8_t	valuelen;	/* length of value */ | 
 | 55 | 	__uint8_t	flags;		/* flags bits (see xfs_attr_leaf.h) */ | 
 | 56 | 	xfs_dahash_t	hash;		/* this entry's hash value */ | 
 | 57 | 	char		*name;		/* name value, pointer into buffer */ | 
 | 58 | } xfs_attr_sf_sort_t; | 
 | 59 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | #define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen)	/* space name/value uses */ \ | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 61 | 	(((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen))) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | #define XFS_ATTR_SF_ENTSIZE_MAX			/* max space for name&value */ \ | 
 | 63 | 	((1 << (NBBY*(int)sizeof(__uint8_t))) - 1) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | #define XFS_ATTR_SF_ENTSIZE(sfep)		/* space an entry uses */ \ | 
 | 65 | 	((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | #define XFS_ATTR_SF_NEXTENTRY(sfep)		/* next entry in struct */ \ | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 67 | 	((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep))) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | #define XFS_ATTR_SF_TOTSIZE(dp)			/* total space in use */ \ | 
| Nathan Scott | 3b244aa | 2006-03-17 17:29:25 +1100 | [diff] [blame] | 69 | 	(be16_to_cpu(((xfs_attr_shortform_t *)	\ | 
 | 70 | 		((dp)->i_afp->if_u1.if_data))->hdr.totsize)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 |  | 
 | 72 | #if defined(XFS_ATTR_TRACE) | 
 | 73 | /* | 
 | 74 |  * Kernel tracing support for attribute lists | 
 | 75 |  */ | 
 | 76 | struct xfs_attr_list_context; | 
 | 77 | struct xfs_da_intnode; | 
 | 78 | struct xfs_da_node_entry; | 
 | 79 | struct xfs_attr_leafblock; | 
 | 80 |  | 
 | 81 | #define	XFS_ATTR_TRACE_SIZE	4096	/* size of global trace buffer */ | 
 | 82 | extern ktrace_t	*xfs_attr_trace_buf; | 
 | 83 |  | 
 | 84 | /* | 
 | 85 |  * Trace record types. | 
 | 86 |  */ | 
 | 87 | #define	XFS_ATTR_KTRACE_L_C	1	/* context */ | 
 | 88 | #define	XFS_ATTR_KTRACE_L_CN	2	/* context, node */ | 
 | 89 | #define	XFS_ATTR_KTRACE_L_CB	3	/* context, btree */ | 
 | 90 | #define	XFS_ATTR_KTRACE_L_CL	4	/* context, leaf */ | 
 | 91 |  | 
 | 92 | void xfs_attr_trace_l_c(char *where, struct xfs_attr_list_context *context); | 
 | 93 | void xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context, | 
 | 94 | 			      struct xfs_da_intnode *node); | 
 | 95 | void xfs_attr_trace_l_cb(char *where, struct xfs_attr_list_context *context, | 
 | 96 | 			      struct xfs_da_node_entry *btree); | 
 | 97 | void xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context, | 
 | 98 | 			      struct xfs_attr_leafblock *leaf); | 
 | 99 | void xfs_attr_trace_enter(int type, char *where, | 
 | 100 | 			     __psunsigned_t a2, __psunsigned_t a3, | 
 | 101 | 			     __psunsigned_t a4, __psunsigned_t a5, | 
 | 102 | 			     __psunsigned_t a6, __psunsigned_t a7, | 
 | 103 | 			     __psunsigned_t a8, __psunsigned_t a9, | 
 | 104 | 			     __psunsigned_t a10, __psunsigned_t a11, | 
 | 105 | 			     __psunsigned_t a12, __psunsigned_t a13, | 
 | 106 | 			     __psunsigned_t a14, __psunsigned_t a15); | 
 | 107 | #else | 
 | 108 | #define	xfs_attr_trace_l_c(w,c) | 
 | 109 | #define	xfs_attr_trace_l_cn(w,c,n) | 
 | 110 | #define	xfs_attr_trace_l_cb(w,c,b) | 
 | 111 | #define	xfs_attr_trace_l_cl(w,c,l) | 
 | 112 | #endif /* XFS_ATTR_TRACE */ | 
 | 113 |  | 
 | 114 | #endif	/* __XFS_ATTR_SF_H__ */ |