what the heck one last one before i go take a nap...
[dragonfly.git] / sys / i386 / boot / dosboot / inode.h
CommitLineData
984263bc
MD
1/*\r
2 * Copyright (c) 1982, 1989 The Regents of the University of California.\r
3 * All rights reserved.\r
4 *\r
5 * Redistribution and use in source and binary forms, with or without\r
6 * modification, are permitted provided that the following conditions\r
7 * are met:\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
20 *\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
31 * SUCH DAMAGE.\r
32 *\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
3ae0cd58 35 * $DragonFly: src/sys/i386/boot/dosboot/Attic/inode.h,v 1.4 2003/08/26 21:42:17 rob Exp $\r
984263bc
MD
36 */\r
37\r
38#ifndef _UFS_INODE_H_\r
39#define _UFS_INODE_H_ 1\r
40\r
41#ifdef KERNEL\r
42include "../ufs/dinode.h"\r
43#else\r
44#include "dinode.h"\r
45#endif\r
46\r
47/*\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
56 * being used.\r
57 */\r
58struct inode {\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
70 long i_spare0;\r
71 long i_spare1;\r
72 struct dinode i_din; /* the on-disk dinode */\r
73};\r
74\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
85#endif\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
98\r
99/* flags */\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
110\r
111#ifdef KERNEL\r
112/*\r
113 * Convert between inode pointers and vnode pointers\r
114 */\r
115#define VTOI(vp) ((struct inode *)(vp)->v_data)\r
116#define ITOV(ip) ((ip)->i_vnode)\r
117\r
118/*\r
119 * Convert between vnode types and inode formats\r
120 */\r
121extern enum vtype iftovt_tab[];\r
122extern int vttoif_tab[];\r
123#define IFTOVT(mode) (iftovt_tab[((mode) & IFMT) >> 12])\r
124#define VTTOIF(indx) (vttoif_tab[(int)(indx)])\r
125\r
126#define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))\r
127\r
128extern u_long nextgennumber; /* next generation number to assign */\r
129\r
130extern ino_t dirpref();\r
131\r
132/*\r
133 * Lock and unlock inodes.\r
134 */\r
135#ifdef notdef\r
136#define ILOCK(ip) { \\r
137 while ((ip)->i_flag & ILOCKED) { \\r
138 (ip)->i_flag |= IWANT; \\r
2f65cd66 139 (void) sleep((caddr_t)(ip), 0); \\r
984263bc
MD
140 } \\r
141 (ip)->i_flag |= ILOCKED; \\r
142}\r
143\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
149 } \\r
150}\r
151#else\r
152#define ILOCK(ip) ilock(ip)\r
153#define IUNLOCK(ip) iunlock(ip)\r
154#endif\r
155\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
159}\r
160\r
161/*\r
162 * This overlays the fid sturcture (see mount.h)\r
163 */\r
164struct ufid {\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
169};\r
170\r
171/*\r
172 * Prototypes for UFS vnode operations\r
173 */\r
3ae0cd58
RG
174int ufs_lookup (struct vnode *vp, struct nameidata *ndp, struct proc *p);\r
175int ufs_create (struct nameidata *ndp, struct vattr *vap, struct proc *p);\r
176int ufs_mknod (struct nameidata *ndp, struct vattr *vap, struct ucred *cred,\r
177 struct proc *p);\r
178int ufs_open (struct vnode *vp, int mode, struct ucred *cred,\r
179 struct proc *p);\r
180int ufs_close (struct vnode *vp, int fflag, struct ucred *cred,\r
181 struct proc *p);\r
182int ufs_access (struct vnode *vp, int mode, struct ucred *cred,\r
183 struct proc *p);\r
184int ufs_getattr (struct vnode *vp, struct vattr *vap, struct ucred *cred,\r
185 struct proc *p);\r
186int ufs_setattr (struct vnode *vp, struct vattr *vap, struct ucred *cred,\r
187 struct proc *p);\r
188int ufs_read (struct vnode *vp, struct uio *uio, int ioflag,\r
189 struct ucred *cred);\r
190int ufs_write (struct vnode *vp, struct uio *uio, int ioflag,\r
191 struct ucred *cred);\r
192int ufs_ioctl (struct vnode *vp, int command, caddr_t data, int fflag,\r
193 struct ucred *cred, struct proc *p);\r
194int ufs_select (struct vnode *vp, int which, int fflags, struct ucred *cred,\r
195 struct proc *p);\r
196int ufs_mmap (struct vnode *vp, int fflags, struct ucred *cred,\r
197 struct proc *p);\r
198int ufs_fsync (struct vnode *vp, int fflags, struct ucred *cred,\r
199 int waitfor, struct proc *p);\r
200int ufs_seek (struct vnode *vp, off_t oldoff, off_t newoff,\r
201 struct ucred *cred);\r
202int ufs_remove (struct nameidata *ndp, struct proc *p);\r
203int ufs_link (struct vnode *vp, struct nameidata *ndp, struct proc *p);\r
204int ufs_rename (struct nameidata *fndp, struct nameidata *tdnp,\r
205 struct proc *p);\r
206int ufs_mkdir (struct nameidata *ndp, struct vattr *vap, struct proc *p);\r
207int ufs_rmdir (struct nameidata *ndp, struct proc *p);\r
208int ufs_symlink (struct nameidata *ndp, struct vattr *vap, char *target,\r
209 struct proc *p);\r
210int ufs_readdir (struct vnode *vp, struct uio *uio, struct ucred *cred,\r
211 int *eofflagp);\r
212int ufs_readlink (struct vnode *vp, struct uio *uio, struct ucred *cred);\r
213int ufs_abortop (struct nameidata *ndp);\r
214int ufs_inactive (struct vnode *vp, struct proc *p);\r
215int ufs_reclaim (struct vnode *vp);\r
216int ufs_lock (struct vnode *vp);\r
217int ufs_unlock (struct vnode *vp);\r
218int ufs_bmap (struct vnode *vp, daddr_t bn, struct vnode **vpp,\r
219 daddr_t *bnp);\r
220int ufs_strategy (struct buf *bp);\r
221void ufs_print (struct vnode *vp);\r
222int ufs_islocked (struct vnode *vp);\r
223int ufs_advlock (struct vnode *vp, caddr_t id, int op, struct flock *fl,\r
224 int flags);\r
984263bc
MD
225\r
226extern void blkfree(struct inode *, daddr_t, off_t);\r
227extern void ifree(struct inode *, ino_t, int);\r
228extern void iput(struct inode *);\r
229extern void ilock(struct inode *);\r
230extern void iunlock(struct inode *);\r
231extern void dirbad(struct inode *, off_t, char *);\r
232\r
233extern int alloc(struct inode *, daddr_t, daddr_t, int, daddr_t *);\r
234extern int realloccg(struct inode *, off_t, daddr_t, int, int, struct buf **);\r
235extern int ialloc(struct inode *, ino_t, int, struct ucred *, struct inode **);\r
236extern daddr_t blkpref(struct inode *, daddr_t, int, daddr_t *);\r
237extern u_long hashalloc(struct inode *, int, long, int, \r
3ae0cd58 238 u_long (*)(struct inode *, int, long, int);\r
984263bc
MD
239extern daddr_t fragextend(struct inode *, int, long, int, int);\r
240extern daddr_t alloccg(struct inode *, int, daddr_t, int);\r
241\r
242struct cg; /* I really don't want to know why */\r
243struct direct; /* this header is required by NFS... */\r
244\r
245extern daddr_t alloccgblk(struct fs *, struct cg *, daddr_t);\r
246extern ino_t ialloccg(struct inode *, int, daddr_t, int);\r
247extern int ufs_lookup(struct vnode *, struct nameidata *, struct proc *);\r
248extern int dirbadentry(struct direct *, int);\r
249extern int direnter(struct inode *, struct nameidata *);\r
250extern int dirremove(struct nameidata *);\r
251extern int dirrewrite(struct inode *, struct inode *, struct nameidata *);\r
252extern int blkatoff(struct inode *, off_t, char **, struct buf **);\r
253extern int dirempty(struct inode *, ino_t, struct ucred *);\r
254extern int checkpath(struct inode *, struct inode *, struct ucred *);\r
255\r
256extern void ufs_init(void);\r
257extern int iget(struct inode *, ino_t, struct inode **);\r
258extern int ufs_inactive(struct vnode *, struct proc *);\r
259extern int ufs_reclaim(struct vnode *);\r
260extern int iupdat(struct inode *, struct timeval *, struct timeval *,\r
261 int);\r
262extern int itrunc(struct inode *, u_long, int);\r
263extern int indirtrunc(struct inode *, daddr_t, daddr_t, int, long *);\r
264\r
265extern int bmap(struct inode *, daddr_t, daddr_t *);\r
266extern int balloc(struct inode *, daddr_t, int, struct buf **, int);\r
267\r
268#endif /* _KERNEL */\r
269#endif /* _UFS_INODE_H_ */\r