blob: aafa4fe706240e3575448253b6d085be3711c504 [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Nathan Scott7b718762005-11-02 14:58:39 +11003 * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
6#ifndef __XFS_ATTR_SF_H__
7#define __XFS_ATTR_SF_H__
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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070015typedef 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 {
Darrick J. Wongc8ce5402017-06-16 11:00:05 -070022 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) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 xfs_dahash_t hash; /* this entry's hash value */
Dave Chinnera9273ca2010-01-20 10:47:48 +110027 unsigned char *name; /* name value, pointer into buffer */
Linus Torvalds1da177e2005-04-16 15:20:36 -070028} xfs_attr_sf_sort_t;
29
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \
Nathan Scotta844f452005-11-02 14:38:42 +110031 (((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen)))
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \
Darrick J. Wongc8ce5402017-06-16 11:00:05 -070033 ((1 << (NBBY*(int)sizeof(uint8_t))) - 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#define XFS_ATTR_SF_ENTSIZE(sfep) /* space an entry uses */ \
35 ((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen)
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \
Nathan Scotta844f452005-11-02 14:38:42 +110037 ((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep)))
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \
Nathan Scott3b244aa2006-03-17 17:29:25 +110039 (be16_to_cpu(((xfs_attr_shortform_t *) \
40 ((dp)->i_afp->if_u1.if_data))->hdr.totsize))
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#endif /* __XFS_ATTR_SF_H__ */