Dave Chinner | 0b61f8a | 2018-06-05 19:42:14 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 3 | * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc. |
| 4 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | */ |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | typedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t; |
| 16 | typedef 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 | */ |
| 21 | typedef struct xfs_attr_sf_sort { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 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) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | xfs_dahash_t hash; /* this entry's hash value */ |
Dave Chinner | a9273ca | 2010-01-20 10:47:48 +1100 | [diff] [blame] | 27 | unsigned char *name; /* name value, pointer into buffer */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | } xfs_attr_sf_sort_t; |
| 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \ |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 31 | (((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \ |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 33 | ((1 << (NBBY*(int)sizeof(uint8_t))) - 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #define XFS_ATTR_SF_ENTSIZE(sfep) /* space an entry uses */ \ |
| 35 | ((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \ |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 37 | ((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \ |
Nathan Scott | 3b244aa | 2006-03-17 17:29:25 +1100 | [diff] [blame] | 39 | (be16_to_cpu(((xfs_attr_shortform_t *) \ |
| 40 | ((dp)->i_afp->if_u1.if_data))->hdr.totsize)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #endif /* __XFS_ATTR_SF_H__ */ |