xref: /linux/fs/xfs/libxfs/xfs_attr_sf.h (revision 0526b56cbc3c489642bd6a5fe4b718dea7ef0ee8)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
4  * All Rights Reserved.
5  */
6 #ifndef __XFS_ATTR_SF_H__
7 #define	__XFS_ATTR_SF_H__
8 
9 /*
10  * Attribute storage when stored inside the inode.
11  *
12  * Small attribute lists are packed as tightly as possible so as
13  * to fit into the literal area of the inode.
14  */
15 typedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t;
16 
17 /*
18  * We generate this then sort it, attr_list() must return things in hash-order.
19  */
20 typedef struct xfs_attr_sf_sort {
21 	uint8_t		entno;		/* entry number in original list */
22 	uint8_t		namelen;	/* length of name value (no null) */
23 	uint8_t		valuelen;	/* length of value */
24 	uint8_t		flags;		/* flags bits (see xfs_attr_leaf.h) */
25 	xfs_dahash_t	hash;		/* this entry's hash value */
26 	unsigned char	*name;		/* name value, pointer into buffer */
27 } xfs_attr_sf_sort_t;
28 
29 #define XFS_ATTR_SF_ENTSIZE_MAX			/* max space for name&value */ \
30 	((1 << (NBBY*(int)sizeof(uint8_t))) - 1)
31 
32 /* space name/value uses */
33 static inline int xfs_attr_sf_entsize_byname(uint8_t nlen, uint8_t vlen)
34 {
35 	return sizeof(struct xfs_attr_sf_entry) + nlen + vlen;
36 }
37 
38 /* space an entry uses */
39 static inline int xfs_attr_sf_entsize(struct xfs_attr_sf_entry *sfep)
40 {
41 	return struct_size(sfep, nameval, sfep->namelen + sfep->valuelen);
42 }
43 
44 /* next entry in struct */
45 static inline struct xfs_attr_sf_entry *
46 xfs_attr_sf_nextentry(struct xfs_attr_sf_entry *sfep)
47 {
48 	return (void *)sfep + xfs_attr_sf_entsize(sfep);
49 }
50 
51 #endif	/* __XFS_ATTR_SF_H__ */
52