1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
6 #ifndef __XFS_ATTR_SF_H__
7 #define __XFS_ATTR_SF_H__
10 * We generate this then sort it, attr_list() must return things in hash-order.
12 typedef struct xfs_attr_sf_sort
{
13 uint8_t entno
; /* entry number in original list */
14 uint8_t namelen
; /* length of name value (no null) */
15 uint8_t valuelen
; /* length of value */
16 uint8_t flags
; /* flags bits (see xfs_attr_leaf.h) */
17 xfs_dahash_t hash
; /* this entry's hash value */
18 unsigned char *name
; /* name value, pointer into buffer */
22 #define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \
23 ((1 << (NBBY*(int)sizeof(uint8_t))) - 1)
25 /* space name/value uses */
26 static inline int xfs_attr_sf_entsize_byname(uint8_t nlen
, uint8_t vlen
)
28 return sizeof(struct xfs_attr_sf_entry
) + nlen
+ vlen
;
31 /* space an entry uses */
32 static inline int xfs_attr_sf_entsize(struct xfs_attr_sf_entry
*sfep
)
34 return struct_size(sfep
, nameval
, sfep
->namelen
+ sfep
->valuelen
);
37 /* first entry in the SF attr fork */
38 static inline struct xfs_attr_sf_entry
*
39 xfs_attr_sf_firstentry(struct xfs_attr_sf_hdr
*hdr
)
41 return (struct xfs_attr_sf_entry
*)(hdr
+ 1);
44 /* next entry after sfep */
45 static inline struct xfs_attr_sf_entry
*
46 xfs_attr_sf_nextentry(struct xfs_attr_sf_entry
*sfep
)
48 return (void *)sfep
+ xfs_attr_sf_entsize(sfep
);
51 /* pointer to the space after the last entry, e.g. for adding a new one */
52 static inline struct xfs_attr_sf_entry
*
53 xfs_attr_sf_endptr(struct xfs_attr_sf_hdr
*sf
)
55 return (void *)sf
+ be16_to_cpu(sf
->totsize
);
58 #endif /* __XFS_ATTR_SF_H__ */