lfs_accessors.h revision 1.49 1 1.49 riastrad /* $NetBSD: lfs_accessors.h,v 1.49 2020/03/21 06:11:05 riastradh Exp $ */
2 1.1 dholland
3 1.1 dholland /* from NetBSD: lfs.h,v 1.165 2015/07/24 06:59:32 dholland Exp */
4 1.46 dholland /* from NetBSD: dinode.h,v 1.25 2016/01/22 23:06:10 dholland Exp */
5 1.45 dholland /* from NetBSD: dir.h,v 1.25 2015/09/01 06:16:03 dholland Exp */
6 1.1 dholland
7 1.1 dholland /*-
8 1.1 dholland * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
9 1.1 dholland * All rights reserved.
10 1.1 dholland *
11 1.1 dholland * This code is derived from software contributed to The NetBSD Foundation
12 1.1 dholland * by Konrad E. Schroder <perseant (at) hhhh.org>.
13 1.1 dholland *
14 1.1 dholland * Redistribution and use in source and binary forms, with or without
15 1.1 dholland * modification, are permitted provided that the following conditions
16 1.1 dholland * are met:
17 1.1 dholland * 1. Redistributions of source code must retain the above copyright
18 1.1 dholland * notice, this list of conditions and the following disclaimer.
19 1.1 dholland * 2. Redistributions in binary form must reproduce the above copyright
20 1.1 dholland * notice, this list of conditions and the following disclaimer in the
21 1.1 dholland * documentation and/or other materials provided with the distribution.
22 1.1 dholland *
23 1.1 dholland * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 1.1 dholland * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 1.1 dholland * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 1.1 dholland * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 1.1 dholland * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 1.1 dholland * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 1.1 dholland * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 1.1 dholland * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 1.1 dholland * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 1.1 dholland * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 1.1 dholland * POSSIBILITY OF SUCH DAMAGE.
34 1.1 dholland */
35 1.1 dholland /*-
36 1.1 dholland * Copyright (c) 1991, 1993
37 1.1 dholland * The Regents of the University of California. All rights reserved.
38 1.1 dholland *
39 1.1 dholland * Redistribution and use in source and binary forms, with or without
40 1.1 dholland * modification, are permitted provided that the following conditions
41 1.1 dholland * are met:
42 1.1 dholland * 1. Redistributions of source code must retain the above copyright
43 1.1 dholland * notice, this list of conditions and the following disclaimer.
44 1.1 dholland * 2. Redistributions in binary form must reproduce the above copyright
45 1.1 dholland * notice, this list of conditions and the following disclaimer in the
46 1.1 dholland * documentation and/or other materials provided with the distribution.
47 1.1 dholland * 3. Neither the name of the University nor the names of its contributors
48 1.1 dholland * may be used to endorse or promote products derived from this software
49 1.1 dholland * without specific prior written permission.
50 1.1 dholland *
51 1.1 dholland * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
52 1.1 dholland * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 1.1 dholland * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 1.1 dholland * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
55 1.1 dholland * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56 1.1 dholland * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57 1.1 dholland * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 1.1 dholland * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59 1.1 dholland * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60 1.1 dholland * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61 1.1 dholland * SUCH DAMAGE.
62 1.1 dholland *
63 1.1 dholland * @(#)lfs.h 8.9 (Berkeley) 5/8/95
64 1.1 dholland */
65 1.1 dholland /*
66 1.1 dholland * Copyright (c) 2002 Networks Associates Technology, Inc.
67 1.1 dholland * All rights reserved.
68 1.1 dholland *
69 1.1 dholland * This software was developed for the FreeBSD Project by Marshall
70 1.1 dholland * Kirk McKusick and Network Associates Laboratories, the Security
71 1.1 dholland * Research Division of Network Associates, Inc. under DARPA/SPAWAR
72 1.1 dholland * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS
73 1.1 dholland * research program
74 1.1 dholland *
75 1.1 dholland * Copyright (c) 1982, 1989, 1993
76 1.1 dholland * The Regents of the University of California. All rights reserved.
77 1.1 dholland * (c) UNIX System Laboratories, Inc.
78 1.1 dholland * All or some portions of this file are derived from material licensed
79 1.1 dholland * to the University of California by American Telephone and Telegraph
80 1.1 dholland * Co. or Unix System Laboratories, Inc. and are reproduced herein with
81 1.1 dholland * the permission of UNIX System Laboratories, Inc.
82 1.1 dholland *
83 1.1 dholland * Redistribution and use in source and binary forms, with or without
84 1.1 dholland * modification, are permitted provided that the following conditions
85 1.1 dholland * are met:
86 1.1 dholland * 1. Redistributions of source code must retain the above copyright
87 1.1 dholland * notice, this list of conditions and the following disclaimer.
88 1.1 dholland * 2. Redistributions in binary form must reproduce the above copyright
89 1.1 dholland * notice, this list of conditions and the following disclaimer in the
90 1.1 dholland * documentation and/or other materials provided with the distribution.
91 1.1 dholland * 3. Neither the name of the University nor the names of its contributors
92 1.1 dholland * may be used to endorse or promote products derived from this software
93 1.1 dholland * without specific prior written permission.
94 1.1 dholland *
95 1.1 dholland * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
96 1.1 dholland * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
97 1.1 dholland * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
98 1.1 dholland * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
99 1.1 dholland * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
100 1.1 dholland * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
101 1.1 dholland * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
102 1.1 dholland * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
103 1.1 dholland * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
104 1.1 dholland * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
105 1.1 dholland * SUCH DAMAGE.
106 1.1 dholland *
107 1.1 dholland * @(#)dinode.h 8.9 (Berkeley) 3/29/95
108 1.1 dholland */
109 1.1 dholland /*
110 1.1 dholland * Copyright (c) 1982, 1986, 1989, 1993
111 1.1 dholland * The Regents of the University of California. All rights reserved.
112 1.1 dholland * (c) UNIX System Laboratories, Inc.
113 1.1 dholland * All or some portions of this file are derived from material licensed
114 1.1 dholland * to the University of California by American Telephone and Telegraph
115 1.1 dholland * Co. or Unix System Laboratories, Inc. and are reproduced herein with
116 1.1 dholland * the permission of UNIX System Laboratories, Inc.
117 1.1 dholland *
118 1.1 dholland * Redistribution and use in source and binary forms, with or without
119 1.1 dholland * modification, are permitted provided that the following conditions
120 1.1 dholland * are met:
121 1.1 dholland * 1. Redistributions of source code must retain the above copyright
122 1.1 dholland * notice, this list of conditions and the following disclaimer.
123 1.1 dholland * 2. Redistributions in binary form must reproduce the above copyright
124 1.1 dholland * notice, this list of conditions and the following disclaimer in the
125 1.1 dholland * documentation and/or other materials provided with the distribution.
126 1.1 dholland * 3. Neither the name of the University nor the names of its contributors
127 1.1 dholland * may be used to endorse or promote products derived from this software
128 1.1 dholland * without specific prior written permission.
129 1.1 dholland *
130 1.1 dholland * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
131 1.1 dholland * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
132 1.1 dholland * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
133 1.1 dholland * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
134 1.1 dholland * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
135 1.1 dholland * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
136 1.1 dholland * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
137 1.1 dholland * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
138 1.1 dholland * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
139 1.1 dholland * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
140 1.1 dholland * SUCH DAMAGE.
141 1.1 dholland *
142 1.1 dholland * @(#)dir.h 8.5 (Berkeley) 4/27/95
143 1.1 dholland */
144 1.1 dholland
145 1.1 dholland #ifndef _UFS_LFS_LFS_ACCESSORS_H_
146 1.1 dholland #define _UFS_LFS_LFS_ACCESSORS_H_
147 1.1 dholland
148 1.17 dholland #if defined(_KERNEL_OPT)
149 1.17 dholland #include "opt_lfs.h"
150 1.17 dholland #endif
151 1.17 dholland
152 1.17 dholland #include <sys/bswap.h>
153 1.17 dholland
154 1.43 riastrad #include <ufs/lfs/lfs.h>
155 1.43 riastrad
156 1.11 dholland #if !defined(_KERNEL) && !defined(_STANDALONE)
157 1.11 dholland #include <assert.h>
158 1.43 riastrad #include <string.h>
159 1.11 dholland #define KASSERT assert
160 1.43 riastrad #else
161 1.43 riastrad #include <sys/systm.h>
162 1.11 dholland #endif
163 1.11 dholland
164 1.1 dholland /*
165 1.9 dholland * STRUCT_LFS is used by the libsa code to get accessors that work
166 1.9 dholland * with struct salfs instead of struct lfs, and by the cleaner to
167 1.9 dholland * get accessors that work with struct clfs.
168 1.9 dholland */
169 1.9 dholland
170 1.9 dholland #ifndef STRUCT_LFS
171 1.9 dholland #define STRUCT_LFS struct lfs
172 1.9 dholland #endif
173 1.9 dholland
174 1.13 dholland /*
175 1.17 dholland * byte order
176 1.17 dholland */
177 1.17 dholland
178 1.17 dholland /*
179 1.17 dholland * For now at least, the bootblocks shall not be endian-independent.
180 1.17 dholland * We can see later if it fits in the size budget. Also disable the
181 1.17 dholland * byteswapping if LFS_EI is off.
182 1.17 dholland *
183 1.17 dholland * Caution: these functions "know" that bswap16/32/64 are unsigned,
184 1.17 dholland * and if that changes will likely break silently.
185 1.17 dholland */
186 1.17 dholland
187 1.17 dholland #if defined(_STANDALONE) || (defined(_KERNEL) && !defined(LFS_EI))
188 1.17 dholland #define LFS_SWAP_int16_t(fs, val) (val)
189 1.17 dholland #define LFS_SWAP_int32_t(fs, val) (val)
190 1.17 dholland #define LFS_SWAP_int64_t(fs, val) (val)
191 1.17 dholland #define LFS_SWAP_uint16_t(fs, val) (val)
192 1.17 dholland #define LFS_SWAP_uint32_t(fs, val) (val)
193 1.17 dholland #define LFS_SWAP_uint64_t(fs, val) (val)
194 1.17 dholland #else
195 1.17 dholland #define LFS_SWAP_int16_t(fs, val) \
196 1.17 dholland ((fs)->lfs_dobyteswap ? (int16_t)bswap16(val) : (val))
197 1.17 dholland #define LFS_SWAP_int32_t(fs, val) \
198 1.17 dholland ((fs)->lfs_dobyteswap ? (int32_t)bswap32(val) : (val))
199 1.17 dholland #define LFS_SWAP_int64_t(fs, val) \
200 1.17 dholland ((fs)->lfs_dobyteswap ? (int64_t)bswap64(val) : (val))
201 1.17 dholland #define LFS_SWAP_uint16_t(fs, val) \
202 1.17 dholland ((fs)->lfs_dobyteswap ? bswap16(val) : (val))
203 1.17 dholland #define LFS_SWAP_uint32_t(fs, val) \
204 1.17 dholland ((fs)->lfs_dobyteswap ? bswap32(val) : (val))
205 1.17 dholland #define LFS_SWAP_uint64_t(fs, val) \
206 1.17 dholland ((fs)->lfs_dobyteswap ? bswap64(val) : (val))
207 1.17 dholland #endif
208 1.17 dholland
209 1.17 dholland /*
210 1.22 dholland * For handling directories we will need to know if the volume is
211 1.22 dholland * little-endian.
212 1.22 dholland */
213 1.22 dholland #if BYTE_ORDER == LITTLE_ENDIAN
214 1.22 dholland #define LFS_LITTLE_ENDIAN_ONDISK(fs) (!(fs)->lfs_dobyteswap)
215 1.22 dholland #else
216 1.22 dholland #define LFS_LITTLE_ENDIAN_ONDISK(fs) ((fs)->lfs_dobyteswap)
217 1.22 dholland #endif
218 1.22 dholland
219 1.22 dholland
220 1.22 dholland /*
221 1.22 dholland * directories
222 1.22 dholland */
223 1.22 dholland
224 1.31 dholland #define LFS_DIRHEADERSIZE(fs) \
225 1.31 dholland ((fs)->lfs_is64 ? sizeof(struct lfs_dirheader64) : sizeof(struct lfs_dirheader32))
226 1.31 dholland
227 1.22 dholland /*
228 1.22 dholland * The LFS_DIRSIZ macro gives the minimum record length which will hold
229 1.22 dholland * the directory entry. This requires the amount of space in struct lfs_direct
230 1.22 dholland * without the d_name field, plus enough space for the name with a terminating
231 1.22 dholland * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
232 1.22 dholland */
233 1.30 dholland #define LFS_DIRECTSIZ(fs, namlen) \
234 1.31 dholland (LFS_DIRHEADERSIZE(fs) + (((namlen)+1 + 3) &~ 3))
235 1.22 dholland
236 1.30 dholland /*
237 1.30 dholland * The size of the largest possible directory entry. This is
238 1.30 dholland * used by ulfs_dirhash to figure the size of an array, so we
239 1.30 dholland * need a single constant value true for both lfs32 and lfs64.
240 1.30 dholland */
241 1.30 dholland #define LFS_MAXDIRENTRYSIZE \
242 1.31 dholland (sizeof(struct lfs_dirheader64) + (((LFS_MAXNAMLEN+1)+1 + 3) & ~3))
243 1.30 dholland
244 1.22 dholland #if (BYTE_ORDER == LITTLE_ENDIAN)
245 1.22 dholland #define LFS_OLDDIRSIZ(oldfmt, dp, needswap) \
246 1.22 dholland (((oldfmt) && !(needswap)) ? \
247 1.22 dholland LFS_DIRECTSIZ((dp)->d_type) : LFS_DIRECTSIZ((dp)->d_namlen))
248 1.22 dholland #else
249 1.22 dholland #define LFS_OLDDIRSIZ(oldfmt, dp, needswap) \
250 1.22 dholland (((oldfmt) && (needswap)) ? \
251 1.22 dholland LFS_DIRECTSIZ((dp)->d_type) : LFS_DIRECTSIZ((dp)->d_namlen))
252 1.22 dholland #endif
253 1.22 dholland
254 1.30 dholland #define LFS_DIRSIZ(fs, dp) LFS_DIRECTSIZ(fs, lfs_dir_getnamlen(fs, dp))
255 1.22 dholland
256 1.22 dholland /* Constants for the first argument of LFS_OLDDIRSIZ */
257 1.22 dholland #define LFS_OLDDIRFMT 1
258 1.22 dholland #define LFS_NEWDIRFMT 0
259 1.22 dholland
260 1.23 dholland #define LFS_NEXTDIR(fs, dp) \
261 1.31 dholland ((LFS_DIRHEADER *)((char *)(dp) + lfs_dir_getreclen(fs, dp)))
262 1.23 dholland
263 1.42 christos static __inline char *
264 1.31 dholland lfs_dir_nameptr(const STRUCT_LFS *fs, LFS_DIRHEADER *dh)
265 1.26 dholland {
266 1.31 dholland if (fs->lfs_is64) {
267 1.31 dholland return (char *)(&dh->u_64 + 1);
268 1.31 dholland } else {
269 1.31 dholland return (char *)(&dh->u_32 + 1);
270 1.31 dholland }
271 1.26 dholland }
272 1.26 dholland
273 1.42 christos static __inline uint64_t
274 1.31 dholland lfs_dir_getino(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh)
275 1.23 dholland {
276 1.31 dholland if (fs->lfs_is64) {
277 1.49 riastrad return LFS_SWAP_uint64_t(fs, dh->u_64.dh_ino);
278 1.31 dholland } else {
279 1.31 dholland return LFS_SWAP_uint32_t(fs, dh->u_32.dh_ino);
280 1.31 dholland }
281 1.23 dholland }
282 1.23 dholland
283 1.42 christos static __inline uint16_t
284 1.31 dholland lfs_dir_getreclen(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh)
285 1.23 dholland {
286 1.31 dholland if (fs->lfs_is64) {
287 1.31 dholland return LFS_SWAP_uint16_t(fs, dh->u_64.dh_reclen);
288 1.31 dholland } else {
289 1.31 dholland return LFS_SWAP_uint16_t(fs, dh->u_32.dh_reclen);
290 1.31 dholland }
291 1.23 dholland }
292 1.23 dholland
293 1.42 christos static __inline uint8_t
294 1.31 dholland lfs_dir_gettype(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh)
295 1.22 dholland {
296 1.31 dholland if (fs->lfs_is64) {
297 1.31 dholland KASSERT(fs->lfs_hasolddirfmt == 0);
298 1.31 dholland return dh->u_64.dh_type;
299 1.31 dholland } else if (fs->lfs_hasolddirfmt) {
300 1.22 dholland return LFS_DT_UNKNOWN;
301 1.31 dholland } else {
302 1.31 dholland return dh->u_32.dh_type;
303 1.22 dholland }
304 1.22 dholland }
305 1.22 dholland
306 1.42 christos static __inline uint8_t
307 1.31 dholland lfs_dir_getnamlen(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh)
308 1.22 dholland {
309 1.31 dholland if (fs->lfs_is64) {
310 1.31 dholland KASSERT(fs->lfs_hasolddirfmt == 0);
311 1.40 dholland return dh->u_64.dh_namlen;
312 1.31 dholland } else if (fs->lfs_hasolddirfmt && LFS_LITTLE_ENDIAN_ONDISK(fs)) {
313 1.22 dholland /* low-order byte of old 16-bit namlen field */
314 1.31 dholland return dh->u_32.dh_type;
315 1.31 dholland } else {
316 1.31 dholland return dh->u_32.dh_namlen;
317 1.22 dholland }
318 1.22 dholland }
319 1.22 dholland
320 1.42 christos static __inline void
321 1.31 dholland lfs_dir_setino(STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint64_t ino)
322 1.23 dholland {
323 1.31 dholland if (fs->lfs_is64) {
324 1.49 riastrad dh->u_64.dh_ino = LFS_SWAP_uint64_t(fs, ino);
325 1.31 dholland } else {
326 1.31 dholland dh->u_32.dh_ino = LFS_SWAP_uint32_t(fs, ino);
327 1.31 dholland }
328 1.23 dholland }
329 1.23 dholland
330 1.42 christos static __inline void
331 1.31 dholland lfs_dir_setreclen(STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint16_t reclen)
332 1.23 dholland {
333 1.31 dholland if (fs->lfs_is64) {
334 1.31 dholland dh->u_64.dh_reclen = LFS_SWAP_uint16_t(fs, reclen);
335 1.31 dholland } else {
336 1.31 dholland dh->u_32.dh_reclen = LFS_SWAP_uint16_t(fs, reclen);
337 1.31 dholland }
338 1.23 dholland }
339 1.23 dholland
340 1.42 christos static __inline void
341 1.31 dholland lfs_dir_settype(const STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint8_t type)
342 1.22 dholland {
343 1.31 dholland if (fs->lfs_is64) {
344 1.31 dholland KASSERT(fs->lfs_hasolddirfmt == 0);
345 1.31 dholland dh->u_64.dh_type = type;
346 1.31 dholland } else if (fs->lfs_hasolddirfmt) {
347 1.22 dholland /* do nothing */
348 1.22 dholland return;
349 1.31 dholland } else {
350 1.31 dholland dh->u_32.dh_type = type;
351 1.22 dholland }
352 1.22 dholland }
353 1.22 dholland
354 1.42 christos static __inline void
355 1.31 dholland lfs_dir_setnamlen(const STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint8_t namlen)
356 1.22 dholland {
357 1.31 dholland if (fs->lfs_is64) {
358 1.31 dholland KASSERT(fs->lfs_hasolddirfmt == 0);
359 1.31 dholland dh->u_64.dh_namlen = namlen;
360 1.31 dholland } else if (fs->lfs_hasolddirfmt && LFS_LITTLE_ENDIAN_ONDISK(fs)) {
361 1.22 dholland /* low-order byte of old 16-bit namlen field */
362 1.31 dholland dh->u_32.dh_type = namlen;
363 1.31 dholland } else {
364 1.31 dholland dh->u_32.dh_namlen = namlen;
365 1.22 dholland }
366 1.22 dholland }
367 1.22 dholland
368 1.42 christos static __inline void
369 1.25 dholland lfs_copydirname(STRUCT_LFS *fs, char *dest, const char *src,
370 1.25 dholland unsigned namlen, unsigned reclen)
371 1.25 dholland {
372 1.28 dholland unsigned spacelen;
373 1.28 dholland
374 1.31 dholland KASSERT(reclen > LFS_DIRHEADERSIZE(fs));
375 1.31 dholland spacelen = reclen - LFS_DIRHEADERSIZE(fs);
376 1.28 dholland
377 1.25 dholland /* must always be at least 1 byte as a null terminator */
378 1.28 dholland KASSERT(spacelen > namlen);
379 1.25 dholland
380 1.25 dholland memcpy(dest, src, namlen);
381 1.28 dholland memset(dest + namlen, '\0', spacelen - namlen);
382 1.25 dholland }
383 1.25 dholland
384 1.42 christos static __inline LFS_DIRHEADER *
385 1.31 dholland lfs_dirtemplate_dotdot(STRUCT_LFS *fs, union lfs_dirtemplate *dt)
386 1.31 dholland {
387 1.31 dholland /* XXX blah, be nice to have a way to do this w/o casts */
388 1.31 dholland if (fs->lfs_is64) {
389 1.31 dholland return (LFS_DIRHEADER *)&dt->u_64.dotdot_header;
390 1.31 dholland } else {
391 1.31 dholland return (LFS_DIRHEADER *)&dt->u_32.dotdot_header;
392 1.31 dholland }
393 1.31 dholland }
394 1.31 dholland
395 1.42 christos static __inline char *
396 1.31 dholland lfs_dirtemplate_dotdotname(STRUCT_LFS *fs, union lfs_dirtemplate *dt)
397 1.31 dholland {
398 1.31 dholland if (fs->lfs_is64) {
399 1.31 dholland return dt->u_64.dotdot_name;
400 1.31 dholland } else {
401 1.31 dholland return dt->u_32.dotdot_name;
402 1.31 dholland }
403 1.31 dholland }
404 1.31 dholland
405 1.22 dholland /*
406 1.13 dholland * dinodes
407 1.13 dholland */
408 1.9 dholland
409 1.9 dholland /*
410 1.1 dholland * Maximum length of a symlink that can be stored within the inode.
411 1.1 dholland */
412 1.20 dholland #define LFS32_MAXSYMLINKLEN ((ULFS_NDADDR + ULFS_NIADDR) * sizeof(int32_t))
413 1.20 dholland #define LFS64_MAXSYMLINKLEN ((ULFS_NDADDR + ULFS_NIADDR) * sizeof(int64_t))
414 1.1 dholland
415 1.20 dholland #define LFS_MAXSYMLINKLEN(fs) \
416 1.20 dholland ((fs)->lfs_is64 ? LFS64_MAXSYMLINKLEN : LFS32_MAXSYMLINKLEN)
417 1.20 dholland
418 1.13 dholland #define DINOSIZE(fs) ((fs)->lfs_is64 ? sizeof(struct lfs64_dinode) : sizeof(struct lfs32_dinode))
419 1.13 dholland
420 1.13 dholland #define DINO_IN_BLOCK(fs, base, ix) \
421 1.13 dholland ((union lfs_dinode *)((char *)(base) + DINOSIZE(fs) * (ix)))
422 1.13 dholland
423 1.42 christos static __inline void
424 1.14 dholland lfs_copy_dinode(STRUCT_LFS *fs,
425 1.14 dholland union lfs_dinode *dst, const union lfs_dinode *src)
426 1.14 dholland {
427 1.14 dholland /*
428 1.14 dholland * We can do structure assignment of the structs, but not of
429 1.14 dholland * the whole union, as the union is the size of the (larger)
430 1.14 dholland * 64-bit struct and on a 32-bit fs the upper half of it might
431 1.14 dholland * be off the end of a buffer or otherwise invalid.
432 1.14 dholland */
433 1.14 dholland if (fs->lfs_is64) {
434 1.14 dholland dst->u_64 = src->u_64;
435 1.14 dholland } else {
436 1.14 dholland dst->u_32 = src->u_32;
437 1.14 dholland }
438 1.14 dholland }
439 1.14 dholland
440 1.13 dholland #define LFS_DEF_DINO_ACCESSOR(type, type32, field) \
441 1.42 christos static __inline type \
442 1.13 dholland lfs_dino_get##field(STRUCT_LFS *fs, union lfs_dinode *dip) \
443 1.13 dholland { \
444 1.13 dholland if (fs->lfs_is64) { \
445 1.17 dholland return LFS_SWAP_##type(fs, dip->u_64.di_##field); \
446 1.13 dholland } else { \
447 1.17 dholland return LFS_SWAP_##type32(fs, dip->u_32.di_##field); \
448 1.13 dholland } \
449 1.13 dholland } \
450 1.42 christos static __inline void \
451 1.13 dholland lfs_dino_set##field(STRUCT_LFS *fs, union lfs_dinode *dip, type val) \
452 1.13 dholland { \
453 1.13 dholland if (fs->lfs_is64) { \
454 1.13 dholland type *p = &dip->u_64.di_##field; \
455 1.13 dholland (void)p; \
456 1.17 dholland dip->u_64.di_##field = LFS_SWAP_##type(fs, val); \
457 1.13 dholland } else { \
458 1.13 dholland type32 *p = &dip->u_32.di_##field; \
459 1.13 dholland (void)p; \
460 1.17 dholland dip->u_32.di_##field = LFS_SWAP_##type32(fs, val); \
461 1.13 dholland } \
462 1.13 dholland } \
463 1.13 dholland
464 1.13 dholland LFS_DEF_DINO_ACCESSOR(uint16_t, uint16_t, mode);
465 1.13 dholland LFS_DEF_DINO_ACCESSOR(int16_t, int16_t, nlink);
466 1.13 dholland LFS_DEF_DINO_ACCESSOR(uint64_t, uint32_t, inumber);
467 1.13 dholland LFS_DEF_DINO_ACCESSOR(uint64_t, uint64_t, size);
468 1.13 dholland LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, atime);
469 1.13 dholland LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, atimensec);
470 1.13 dholland LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, mtime);
471 1.13 dholland LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, mtimensec);
472 1.13 dholland LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, ctime);
473 1.13 dholland LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, ctimensec);
474 1.13 dholland LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, flags);
475 1.13 dholland LFS_DEF_DINO_ACCESSOR(uint64_t, uint32_t, blocks);
476 1.13 dholland LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, gen);
477 1.13 dholland LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, uid);
478 1.13 dholland LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, gid);
479 1.13 dholland
480 1.16 dholland /* XXX this should be done differently (it's a fake field) */
481 1.43 riastrad LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, rdev);
482 1.16 dholland
483 1.42 christos static __inline daddr_t
484 1.13 dholland lfs_dino_getdb(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix)
485 1.13 dholland {
486 1.13 dholland KASSERT(ix < ULFS_NDADDR);
487 1.13 dholland if (fs->lfs_is64) {
488 1.47 christos return LFS_SWAP_int64_t(fs, dip->u_64.di_db[ix]);
489 1.13 dholland } else {
490 1.36 dholland /* note: this must sign-extend or UNWRITTEN gets trashed */
491 1.47 christos return (int32_t)LFS_SWAP_int32_t(fs, dip->u_32.di_db[ix]);
492 1.13 dholland }
493 1.13 dholland }
494 1.13 dholland
495 1.42 christos static __inline daddr_t
496 1.13 dholland lfs_dino_getib(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix)
497 1.13 dholland {
498 1.13 dholland KASSERT(ix < ULFS_NIADDR);
499 1.13 dholland if (fs->lfs_is64) {
500 1.47 christos return LFS_SWAP_int64_t(fs, dip->u_64.di_ib[ix]);
501 1.13 dholland } else {
502 1.36 dholland /* note: this must sign-extend or UNWRITTEN gets trashed */
503 1.47 christos return (int32_t)LFS_SWAP_int32_t(fs, dip->u_32.di_ib[ix]);
504 1.13 dholland }
505 1.13 dholland }
506 1.13 dholland
507 1.42 christos static __inline void
508 1.13 dholland lfs_dino_setdb(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix, daddr_t val)
509 1.13 dholland {
510 1.13 dholland KASSERT(ix < ULFS_NDADDR);
511 1.13 dholland if (fs->lfs_is64) {
512 1.47 christos dip->u_64.di_db[ix] = LFS_SWAP_int64_t(fs, val);
513 1.13 dholland } else {
514 1.37 dholland dip->u_32.di_db[ix] = LFS_SWAP_uint32_t(fs, val);
515 1.13 dholland }
516 1.13 dholland }
517 1.13 dholland
518 1.42 christos static __inline void
519 1.13 dholland lfs_dino_setib(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix, daddr_t val)
520 1.13 dholland {
521 1.13 dholland KASSERT(ix < ULFS_NIADDR);
522 1.13 dholland if (fs->lfs_is64) {
523 1.47 christos dip->u_64.di_ib[ix] = LFS_SWAP_int64_t(fs, val);
524 1.13 dholland } else {
525 1.37 dholland dip->u_32.di_ib[ix] = LFS_SWAP_uint32_t(fs, val);
526 1.13 dholland }
527 1.13 dholland }
528 1.13 dholland
529 1.16 dholland /* birthtime is present only in the 64-bit inode */
530 1.42 christos static __inline void
531 1.16 dholland lfs_dino_setbirthtime(STRUCT_LFS *fs, union lfs_dinode *dip,
532 1.16 dholland const struct timespec *ts)
533 1.16 dholland {
534 1.16 dholland if (fs->lfs_is64) {
535 1.16 dholland dip->u_64.di_birthtime = ts->tv_sec;
536 1.16 dholland dip->u_64.di_birthnsec = ts->tv_nsec;
537 1.16 dholland } else {
538 1.16 dholland /* drop it on the floor */
539 1.16 dholland }
540 1.16 dholland }
541 1.16 dholland
542 1.16 dholland /*
543 1.16 dholland * indirect blocks
544 1.16 dholland */
545 1.16 dholland
546 1.42 christos static __inline daddr_t
547 1.16 dholland lfs_iblock_get(STRUCT_LFS *fs, void *block, unsigned ix)
548 1.16 dholland {
549 1.16 dholland if (fs->lfs_is64) {
550 1.16 dholland // XXX re-enable these asserts after reorging this file
551 1.16 dholland //KASSERT(ix < lfs_sb_getbsize(fs) / sizeof(int64_t));
552 1.16 dholland return (daddr_t)(((int64_t *)block)[ix]);
553 1.16 dholland } else {
554 1.16 dholland //KASSERT(ix < lfs_sb_getbsize(fs) / sizeof(int32_t));
555 1.16 dholland /* must sign-extend or UNWRITTEN gets trashed */
556 1.16 dholland return (daddr_t)(int64_t)(((int32_t *)block)[ix]);
557 1.16 dholland }
558 1.16 dholland }
559 1.16 dholland
560 1.42 christos static __inline void
561 1.16 dholland lfs_iblock_set(STRUCT_LFS *fs, void *block, unsigned ix, daddr_t val)
562 1.16 dholland {
563 1.16 dholland if (fs->lfs_is64) {
564 1.16 dholland //KASSERT(ix < lfs_sb_getbsize(fs) / sizeof(int64_t));
565 1.16 dholland ((int64_t *)block)[ix] = val;
566 1.16 dholland } else {
567 1.16 dholland //KASSERT(ix < lfs_sb_getbsize(fs) / sizeof(int32_t));
568 1.16 dholland ((int32_t *)block)[ix] = val;
569 1.16 dholland }
570 1.16 dholland }
571 1.16 dholland
572 1.1 dholland /*
573 1.1 dholland * "struct buf" associated definitions
574 1.1 dholland */
575 1.1 dholland
576 1.1 dholland # define LFS_LOCK_BUF(bp) do { \
577 1.1 dholland if (((bp)->b_flags & B_LOCKED) == 0 && bp->b_iodone == NULL) { \
578 1.1 dholland mutex_enter(&lfs_lock); \
579 1.1 dholland ++locked_queue_count; \
580 1.1 dholland locked_queue_bytes += bp->b_bufsize; \
581 1.1 dholland mutex_exit(&lfs_lock); \
582 1.1 dholland } \
583 1.1 dholland (bp)->b_flags |= B_LOCKED; \
584 1.1 dholland } while (0)
585 1.1 dholland
586 1.1 dholland # define LFS_UNLOCK_BUF(bp) do { \
587 1.1 dholland if (((bp)->b_flags & B_LOCKED) != 0 && bp->b_iodone == NULL) { \
588 1.1 dholland mutex_enter(&lfs_lock); \
589 1.1 dholland --locked_queue_count; \
590 1.1 dholland locked_queue_bytes -= bp->b_bufsize; \
591 1.1 dholland if (locked_queue_count < LFS_WAIT_BUFS && \
592 1.1 dholland locked_queue_bytes < LFS_WAIT_BYTES) \
593 1.1 dholland cv_broadcast(&locked_queue_cv); \
594 1.1 dholland mutex_exit(&lfs_lock); \
595 1.1 dholland } \
596 1.1 dholland (bp)->b_flags &= ~B_LOCKED; \
597 1.1 dholland } while (0)
598 1.1 dholland
599 1.1 dholland /*
600 1.1 dholland * "struct inode" associated definitions
601 1.1 dholland */
602 1.1 dholland
603 1.48 maya #define LFS_SET_UINO(ip, states) do { \
604 1.48 maya if (((states) & IN_ACCESSED) && !((ip)->i_state & IN_ACCESSED)) \
605 1.1 dholland lfs_sb_adduinodes((ip)->i_lfs, 1); \
606 1.48 maya if (((states) & IN_CLEANING) && !((ip)->i_state & IN_CLEANING)) \
607 1.1 dholland lfs_sb_adduinodes((ip)->i_lfs, 1); \
608 1.48 maya if (((states) & IN_MODIFIED) && !((ip)->i_state & IN_MODIFIED)) \
609 1.1 dholland lfs_sb_adduinodes((ip)->i_lfs, 1); \
610 1.48 maya (ip)->i_state |= (states); \
611 1.1 dholland } while (0)
612 1.1 dholland
613 1.48 maya #define LFS_CLR_UINO(ip, states) do { \
614 1.48 maya if (((states) & IN_ACCESSED) && ((ip)->i_state & IN_ACCESSED)) \
615 1.1 dholland lfs_sb_subuinodes((ip)->i_lfs, 1); \
616 1.48 maya if (((states) & IN_CLEANING) && ((ip)->i_state & IN_CLEANING)) \
617 1.1 dholland lfs_sb_subuinodes((ip)->i_lfs, 1); \
618 1.48 maya if (((states) & IN_MODIFIED) && ((ip)->i_state & IN_MODIFIED)) \
619 1.1 dholland lfs_sb_subuinodes((ip)->i_lfs, 1); \
620 1.48 maya (ip)->i_state &= ~(states); \
621 1.1 dholland if (lfs_sb_getuinodes((ip)->i_lfs) < 0) { \
622 1.1 dholland panic("lfs_uinodes < 0"); \
623 1.1 dholland } \
624 1.1 dholland } while (0)
625 1.1 dholland
626 1.1 dholland #define LFS_ITIMES(ip, acc, mod, cre) \
627 1.48 maya while ((ip)->i_state & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY)) \
628 1.1 dholland lfs_itimes(ip, acc, mod, cre)
629 1.1 dholland
630 1.1 dholland /*
631 1.1 dholland * On-disk and in-memory checkpoint segment usage structure.
632 1.1 dholland */
633 1.1 dholland
634 1.1 dholland #define SEGUPB(fs) (lfs_sb_getsepb(fs))
635 1.1 dholland #define SEGTABSIZE_SU(fs) \
636 1.1 dholland ((lfs_sb_getnseg(fs) + SEGUPB(fs) - 1) / lfs_sb_getsepb(fs))
637 1.1 dholland
638 1.1 dholland #ifdef _KERNEL
639 1.1 dholland # define SHARE_IFLOCK(F) \
640 1.1 dholland do { \
641 1.1 dholland rw_enter(&(F)->lfs_iflock, RW_READER); \
642 1.1 dholland } while(0)
643 1.1 dholland # define UNSHARE_IFLOCK(F) \
644 1.1 dholland do { \
645 1.1 dholland rw_exit(&(F)->lfs_iflock); \
646 1.1 dholland } while(0)
647 1.1 dholland #else /* ! _KERNEL */
648 1.1 dholland # define SHARE_IFLOCK(F)
649 1.1 dholland # define UNSHARE_IFLOCK(F)
650 1.1 dholland #endif /* ! _KERNEL */
651 1.1 dholland
652 1.1 dholland /* Read in the block with a specific segment usage entry from the ifile. */
653 1.1 dholland #define LFS_SEGENTRY(SP, F, IN, BP) do { \
654 1.1 dholland int _e; \
655 1.1 dholland SHARE_IFLOCK(F); \
656 1.48 maya VTOI((F)->lfs_ivnode)->i_state |= IN_ACCESS; \
657 1.1 dholland if ((_e = bread((F)->lfs_ivnode, \
658 1.1 dholland ((IN) / lfs_sb_getsepb(F)) + lfs_sb_getcleansz(F), \
659 1.1 dholland lfs_sb_getbsize(F), 0, &(BP))) != 0) \
660 1.39 dholland panic("lfs: ifile read: segentry %llu: error %d\n", \
661 1.39 dholland (unsigned long long)(IN), _e); \
662 1.6 dholland if (lfs_sb_getversion(F) == 1) \
663 1.1 dholland (SP) = (SEGUSE *)((SEGUSE_V1 *)(BP)->b_data + \
664 1.1 dholland ((IN) & (lfs_sb_getsepb(F) - 1))); \
665 1.1 dholland else \
666 1.1 dholland (SP) = (SEGUSE *)(BP)->b_data + ((IN) % lfs_sb_getsepb(F)); \
667 1.1 dholland UNSHARE_IFLOCK(F); \
668 1.1 dholland } while (0)
669 1.1 dholland
670 1.1 dholland #define LFS_WRITESEGENTRY(SP, F, IN, BP) do { \
671 1.1 dholland if ((SP)->su_nbytes == 0) \
672 1.1 dholland (SP)->su_flags |= SEGUSE_EMPTY; \
673 1.1 dholland else \
674 1.1 dholland (SP)->su_flags &= ~SEGUSE_EMPTY; \
675 1.1 dholland (F)->lfs_suflags[(F)->lfs_activesb][(IN)] = (SP)->su_flags; \
676 1.1 dholland LFS_BWRITE_LOG(BP); \
677 1.1 dholland } while (0)
678 1.1 dholland
679 1.1 dholland /*
680 1.11 dholland * FINFO (file info) entries.
681 1.11 dholland */
682 1.11 dholland
683 1.11 dholland /* Size of an on-disk block pointer, e.g. in an indirect block. */
684 1.11 dholland /* XXX: move to a more suitable location in this file */
685 1.11 dholland #define LFS_BLKPTRSIZE(fs) ((fs)->lfs_is64 ? sizeof(int64_t) : sizeof(int32_t))
686 1.11 dholland
687 1.12 dholland /* Size of an on-disk inode number. */
688 1.12 dholland /* XXX: move to a more suitable location in this file */
689 1.12 dholland #define LFS_INUMSIZE(fs) ((fs)->lfs_is64 ? sizeof(int64_t) : sizeof(int32_t))
690 1.12 dholland
691 1.12 dholland /* size of a FINFO, without the block pointers */
692 1.12 dholland #define FINFOSIZE(fs) ((fs)->lfs_is64 ? sizeof(FINFO64) : sizeof(FINFO32))
693 1.12 dholland
694 1.11 dholland /* Full size of the provided FINFO record, including its block pointers. */
695 1.11 dholland #define FINFO_FULLSIZE(fs, fip) \
696 1.12 dholland (FINFOSIZE(fs) + lfs_fi_getnblocks(fs, fip) * LFS_BLKPTRSIZE(fs))
697 1.11 dholland
698 1.11 dholland #define NEXT_FINFO(fs, fip) \
699 1.11 dholland ((FINFO *)((char *)(fip) + FINFO_FULLSIZE(fs, fip)))
700 1.11 dholland
701 1.12 dholland #define LFS_DEF_FI_ACCESSOR(type, type32, field) \
702 1.42 christos static __inline type \
703 1.12 dholland lfs_fi_get##field(STRUCT_LFS *fs, FINFO *fip) \
704 1.12 dholland { \
705 1.12 dholland if (fs->lfs_is64) { \
706 1.12 dholland return fip->u_64.fi_##field; \
707 1.12 dholland } else { \
708 1.12 dholland return fip->u_32.fi_##field; \
709 1.12 dholland } \
710 1.12 dholland } \
711 1.42 christos static __inline void \
712 1.12 dholland lfs_fi_set##field(STRUCT_LFS *fs, FINFO *fip, type val) \
713 1.12 dholland { \
714 1.12 dholland if (fs->lfs_is64) { \
715 1.12 dholland type *p = &fip->u_64.fi_##field; \
716 1.12 dholland (void)p; \
717 1.12 dholland fip->u_64.fi_##field = val; \
718 1.12 dholland } else { \
719 1.12 dholland type32 *p = &fip->u_32.fi_##field; \
720 1.12 dholland (void)p; \
721 1.12 dholland fip->u_32.fi_##field = val; \
722 1.12 dholland } \
723 1.12 dholland } \
724 1.12 dholland
725 1.12 dholland LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, nblocks);
726 1.12 dholland LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, version);
727 1.12 dholland LFS_DEF_FI_ACCESSOR(uint64_t, uint32_t, ino);
728 1.12 dholland LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, lastlength);
729 1.12 dholland
730 1.42 christos static __inline daddr_t
731 1.43 riastrad lfs_fi_getblock(STRUCT_LFS *fs, FINFO *fip, unsigned idx)
732 1.12 dholland {
733 1.12 dholland void *firstblock;
734 1.12 dholland
735 1.12 dholland firstblock = (char *)fip + FINFOSIZE(fs);
736 1.43 riastrad KASSERT(idx < lfs_fi_getnblocks(fs, fip));
737 1.12 dholland if (fs->lfs_is64) {
738 1.43 riastrad return ((int64_t *)firstblock)[idx];
739 1.12 dholland } else {
740 1.43 riastrad return ((int32_t *)firstblock)[idx];
741 1.12 dholland }
742 1.12 dholland }
743 1.12 dholland
744 1.42 christos static __inline void
745 1.43 riastrad lfs_fi_setblock(STRUCT_LFS *fs, FINFO *fip, unsigned idx, daddr_t blk)
746 1.12 dholland {
747 1.12 dholland void *firstblock;
748 1.12 dholland
749 1.12 dholland firstblock = (char *)fip + FINFOSIZE(fs);
750 1.43 riastrad KASSERT(idx < lfs_fi_getnblocks(fs, fip));
751 1.12 dholland if (fs->lfs_is64) {
752 1.43 riastrad ((int64_t *)firstblock)[idx] = blk;
753 1.12 dholland } else {
754 1.43 riastrad ((int32_t *)firstblock)[idx] = blk;
755 1.12 dholland }
756 1.12 dholland }
757 1.12 dholland
758 1.11 dholland /*
759 1.34 dholland * inode info entries (in the segment summary)
760 1.34 dholland */
761 1.34 dholland
762 1.34 dholland #define IINFOSIZE(fs) ((fs)->lfs_is64 ? sizeof(IINFO64) : sizeof(IINFO32))
763 1.34 dholland
764 1.34 dholland /* iinfos scroll backward from the end of the segment summary block */
765 1.34 dholland #define SEGSUM_IINFOSTART(fs, buf) \
766 1.34 dholland ((IINFO *)((char *)buf + lfs_sb_getsumsize(fs) - IINFOSIZE(fs)))
767 1.34 dholland
768 1.34 dholland #define NEXTLOWER_IINFO(fs, iip) \
769 1.34 dholland ((IINFO *)((char *)(iip) - IINFOSIZE(fs)))
770 1.34 dholland
771 1.35 dholland #define NTH_IINFO(fs, buf, n) \
772 1.35 dholland ((IINFO *)((char *)SEGSUM_IINFOSTART(fs, buf) - (n)*IINFOSIZE(fs)))
773 1.35 dholland
774 1.42 christos static __inline uint64_t
775 1.34 dholland lfs_ii_getblock(STRUCT_LFS *fs, IINFO *iip)
776 1.34 dholland {
777 1.34 dholland if (fs->lfs_is64) {
778 1.34 dholland return iip->u_64.ii_block;
779 1.34 dholland } else {
780 1.34 dholland return iip->u_32.ii_block;
781 1.34 dholland }
782 1.34 dholland }
783 1.34 dholland
784 1.42 christos static __inline void
785 1.34 dholland lfs_ii_setblock(STRUCT_LFS *fs, IINFO *iip, uint64_t block)
786 1.34 dholland {
787 1.34 dholland if (fs->lfs_is64) {
788 1.34 dholland iip->u_64.ii_block = block;
789 1.34 dholland } else {
790 1.34 dholland iip->u_32.ii_block = block;
791 1.34 dholland }
792 1.34 dholland }
793 1.34 dholland
794 1.34 dholland /*
795 1.1 dholland * Index file inode entries.
796 1.1 dholland */
797 1.1 dholland
798 1.33 dholland #define IFILE_ENTRYSIZE(fs) \
799 1.33 dholland ((fs)->lfs_is64 ? sizeof(IFILE64) : sizeof(IFILE32))
800 1.33 dholland
801 1.1 dholland /*
802 1.1 dholland * LFSv1 compatibility code is not allowed to touch if_atime, since it
803 1.1 dholland * may not be mapped!
804 1.1 dholland */
805 1.1 dholland /* Read in the block with a specific inode from the ifile. */
806 1.1 dholland #define LFS_IENTRY(IP, F, IN, BP) do { \
807 1.1 dholland int _e; \
808 1.1 dholland SHARE_IFLOCK(F); \
809 1.48 maya VTOI((F)->lfs_ivnode)->i_state |= IN_ACCESS; \
810 1.1 dholland if ((_e = bread((F)->lfs_ivnode, \
811 1.1 dholland (IN) / lfs_sb_getifpb(F) + lfs_sb_getcleansz(F) + lfs_sb_getsegtabsz(F), \
812 1.1 dholland lfs_sb_getbsize(F), 0, &(BP))) != 0) \
813 1.1 dholland panic("lfs: ifile ino %d read %d", (int)(IN), _e); \
814 1.10 dholland if ((F)->lfs_is64) { \
815 1.10 dholland (IP) = (IFILE *)((IFILE64 *)(BP)->b_data + \
816 1.10 dholland (IN) % lfs_sb_getifpb(F)); \
817 1.10 dholland } else if (lfs_sb_getversion(F) > 1) { \
818 1.10 dholland (IP) = (IFILE *)((IFILE32 *)(BP)->b_data + \
819 1.10 dholland (IN) % lfs_sb_getifpb(F)); \
820 1.10 dholland } else { \
821 1.1 dholland (IP) = (IFILE *)((IFILE_V1 *)(BP)->b_data + \
822 1.1 dholland (IN) % lfs_sb_getifpb(F)); \
823 1.10 dholland } \
824 1.1 dholland UNSHARE_IFLOCK(F); \
825 1.1 dholland } while (0)
826 1.15 mlelstv #define LFS_IENTRY_NEXT(IP, F) do { \
827 1.15 mlelstv if ((F)->lfs_is64) { \
828 1.15 mlelstv (IP) = (IFILE *)((IFILE64 *)(IP) + 1); \
829 1.15 mlelstv } else if (lfs_sb_getversion(F) > 1) { \
830 1.15 mlelstv (IP) = (IFILE *)((IFILE32 *)(IP) + 1); \
831 1.15 mlelstv } else { \
832 1.15 mlelstv (IP) = (IFILE *)((IFILE_V1 *)(IP) + 1); \
833 1.15 mlelstv } \
834 1.15 mlelstv } while (0)
835 1.1 dholland
836 1.10 dholland #define LFS_DEF_IF_ACCESSOR(type, type32, field) \
837 1.42 christos static __inline type \
838 1.10 dholland lfs_if_get##field(STRUCT_LFS *fs, IFILE *ifp) \
839 1.10 dholland { \
840 1.10 dholland if (fs->lfs_is64) { \
841 1.10 dholland return ifp->u_64.if_##field; \
842 1.10 dholland } else { \
843 1.10 dholland return ifp->u_32.if_##field; \
844 1.10 dholland } \
845 1.10 dholland } \
846 1.42 christos static __inline void \
847 1.10 dholland lfs_if_set##field(STRUCT_LFS *fs, IFILE *ifp, type val) \
848 1.10 dholland { \
849 1.10 dholland if (fs->lfs_is64) { \
850 1.10 dholland type *p = &ifp->u_64.if_##field; \
851 1.10 dholland (void)p; \
852 1.10 dholland ifp->u_64.if_##field = val; \
853 1.10 dholland } else { \
854 1.10 dholland type32 *p = &ifp->u_32.if_##field; \
855 1.10 dholland (void)p; \
856 1.10 dholland ifp->u_32.if_##field = val; \
857 1.10 dholland } \
858 1.10 dholland } \
859 1.10 dholland
860 1.46 dholland LFS_DEF_IF_ACCESSOR(uint32_t, uint32_t, version);
861 1.10 dholland LFS_DEF_IF_ACCESSOR(int64_t, int32_t, daddr);
862 1.46 dholland LFS_DEF_IF_ACCESSOR(uint64_t, uint32_t, nextfree);
863 1.46 dholland LFS_DEF_IF_ACCESSOR(uint64_t, uint32_t, atime_sec);
864 1.46 dholland LFS_DEF_IF_ACCESSOR(uint32_t, uint32_t, atime_nsec);
865 1.10 dholland
866 1.1 dholland /*
867 1.1 dholland * Cleaner information structure. This resides in the ifile and is used
868 1.1 dholland * to pass information from the kernel to the cleaner.
869 1.1 dholland */
870 1.1 dholland
871 1.1 dholland #define CLEANSIZE_SU(fs) \
872 1.9 dholland ((((fs)->lfs_is64 ? sizeof(CLEANERINFO64) : sizeof(CLEANERINFO32)) + \
873 1.9 dholland lfs_sb_getbsize(fs) - 1) >> lfs_sb_getbshift(fs))
874 1.9 dholland
875 1.9 dholland #define LFS_DEF_CI_ACCESSOR(type, type32, field) \
876 1.42 christos static __inline type \
877 1.9 dholland lfs_ci_get##field(STRUCT_LFS *fs, CLEANERINFO *cip) \
878 1.9 dholland { \
879 1.9 dholland if (fs->lfs_is64) { \
880 1.9 dholland return cip->u_64.field; \
881 1.9 dholland } else { \
882 1.9 dholland return cip->u_32.field; \
883 1.9 dholland } \
884 1.9 dholland } \
885 1.42 christos static __inline void \
886 1.9 dholland lfs_ci_set##field(STRUCT_LFS *fs, CLEANERINFO *cip, type val) \
887 1.9 dholland { \
888 1.9 dholland if (fs->lfs_is64) { \
889 1.9 dholland type *p = &cip->u_64.field; \
890 1.9 dholland (void)p; \
891 1.9 dholland cip->u_64.field = val; \
892 1.9 dholland } else { \
893 1.9 dholland type32 *p = &cip->u_32.field; \
894 1.9 dholland (void)p; \
895 1.9 dholland cip->u_32.field = val; \
896 1.9 dholland } \
897 1.9 dholland } \
898 1.9 dholland
899 1.46 dholland LFS_DEF_CI_ACCESSOR(uint32_t, uint32_t, clean);
900 1.46 dholland LFS_DEF_CI_ACCESSOR(uint32_t, uint32_t, dirty);
901 1.9 dholland LFS_DEF_CI_ACCESSOR(int64_t, int32_t, bfree);
902 1.9 dholland LFS_DEF_CI_ACCESSOR(int64_t, int32_t, avail);
903 1.46 dholland LFS_DEF_CI_ACCESSOR(uint64_t, uint32_t, free_head);
904 1.46 dholland LFS_DEF_CI_ACCESSOR(uint64_t, uint32_t, free_tail);
905 1.46 dholland LFS_DEF_CI_ACCESSOR(uint32_t, uint32_t, flags);
906 1.9 dholland
907 1.42 christos static __inline void
908 1.9 dholland lfs_ci_shiftcleantodirty(STRUCT_LFS *fs, CLEANERINFO *cip, unsigned num)
909 1.9 dholland {
910 1.9 dholland lfs_ci_setclean(fs, cip, lfs_ci_getclean(fs, cip) - num);
911 1.9 dholland lfs_ci_setdirty(fs, cip, lfs_ci_getdirty(fs, cip) + num);
912 1.9 dholland }
913 1.9 dholland
914 1.42 christos static __inline void
915 1.9 dholland lfs_ci_shiftdirtytoclean(STRUCT_LFS *fs, CLEANERINFO *cip, unsigned num)
916 1.9 dholland {
917 1.9 dholland lfs_ci_setdirty(fs, cip, lfs_ci_getdirty(fs, cip) - num);
918 1.9 dholland lfs_ci_setclean(fs, cip, lfs_ci_getclean(fs, cip) + num);
919 1.9 dholland }
920 1.1 dholland
921 1.1 dholland /* Read in the block with the cleaner info from the ifile. */
922 1.1 dholland #define LFS_CLEANERINFO(CP, F, BP) do { \
923 1.39 dholland int _e; \
924 1.1 dholland SHARE_IFLOCK(F); \
925 1.48 maya VTOI((F)->lfs_ivnode)->i_state |= IN_ACCESS; \
926 1.39 dholland _e = bread((F)->lfs_ivnode, \
927 1.39 dholland (daddr_t)0, lfs_sb_getbsize(F), 0, &(BP)); \
928 1.39 dholland if (_e) \
929 1.39 dholland panic("lfs: ifile read: cleanerinfo: error %d\n", _e); \
930 1.1 dholland (CP) = (CLEANERINFO *)(BP)->b_data; \
931 1.1 dholland UNSHARE_IFLOCK(F); \
932 1.1 dholland } while (0)
933 1.1 dholland
934 1.1 dholland /*
935 1.1 dholland * Synchronize the Ifile cleaner info with current avail and bfree.
936 1.1 dholland */
937 1.1 dholland #define LFS_SYNC_CLEANERINFO(cip, fs, bp, w) do { \
938 1.1 dholland mutex_enter(&lfs_lock); \
939 1.9 dholland if ((w) || lfs_ci_getbfree(fs, cip) != lfs_sb_getbfree(fs) || \
940 1.9 dholland lfs_ci_getavail(fs, cip) != lfs_sb_getavail(fs) - fs->lfs_ravail - \
941 1.1 dholland fs->lfs_favail) { \
942 1.9 dholland lfs_ci_setbfree(fs, cip, lfs_sb_getbfree(fs)); \
943 1.9 dholland lfs_ci_setavail(fs, cip, lfs_sb_getavail(fs) - fs->lfs_ravail - \
944 1.9 dholland fs->lfs_favail); \
945 1.1 dholland if (((bp)->b_flags & B_GATHERED) == 0) { \
946 1.1 dholland fs->lfs_flags |= LFS_IFDIRTY; \
947 1.1 dholland } \
948 1.1 dholland mutex_exit(&lfs_lock); \
949 1.1 dholland (void) LFS_BWRITE_LOG(bp); /* Ifile */ \
950 1.1 dholland } else { \
951 1.1 dholland mutex_exit(&lfs_lock); \
952 1.1 dholland brelse(bp, 0); \
953 1.1 dholland } \
954 1.1 dholland } while (0)
955 1.1 dholland
956 1.1 dholland /*
957 1.1 dholland * Get the head of the inode free list.
958 1.1 dholland * Always called with the segment lock held.
959 1.1 dholland */
960 1.1 dholland #define LFS_GET_HEADFREE(FS, CIP, BP, FREEP) do { \
961 1.6 dholland if (lfs_sb_getversion(FS) > 1) { \
962 1.1 dholland LFS_CLEANERINFO((CIP), (FS), (BP)); \
963 1.9 dholland lfs_sb_setfreehd(FS, lfs_ci_getfree_head(FS, CIP)); \
964 1.1 dholland brelse(BP, 0); \
965 1.1 dholland } \
966 1.1 dholland *(FREEP) = lfs_sb_getfreehd(FS); \
967 1.1 dholland } while (0)
968 1.1 dholland
969 1.1 dholland #define LFS_PUT_HEADFREE(FS, CIP, BP, VAL) do { \
970 1.1 dholland lfs_sb_setfreehd(FS, VAL); \
971 1.6 dholland if (lfs_sb_getversion(FS) > 1) { \
972 1.1 dholland LFS_CLEANERINFO((CIP), (FS), (BP)); \
973 1.9 dholland lfs_ci_setfree_head(FS, CIP, VAL); \
974 1.1 dholland LFS_BWRITE_LOG(BP); \
975 1.1 dholland mutex_enter(&lfs_lock); \
976 1.1 dholland (FS)->lfs_flags |= LFS_IFDIRTY; \
977 1.1 dholland mutex_exit(&lfs_lock); \
978 1.1 dholland } \
979 1.1 dholland } while (0)
980 1.1 dholland
981 1.1 dholland #define LFS_GET_TAILFREE(FS, CIP, BP, FREEP) do { \
982 1.1 dholland LFS_CLEANERINFO((CIP), (FS), (BP)); \
983 1.9 dholland *(FREEP) = lfs_ci_getfree_tail(FS, CIP); \
984 1.1 dholland brelse(BP, 0); \
985 1.1 dholland } while (0)
986 1.1 dholland
987 1.1 dholland #define LFS_PUT_TAILFREE(FS, CIP, BP, VAL) do { \
988 1.1 dholland LFS_CLEANERINFO((CIP), (FS), (BP)); \
989 1.9 dholland lfs_ci_setfree_tail(FS, CIP, VAL); \
990 1.1 dholland LFS_BWRITE_LOG(BP); \
991 1.1 dholland mutex_enter(&lfs_lock); \
992 1.1 dholland (FS)->lfs_flags |= LFS_IFDIRTY; \
993 1.1 dholland mutex_exit(&lfs_lock); \
994 1.1 dholland } while (0)
995 1.1 dholland
996 1.1 dholland /*
997 1.1 dholland * On-disk segment summary information
998 1.1 dholland */
999 1.1 dholland
1000 1.11 dholland #define SEGSUM_SIZE(fs) \
1001 1.11 dholland (fs->lfs_is64 ? sizeof(SEGSUM64) : \
1002 1.11 dholland lfs_sb_getversion(fs) > 1 ? sizeof(SEGSUM32) : sizeof(SEGSUM_V1))
1003 1.11 dholland
1004 1.11 dholland /*
1005 1.11 dholland * The SEGSUM structure is followed by FINFO structures. Get the pointer
1006 1.11 dholland * to the first FINFO.
1007 1.11 dholland *
1008 1.11 dholland * XXX this can't be a macro yet; this file needs to be resorted.
1009 1.11 dholland */
1010 1.11 dholland #if 0
1011 1.42 christos static __inline FINFO *
1012 1.11 dholland segsum_finfobase(STRUCT_LFS *fs, SEGSUM *ssp)
1013 1.11 dholland {
1014 1.12 dholland return (FINFO *)((char *)ssp + SEGSUM_SIZE(fs));
1015 1.11 dholland }
1016 1.11 dholland #else
1017 1.11 dholland #define SEGSUM_FINFOBASE(fs, ssp) \
1018 1.12 dholland ((FINFO *)((char *)(ssp) + SEGSUM_SIZE(fs)));
1019 1.11 dholland #endif
1020 1.11 dholland
1021 1.11 dholland #define LFS_DEF_SS_ACCESSOR(type, type32, field) \
1022 1.42 christos static __inline type \
1023 1.11 dholland lfs_ss_get##field(STRUCT_LFS *fs, SEGSUM *ssp) \
1024 1.11 dholland { \
1025 1.11 dholland if (fs->lfs_is64) { \
1026 1.11 dholland return ssp->u_64.ss_##field; \
1027 1.11 dholland } else { \
1028 1.11 dholland return ssp->u_32.ss_##field; \
1029 1.11 dholland } \
1030 1.11 dholland } \
1031 1.42 christos static __inline void \
1032 1.11 dholland lfs_ss_set##field(STRUCT_LFS *fs, SEGSUM *ssp, type val) \
1033 1.11 dholland { \
1034 1.11 dholland if (fs->lfs_is64) { \
1035 1.11 dholland type *p = &ssp->u_64.ss_##field; \
1036 1.11 dholland (void)p; \
1037 1.11 dholland ssp->u_64.ss_##field = val; \
1038 1.11 dholland } else { \
1039 1.11 dholland type32 *p = &ssp->u_32.ss_##field; \
1040 1.11 dholland (void)p; \
1041 1.11 dholland ssp->u_32.ss_##field = val; \
1042 1.11 dholland } \
1043 1.11 dholland } \
1044 1.11 dholland
1045 1.11 dholland LFS_DEF_SS_ACCESSOR(uint32_t, uint32_t, sumsum);
1046 1.11 dholland LFS_DEF_SS_ACCESSOR(uint32_t, uint32_t, datasum);
1047 1.11 dholland LFS_DEF_SS_ACCESSOR(uint32_t, uint32_t, magic);
1048 1.11 dholland LFS_DEF_SS_ACCESSOR(uint32_t, uint32_t, ident);
1049 1.11 dholland LFS_DEF_SS_ACCESSOR(int64_t, int32_t, next);
1050 1.11 dholland LFS_DEF_SS_ACCESSOR(uint16_t, uint16_t, nfinfo);
1051 1.11 dholland LFS_DEF_SS_ACCESSOR(uint16_t, uint16_t, ninos);
1052 1.11 dholland LFS_DEF_SS_ACCESSOR(uint16_t, uint16_t, flags);
1053 1.11 dholland LFS_DEF_SS_ACCESSOR(uint64_t, uint32_t, reclino);
1054 1.11 dholland LFS_DEF_SS_ACCESSOR(uint64_t, uint64_t, serial);
1055 1.11 dholland LFS_DEF_SS_ACCESSOR(uint64_t, uint64_t, create);
1056 1.11 dholland
1057 1.42 christos static __inline size_t
1058 1.11 dholland lfs_ss_getsumstart(STRUCT_LFS *fs)
1059 1.11 dholland {
1060 1.11 dholland /* These are actually all the same. */
1061 1.11 dholland if (fs->lfs_is64) {
1062 1.11 dholland return offsetof(SEGSUM64, ss_datasum);
1063 1.11 dholland } else /* if (lfs_sb_getversion(fs) > 1) */ {
1064 1.11 dholland return offsetof(SEGSUM32, ss_datasum);
1065 1.11 dholland } /* else {
1066 1.11 dholland return offsetof(SEGSUM_V1, ss_datasum);
1067 1.11 dholland } */
1068 1.11 dholland /*
1069 1.11 dholland * XXX ^^^ until this file is resorted lfs_sb_getversion isn't
1070 1.11 dholland * defined yet.
1071 1.11 dholland */
1072 1.11 dholland }
1073 1.11 dholland
1074 1.42 christos static __inline uint32_t
1075 1.11 dholland lfs_ss_getocreate(STRUCT_LFS *fs, SEGSUM *ssp)
1076 1.11 dholland {
1077 1.11 dholland KASSERT(fs->lfs_is64 == 0);
1078 1.11 dholland /* XXX need to resort this file before we can do this */
1079 1.11 dholland //KASSERT(lfs_sb_getversion(fs) == 1);
1080 1.11 dholland
1081 1.11 dholland return ssp->u_v1.ss_create;
1082 1.11 dholland }
1083 1.11 dholland
1084 1.42 christos static __inline void
1085 1.11 dholland lfs_ss_setocreate(STRUCT_LFS *fs, SEGSUM *ssp, uint32_t val)
1086 1.11 dholland {
1087 1.11 dholland KASSERT(fs->lfs_is64 == 0);
1088 1.11 dholland /* XXX need to resort this file before we can do this */
1089 1.11 dholland //KASSERT(lfs_sb_getversion(fs) == 1);
1090 1.11 dholland
1091 1.11 dholland ssp->u_v1.ss_create = val;
1092 1.11 dholland }
1093 1.11 dholland
1094 1.1 dholland
1095 1.1 dholland /*
1096 1.1 dholland * Super block.
1097 1.1 dholland */
1098 1.1 dholland
1099 1.1 dholland /*
1100 1.1 dholland * Generate accessors for the on-disk superblock fields with cpp.
1101 1.1 dholland */
1102 1.1 dholland
1103 1.3 dholland #define LFS_DEF_SB_ACCESSOR_FULL(type, type32, field) \
1104 1.42 christos static __inline type \
1105 1.1 dholland lfs_sb_get##field(STRUCT_LFS *fs) \
1106 1.1 dholland { \
1107 1.7 dholland if (fs->lfs_is64) { \
1108 1.7 dholland return fs->lfs_dlfs_u.u_64.dlfs_##field; \
1109 1.7 dholland } else { \
1110 1.7 dholland return fs->lfs_dlfs_u.u_32.dlfs_##field; \
1111 1.7 dholland } \
1112 1.1 dholland } \
1113 1.42 christos static __inline void \
1114 1.1 dholland lfs_sb_set##field(STRUCT_LFS *fs, type val) \
1115 1.1 dholland { \
1116 1.7 dholland if (fs->lfs_is64) { \
1117 1.7 dholland fs->lfs_dlfs_u.u_64.dlfs_##field = val; \
1118 1.7 dholland } else { \
1119 1.7 dholland fs->lfs_dlfs_u.u_32.dlfs_##field = val; \
1120 1.7 dholland } \
1121 1.1 dholland } \
1122 1.42 christos static __inline void \
1123 1.1 dholland lfs_sb_add##field(STRUCT_LFS *fs, type val) \
1124 1.1 dholland { \
1125 1.7 dholland if (fs->lfs_is64) { \
1126 1.7 dholland type *p64 = &fs->lfs_dlfs_u.u_64.dlfs_##field; \
1127 1.7 dholland *p64 += val; \
1128 1.7 dholland } else { \
1129 1.7 dholland type32 *p32 = &fs->lfs_dlfs_u.u_32.dlfs_##field; \
1130 1.7 dholland *p32 += val; \
1131 1.7 dholland } \
1132 1.1 dholland } \
1133 1.42 christos static __inline void \
1134 1.1 dholland lfs_sb_sub##field(STRUCT_LFS *fs, type val) \
1135 1.1 dholland { \
1136 1.7 dholland if (fs->lfs_is64) { \
1137 1.7 dholland type *p64 = &fs->lfs_dlfs_u.u_64.dlfs_##field; \
1138 1.7 dholland *p64 -= val; \
1139 1.7 dholland } else { \
1140 1.7 dholland type32 *p32 = &fs->lfs_dlfs_u.u_32.dlfs_##field; \
1141 1.7 dholland *p32 -= val; \
1142 1.7 dholland } \
1143 1.1 dholland }
1144 1.1 dholland
1145 1.3 dholland #define LFS_DEF_SB_ACCESSOR(t, f) LFS_DEF_SB_ACCESSOR_FULL(t, t, f)
1146 1.3 dholland
1147 1.7 dholland #define LFS_DEF_SB_ACCESSOR_32ONLY(type, field, val64) \
1148 1.42 christos static __inline type \
1149 1.7 dholland lfs_sb_get##field(STRUCT_LFS *fs) \
1150 1.7 dholland { \
1151 1.7 dholland if (fs->lfs_is64) { \
1152 1.7 dholland return val64; \
1153 1.7 dholland } else { \
1154 1.7 dholland return fs->lfs_dlfs_u.u_32.dlfs_##field; \
1155 1.7 dholland } \
1156 1.7 dholland }
1157 1.7 dholland
1158 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, version);
1159 1.46 dholland LFS_DEF_SB_ACCESSOR_FULL(uint64_t, uint32_t, size);
1160 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, ssize);
1161 1.46 dholland LFS_DEF_SB_ACCESSOR_FULL(uint64_t, uint32_t, dsize);
1162 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, bsize);
1163 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, fsize);
1164 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, frag);
1165 1.18 dholland LFS_DEF_SB_ACCESSOR_FULL(uint64_t, uint32_t, freehd);
1166 1.4 dholland LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, bfree);
1167 1.18 dholland LFS_DEF_SB_ACCESSOR_FULL(uint64_t, uint32_t, nfiles);
1168 1.4 dholland LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, avail);
1169 1.1 dholland LFS_DEF_SB_ACCESSOR(int32_t, uinodes);
1170 1.5 dholland LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, idaddr);
1171 1.46 dholland LFS_DEF_SB_ACCESSOR_32ONLY(uint32_t, ifile, LFS_IFILE_INUM);
1172 1.5 dholland LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, lastseg);
1173 1.5 dholland LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, nextseg);
1174 1.5 dholland LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, curseg);
1175 1.5 dholland LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, offset);
1176 1.5 dholland LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, lastpseg);
1177 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, inopf);
1178 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, minfree);
1179 1.1 dholland LFS_DEF_SB_ACCESSOR(uint64_t, maxfilesize);
1180 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, fsbpseg);
1181 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, inopb);
1182 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, ifpb);
1183 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, sepb);
1184 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, nindir);
1185 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, nseg);
1186 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, nspf);
1187 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, cleansz);
1188 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, segtabsz);
1189 1.46 dholland LFS_DEF_SB_ACCESSOR_32ONLY(uint32_t, segmask, 0);
1190 1.46 dholland LFS_DEF_SB_ACCESSOR_32ONLY(uint32_t, segshift, 0);
1191 1.46 dholland LFS_DEF_SB_ACCESSOR(uint64_t, bmask);
1192 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, bshift);
1193 1.46 dholland LFS_DEF_SB_ACCESSOR(uint64_t, ffmask);
1194 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, ffshift);
1195 1.46 dholland LFS_DEF_SB_ACCESSOR(uint64_t, fbmask);
1196 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, fbshift);
1197 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, blktodb);
1198 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, fsbtodb);
1199 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, sushift);
1200 1.1 dholland LFS_DEF_SB_ACCESSOR(int32_t, maxsymlinklen);
1201 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, cksum);
1202 1.46 dholland LFS_DEF_SB_ACCESSOR(uint16_t, pflags);
1203 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, nclean);
1204 1.1 dholland LFS_DEF_SB_ACCESSOR(int32_t, dmeta);
1205 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, minfreeseg);
1206 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, sumsize);
1207 1.46 dholland LFS_DEF_SB_ACCESSOR(uint64_t, serial);
1208 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, ibsize);
1209 1.5 dholland LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, s0addr);
1210 1.46 dholland LFS_DEF_SB_ACCESSOR(uint64_t, tstamp);
1211 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, inodefmt);
1212 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, interleave);
1213 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, ident);
1214 1.46 dholland LFS_DEF_SB_ACCESSOR(uint32_t, resvseg);
1215 1.1 dholland
1216 1.1 dholland /* special-case accessors */
1217 1.1 dholland
1218 1.1 dholland /*
1219 1.1 dholland * the v1 otstamp field lives in what's now dlfs_inopf
1220 1.1 dholland */
1221 1.1 dholland #define lfs_sb_getotstamp(fs) lfs_sb_getinopf(fs)
1222 1.1 dholland #define lfs_sb_setotstamp(fs, val) lfs_sb_setinopf(fs, val)
1223 1.1 dholland
1224 1.1 dholland /*
1225 1.1 dholland * lfs_sboffs is an array
1226 1.1 dholland */
1227 1.42 christos static __inline int32_t
1228 1.2 dholland lfs_sb_getsboff(STRUCT_LFS *fs, unsigned n)
1229 1.1 dholland {
1230 1.1 dholland #ifdef KASSERT /* ugh */
1231 1.1 dholland KASSERT(n < LFS_MAXNUMSB);
1232 1.1 dholland #endif
1233 1.7 dholland if (fs->lfs_is64) {
1234 1.7 dholland return fs->lfs_dlfs_u.u_64.dlfs_sboffs[n];
1235 1.7 dholland } else {
1236 1.7 dholland return fs->lfs_dlfs_u.u_32.dlfs_sboffs[n];
1237 1.7 dholland }
1238 1.1 dholland }
1239 1.42 christos static __inline void
1240 1.2 dholland lfs_sb_setsboff(STRUCT_LFS *fs, unsigned n, int32_t val)
1241 1.1 dholland {
1242 1.1 dholland #ifdef KASSERT /* ugh */
1243 1.1 dholland KASSERT(n < LFS_MAXNUMSB);
1244 1.1 dholland #endif
1245 1.7 dholland if (fs->lfs_is64) {
1246 1.7 dholland fs->lfs_dlfs_u.u_64.dlfs_sboffs[n] = val;
1247 1.7 dholland } else {
1248 1.7 dholland fs->lfs_dlfs_u.u_32.dlfs_sboffs[n] = val;
1249 1.7 dholland }
1250 1.1 dholland }
1251 1.1 dholland
1252 1.1 dholland /*
1253 1.1 dholland * lfs_fsmnt is a string
1254 1.1 dholland */
1255 1.42 christos static __inline const char *
1256 1.2 dholland lfs_sb_getfsmnt(STRUCT_LFS *fs)
1257 1.1 dholland {
1258 1.7 dholland if (fs->lfs_is64) {
1259 1.44 riastrad return (const char *)fs->lfs_dlfs_u.u_64.dlfs_fsmnt;
1260 1.7 dholland } else {
1261 1.44 riastrad return (const char *)fs->lfs_dlfs_u.u_32.dlfs_fsmnt;
1262 1.7 dholland }
1263 1.7 dholland }
1264 1.7 dholland
1265 1.42 christos static __inline void
1266 1.7 dholland lfs_sb_setfsmnt(STRUCT_LFS *fs, const char *str)
1267 1.7 dholland {
1268 1.7 dholland if (fs->lfs_is64) {
1269 1.44 riastrad (void)strncpy((char *)fs->lfs_dlfs_u.u_64.dlfs_fsmnt, str,
1270 1.7 dholland sizeof(fs->lfs_dlfs_u.u_64.dlfs_fsmnt));
1271 1.7 dholland } else {
1272 1.44 riastrad (void)strncpy((char *)fs->lfs_dlfs_u.u_32.dlfs_fsmnt, str,
1273 1.7 dholland sizeof(fs->lfs_dlfs_u.u_32.dlfs_fsmnt));
1274 1.7 dholland }
1275 1.1 dholland }
1276 1.1 dholland
1277 1.8 dholland /* Highest addressable fsb */
1278 1.8 dholland #define LFS_MAX_DADDR(fs) \
1279 1.8 dholland ((fs)->lfs_is64 ? 0x7fffffffffffffff : 0x7fffffff)
1280 1.8 dholland
1281 1.1 dholland /* LFS_NINDIR is the number of indirects in a file system block. */
1282 1.1 dholland #define LFS_NINDIR(fs) (lfs_sb_getnindir(fs))
1283 1.1 dholland
1284 1.1 dholland /* LFS_INOPB is the number of inodes in a secondary storage block. */
1285 1.1 dholland #define LFS_INOPB(fs) (lfs_sb_getinopb(fs))
1286 1.1 dholland /* LFS_INOPF is the number of inodes in a fragment. */
1287 1.1 dholland #define LFS_INOPF(fs) (lfs_sb_getinopf(fs))
1288 1.1 dholland
1289 1.1 dholland #define lfs_blkoff(fs, loc) ((int)((loc) & lfs_sb_getbmask(fs)))
1290 1.1 dholland #define lfs_fragoff(fs, loc) /* calculates (loc % fs->lfs_fsize) */ \
1291 1.1 dholland ((int)((loc) & lfs_sb_getffmask(fs)))
1292 1.1 dholland
1293 1.4 dholland /* XXX: lowercase these as they're no longer macros */
1294 1.4 dholland /* Frags to diskblocks */
1295 1.42 christos static __inline uint64_t
1296 1.4 dholland LFS_FSBTODB(STRUCT_LFS *fs, uint64_t b)
1297 1.4 dholland {
1298 1.1 dholland #if defined(_KERNEL)
1299 1.4 dholland return b << (lfs_sb_getffshift(fs) - DEV_BSHIFT);
1300 1.1 dholland #else
1301 1.4 dholland return b << lfs_sb_getfsbtodb(fs);
1302 1.1 dholland #endif
1303 1.4 dholland }
1304 1.4 dholland /* Diskblocks to frags */
1305 1.42 christos static __inline uint64_t
1306 1.4 dholland LFS_DBTOFSB(STRUCT_LFS *fs, uint64_t b)
1307 1.4 dholland {
1308 1.4 dholland #if defined(_KERNEL)
1309 1.4 dholland return b >> (lfs_sb_getffshift(fs) - DEV_BSHIFT);
1310 1.4 dholland #else
1311 1.4 dholland return b >> lfs_sb_getfsbtodb(fs);
1312 1.4 dholland #endif
1313 1.4 dholland }
1314 1.1 dholland
1315 1.1 dholland #define lfs_lblkno(fs, loc) ((loc) >> lfs_sb_getbshift(fs))
1316 1.1 dholland #define lfs_lblktosize(fs, blk) ((blk) << lfs_sb_getbshift(fs))
1317 1.1 dholland
1318 1.4 dholland /* Frags to bytes */
1319 1.42 christos static __inline uint64_t
1320 1.4 dholland lfs_fsbtob(STRUCT_LFS *fs, uint64_t b)
1321 1.4 dholland {
1322 1.4 dholland return b << lfs_sb_getffshift(fs);
1323 1.4 dholland }
1324 1.4 dholland /* Bytes to frags */
1325 1.42 christos static __inline uint64_t
1326 1.4 dholland lfs_btofsb(STRUCT_LFS *fs, uint64_t b)
1327 1.4 dholland {
1328 1.4 dholland return b >> lfs_sb_getffshift(fs);
1329 1.4 dholland }
1330 1.1 dholland
1331 1.1 dholland #define lfs_numfrags(fs, loc) /* calculates (loc / fs->lfs_fsize) */ \
1332 1.1 dholland ((loc) >> lfs_sb_getffshift(fs))
1333 1.1 dholland #define lfs_blkroundup(fs, size)/* calculates roundup(size, lfs_sb_getbsize(fs)) */ \
1334 1.1 dholland ((off_t)(((size) + lfs_sb_getbmask(fs)) & (~lfs_sb_getbmask(fs))))
1335 1.1 dholland #define lfs_fragroundup(fs, size)/* calculates roundup(size, fs->lfs_fsize) */ \
1336 1.1 dholland ((off_t)(((size) + lfs_sb_getffmask(fs)) & (~lfs_sb_getffmask(fs))))
1337 1.1 dholland #define lfs_fragstoblks(fs, frags)/* calculates (frags / fs->fs_frag) */ \
1338 1.1 dholland ((frags) >> lfs_sb_getfbshift(fs))
1339 1.1 dholland #define lfs_blkstofrags(fs, blks)/* calculates (blks * fs->fs_frag) */ \
1340 1.1 dholland ((blks) << lfs_sb_getfbshift(fs))
1341 1.1 dholland #define lfs_fragnum(fs, fsb) /* calculates (fsb % fs->lfs_frag) */ \
1342 1.1 dholland ((fsb) & ((fs)->lfs_frag - 1))
1343 1.1 dholland #define lfs_blknum(fs, fsb) /* calculates rounddown(fsb, fs->lfs_frag) */ \
1344 1.1 dholland ((fsb) &~ ((fs)->lfs_frag - 1))
1345 1.1 dholland #define lfs_dblksize(fs, dp, lbn) \
1346 1.13 dholland (((lbn) >= ULFS_NDADDR || lfs_dino_getsize(fs, dp) >= ((lbn) + 1) << lfs_sb_getbshift(fs)) \
1347 1.1 dholland ? lfs_sb_getbsize(fs) \
1348 1.13 dholland : (lfs_fragroundup(fs, lfs_blkoff(fs, lfs_dino_getsize(fs, dp)))))
1349 1.1 dholland
1350 1.6 dholland #define lfs_segsize(fs) (lfs_sb_getversion(fs) == 1 ? \
1351 1.1 dholland lfs_lblktosize((fs), lfs_sb_getssize(fs)) : \
1352 1.1 dholland lfs_sb_getssize(fs))
1353 1.4 dholland /* XXX segtod produces a result in frags despite the 'd' */
1354 1.4 dholland #define lfs_segtod(fs, seg) (lfs_btofsb(fs, lfs_segsize(fs)) * (seg))
1355 1.1 dholland #define lfs_dtosn(fs, daddr) /* block address to segment number */ \
1356 1.1 dholland ((uint32_t)(((daddr) - lfs_sb_gets0addr(fs)) / lfs_segtod((fs), 1)))
1357 1.1 dholland #define lfs_sntod(fs, sn) /* segment number to disk address */ \
1358 1.1 dholland ((daddr_t)(lfs_segtod((fs), (sn)) + lfs_sb_gets0addr(fs)))
1359 1.1 dholland
1360 1.4 dholland /* XXX, blah. make this appear only if struct inode is defined */
1361 1.4 dholland #ifdef _UFS_LFS_LFS_INODE_H_
1362 1.42 christos static __inline uint32_t
1363 1.4 dholland lfs_blksize(STRUCT_LFS *fs, struct inode *ip, uint64_t lbn)
1364 1.4 dholland {
1365 1.16 dholland if (lbn >= ULFS_NDADDR || lfs_dino_getsize(fs, ip->i_din) >= (lbn + 1) << lfs_sb_getbshift(fs)) {
1366 1.4 dholland return lfs_sb_getbsize(fs);
1367 1.4 dholland } else {
1368 1.16 dholland return lfs_fragroundup(fs, lfs_blkoff(fs, lfs_dino_getsize(fs, ip->i_din)));
1369 1.4 dholland }
1370 1.4 dholland }
1371 1.4 dholland #endif
1372 1.4 dholland
1373 1.12 dholland /*
1374 1.12 dholland * union lfs_blocks
1375 1.12 dholland */
1376 1.12 dholland
1377 1.42 christos static __inline void
1378 1.12 dholland lfs_blocks_fromvoid(STRUCT_LFS *fs, union lfs_blocks *bp, void *p)
1379 1.12 dholland {
1380 1.12 dholland if (fs->lfs_is64) {
1381 1.12 dholland bp->b64 = p;
1382 1.12 dholland } else {
1383 1.12 dholland bp->b32 = p;
1384 1.12 dholland }
1385 1.12 dholland }
1386 1.12 dholland
1387 1.42 christos static __inline void
1388 1.12 dholland lfs_blocks_fromfinfo(STRUCT_LFS *fs, union lfs_blocks *bp, FINFO *fip)
1389 1.12 dholland {
1390 1.12 dholland void *firstblock;
1391 1.12 dholland
1392 1.12 dholland firstblock = (char *)fip + FINFOSIZE(fs);
1393 1.12 dholland if (fs->lfs_is64) {
1394 1.12 dholland bp->b64 = (int64_t *)firstblock;
1395 1.12 dholland } else {
1396 1.12 dholland bp->b32 = (int32_t *)firstblock;
1397 1.12 dholland }
1398 1.12 dholland }
1399 1.12 dholland
1400 1.42 christos static __inline daddr_t
1401 1.43 riastrad lfs_blocks_get(STRUCT_LFS *fs, union lfs_blocks *bp, unsigned idx)
1402 1.12 dholland {
1403 1.12 dholland if (fs->lfs_is64) {
1404 1.43 riastrad return bp->b64[idx];
1405 1.12 dholland } else {
1406 1.43 riastrad return bp->b32[idx];
1407 1.12 dholland }
1408 1.12 dholland }
1409 1.12 dholland
1410 1.42 christos static __inline void
1411 1.43 riastrad lfs_blocks_set(STRUCT_LFS *fs, union lfs_blocks *bp, unsigned idx, daddr_t val)
1412 1.12 dholland {
1413 1.12 dholland if (fs->lfs_is64) {
1414 1.43 riastrad bp->b64[idx] = val;
1415 1.12 dholland } else {
1416 1.43 riastrad bp->b32[idx] = val;
1417 1.12 dholland }
1418 1.12 dholland }
1419 1.12 dholland
1420 1.42 christos static __inline void
1421 1.12 dholland lfs_blocks_inc(STRUCT_LFS *fs, union lfs_blocks *bp)
1422 1.12 dholland {
1423 1.12 dholland if (fs->lfs_is64) {
1424 1.12 dholland bp->b64++;
1425 1.12 dholland } else {
1426 1.12 dholland bp->b32++;
1427 1.12 dholland }
1428 1.12 dholland }
1429 1.12 dholland
1430 1.42 christos static __inline int
1431 1.12 dholland lfs_blocks_eq(STRUCT_LFS *fs, union lfs_blocks *bp1, union lfs_blocks *bp2)
1432 1.12 dholland {
1433 1.12 dholland if (fs->lfs_is64) {
1434 1.12 dholland return bp1->b64 == bp2->b64;
1435 1.12 dholland } else {
1436 1.12 dholland return bp1->b32 == bp2->b32;
1437 1.12 dholland }
1438 1.12 dholland }
1439 1.12 dholland
1440 1.42 christos static __inline int
1441 1.12 dholland lfs_blocks_sub(STRUCT_LFS *fs, union lfs_blocks *bp1, union lfs_blocks *bp2)
1442 1.12 dholland {
1443 1.12 dholland /* (remember that the pointers are typed) */
1444 1.12 dholland if (fs->lfs_is64) {
1445 1.12 dholland return bp1->b64 - bp2->b64;
1446 1.12 dholland } else {
1447 1.12 dholland return bp1->b32 - bp2->b32;
1448 1.12 dholland }
1449 1.12 dholland }
1450 1.12 dholland
1451 1.12 dholland /*
1452 1.12 dholland * struct segment
1453 1.12 dholland */
1454 1.12 dholland
1455 1.4 dholland
1456 1.1 dholland /*
1457 1.1 dholland * Macros for determining free space on the disk, with the variable metadata
1458 1.1 dholland * of segment summaries and inode blocks taken into account.
1459 1.1 dholland */
1460 1.1 dholland /*
1461 1.1 dholland * Estimate number of clean blocks not available for writing because
1462 1.1 dholland * they will contain metadata or overhead. This is calculated as
1463 1.1 dholland *
1464 1.1 dholland * E = ((C * M / D) * D + (0) * (T - D)) / T
1465 1.1 dholland * or more simply
1466 1.1 dholland * E = (C * M) / T
1467 1.1 dholland *
1468 1.1 dholland * where
1469 1.1 dholland * C is the clean space,
1470 1.1 dholland * D is the dirty space,
1471 1.1 dholland * M is the dirty metadata, and
1472 1.1 dholland * T = C + D is the total space on disk.
1473 1.1 dholland *
1474 1.1 dholland * This approximates the old formula of E = C * M / D when D is close to T,
1475 1.1 dholland * but avoids falsely reporting "disk full" when the sample size (D) is small.
1476 1.1 dholland */
1477 1.33 dholland #define LFS_EST_CMETA(F) (( \
1478 1.1 dholland (lfs_sb_getdmeta(F) * (int64_t)lfs_sb_getnclean(F)) / \
1479 1.1 dholland (lfs_sb_getnseg(F))))
1480 1.1 dholland
1481 1.1 dholland /* Estimate total size of the disk not including metadata */
1482 1.1 dholland #define LFS_EST_NONMETA(F) (lfs_sb_getdsize(F) - lfs_sb_getdmeta(F) - LFS_EST_CMETA(F))
1483 1.1 dholland
1484 1.1 dholland /* Estimate number of blocks actually available for writing */
1485 1.1 dholland #define LFS_EST_BFREE(F) (lfs_sb_getbfree(F) > LFS_EST_CMETA(F) ? \
1486 1.1 dholland lfs_sb_getbfree(F) - LFS_EST_CMETA(F) : 0)
1487 1.1 dholland
1488 1.1 dholland /* Amount of non-meta space not available to mortal man */
1489 1.33 dholland #define LFS_EST_RSVD(F) ((LFS_EST_NONMETA(F) * \
1490 1.46 dholland (uint64_t)lfs_sb_getminfree(F)) / \
1491 1.1 dholland 100)
1492 1.1 dholland
1493 1.4 dholland /* Can credential C write BB blocks? XXX: kauth_cred_geteuid is abusive */
1494 1.1 dholland #define ISSPACE(F, BB, C) \
1495 1.1 dholland ((((C) == NOCRED || kauth_cred_geteuid(C) == 0) && \
1496 1.1 dholland LFS_EST_BFREE(F) >= (BB)) || \
1497 1.1 dholland (kauth_cred_geteuid(C) != 0 && IS_FREESPACE(F, BB)))
1498 1.1 dholland
1499 1.1 dholland /* Can an ordinary user write BB blocks */
1500 1.1 dholland #define IS_FREESPACE(F, BB) \
1501 1.1 dholland (LFS_EST_BFREE(F) >= (BB) + LFS_EST_RSVD(F))
1502 1.1 dholland
1503 1.1 dholland /*
1504 1.1 dholland * The minimum number of blocks to create a new inode. This is:
1505 1.1 dholland * directory direct block (1) + ULFS_NIADDR indirect blocks + inode block (1) +
1506 1.1 dholland * ifile direct block (1) + ULFS_NIADDR indirect blocks = 3 + 2 * ULFS_NIADDR blocks.
1507 1.1 dholland */
1508 1.1 dholland #define LFS_NRESERVE(F) (lfs_btofsb((F), (2 * ULFS_NIADDR + 3) << lfs_sb_getbshift(F)))
1509 1.1 dholland
1510 1.1 dholland
1511 1.1 dholland
1512 1.1 dholland #endif /* _UFS_LFS_LFS_ACCESSORS_H_ */
1513