|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1982, 1989 The Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution is only permitted until one year after the first shipment ! 6: * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and ! 7: * binary forms are permitted provided that: (1) source distributions retain ! 8: * this entire copyright notice and comment, and (2) distributions including ! 9: * binaries display the following acknowledgement: This product includes ! 10: * software developed by the University of California, Berkeley and its ! 11: * contributors'' in the documentation or other materials provided with the ! 12: * distribution and in all advertising materials mentioning features or use ! 13: * of this software. Neither the name of the University nor the names of ! 14: * its contributors may be used to endorse or promote products derived from ! 15: * this software without specific prior written permission. ! 16: * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 17: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 18: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 19: * ! 20: * @(#)inode.h 7.13 (Berkeley) 5/10/90 ! 21: */ ! 22: ! 23: #ifdef KERNEL ! 24: #include "../ufs/dinode.h" ! 25: #else ! 26: #include <ufs/dinode.h> ! 27: #endif ! 28: ! 29: /* ! 30: * The I node is the focus of all file activity in UNIX. ! 31: * There is a unique inode allocated for each active file, ! 32: * each current directory, each mounted-on file, text file, and the root. ! 33: * An inode is 'named' by its dev/inumber pair. (iget/iget.c) ! 34: * Data in `struct dinode' is read in from permanent inode on volume. ! 35: */ ! 36: ! 37: struct inode { ! 38: struct inode *i_chain[2]; /* hash chain, MUST be first */ ! 39: struct vnode *i_vnode; /* vnode associated with this inode */ ! 40: struct vnode *i_devvp; /* vnode for block I/O */ ! 41: u_long i_flag; /* see below */ ! 42: dev_t i_dev; /* device where inode resides */ ! 43: ino_t i_number; /* i number, 1-to-1 with device address */ ! 44: struct fs *i_fs; /* file sys associated with this inode */ ! 45: struct dquot *i_dquot[MAXQUOTAS]; /* pointer to dquot strauctures */ ! 46: long i_diroff; /* offset in dir, where we found last entry */ ! 47: off_t i_endoff; /* end of useful stuff in directory */ ! 48: long i_spare0; ! 49: long i_spare1; ! 50: struct dinode i_din; /* the on-disk inode */ ! 51: }; ! 52: ! 53: #define i_mode i_din.di_mode ! 54: #define i_nlink i_din.di_nlink ! 55: #define i_uid i_din.di_uid ! 56: #define i_gid i_din.di_gid ! 57: #if BYTE_ORDER == LITTLE_ENDIAN || defined(tahoe) /* ugh! -- must be fixed */ ! 58: #define i_size i_din.di_qsize.val[0] ! 59: #else /* BYTE_ORDER == BIG_ENDIAN */ ! 60: #define i_size i_din.di_qsize.val[1] ! 61: #endif ! 62: #define i_db i_din.di_db ! 63: #define i_ib i_din.di_ib ! 64: #define i_atime i_din.di_atime ! 65: #define i_mtime i_din.di_mtime ! 66: #define i_ctime i_din.di_ctime ! 67: #define i_blocks i_din.di_blocks ! 68: #define i_rdev i_din.di_db[0] ! 69: #define i_flags i_din.di_flags ! 70: #define i_gen i_din.di_gen ! 71: #define i_forw i_chain[0] ! 72: #define i_back i_chain[1] ! 73: ! 74: /* flags */ ! 75: #define ILOCKED 0x0001 /* inode is locked */ ! 76: #define IWANT 0x0002 /* some process waiting on lock */ ! 77: #define IRENAME 0x0004 /* inode is being renamed */ ! 78: #define IUPD 0x0010 /* file has been modified */ ! 79: #define IACC 0x0020 /* inode access time to be updated */ ! 80: #define ICHG 0x0040 /* inode has been changed */ ! 81: #define IMOD 0x0080 /* inode has been modified */ ! 82: #define ISHLOCK 0x0100 /* file has shared lock */ ! 83: #define IEXLOCK 0x0200 /* file has exclusive lock */ ! 84: #define ILWAIT 0x0400 /* someone waiting on file lock */ ! 85: ! 86: #ifdef KERNEL ! 87: /* ! 88: * Convert between inode pointers and vnode pointers ! 89: */ ! 90: #define VTOI(vp) ((struct inode *)(vp)->v_data) ! 91: #define ITOV(ip) ((ip)->i_vnode) ! 92: ! 93: /* ! 94: * Convert between vnode types and inode formats ! 95: */ ! 96: extern enum vtype iftovt_tab[]; ! 97: extern int vttoif_tab[]; ! 98: #define IFTOVT(mode) (iftovt_tab[((mode) & IFMT) >> 12]) ! 99: #define VTTOIF(indx) (vttoif_tab[(int)(indx)]) ! 100: ! 101: #define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode)) ! 102: ! 103: u_long nextgennumber; /* next generation number to assign */ ! 104: ! 105: extern ino_t dirpref(); ! 106: ! 107: /* ! 108: * Lock and unlock inodes. ! 109: */ ! 110: #ifdef notdef ! 111: #define ILOCK(ip) { \ ! 112: while ((ip)->i_flag & ILOCKED) { \ ! 113: (ip)->i_flag |= IWANT; \ ! 114: (void) sleep((caddr_t)(ip), PINOD); \ ! 115: } \ ! 116: (ip)->i_flag |= ILOCKED; \ ! 117: } ! 118: ! 119: #define IUNLOCK(ip) { \ ! 120: (ip)->i_flag &= ~ILOCKED; \ ! 121: if ((ip)->i_flag&IWANT) { \ ! 122: (ip)->i_flag &= ~IWANT; \ ! 123: wakeup((caddr_t)(ip)); \ ! 124: } \ ! 125: } ! 126: #else ! 127: #define ILOCK(ip) ilock(ip) ! 128: #define IUNLOCK(ip) iunlock(ip) ! 129: #endif ! 130: ! 131: #define IUPDAT(ip, t1, t2, waitfor) { \ ! 132: if (ip->i_flag&(IUPD|IACC|ICHG|IMOD)) \ ! 133: (void) iupdat(ip, t1, t2, waitfor); \ ! 134: } ! 135: ! 136: #define ITIMES(ip, t1, t2) { \ ! 137: if ((ip)->i_flag&(IUPD|IACC|ICHG)) { \ ! 138: (ip)->i_flag |= IMOD; \ ! 139: if ((ip)->i_flag&IACC) \ ! 140: (ip)->i_atime = (t1)->tv_sec; \ ! 141: if ((ip)->i_flag&IUPD) \ ! 142: (ip)->i_mtime = (t2)->tv_sec; \ ! 143: if ((ip)->i_flag&ICHG) \ ! 144: (ip)->i_ctime = time.tv_sec; \ ! 145: (ip)->i_flag &= ~(IACC|IUPD|ICHG); \ ! 146: } \ ! 147: } ! 148: ! 149: /* ! 150: * This overlays the fid sturcture (see mount.h) ! 151: */ ! 152: struct ufid { ! 153: u_short ufid_len; /* length of structure */ ! 154: u_short ufid_pad; /* force long alignment */ ! 155: ino_t ufid_ino; /* file number (ino) */ ! 156: long ufid_gen; /* generation number */ ! 157: }; ! 158: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.