]>
git.saurik.com Git - apple/xnu.git/blob - bsd/ufs/ufs/inode.h
3aeaeab6b7a20c09b56e3a5d640f7086cfd7ed9d
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
24 * Copyright (c) 1982, 1989, 1993
25 * The Regents of the University of California. All rights reserved.
26 * (c) UNIX System Laboratories, Inc.
27 * All or some portions of this file are derived from material licensed
28 * to the University of California by American Telephone and Telegraph
29 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
30 * the permission of UNIX System Laboratories, Inc.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 3. All advertising materials mentioning features or use of this software
41 * must display the following acknowledgement:
42 * This product includes software developed by the University of
43 * California, Berkeley and its contributors.
44 * 4. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * @(#)inode.h 8.9 (Berkeley) 5/14/95
65 #include <ufs/ufs/dir.h>
66 #include <ufs/ufs/dinode.h>
70 * The inode is used to describe each active (or recently active) file in the
71 * UFS filesystem. It is composed of two types of information. The first part
72 * is the information that is needed only while the file is active (such as
73 * the identity of the file and linkage to speed its lookup). The second part
74 * is * the permanent meta-data associated with the file which is read in
75 * from the permanent dinode from long term storage when the file becomes
76 * active, and is put back when the file is no longer being used.
79 LIST_ENTRY(inode
) i_hash
;/* Hash chain. */
80 struct vnode
*i_vnode
;/* Vnode associated with this inode. */
81 struct vnode
*i_devvp
;/* Vnode for block I/O. */
82 u_int32_t i_flag
; /* flags, see below */
83 dev_t i_dev
; /* Device associated with the inode. */
84 ino_t i_number
; /* The identity of the inode. */
86 union { /* Associated filesystem. */
87 struct fs
*fs
; /* FFS */
89 struct lfs
*lfs
; /* LFS */
92 #define i_fs inode_u.fs
94 #define i_lfs inode_u.lfs
97 struct dquot
*i_dquot
[MAXQUOTAS
]; /* Dquot structures. */
98 u_quad_t i_modrev
; /* Revision level for NFS lease. */
99 struct lockf
*i_lockf
;/* Head of byte-level lock list. */
100 struct lock__bsd__ i_lock
; /* Inode lock. */
102 * Side effects; used during directory lookup.
104 int32_t i_count
; /* Size of free slot in directory. */
105 doff_t i_endoff
; /* End of useful stuff in directory. */
106 doff_t i_diroff
; /* Offset in dir, where we found last entry. */
107 doff_t i_offset
; /* Offset of free space in directory. */
108 ino_t i_ino
; /* Inode number of found directory. */
109 u_int32_t i_reclen
; /* Size of found directory entry. */
111 * The on-disk dinode itself.
113 struct dinode i_din
; /* 128 bytes of the on-disk dinode. */
116 #define i_atime i_din.di_atime
117 #define i_atimensec i_din.di_atimensec
118 #define i_blocks i_din.di_blocks
119 #define i_ctime i_din.di_ctime
120 #define i_ctimensec i_din.di_ctimensec
121 #define i_db i_din.di_db
122 #define i_flags i_din.di_flags
123 #define i_gen i_din.di_gen
124 #define i_gid i_din.di_gid
125 #define i_ib i_din.di_ib
126 #define i_mode i_din.di_mode
127 #define i_mtime i_din.di_mtime
128 #define i_mtimensec i_din.di_mtimensec
129 #define i_nlink i_din.di_nlink
130 #define i_rdev i_din.di_rdev
131 #define i_shortlink i_din.di_shortlink
132 #define i_size i_din.di_size
133 #define i_uid i_din.di_uid
134 #define i_spare i_din.di_spare
135 #define i_oldids i_din.di_u.oldids
136 #define i_inumber i_din.di_u.inumber
138 /* These flags are kept in i_flag. */
139 #define IN_ACCESS 0x0001 /* Access time update request. */
140 #define IN_CHANGE 0x0002 /* Inode change time update request. */
141 #define IN_UPDATE 0x0004 /* Modification time update request. */
142 #define IN_MODIFIED 0x0008 /* Inode has been modified. */
143 #define IN_RENAME 0x0010 /* Inode is being renamed. */
144 #define IN_SHLOCK 0x0020 /* File has shared lock. */
145 #define IN_EXLOCK 0x0040 /* File has exclusive lock. */
146 #define IN_TRANSIT 0x0080 /* inode is getting recycled */
147 #define IN_WTRANSIT 0x0100 /* waiting for inode getting recycled */
151 * Structure used to pass around logical block paths generated by
152 * ufs_getlbns and used by truncate and bmap code.
155 ufs_daddr_t in_lbn
; /* Logical block number. */
156 int in_off
; /* Offset in buffer. */
157 int in_exists
; /* Flag if the block exists. */
160 /* Convert between inode pointers and vnode pointers. */
161 #define VTOI(vp) ((struct inode *)(vp)->v_data)
162 #define ITOV(ip) ((ip)->i_vnode)
164 #define ITIMES(ip, t1, t2) { \
165 if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \
166 (ip)->i_flag |= IN_MODIFIED; \
167 if ((ip)->i_flag & IN_ACCESS) \
168 (ip)->i_atime = (t1)->tv_sec; \
169 if ((ip)->i_flag & IN_UPDATE) { \
170 (ip)->i_mtime = (t2)->tv_sec; \
173 if ((ip)->i_flag & IN_CHANGE) \
174 (ip)->i_ctime = time.tv_sec; \
175 (ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \
179 /* This overlays the fid structure (see mount.h). */
181 u_int16_t ufid_len
; /* Length of structure. */
182 u_int16_t ufid_pad
; /* Force 32-bit alignment. */
183 ino_t ufid_ino
; /* File number (ino). */
184 int32_t ufid_gen
; /* Generation number. */
188 #endif /* ! _UFS_INDOE_H_ */