Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
0004  * All Rights Reserved.
0005  */
0006 #ifndef __XFS_ATTR_SF_H__
0007 #define __XFS_ATTR_SF_H__
0008 
0009 /*
0010  * Attribute storage when stored inside the inode.
0011  *
0012  * Small attribute lists are packed as tightly as possible so as
0013  * to fit into the literal area of the inode.
0014  */
0015 typedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t;
0016 
0017 /*
0018  * We generate this then sort it, attr_list() must return things in hash-order.
0019  */
0020 typedef struct xfs_attr_sf_sort {
0021     uint8_t     entno;      /* entry number in original list */
0022     uint8_t     namelen;    /* length of name value (no null) */
0023     uint8_t     valuelen;   /* length of value */
0024     uint8_t     flags;      /* flags bits (see xfs_attr_leaf.h) */
0025     xfs_dahash_t    hash;       /* this entry's hash value */
0026     unsigned char   *name;      /* name value, pointer into buffer */
0027 } xfs_attr_sf_sort_t;
0028 
0029 #define XFS_ATTR_SF_ENTSIZE_MAX         /* max space for name&value */ \
0030     ((1 << (NBBY*(int)sizeof(uint8_t))) - 1)
0031 
0032 /* space name/value uses */
0033 static inline int xfs_attr_sf_entsize_byname(uint8_t nlen, uint8_t vlen)
0034 {
0035     return sizeof(struct xfs_attr_sf_entry) + nlen + vlen;
0036 }
0037 
0038 /* space an entry uses */
0039 static inline int xfs_attr_sf_entsize(struct xfs_attr_sf_entry *sfep)
0040 {
0041     return struct_size(sfep, nameval, sfep->namelen + sfep->valuelen);
0042 }
0043 
0044 /* next entry in struct */
0045 static inline struct xfs_attr_sf_entry *
0046 xfs_attr_sf_nextentry(struct xfs_attr_sf_entry *sfep)
0047 {
0048     return (void *)sfep + xfs_attr_sf_entsize(sfep);
0049 }
0050 
0051 #endif  /* __XFS_ATTR_SF_H__ */