minor lint; initialize modrev time for NFS leases
[unix-history] / usr / src / sys / ufs / ufs / inode.h
CommitLineData
da7c5cc6 1/*
6d0f0ece
KM
2 * Copyright (c) 1982, 1989 The Regents of the University of California.
3 * All rights reserved.
da7c5cc6 4 *
beeb3369 5 * %sccs.include.redist.c%
6d0f0ece 6 *
c0f23154 7 * @(#)inode.h 7.20 (Berkeley) %G%
da7c5cc6 8 */
d0064d3a 9
9abdb11d 10#include <ufs/ufs/dinode.h>
be213d5e 11
d0064d3a 12/*
409536a4
KM
13 * The inode is used to describe each active (or recently active)
14 * file in the UFS filesystem. It is composed of two types of
15 * information. The first part is the information that is needed
16 * only while the file is active (such as the identity of the file
17 * and linkage to speed its lookup). The second part is the
18 * permannent meta-data associated with the file which is read
19 * in from the permanent dinode from long term storage when the
20 * file becomes active, and is put back when the file is no longer
21 * being used.
d0064d3a 22 */
a59abf09 23struct inode {
be213d5e
KM
24 struct inode *i_chain[2]; /* hash chain, MUST be first */
25 struct vnode *i_vnode; /* vnode associated with this inode */
6d0f0ece 26 struct vnode *i_devvp; /* vnode for block I/O */
0997b03c 27 u_long i_flag; /* see below */
d0064d3a 28 dev_t i_dev; /* device where inode resides */
200c8b2d 29 short i_pad;
409536a4 30 ino_t i_number; /* the identity of the inode */
9abdb11d
KB
31 union { /* associated filesystem */
32 struct fs *fs; /* FFS */
33 struct lfs *lfs; /* LFS */
34 } inode_u;
35#define i_fs inode_u.fs
36#define i_lfs inode_u.lfs
8923104b 37 struct dquot *i_dquot[MAXQUOTAS]; /* pointer to dquot structures */
409536a4 38 struct lockf *i_lockf; /* head of byte-level lock list */
be213d5e 39 long i_diroff; /* offset in dir, where we found last entry */
6d0f0ece 40 off_t i_endoff; /* end of useful stuff in directory */
c0f23154 41 u_quad_t i_modrev; /* revision level for lease */
200c8b2d
KM
42 pid_t i_lockholder; /* DEBUG: holder of inode lock */
43 pid_t i_lockwaiter; /* DEBUG: latest blocked for inode lock */
44 long i_spare[16]; /* spares to round up to 256 bytes */
409536a4 45 struct dinode i_din; /* the on-disk dinode */
d0064d3a
BJ
46};
47
be213d5e
KM
48#define i_mode i_din.di_mode
49#define i_nlink i_din.di_nlink
50#define i_uid i_din.di_uid
51#define i_gid i_din.di_gid
c0f23154
KM
52#ifdef _NOQUAD
53#define i_size i_din.di_qsize.val[_QUAD_LOWWORD]
54#else
55#define i_size i_din.di_qsize
56#endif
57#if defined(tahoe) /* ugh! -- must be fixed */
58#undef i_size
be213d5e 59#define i_size i_din.di_qsize.val[0]
961945a8 60#endif
be213d5e
KM
61#define i_db i_din.di_db
62#define i_ib i_din.di_ib
63#define i_atime i_din.di_atime
64#define i_mtime i_din.di_mtime
65#define i_ctime i_din.di_ctime
66#define i_blocks i_din.di_blocks
67#define i_rdev i_din.di_db[0]
68#define i_flags i_din.di_flags
69#define i_gen i_din.di_gen
69bd12a8
RE
70#define i_forw i_chain[0]
71#define i_back i_chain[1]
ad30fb67 72
d0064d3a 73/* flags */
771f4649
KM
74#define ILOCKED 0x0001 /* inode is locked */
75#define IWANT 0x0002 /* some process waiting on lock */
76#define IRENAME 0x0004 /* inode is being renamed */
77#define IUPD 0x0010 /* file has been modified */
78#define IACC 0x0020 /* inode access time to be updated */
79#define ICHG 0x0040 /* inode has been changed */
80#define IMOD 0x0080 /* inode has been modified */
81#define ISHLOCK 0x0100 /* file has shared lock */
82#define IEXLOCK 0x0200 /* file has exclusive lock */
83#define ILWAIT 0x0400 /* someone waiting on file lock */
d0064d3a 84
6d0f0ece 85#ifdef KERNEL
9abdb11d 86/* Convert between inode pointers and vnode pointers. */
6d0f0ece 87#define VTOI(vp) ((struct inode *)(vp)->v_data)
be213d5e 88#define ITOV(ip) ((ip)->i_vnode)
6d0f0ece 89
9abdb11d 90/* Convert between vnode types and inode formats. */
6d0f0ece
KM
91extern enum vtype iftovt_tab[];
92extern int vttoif_tab[];
45b72508 93#define IFTOVT(mode) (iftovt_tab[((mode) & IFMT) >> 12])
6d0f0ece
KM
94#define VTTOIF(indx) (vttoif_tab[(int)(indx)])
95
96#define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))
97
9abdb11d 98/* Lock and unlock inodes. */
30fd732d 99#ifdef notdef
02dd5a44
BJ
100#define ILOCK(ip) { \
101 while ((ip)->i_flag & ILOCKED) { \
102 (ip)->i_flag |= IWANT; \
6d0f0ece 103 (void) sleep((caddr_t)(ip), PINOD); \
02dd5a44
BJ
104 } \
105 (ip)->i_flag |= ILOCKED; \
106}
107
108#define IUNLOCK(ip) { \
109 (ip)->i_flag &= ~ILOCKED; \
110 if ((ip)->i_flag&IWANT) { \
111 (ip)->i_flag &= ~IWANT; \
112 wakeup((caddr_t)(ip)); \
113 } \
114}
30fd732d 115#else
9abdb11d
KB
116#define ILOCK(ip) ufs_ilock(ip)
117#define IUNLOCK(ip) ufs_iunlock(ip)
30fd732d 118#endif
02dd5a44 119
232d0cb7
MK
120#define ITIMES(ip, t1, t2) { \
121 if ((ip)->i_flag&(IUPD|IACC|ICHG)) { \
122 (ip)->i_flag |= IMOD; \
123 if ((ip)->i_flag&IACC) \
124 (ip)->i_atime = (t1)->tv_sec; \
c0f23154 125 if ((ip)->i_flag&IUPD) { \
232d0cb7 126 (ip)->i_mtime = (t2)->tv_sec; \
c0f23154
KM
127 INCRQUAD((ip)->i_modrev); \
128 } \
232d0cb7
MK
129 if ((ip)->i_flag&ICHG) \
130 (ip)->i_ctime = time.tv_sec; \
131 (ip)->i_flag &= ~(IACC|IUPD|ICHG); \
132 } \
133}
6d0f0ece 134
9abdb11d 135/* This overlays the fid structure (see mount.h). */
6d0f0ece 136struct ufid {
be213d5e
KM
137 u_short ufid_len; /* length of structure */
138 u_short ufid_pad; /* force long alignment */
139 ino_t ufid_ino; /* file number (ino) */
140 long ufid_gen; /* generation number */
6d0f0ece 141};
f1d03a87 142#endif /* KERNEL */