162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc. 462306a36Sopenharmony_ci * All Rights Reserved. 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci#ifndef __XFS_ATTR_SF_H__ 762306a36Sopenharmony_ci#define __XFS_ATTR_SF_H__ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci/* 1062306a36Sopenharmony_ci * Attribute storage when stored inside the inode. 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci * Small attribute lists are packed as tightly as possible so as 1362306a36Sopenharmony_ci * to fit into the literal area of the inode. 1462306a36Sopenharmony_ci */ 1562306a36Sopenharmony_citypedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t; 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci/* 1862306a36Sopenharmony_ci * We generate this then sort it, attr_list() must return things in hash-order. 1962306a36Sopenharmony_ci */ 2062306a36Sopenharmony_citypedef struct xfs_attr_sf_sort { 2162306a36Sopenharmony_ci uint8_t entno; /* entry number in original list */ 2262306a36Sopenharmony_ci uint8_t namelen; /* length of name value (no null) */ 2362306a36Sopenharmony_ci uint8_t valuelen; /* length of value */ 2462306a36Sopenharmony_ci uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */ 2562306a36Sopenharmony_ci xfs_dahash_t hash; /* this entry's hash value */ 2662306a36Sopenharmony_ci unsigned char *name; /* name value, pointer into buffer */ 2762306a36Sopenharmony_ci} xfs_attr_sf_sort_t; 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci#define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \ 3062306a36Sopenharmony_ci ((1 << (NBBY*(int)sizeof(uint8_t))) - 1) 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci/* space name/value uses */ 3362306a36Sopenharmony_cistatic inline int xfs_attr_sf_entsize_byname(uint8_t nlen, uint8_t vlen) 3462306a36Sopenharmony_ci{ 3562306a36Sopenharmony_ci return sizeof(struct xfs_attr_sf_entry) + nlen + vlen; 3662306a36Sopenharmony_ci} 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci/* space an entry uses */ 3962306a36Sopenharmony_cistatic inline int xfs_attr_sf_entsize(struct xfs_attr_sf_entry *sfep) 4062306a36Sopenharmony_ci{ 4162306a36Sopenharmony_ci return struct_size(sfep, nameval, sfep->namelen + sfep->valuelen); 4262306a36Sopenharmony_ci} 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci/* next entry in struct */ 4562306a36Sopenharmony_cistatic inline struct xfs_attr_sf_entry * 4662306a36Sopenharmony_cixfs_attr_sf_nextentry(struct xfs_attr_sf_entry *sfep) 4762306a36Sopenharmony_ci{ 4862306a36Sopenharmony_ci return (void *)sfep + xfs_attr_sf_entsize(sfep); 4962306a36Sopenharmony_ci} 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#endif /* __XFS_ATTR_SF_H__ */ 52