]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - libxfs/xfs_attr_sf.h
xfs: fix transaction leak on remote attr set/remove failure
[thirdparty/xfsprogs-dev.git] / libxfs / xfs_attr_sf.h
CommitLineData
37b3b4d6 1// SPDX-License-Identifier: GPL-2.0
2bd0ea18 2/*
f302e9e4
NS
3 * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
2bd0ea18
NS
5 */
6#ifndef __XFS_ATTR_SF_H__
dfc130f3 7#define __XFS_ATTR_SF_H__
2bd0ea18
NS
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 */
2bd0ea18
NS
15typedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t;
16typedef struct xfs_attr_sf_entry xfs_attr_sf_entry_t;
17
18/*
19 * We generate this then sort it, attr_list() must return things in hash-order.
20 */
21typedef struct xfs_attr_sf_sort {
4a492e72
DW
22 uint8_t entno; /* entry number in original list */
23 uint8_t namelen; /* length of name value (no null) */
24 uint8_t valuelen; /* length of value */
25 uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
2bd0ea18 26 xfs_dahash_t hash; /* this entry's hash value */
56b2de80 27 unsigned char *name; /* name value, pointer into buffer */
2bd0ea18
NS
28} xfs_attr_sf_sort_t;
29
2bd0ea18 30#define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \
f302e9e4 31 (((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen)))
2bd0ea18 32#define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \
4a492e72 33 ((1 << (NBBY*(int)sizeof(uint8_t))) - 1)
2bd0ea18
NS
34#define XFS_ATTR_SF_ENTSIZE(sfep) /* space an entry uses */ \
35 ((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen)
2bd0ea18 36#define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \
f302e9e4 37 ((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep)))
2bd0ea18 38#define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \
5e656dbb
BN
39 (be16_to_cpu(((xfs_attr_shortform_t *) \
40 ((dp)->i_afp->if_u1.if_data))->hdr.totsize))
2bd0ea18 41
2bd0ea18 42#endif /* __XFS_ATTR_SF_H__ */