123419Smckusick /* 263376Sbostic * Copyright (c) 1982, 1989, 1993 363376Sbostic * The Regents of the University of California. All rights reserved. 4*65774Sbostic * (c) UNIX System Laboratories, Inc. 5*65774Sbostic * All or some portions of this file are derived from material licensed 6*65774Sbostic * to the University of California by American Telephone and Telegraph 7*65774Sbostic * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8*65774Sbostic * the permission of UNIX System Laboratories, Inc. 923419Smckusick * 1041535Smckusick * %sccs.include.redist.c% 1137714Smckusick * 12*65774Sbostic * @(#)inode.h 8.4 (Berkeley) 01/21/94 1323419Smckusick */ 1458Sbill 1551505Sbostic #include <ufs/ufs/dinode.h> 1639387Smckusick 1758Sbill /* 1864513Sbostic * Theoretically, directories can be more than 2Gb in length, however, in 1964513Sbostic * practice this seems unlikely. So, we define the type doff_t as a long 2064513Sbostic * to keep down the cost of doing lookup on a 32-bit machine. If you are 2164513Sbostic * porting to a 64-bit architecture, you should make doff_t the same as off_t. 2253061Smckusick */ 2364513Sbostic #define doff_t long 2453061Smckusick 2553061Smckusick /* 2649448Smckusick * The inode is used to describe each active (or recently active) 2749448Smckusick * file in the UFS filesystem. It is composed of two types of 2849448Smckusick * information. The first part is the information that is needed 2949448Smckusick * only while the file is active (such as the identity of the file 3049448Smckusick * and linkage to speed its lookup). The second part is the 3149448Smckusick * permannent meta-data associated with the file which is read 3249448Smckusick * in from the permanent dinode from long term storage when the 3349448Smckusick * file becomes active, and is put back when the file is no longer 3449448Smckusick * being used. 3558Sbill */ 364814Swnj struct inode { 3764513Sbostic struct inode *i_next; /* Hash chain forward. */ 3864513Sbostic struct inode **i_prev; /* Hash chain back. */ 3964513Sbostic struct vnode *i_vnode; /* Vnode associated with this inode. */ 4064513Sbostic struct vnode *i_devvp; /* Vnode for block I/O. */ 4164513Sbostic u_long i_flag; /* I* flags. */ 4264513Sbostic dev_t i_dev; /* Device associated with the inode. */ 4364513Sbostic ino_t i_number; /* The identity of the inode. */ 4464513Sbostic union { /* Associated filesystem. */ 4551505Sbostic struct fs *fs; /* FFS */ 4651505Sbostic struct lfs *lfs; /* LFS */ 4751505Sbostic } inode_u; 4851505Sbostic #define i_fs inode_u.fs 4951505Sbostic #define i_lfs inode_u.lfs 5064513Sbostic struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ 5164513Sbostic u_quad_t i_modrev; /* Revision level for lease. */ 5264513Sbostic struct lockf *i_lockf; /* Head of byte-level lock list. */ 5364513Sbostic pid_t i_lockholder; /* DEBUG: holder of inode lock. */ 5464513Sbostic pid_t i_lockwaiter; /* DEBUG: latest blocked for inode lock. */ 5552334Smckusick /* 5652334Smckusick * Side effects; used during directory lookup. 5752334Smckusick */ 5864513Sbostic long i_count; /* Size of free slot in directory. */ 5964513Sbostic doff_t i_endoff; /* End of useful stuff in directory. */ 6064513Sbostic doff_t i_diroff; /* Offset in dir, where we found last entry. */ 6164513Sbostic doff_t i_offset; /* Offset of free space in directory. */ 6264513Sbostic ino_t i_ino; /* Inode number of found directory. */ 6364513Sbostic u_long i_reclen; /* Size of found directory entry. */ 6464513Sbostic long i_spare[11]; /* Spares to round up to 128 bytes. */ 6552334Smckusick /* 6664513Sbostic * The on-disk dinode itself. 6752334Smckusick */ 6864513Sbostic struct dinode i_din; /* 128 bytes of the on-disk dinode. */ 6958Sbill }; 7058Sbill 7164513Sbostic #define i_atime i_din.di_atime 7264513Sbostic #define i_blocks i_din.di_blocks 7364513Sbostic #define i_ctime i_din.di_ctime 7464513Sbostic #define i_db i_din.di_db 7564513Sbostic #define i_flags i_din.di_flags 7664513Sbostic #define i_gen i_din.di_gen 7739387Smckusick #define i_gid i_din.di_gid 7839387Smckusick #define i_ib i_din.di_ib 7964513Sbostic #define i_mode i_din.di_mode 8039387Smckusick #define i_mtime i_din.di_mtime 8164513Sbostic #define i_nlink i_din.di_nlink 8254302Smckusick #define i_rdev i_din.di_rdev 8354302Smckusick #define i_shortlink i_din.di_shortlink 8464513Sbostic #define i_size i_din.di_size 8564513Sbostic #define i_uid i_din.di_uid 866565Smckusic 8764513Sbostic /* These flags are kept in i_flag. */ 8864596Sbostic #define IN_ACCESS 0x0001 /* Access time update request. */ 8964596Sbostic #define IN_CHANGE 0x0002 /* Inode change time update request. */ 9064596Sbostic #define IN_EXLOCK 0x0004 /* File has exclusive lock. */ 9164596Sbostic #define IN_LOCKED 0x0008 /* Inode lock. */ 9264596Sbostic #define IN_LWAIT 0x0010 /* Process waiting on file lock. */ 9364596Sbostic #define IN_MODIFIED 0x0020 /* Inode has been modified. */ 9464596Sbostic #define IN_RENAME 0x0040 /* Inode is being renamed. */ 9564596Sbostic #define IN_SHLOCK 0x0080 /* File has shared lock. */ 9664596Sbostic #define IN_UPDATE 0x0100 /* Modification time update request. */ 9764596Sbostic #define IN_WANTED 0x0200 /* Inode is wanted by a process. */ 9858Sbill 9937714Smckusick #ifdef KERNEL 10056449Smargo /* 10156449Smargo * Structure used to pass around logical block paths generated by 10256449Smargo * ufs_getlbns and used by truncate and bmap code. 10356449Smargo */ 10456449Smargo struct indir { 10564513Sbostic daddr_t in_lbn; /* Logical block number. */ 10664513Sbostic int in_off; /* Offset in buffer. */ 10764513Sbostic int in_exists; /* Flag if the block exists. */ 10856449Smargo }; 10956449Smargo 11051505Sbostic /* Convert between inode pointers and vnode pointers. */ 11137714Smckusick #define VTOI(vp) ((struct inode *)(vp)->v_data) 11239387Smckusick #define ITOV(ip) ((ip)->i_vnode) 11337714Smckusick 11464513Sbostic #define ITIMES(ip, t1, t2) { \ 11564596Sbostic if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \ 11664596Sbostic (ip)->i_flag |= IN_MODIFIED; \ 11764596Sbostic if ((ip)->i_flag & IN_ACCESS) \ 11864513Sbostic (ip)->i_atime.ts_sec = (t1)->tv_sec; \ 11964596Sbostic if ((ip)->i_flag & IN_UPDATE) { \ 12064513Sbostic (ip)->i_mtime.ts_sec = (t2)->tv_sec; \ 12164513Sbostic (ip)->i_modrev++; \ 12264513Sbostic } \ 12364596Sbostic if ((ip)->i_flag & IN_CHANGE) \ 12464513Sbostic (ip)->i_ctime.ts_sec = time.tv_sec; \ 12564596Sbostic (ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ 12664513Sbostic } \ 12716057Skarels } 12837714Smckusick 12951505Sbostic /* This overlays the fid structure (see mount.h). */ 13037714Smckusick struct ufid { 13164513Sbostic u_short ufid_len; /* Length of structure. */ 13264513Sbostic u_short ufid_pad; /* Force long alignment. */ 13364513Sbostic ino_t ufid_ino; /* File number (ino). */ 13464513Sbostic long ufid_gen; /* Generation number. */ 13537714Smckusick }; 13648031Smckusick #endif /* KERNEL */ 137