2 * Copyright (c) 1982, 1989 The Regents of the University of California.
\r
3 * All rights reserved.
\r
5 * Redistribution and use in source and binary forms, with or without
\r
6 * modification, are permitted provided that the following conditions
\r
8 * 1. Redistributions of source code must retain the above copyright
\r
9 * notice, this list of conditions and the following disclaimer.
\r
10 * 2. Redistributions in binary form must reproduce the above copyright
\r
11 * notice, this list of conditions and the following disclaimer in the
\r
12 * documentation and/or other materials provided with the distribution.
\r
13 * 3. All advertising materials mentioning features or use of this software
\r
14 * must display the following acknowledgement:
\r
15 * This product includes software developed by the University of
\r
16 * California, Berkeley and its contributors.
\r
17 * 4. Neither the name of the University nor the names of its contributors
\r
18 * may be used to endorse or promote products derived from this software
\r
19 * without specific prior written permission.
\r
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
\r
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
\r
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
\r
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\r
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
\r
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
\r
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
\r
33 * from: @(#)inode.h 7.17 (Berkeley) 5/8/91
\r
34 * $FreeBSD: src/sys/i386/boot/dosboot/inode.h,v 1.7 1999/12/29 04:32:51 peter Exp $
\r
35 * $DragonFly: src/sys/i386/boot/dosboot/Attic/inode.h,v 1.2 2003/06/17 04:28:34 dillon Exp $
\r
38 #ifndef _UFS_INODE_H_
\r
39 #define _UFS_INODE_H_ 1
\r
42 include "../ufs/dinode.h"
\r
48 * The inode is used to describe each active (or recently active)
\r
49 * file in the UFS filesystem. It is composed of two types of
\r
50 * information. The first part is the information that is needed
\r
51 * only while the file is active (such as the identity of the file
\r
52 * and linkage to speed its lookup). The second part is the
\r
53 * permannent meta-data associated with the file which is read
\r
54 * in from the permanent dinode from long term storage when the
\r
55 * file becomes active, and is put back when the file is no longer
\r
59 struct inode *i_chain[2]; /* hash chain, MUST be first */
\r
60 struct vnode *i_vnode; /* vnode associated with this inode */
\r
61 struct vnode *i_devvp; /* vnode for block I/O */
\r
62 u_long i_flag; /* see below */
\r
63 dev_t i_dev; /* device where inode resides */
\r
64 ino_t i_number; /* the identity of the inode */
\r
65 struct fs *i_fs; /* filesystem associated with this inode */
\r
66 struct dquot *i_dquot[MAXQUOTAS]; /* pointer to dquot structures */
\r
67 struct lockf *i_lockf; /* head of byte-level lock list */
\r
68 long i_diroff; /* offset in dir, where we found last entry */
\r
69 off_t i_endoff; /* end of useful stuff in directory */
\r
72 struct dinode i_din; /* the on-disk dinode */
\r
75 #define FASTLINK(ip) (DFASTLINK((ip)->i_din))
\r
76 #define i_symlink i_din.di_symlink
\r
77 #define i_mode i_din.di_mode
\r
78 #define i_nlink i_din.di_nlink
\r
79 #define i_uid i_din.di_uid
\r
80 #define i_gid i_din.di_gid
\r
81 #if BYTE_ORDER == LITTLE_ENDIAN || defined(tahoe) /* ugh! -- must be fixed */
\r
82 #define i_size i_din.di_qsize.val[0]
\r
83 #else /* BYTE_ORDER == BIG_ENDIAN */
\r
84 #define i_size i_din.di_qsize.val[1]
\r
86 #define i_db i_din.di_db
\r
87 #define i_ib i_din.di_ib
\r
88 #define i_atime i_din.di_atime
\r
89 #define i_mtime i_din.di_mtime
\r
90 #define i_ctime i_din.di_ctime
\r
91 #define i_blocks i_din.di_blocks
\r
92 #define i_rdev i_din.di_db[0]
\r
93 #define i_flags i_din.di_flags
\r
94 #define i_gen i_din.di_gen
\r
95 #define i_forw i_chain[0]
\r
96 #define i_back i_chain[1]
\r
97 #define i_di_spare i_din.di_spare
\r
100 #define ILOCKED 0x0001 /* inode is locked */
\r
101 #define IWANT 0x0002 /* some process waiting on lock */
\r
102 #define IRENAME 0x0004 /* inode is being renamed */
\r
103 #define IUPD 0x0010 /* file has been modified */
\r
104 #define IACC 0x0020 /* inode access time to be updated */
\r
105 #define ICHG 0x0040 /* inode has been changed */
\r
106 #define IMOD 0x0080 /* inode has been modified */
\r
107 #define ISHLOCK 0x0100 /* file has shared lock */
\r
108 #define IEXLOCK 0x0200 /* file has exclusive lock */
\r
109 #define ILWAIT 0x0400 /* someone waiting on file lock */
\r
113 * Convert between inode pointers and vnode pointers
\r
115 #define VTOI(vp) ((struct inode *)(vp)->v_data)
\r
116 #define ITOV(ip) ((ip)->i_vnode)
\r
119 * Convert between vnode types and inode formats
\r
121 extern enum vtype iftovt_tab[];
\r
122 extern int vttoif_tab[];
\r
123 #define IFTOVT(mode) (iftovt_tab[((mode) & IFMT) >> 12])
\r
124 #define VTTOIF(indx) (vttoif_tab[(int)(indx)])
\r
126 #define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))
\r
128 extern u_long nextgennumber; /* next generation number to assign */
\r
130 extern ino_t dirpref();
\r
133 * Lock and unlock inodes.
\r
136 #define ILOCK(ip) { \
\r
137 while ((ip)->i_flag & ILOCKED) { \
\r
138 (ip)->i_flag |= IWANT; \
\r
139 (void) sleep((caddr_t)(ip), PINOD); \
\r
141 (ip)->i_flag |= ILOCKED; \
\r
144 #define IUNLOCK(ip) { \
\r
145 (ip)->i_flag &= ~ILOCKED; \
\r
146 if ((ip)->i_flag&IWANT) { \
\r
147 (ip)->i_flag &= ~IWANT; \
\r
148 wakeup((caddr_t)(ip)); \
\r
152 #define ILOCK(ip) ilock(ip)
\r
153 #define IUNLOCK(ip) iunlock(ip)
\r
156 #define IUPDAT(ip, t1, t2, waitfor) { \
\r
157 if (ip->i_flag&(IUPD|IACC|ICHG|IMOD)) \
\r
158 (void) iupdat(ip, t1, t2, waitfor); \
\r
162 * This overlays the fid sturcture (see mount.h)
\r
165 u_short ufid_len; /* length of structure */
\r
166 u_short ufid_pad; /* force long alignment */
\r
167 ino_t ufid_ino; /* file number (ino) */
\r
168 long ufid_gen; /* generation number */
\r
172 * Prototypes for UFS vnode operations
\r
174 int ufs_lookup __P((struct vnode *vp, struct nameidata *ndp, struct proc *p));
\r
175 int ufs_create __P((struct nameidata *ndp, struct vattr *vap, struct proc *p));
\r
176 int ufs_mknod __P((struct nameidata *ndp, struct vattr *vap, struct ucred *cred,
\r
178 int ufs_open __P((struct vnode *vp, int mode, struct ucred *cred,
\r
180 int ufs_close __P((struct vnode *vp, int fflag, struct ucred *cred,
\r
182 int ufs_access __P((struct vnode *vp, int mode, struct ucred *cred,
\r
184 int ufs_getattr __P((struct vnode *vp, struct vattr *vap, struct ucred *cred,
\r
186 int ufs_setattr __P((struct vnode *vp, struct vattr *vap, struct ucred *cred,
\r
188 int ufs_read __P((struct vnode *vp, struct uio *uio, int ioflag,
\r
189 struct ucred *cred));
\r
190 int ufs_write __P((struct vnode *vp, struct uio *uio, int ioflag,
\r
191 struct ucred *cred));
\r
192 int ufs_ioctl __P((struct vnode *vp, int command, caddr_t data, int fflag,
\r
193 struct ucred *cred, struct proc *p));
\r
194 int ufs_select __P((struct vnode *vp, int which, int fflags, struct ucred *cred,
\r
196 int ufs_mmap __P((struct vnode *vp, int fflags, struct ucred *cred,
\r
198 int ufs_fsync __P((struct vnode *vp, int fflags, struct ucred *cred,
\r
199 int waitfor, struct proc *p));
\r
200 int ufs_seek __P((struct vnode *vp, off_t oldoff, off_t newoff,
\r
201 struct ucred *cred));
\r
202 int ufs_remove __P((struct nameidata *ndp, struct proc *p));
\r
203 int ufs_link __P((struct vnode *vp, struct nameidata *ndp, struct proc *p));
\r
204 int ufs_rename __P((struct nameidata *fndp, struct nameidata *tdnp,
\r
206 int ufs_mkdir __P((struct nameidata *ndp, struct vattr *vap, struct proc *p));
\r
207 int ufs_rmdir __P((struct nameidata *ndp, struct proc *p));
\r
208 int ufs_symlink __P((struct nameidata *ndp, struct vattr *vap, char *target,
\r
210 int ufs_readdir __P((struct vnode *vp, struct uio *uio, struct ucred *cred,
\r
212 int ufs_readlink __P((struct vnode *vp, struct uio *uio, struct ucred *cred));
\r
213 int ufs_abortop __P((struct nameidata *ndp));
\r
214 int ufs_inactive __P((struct vnode *vp, struct proc *p));
\r
215 int ufs_reclaim __P((struct vnode *vp));
\r
216 int ufs_lock __P((struct vnode *vp));
\r
217 int ufs_unlock __P((struct vnode *vp));
\r
218 int ufs_bmap __P((struct vnode *vp, daddr_t bn, struct vnode **vpp,
\r
220 int ufs_strategy __P((struct buf *bp));
\r
221 void ufs_print __P((struct vnode *vp));
\r
222 int ufs_islocked __P((struct vnode *vp));
\r
223 int ufs_advlock __P((struct vnode *vp, caddr_t id, int op, struct flock *fl,
\r
226 extern void blkfree(struct inode *, daddr_t, off_t);
\r
227 extern void ifree(struct inode *, ino_t, int);
\r
228 extern void iput(struct inode *);
\r
229 extern void ilock(struct inode *);
\r
230 extern void iunlock(struct inode *);
\r
231 extern void dirbad(struct inode *, off_t, char *);
\r
233 extern int alloc(struct inode *, daddr_t, daddr_t, int, daddr_t *);
\r
234 extern int realloccg(struct inode *, off_t, daddr_t, int, int, struct buf **);
\r
235 extern int ialloc(struct inode *, ino_t, int, struct ucred *, struct inode **);
\r
236 extern daddr_t blkpref(struct inode *, daddr_t, int, daddr_t *);
\r
237 extern u_long hashalloc(struct inode *, int, long, int,
\r
238 u_long (*)(struct inode *, int, long, int));
\r
239 extern daddr_t fragextend(struct inode *, int, long, int, int);
\r
240 extern daddr_t alloccg(struct inode *, int, daddr_t, int);
\r
242 struct cg; /* I really don't want to know why */
\r
243 struct direct; /* this header is required by NFS... */
\r
245 extern daddr_t alloccgblk(struct fs *, struct cg *, daddr_t);
\r
246 extern ino_t ialloccg(struct inode *, int, daddr_t, int);
\r
247 extern int ufs_lookup(struct vnode *, struct nameidata *, struct proc *);
\r
248 extern int dirbadentry(struct direct *, int);
\r
249 extern int direnter(struct inode *, struct nameidata *);
\r
250 extern int dirremove(struct nameidata *);
\r
251 extern int dirrewrite(struct inode *, struct inode *, struct nameidata *);
\r
252 extern int blkatoff(struct inode *, off_t, char **, struct buf **);
\r
253 extern int dirempty(struct inode *, ino_t, struct ucred *);
\r
254 extern int checkpath(struct inode *, struct inode *, struct ucred *);
\r
256 extern void ufs_init(void);
\r
257 extern int iget(struct inode *, ino_t, struct inode **);
\r
258 extern int ufs_inactive(struct vnode *, struct proc *);
\r
259 extern int ufs_reclaim(struct vnode *);
\r
260 extern int iupdat(struct inode *, struct timeval *, struct timeval *,
\r
262 extern int itrunc(struct inode *, u_long, int);
\r
263 extern int indirtrunc(struct inode *, daddr_t, daddr_t, int, long *);
\r
265 extern int bmap(struct inode *, daddr_t, daddr_t *);
\r
266 extern int balloc(struct inode *, daddr_t, int, struct buf **, int);
\r
268 #endif /* _KERNEL */
\r
269 #endif /* _UFS_INODE_H_ */
\r