]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - include/xfs_attr_sf.h
Merge whitespace changes over
[thirdparty/xfsprogs-dev.git] / include / xfs_attr_sf.h
CommitLineData
2bd0ea18 1/*
854f7c66 2 * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved.
5000d01d 3 *
2bd0ea18
NS
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
5000d01d 7 *
2bd0ea18
NS
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5000d01d 11 *
2bd0ea18
NS
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
dfc130f3 14 * or the like. Any license provided herein, whether implied or
2bd0ea18
NS
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
5000d01d 18 *
2bd0ea18
NS
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
5000d01d 22 *
2bd0ea18
NS
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
5000d01d
SL
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
2bd0ea18
NS
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32#ifndef __XFS_ATTR_SF_H__
dfc130f3 33#define __XFS_ATTR_SF_H__
2bd0ea18
NS
34
35/*
36 * Attribute storage when stored inside the inode.
37 *
38 * Small attribute lists are packed as tightly as possible so as
39 * to fit into the literal area of the inode.
40 */
41
42struct xfs_inode;
43
44/*
45 * Entries are packed toward the top as tight as possible.
46 */
47typedef struct xfs_attr_shortform {
48 struct xfs_attr_sf_hdr { /* constant-structure header block */
49 __uint16_t totsize; /* total bytes in shortform list */
50 __uint8_t count; /* count of active entries */
51 } hdr;
52 struct xfs_attr_sf_entry {
53 __uint8_t namelen; /* actual length of name (no NULL) */
54 __uint8_t valuelen; /* actual length of value (no NULL) */
55 __uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
56 __uint8_t nameval[1]; /* name & value bytes concatenated */
57 } list[1]; /* variable sized array */
58} xfs_attr_shortform_t;
59typedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t;
60typedef struct xfs_attr_sf_entry xfs_attr_sf_entry_t;
61
62/*
63 * We generate this then sort it, attr_list() must return things in hash-order.
64 */
65typedef struct xfs_attr_sf_sort {
66 __uint8_t entno; /* entry number in original list */
67 __uint8_t namelen; /* length of name value (no null) */
68 __uint8_t valuelen; /* length of value */
2f8883de 69 __uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
2bd0ea18
NS
70 xfs_dahash_t hash; /* this entry's hash value */
71 char *name; /* name value, pointer into buffer */
72} xfs_attr_sf_sort_t;
73
74#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_ENTSIZE_BYNAME)
75int xfs_attr_sf_entsize_byname(int nlen, int vlen);
76#define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) \
77 xfs_attr_sf_entsize_byname(nlen,vlen)
78#else
79#define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \
80 ((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen))
81#endif
82#define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \
83 ((1 << (NBBY*(int)sizeof(__uint8_t))) - 1)
84#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_ENTSIZE)
85int xfs_attr_sf_entsize(xfs_attr_sf_entry_t *sfep);
86#define XFS_ATTR_SF_ENTSIZE(sfep) xfs_attr_sf_entsize(sfep)
87#else
88#define XFS_ATTR_SF_ENTSIZE(sfep) /* space an entry uses */ \
89 ((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen)
90#endif
91#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_NEXTENTRY)
92xfs_attr_sf_entry_t *xfs_attr_sf_nextentry(xfs_attr_sf_entry_t *sfep);
93#define XFS_ATTR_SF_NEXTENTRY(sfep) xfs_attr_sf_nextentry(sfep)
94#else
95#define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \
96 ((xfs_attr_sf_entry_t *) \
97 ((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep)))
98#endif
99#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_TOTSIZE)
100int xfs_attr_sf_totsize(struct xfs_inode *dp);
101#define XFS_ATTR_SF_TOTSIZE(dp) xfs_attr_sf_totsize(dp)
102#else
103#define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \
104 (INT_GET(((xfs_attr_shortform_t *)((dp)->i_afp->if_u1.if_data))->hdr.totsize, ARCH_CONVERT))
105#endif
106
107#ifdef XFS_ALL_TRACE
dfc130f3 108#define XFS_ATTR_TRACE
2bd0ea18
NS
109#endif
110
111#if !defined(DEBUG)
112#undef XFS_ATTR_TRACE
113#endif
114
115/*
116 * Kernel tracing support for attribute lists
117 */
118struct xfs_attr_list_context;
119struct xfs_da_intnode;
120struct xfs_da_node_entry;
121struct xfs_attr_leafblock;
122
dfc130f3 123#define XFS_ATTR_TRACE_SIZE 4096 /* size of global trace buffer */
2bd0ea18
NS
124
125/*
126 * Trace record types.
127 */
dfc130f3
RC
128#define XFS_ATTR_KTRACE_L_C 1 /* context */
129#define XFS_ATTR_KTRACE_L_CN 2 /* context, node */
130#define XFS_ATTR_KTRACE_L_CB 3 /* context, btree */
131#define XFS_ATTR_KTRACE_L_CL 4 /* context, leaf */
2bd0ea18
NS
132
133#if defined(XFS_ATTR_TRACE)
134
135void xfs_attr_trace_l_c(char *where, struct xfs_attr_list_context *context);
136void xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context,
137 struct xfs_da_intnode *node);
138void xfs_attr_trace_l_cb(char *where, struct xfs_attr_list_context *context,
139 struct xfs_da_node_entry *btree);
140void xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context,
141 struct xfs_attr_leafblock *leaf);
142void xfs_attr_trace_enter(int type, char *where,
143 __psunsigned_t a2, __psunsigned_t a3,
144 __psunsigned_t a4, __psunsigned_t a5,
145 __psunsigned_t a6, __psunsigned_t a7,
146 __psunsigned_t a8, __psunsigned_t a9,
147 __psunsigned_t a10, __psunsigned_t a11,
148 __psunsigned_t a12, __psunsigned_t a13,
149 __psunsigned_t a14, __psunsigned_t a15);
150#else
dfc130f3
RC
151#define xfs_attr_trace_l_c(w,c)
152#define xfs_attr_trace_l_cn(w,c,n)
153#define xfs_attr_trace_l_cb(w,c,b)
154#define xfs_attr_trace_l_cl(w,c,l)
2bd0ea18
NS
155#endif /* XFS_ATTR_TRACE */
156
157#endif /* __XFS_ATTR_SF_H__ */