ulfs_inode.h revision 1.6 1 /* $NetBSD: ulfs_inode.h,v 1.6 2013/06/08 02:04:31 dholland Exp $ */
2 /* from NetBSD: inode.h,v 1.64 2012/11/19 00:36:21 jakllsch Exp */
3
4 /*
5 * Copyright (c) 1982, 1989, 1993
6 * The Regents of the University of California. All rights reserved.
7 * (c) UNIX System Laboratories, Inc.
8 * All or some portions of this file are derived from material licensed
9 * to the University of California by American Telephone and Telegraph
10 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
11 * the permission of UNIX System Laboratories, Inc.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * @(#)inode.h 8.9 (Berkeley) 5/14/95
38 */
39
40 #ifndef _UFS_LFS_ULFS_INODE_H_
41 #define _UFS_LFS_ULFS_INODE_H_
42
43 #include <sys/vnode.h>
44 #include <ufs/lfs/lfs_inode.h>
45 #include <ufs/lfs/ulfs_dinode.h>
46 #include <ufs/lfs/ulfs_dir.h>
47 #include <ufs/lfs/ulfs_quotacommon.h>
48
49 #if defined(_KERNEL)
50
51 /*
52 * The DIP macro is used to access fields in the dinode that are
53 * not cached in the inode itself.
54 */
55 #define DIP(ip, field) \
56 (((ip)->i_ump->um_fstype == ULFS1) ? \
57 (ip)->i_ffs1_##field : (ip)->i_ffs2_##field)
58
59 #define DIP_ASSIGN(ip, field, value) \
60 do { \
61 if ((ip)->i_ump->um_fstype == ULFS1) \
62 (ip)->i_ffs1_##field = (value); \
63 else \
64 (ip)->i_ffs2_##field = (value); \
65 } while(0)
66
67 #define DIP_ADD(ip, field, value) \
68 do { \
69 if ((ip)->i_ump->um_fstype == ULFS1) \
70 (ip)->i_ffs1_##field += (value); \
71 else \
72 (ip)->i_ffs2_##field += (value); \
73 } while(0)
74
75 #define SHORTLINK(ip) \
76 (((ip)->i_ump->um_fstype == ULFS1) ? \
77 (void *)(ip)->i_ffs1_db : (void *)(ip)->i_ffs2_db)
78
79
80 /*
81 * Structure used to pass around logical block paths generated by
82 * ulfs_getlbns and used by truncate and bmap code.
83 */
84 struct indir {
85 daddr_t in_lbn; /* Logical block number. */
86 int in_off; /* Offset in buffer. */
87 int in_exists; /* Flag if the block exists. */
88 };
89
90 /* Convert between inode pointers and vnode pointers. */
91 #define VTOI(vp) ((struct inode *)(vp)->v_data)
92 #define ITOV(ip) ((ip)->i_vnode)
93
94 #endif /* _KERNEL */
95
96 #endif /* !_UFS_LFS_ULFS_INODE_H_ */
97