123419Smckusick /* 263376Sbostic * Copyright (c) 1982, 1989, 1993 363376Sbostic * The Regents of the University of California. All rights reserved. 423419Smckusick * 541535Smckusick * %sccs.include.redist.c% 637714Smckusick * 7*64513Sbostic * @(#)inode.h 8.2 (Berkeley) 09/21/93 823419Smckusick */ 958Sbill 1051505Sbostic #include <ufs/ufs/dinode.h> 1139387Smckusick 1258Sbill /* 13*64513Sbostic * Theoretically, directories can be more than 2Gb in length, however, in 14*64513Sbostic * practice this seems unlikely. So, we define the type doff_t as a long 15*64513Sbostic * to keep down the cost of doing lookup on a 32-bit machine. If you are 16*64513Sbostic * porting to a 64-bit architecture, you should make doff_t the same as off_t. 1753061Smckusick */ 18*64513Sbostic #define doff_t long 1953061Smckusick 2053061Smckusick /* 2149448Smckusick * The inode is used to describe each active (or recently active) 2249448Smckusick * file in the UFS filesystem. It is composed of two types of 2349448Smckusick * information. The first part is the information that is needed 2449448Smckusick * only while the file is active (such as the identity of the file 2549448Smckusick * and linkage to speed its lookup). The second part is the 2649448Smckusick * permannent meta-data associated with the file which is read 2749448Smckusick * in from the permanent dinode from long term storage when the 2849448Smckusick * file becomes active, and is put back when the file is no longer 2949448Smckusick * being used. 3058Sbill */ 314814Swnj struct inode { 32*64513Sbostic struct inode *i_next; /* Hash chain forward. */ 33*64513Sbostic struct inode **i_prev; /* Hash chain back. */ 34*64513Sbostic struct vnode *i_vnode; /* Vnode associated with this inode. */ 35*64513Sbostic struct vnode *i_devvp; /* Vnode for block I/O. */ 36*64513Sbostic u_long i_flag; /* I* flags. */ 37*64513Sbostic dev_t i_dev; /* Device associated with the inode. */ 38*64513Sbostic ino_t i_number; /* The identity of the inode. */ 39*64513Sbostic union { /* Associated filesystem. */ 4051505Sbostic struct fs *fs; /* FFS */ 4151505Sbostic struct lfs *lfs; /* LFS */ 4251505Sbostic } inode_u; 4351505Sbostic #define i_fs inode_u.fs 4451505Sbostic #define i_lfs inode_u.lfs 45*64513Sbostic struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ 46*64513Sbostic u_quad_t i_modrev; /* Revision level for lease. */ 47*64513Sbostic struct lockf *i_lockf; /* Head of byte-level lock list. */ 48*64513Sbostic pid_t i_lockholder; /* DEBUG: holder of inode lock. */ 49*64513Sbostic pid_t i_lockwaiter; /* DEBUG: latest blocked for inode lock. */ 5052334Smckusick /* 5152334Smckusick * Side effects; used during directory lookup. 5252334Smckusick */ 53*64513Sbostic long i_count; /* Size of free slot in directory. */ 54*64513Sbostic doff_t i_endoff; /* End of useful stuff in directory. */ 55*64513Sbostic doff_t i_diroff; /* Offset in dir, where we found last entry. */ 56*64513Sbostic doff_t i_offset; /* Offset of free space in directory. */ 57*64513Sbostic ino_t i_ino; /* Inode number of found directory. */ 58*64513Sbostic u_long i_reclen; /* Size of found directory entry. */ 59*64513Sbostic long i_spare[11]; /* Spares to round up to 128 bytes. */ 6052334Smckusick /* 61*64513Sbostic * The on-disk dinode itself. 6252334Smckusick */ 63*64513Sbostic struct dinode i_din; /* 128 bytes of the on-disk dinode. */ 6458Sbill }; 6558Sbill 66*64513Sbostic #define i_atime i_din.di_atime 67*64513Sbostic #define i_blocks i_din.di_blocks 68*64513Sbostic #define i_ctime i_din.di_ctime 69*64513Sbostic #define i_db i_din.di_db 70*64513Sbostic #define i_flags i_din.di_flags 71*64513Sbostic #define i_gen i_din.di_gen 7239387Smckusick #define i_gid i_din.di_gid 7339387Smckusick #define i_ib i_din.di_ib 74*64513Sbostic #define i_mode i_din.di_mode 7539387Smckusick #define i_mtime i_din.di_mtime 76*64513Sbostic #define i_nlink i_din.di_nlink 7754302Smckusick #define i_rdev i_din.di_rdev 7854302Smckusick #define i_shortlink i_din.di_shortlink 79*64513Sbostic #define i_size i_din.di_size 80*64513Sbostic #define i_uid i_din.di_uid 816565Smckusic 82*64513Sbostic /* These flags are kept in i_flag. */ 83*64513Sbostic #define IACCESS 0x0001 /* Access time update request. */ 84*64513Sbostic #define ICHANGE 0x0002 /* Inode change time update request. */ 85*64513Sbostic #define IEXLOCK 0x0004 /* File has exclusive lock. */ 86*64513Sbostic #define ILOCKED 0x0008 /* Inode lock. */ 87*64513Sbostic #define ILWAIT 0x0010 /* Process waiting on file lock. */ 88*64513Sbostic #define IMODIFIED 0x0020 /* Inode has been modified. */ 89*64513Sbostic #define IRENAME 0x0040 /* Inode is being renamed. */ 90*64513Sbostic #define ISHLOCK 0x0080 /* File has shared lock. */ 91*64513Sbostic #define IUPDATE 0x0100 /* Modification time update request. */ 92*64513Sbostic #define IWANT 0x0200 /* Inode is wanted by a process. */ 9358Sbill 9437714Smckusick #ifdef KERNEL 9556449Smargo /* 9656449Smargo * Structure used to pass around logical block paths generated by 9756449Smargo * ufs_getlbns and used by truncate and bmap code. 9856449Smargo */ 9956449Smargo struct indir { 100*64513Sbostic daddr_t in_lbn; /* Logical block number. */ 101*64513Sbostic int in_off; /* Offset in buffer. */ 102*64513Sbostic int in_exists; /* Flag if the block exists. */ 10356449Smargo }; 10456449Smargo 10551505Sbostic /* Convert between inode pointers and vnode pointers. */ 10637714Smckusick #define VTOI(vp) ((struct inode *)(vp)->v_data) 10739387Smckusick #define ITOV(ip) ((ip)->i_vnode) 10837714Smckusick 109*64513Sbostic #define ITIMES(ip, t1, t2) { \ 110*64513Sbostic if ((ip)->i_flag & (IUPDATE | IACCESS | ICHANGE)) { \ 111*64513Sbostic (ip)->i_flag |= IMODIFIED; \ 112*64513Sbostic if ((ip)->i_flag & IACCESS) \ 113*64513Sbostic (ip)->i_atime.ts_sec = (t1)->tv_sec; \ 114*64513Sbostic if ((ip)->i_flag & IUPDATE) { \ 115*64513Sbostic (ip)->i_mtime.ts_sec = (t2)->tv_sec; \ 116*64513Sbostic (ip)->i_modrev++; \ 117*64513Sbostic } \ 118*64513Sbostic if ((ip)->i_flag & ICHANGE) \ 119*64513Sbostic (ip)->i_ctime.ts_sec = time.tv_sec; \ 120*64513Sbostic (ip)->i_flag &= ~(IACCESS | IUPDATE | ICHANGE); \ 121*64513Sbostic } \ 12216057Skarels } 12337714Smckusick 12451505Sbostic /* This overlays the fid structure (see mount.h). */ 12537714Smckusick struct ufid { 126*64513Sbostic u_short ufid_len; /* Length of structure. */ 127*64513Sbostic u_short ufid_pad; /* Force long alignment. */ 128*64513Sbostic ino_t ufid_ino; /* File number (ino). */ 129*64513Sbostic long ufid_gen; /* Generation number. */ 13037714Smckusick }; 13148031Smckusick #endif /* KERNEL */ 132