aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dir2_data.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /fs/xfs/xfs_dir2_data.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'fs/xfs/xfs_dir2_data.h')
-rw-r--r--fs/xfs/xfs_dir2_data.h231
1 files changed, 231 insertions, 0 deletions
diff --git a/fs/xfs/xfs_dir2_data.h b/fs/xfs/xfs_dir2_data.h
new file mode 100644
index 000000000000..3f02294ccff0
--- /dev/null
+++ b/fs/xfs/xfs_dir2_data.h
@@ -0,0 +1,231 @@
1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
3 *
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.
7 *
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.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
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.
18 *
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.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32#ifndef __XFS_DIR2_DATA_H__
33#define __XFS_DIR2_DATA_H__
34
35/*
36 * Directory format 2, data block structures.
37 */
38
39struct xfs_dabuf;
40struct xfs_da_args;
41struct xfs_inode;
42struct xfs_trans;
43
44/*
45 * Constants.
46 */
47#define XFS_DIR2_DATA_MAGIC 0x58443244 /* XD2D: for multiblock dirs */
48#define XFS_DIR2_DATA_ALIGN_LOG 3 /* i.e., 8 bytes */
49#define XFS_DIR2_DATA_ALIGN (1 << XFS_DIR2_DATA_ALIGN_LOG)
50#define XFS_DIR2_DATA_FREE_TAG 0xffff
51#define XFS_DIR2_DATA_FD_COUNT 3
52
53/*
54 * Directory address space divided into sections,
55 * spaces separated by 32gb.
56 */
57#define XFS_DIR2_SPACE_SIZE (1ULL << (32 + XFS_DIR2_DATA_ALIGN_LOG))
58#define XFS_DIR2_DATA_SPACE 0
59#define XFS_DIR2_DATA_OFFSET (XFS_DIR2_DATA_SPACE * XFS_DIR2_SPACE_SIZE)
60#define XFS_DIR2_DATA_FIRSTDB(mp) \
61 XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_DATA_OFFSET)
62
63/*
64 * Offsets of . and .. in data space (always block 0)
65 */
66#define XFS_DIR2_DATA_DOT_OFFSET \
67 ((xfs_dir2_data_aoff_t)sizeof(xfs_dir2_data_hdr_t))
68#define XFS_DIR2_DATA_DOTDOT_OFFSET \
69 (XFS_DIR2_DATA_DOT_OFFSET + XFS_DIR2_DATA_ENTSIZE(1))
70#define XFS_DIR2_DATA_FIRST_OFFSET \
71 (XFS_DIR2_DATA_DOTDOT_OFFSET + XFS_DIR2_DATA_ENTSIZE(2))
72
73/*
74 * Structures.
75 */
76
77/*
78 * Describe a free area in the data block.
79 * The freespace will be formatted as a xfs_dir2_data_unused_t.
80 */
81typedef struct xfs_dir2_data_free {
82 xfs_dir2_data_off_t offset; /* start of freespace */
83 xfs_dir2_data_off_t length; /* length of freespace */
84} xfs_dir2_data_free_t;
85
86/*
87 * Header for the data blocks.
88 * Always at the beginning of a directory-sized block.
89 * The code knows that XFS_DIR2_DATA_FD_COUNT is 3.
90 */
91typedef struct xfs_dir2_data_hdr {
92 __uint32_t magic; /* XFS_DIR2_DATA_MAGIC */
93 /* or XFS_DIR2_BLOCK_MAGIC */
94 xfs_dir2_data_free_t bestfree[XFS_DIR2_DATA_FD_COUNT];
95} xfs_dir2_data_hdr_t;
96
97/*
98 * Active entry in a data block. Aligned to 8 bytes.
99 * Tag appears as the last 2 bytes.
100 */
101typedef struct xfs_dir2_data_entry {
102 xfs_ino_t inumber; /* inode number */
103 __uint8_t namelen; /* name length */
104 __uint8_t name[1]; /* name bytes, no null */
105 /* variable offset */
106 xfs_dir2_data_off_t tag; /* starting offset of us */
107} xfs_dir2_data_entry_t;
108
109/*
110 * Unused entry in a data block. Aligned to 8 bytes.
111 * Tag appears as the last 2 bytes.
112 */
113typedef struct xfs_dir2_data_unused {
114 __uint16_t freetag; /* XFS_DIR2_DATA_FREE_TAG */
115 xfs_dir2_data_off_t length; /* total free length */
116 /* variable offset */
117 xfs_dir2_data_off_t tag; /* starting offset of us */
118} xfs_dir2_data_unused_t;
119
120typedef union {
121 xfs_dir2_data_entry_t entry;
122 xfs_dir2_data_unused_t unused;
123} xfs_dir2_data_union_t;
124
125/*
126 * Generic data block structure, for xfs_db.
127 */
128typedef struct xfs_dir2_data {
129 xfs_dir2_data_hdr_t hdr; /* magic XFS_DIR2_DATA_MAGIC */
130 xfs_dir2_data_union_t u[1];
131} xfs_dir2_data_t;
132
133/*
134 * Macros.
135 */
136
137/*
138 * Size of a data entry.
139 */
140#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATA_ENTSIZE)
141int xfs_dir2_data_entsize(int n);
142#define XFS_DIR2_DATA_ENTSIZE(n) xfs_dir2_data_entsize(n)
143#else
144#define XFS_DIR2_DATA_ENTSIZE(n) \
145 ((int)(roundup(offsetof(xfs_dir2_data_entry_t, name[0]) + (n) + \
146 (uint)sizeof(xfs_dir2_data_off_t), XFS_DIR2_DATA_ALIGN)))
147#endif
148
149/*
150 * Pointer to an entry's tag word.
151 */
152#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATA_ENTRY_TAG_P)
153xfs_dir2_data_off_t *xfs_dir2_data_entry_tag_p(xfs_dir2_data_entry_t *dep);
154#define XFS_DIR2_DATA_ENTRY_TAG_P(dep) xfs_dir2_data_entry_tag_p(dep)
155#else
156#define XFS_DIR2_DATA_ENTRY_TAG_P(dep) \
157 ((xfs_dir2_data_off_t *)\
158 ((char *)(dep) + XFS_DIR2_DATA_ENTSIZE((dep)->namelen) - \
159 (uint)sizeof(xfs_dir2_data_off_t)))
160#endif
161
162/*
163 * Pointer to a freespace's tag word.
164 */
165#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATA_UNUSED_TAG_P)
166xfs_dir2_data_off_t *xfs_dir2_data_unused_tag_p(xfs_dir2_data_unused_t *dup);
167#define XFS_DIR2_DATA_UNUSED_TAG_P(dup) \
168 xfs_dir2_data_unused_tag_p(dup)
169#else
170#define XFS_DIR2_DATA_UNUSED_TAG_P(dup) \
171 ((xfs_dir2_data_off_t *)\
172 ((char *)(dup) + INT_GET((dup)->length, ARCH_CONVERT) \
173 - (uint)sizeof(xfs_dir2_data_off_t)))
174#endif
175
176/*
177 * Function declarations.
178 */
179
180#ifdef DEBUG
181extern void
182 xfs_dir2_data_check(struct xfs_inode *dp, struct xfs_dabuf *bp);
183#else
184#define xfs_dir2_data_check(dp,bp)
185#endif
186
187extern xfs_dir2_data_free_t *
188 xfs_dir2_data_freefind(xfs_dir2_data_t *d,
189 xfs_dir2_data_unused_t *dup);
190
191extern xfs_dir2_data_free_t *
192 xfs_dir2_data_freeinsert(xfs_dir2_data_t *d,
193 xfs_dir2_data_unused_t *dup, int *loghead);
194
195extern void
196 xfs_dir2_data_freeremove(xfs_dir2_data_t *d,
197 xfs_dir2_data_free_t *dfp, int *loghead);
198
199extern void
200 xfs_dir2_data_freescan(struct xfs_mount *mp, xfs_dir2_data_t *d,
201 int *loghead, char *aendp);
202
203extern int
204 xfs_dir2_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno,
205 struct xfs_dabuf **bpp);
206
207extern void
208 xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_dabuf *bp,
209 xfs_dir2_data_entry_t *dep);
210
211extern void
212 xfs_dir2_data_log_header(struct xfs_trans *tp, struct xfs_dabuf *bp);
213
214extern void
215 xfs_dir2_data_log_unused(struct xfs_trans *tp, struct xfs_dabuf *bp,
216 xfs_dir2_data_unused_t *dup);
217
218extern void
219 xfs_dir2_data_make_free(struct xfs_trans *tp, struct xfs_dabuf *bp,
220 xfs_dir2_data_aoff_t offset,
221 xfs_dir2_data_aoff_t len, int *needlogp,
222 int *needscanp);
223
224extern void
225 xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_dabuf *bp,
226 xfs_dir2_data_unused_t *dup,
227 xfs_dir2_data_aoff_t offset,
228 xfs_dir2_data_aoff_t len, int *needlogp,
229 int *needscanp);
230
231#endif /* __XFS_DIR2_DATA_H__ */