brintos

brintos / linux-shallow public Read only

0
0
Text · 1.7 KiB · 73bdc0e Raw
59 lines · c
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 * We generate this then sort it, attr_list() must return things in hash-order.11 */12typedef 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 */19	void		*value;20} xfs_attr_sf_sort_t;21 22#define XFS_ATTR_SF_ENTSIZE_MAX			/* max space for name&value */ \23	((1 << (NBBY*(int)sizeof(uint8_t))) - 1)24 25/* space name/value uses */26static inline int xfs_attr_sf_entsize_byname(uint8_t nlen, uint8_t vlen)27{28	return sizeof(struct xfs_attr_sf_entry) + nlen + vlen;29}30 31/* space an entry uses */32static inline int xfs_attr_sf_entsize(struct xfs_attr_sf_entry *sfep)33{34	return struct_size(sfep, nameval, sfep->namelen + sfep->valuelen);35}36 37/* first entry in the SF attr fork */38static inline struct xfs_attr_sf_entry *39xfs_attr_sf_firstentry(struct xfs_attr_sf_hdr *hdr)40{41	return (struct xfs_attr_sf_entry *)(hdr + 1);42}43 44/* next entry after sfep */45static inline struct xfs_attr_sf_entry *46xfs_attr_sf_nextentry(struct xfs_attr_sf_entry *sfep)47{48	return (void *)sfep + xfs_attr_sf_entsize(sfep);49}50 51/* pointer to the space after the last entry, e.g. for adding a new one */52static inline struct xfs_attr_sf_entry *53xfs_attr_sf_endptr(struct xfs_attr_sf_hdr *sf)54{55	return (void *)sf + be16_to_cpu(sf->totsize);56}57 58#endif	/* __XFS_ATTR_SF_H__ */59