FreeBSD/Linux Kernel Cross Reference
sys/ufs/ufs/inode.h
1 /*
2 * Copyright (c) 1982, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)inode.h 8.9 (Berkeley) 5/14/95
39 * $FreeBSD: releng/5.2/sys/ufs/ufs/inode.h 118969 2003-08-15 20:03:19Z phk $
40 */
41
42 #ifndef _UFS_UFS_INODE_H_
43 #define _UFS_UFS_INODE_H_
44
45 #include <sys/lock.h>
46 #include <sys/queue.h>
47 #include <ufs/ufs/dinode.h>
48
49 /*
50 * This must agree with the definition in <ufs/ufs/dir.h>.
51 */
52 #define doff_t int32_t
53
54 /*
55 * The inode is used to describe each active (or recently active) file in the
56 * UFS filesystem. It is composed of two types of information. The first part
57 * is the information that is needed only while the file is active (such as
58 * the identity of the file and linkage to speed its lookup). The second part
59 * is the permanent meta-data associated with the file which is read in
60 * from the permanent dinode from long term storage when the file becomes
61 * active, and is put back when the file is no longer being used.
62 */
63 struct inode {
64 LIST_ENTRY(inode) i_hash;/* Hash chain. */
65 TAILQ_ENTRY(inode) i_nextsnap; /* snapshot file list. */
66 struct vnode *i_vnode;/* Vnode associated with this inode. */
67 struct ufsmount *i_ump;/* Ufsmount point associated with this inode. */
68 u_int32_t i_flag; /* flags, see below */
69 struct cdev *i_dev; /* Device associated with the inode. */
70 ino_t i_number; /* The identity of the inode. */
71 int i_effnlink; /* i_nlink when I/O completes */
72
73 struct fs *i_fs; /* Associated filesystem superblock. */
74 struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */
75 u_quad_t i_modrev; /* Revision level for NFS lease. */
76 struct lockf *i_lockf;/* Head of byte-level lock list. */
77 /*
78 * Side effects; used during directory lookup.
79 */
80 int32_t i_count; /* Size of free slot in directory. */
81 doff_t i_endoff; /* End of useful stuff in directory. */
82 doff_t i_diroff; /* Offset in dir, where we found last entry. */
83 doff_t i_offset; /* Offset of free space in directory. */
84 ino_t i_ino; /* Inode number of found directory. */
85 u_int32_t i_reclen; /* Size of found directory entry. */
86
87 union {
88 struct dirhash *dirhash; /* Hashing for large directories. */
89 daddr_t *snapblklist; /* Collect expunged snapshot blocks. */
90 } i_un;
91
92 /*
93 * Data for extended attribute modification.
94 */
95 u_char *i_ea_area; /* Pointer to malloced copy of EA area */
96 unsigned i_ea_len; /* Length of i_ea_area */
97 int i_ea_error; /* First errno in transaction */
98
99 /*
100 * Copies from the on-disk dinode itself.
101 */
102 u_int16_t i_mode; /* IFMT, permissions; see below. */
103 int16_t i_nlink; /* File link count. */
104 u_int64_t i_size; /* File byte count. */
105 u_int32_t i_flags; /* Status flags (chflags). */
106 int64_t i_gen; /* Generation number. */
107 u_int32_t i_uid; /* File owner. */
108 u_int32_t i_gid; /* File group. */
109 /*
110 * The real copy of the on-disk inode.
111 */
112 union {
113 struct ufs1_dinode *din1; /* UFS1 on-disk dinode. */
114 struct ufs2_dinode *din2; /* UFS2 on-disk dinode. */
115 } dinode_u;
116 };
117 /*
118 * These flags are kept in i_flag.
119 */
120 #define IN_ACCESS 0x0001 /* Access time update request. */
121 #define IN_CHANGE 0x0002 /* Inode change time update request. */
122 #define IN_UPDATE 0x0004 /* Modification time update request. */
123 #define IN_MODIFIED 0x0008 /* Inode has been modified. */
124 #define IN_RENAME 0x0010 /* Inode is being renamed. */
125 #define IN_HASHED 0x0020 /* Inode is on hash list */
126 #define IN_LAZYMOD 0x0040 /* Modified, but don't write yet. */
127 #define IN_SPACECOUNTED 0x0080 /* Blocks to be freed in free count. */
128
129 #define i_devvp i_ump->um_devvp
130 #define i_dirhash i_un.dirhash
131 #define i_snapblklist i_un.snapblklist
132 #define i_din1 dinode_u.din1
133 #define i_din2 dinode_u.din2
134
135 #ifdef _KERNEL
136 /*
137 * The DIP macro is used to access fields in the dinode that are
138 * not cached in the inode itself.
139 */
140 #define DIP(ip, field) \
141 (((ip)->i_ump->um_fstype == UFS1) ? \
142 (ip)->i_din1->d##field : (ip)->i_din2->d##field)
143
144 #define MAXSYMLINKLEN(ip) \
145 ((ip)->i_ump->um_fstype == UFS1) ? \
146 ((NDADDR + NIADDR) * sizeof(ufs1_daddr_t)) : \
147 ((NDADDR + NIADDR) * sizeof(ufs2_daddr_t))
148 #define SHORTLINK(ip) \
149 (((ip)->i_ump->um_fstype == UFS1) ? \
150 (caddr_t)(ip)->i_din1->di_db : (caddr_t)(ip)->i_din2->di_db)
151
152 /*
153 * Structure used to pass around logical block paths generated by
154 * ufs_getlbns and used by truncate and bmap code.
155 */
156 struct indir {
157 ufs2_daddr_t in_lbn; /* Logical block number. */
158 int in_off; /* Offset in buffer. */
159 int in_exists; /* Flag if the block exists. */
160 };
161
162 /* Convert between inode pointers and vnode pointers. */
163 #define VTOI(vp) ((struct inode *)(vp)->v_data)
164 #define ITOV(ip) ((ip)->i_vnode)
165
166 /* Determine if soft dependencies are being done */
167 #define DOINGSOFTDEP(vp) ((vp)->v_mount->mnt_flag & MNT_SOFTDEP)
168 #define DOINGASYNC(vp) ((vp)->v_mount->mnt_flag & MNT_ASYNC)
169
170 /* This overlays the fid structure (see mount.h). */
171 struct ufid {
172 u_int16_t ufid_len; /* Length of structure. */
173 u_int16_t ufid_pad; /* Force 32-bit alignment. */
174 ino_t ufid_ino; /* File number (ino). */
175 int32_t ufid_gen; /* Generation number. */
176 };
177 #endif /* _KERNEL */
178
179 #endif /* !_UFS_UFS_INODE_H_ */
Cache object: fa328d61ea4edcce3061e99c6a2d6b52
|