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 */
21 #define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \
22 ((1 << (NBBY*(int)sizeof(uint8_t))) - 1)
24 /* space name/value uses */
25 static inline int xfs_attr_sf_entsize_byname(uint8_t nlen, uint8_t vlen)
27 return sizeof(struct xfs_attr_sf_entry) + nlen + vlen;
30 /* space an entry uses */
31 static inline int xfs_attr_sf_entsize(struct xfs_attr_sf_entry *sfep)
33 return struct_size(sfep, nameval, sfep->namelen + sfep->valuelen);
36 /* first entry in the SF attr fork */
37 static inline struct xfs_attr_sf_entry *
38 xfs_attr_sf_firstentry(struct xfs_attr_sf_hdr *hdr)
40 return (struct xfs_attr_sf_entry *)(hdr + 1);
43 /* next entry after sfep */
44 static inline struct xfs_attr_sf_entry *
45 xfs_attr_sf_nextentry(struct xfs_attr_sf_entry *sfep)
47 return (void *)sfep + xfs_attr_sf_entsize(sfep);
50 /* pointer to the space after the last entry, e.g. for adding a new one */
51 static inline struct xfs_attr_sf_entry *
52 xfs_attr_sf_endptr(struct xfs_attr_sf_hdr *sf)
54 return (void *)sf + be16_to_cpu(sf->totsize);
57 #endif /* __XFS_ATTR_SF_H__ */