inode.h revision 2177
11541Srgrimes/* 21541Srgrimes * Copyright (c) 1982, 1989, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * (c) UNIX System Laboratories, Inc. 51541Srgrimes * All or some portions of this file are derived from material licensed 61541Srgrimes * to the University of California by American Telephone and Telegraph 71541Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with 81541Srgrimes * the permission of UNIX System Laboratories, Inc. 91541Srgrimes * 101541Srgrimes * Redistribution and use in source and binary forms, with or without 111541Srgrimes * modification, are permitted provided that the following conditions 121541Srgrimes * are met: 131541Srgrimes * 1. Redistributions of source code must retain the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer. 151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 161541Srgrimes * notice, this list of conditions and the following disclaimer in the 171541Srgrimes * documentation and/or other materials provided with the distribution. 181541Srgrimes * 3. All advertising materials mentioning features or use of this software 191541Srgrimes * must display the following acknowledgement: 201541Srgrimes * This product includes software developed by the University of 211541Srgrimes * California, Berkeley and its contributors. 221541Srgrimes * 4. Neither the name of the University nor the names of its contributors 231541Srgrimes * may be used to endorse or promote products derived from this software 241541Srgrimes * without specific prior written permission. 251541Srgrimes * 261541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 271541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 281541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 291541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 301541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 311541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 321541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 331541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 341541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 351541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 361541Srgrimes * SUCH DAMAGE. 371541Srgrimes * 381541Srgrimes * @(#)inode.h 8.4 (Berkeley) 1/21/94 392177Spaul * $Id: inode.h,v 1.2 1994/08/02 07:54:49 davidg Exp $ 401541Srgrimes */ 411541Srgrimes 422177Spaul#ifndef _UFS_UFS_INODE_H_ 432177Spaul#define _UFS_UFS_INODE_H_ 442177Spaul 451541Srgrimes#include <ufs/ufs/dinode.h> 461541Srgrimes 471541Srgrimes/* 481541Srgrimes * Theoretically, directories can be more than 2Gb in length, however, in 491541Srgrimes * practice this seems unlikely. So, we define the type doff_t as a long 501541Srgrimes * to keep down the cost of doing lookup on a 32-bit machine. If you are 511541Srgrimes * porting to a 64-bit architecture, you should make doff_t the same as off_t. 521541Srgrimes */ 531541Srgrimes#define doff_t long 541541Srgrimes 551541Srgrimes/* 561541Srgrimes * The inode is used to describe each active (or recently active) 571541Srgrimes * file in the UFS filesystem. It is composed of two types of 581541Srgrimes * information. The first part is the information that is needed 591541Srgrimes * only while the file is active (such as the identity of the file 601541Srgrimes * and linkage to speed its lookup). The second part is the 611541Srgrimes * permannent meta-data associated with the file which is read 621541Srgrimes * in from the permanent dinode from long term storage when the 631541Srgrimes * file becomes active, and is put back when the file is no longer 641541Srgrimes * being used. 651541Srgrimes */ 661541Srgrimesstruct inode { 671541Srgrimes struct inode *i_next; /* Hash chain forward. */ 681541Srgrimes struct inode **i_prev; /* Hash chain back. */ 691541Srgrimes struct vnode *i_vnode; /* Vnode associated with this inode. */ 701541Srgrimes struct vnode *i_devvp; /* Vnode for block I/O. */ 711541Srgrimes u_long i_flag; /* I* flags. */ 721541Srgrimes dev_t i_dev; /* Device associated with the inode. */ 731541Srgrimes ino_t i_number; /* The identity of the inode. */ 741541Srgrimes union { /* Associated filesystem. */ 751541Srgrimes struct fs *fs; /* FFS */ 761541Srgrimes struct lfs *lfs; /* LFS */ 771541Srgrimes } inode_u; 781541Srgrimes#define i_fs inode_u.fs 791541Srgrimes#define i_lfs inode_u.lfs 801541Srgrimes struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ 811541Srgrimes u_quad_t i_modrev; /* Revision level for lease. */ 821541Srgrimes struct lockf *i_lockf; /* Head of byte-level lock list. */ 831541Srgrimes pid_t i_lockholder; /* DEBUG: holder of inode lock. */ 841541Srgrimes pid_t i_lockwaiter; /* DEBUG: latest blocked for inode lock. */ 851541Srgrimes /* 861541Srgrimes * Side effects; used during directory lookup. 871541Srgrimes */ 881541Srgrimes long i_count; /* Size of free slot in directory. */ 891541Srgrimes doff_t i_endoff; /* End of useful stuff in directory. */ 901541Srgrimes doff_t i_diroff; /* Offset in dir, where we found last entry. */ 911541Srgrimes doff_t i_offset; /* Offset of free space in directory. */ 921541Srgrimes ino_t i_ino; /* Inode number of found directory. */ 931541Srgrimes u_long i_reclen; /* Size of found directory entry. */ 941541Srgrimes long i_spare[11]; /* Spares to round up to 128 bytes. */ 951541Srgrimes /* 961541Srgrimes * The on-disk dinode itself. 971541Srgrimes */ 981541Srgrimes struct dinode i_din; /* 128 bytes of the on-disk dinode. */ 991541Srgrimes}; 1001541Srgrimes 1011541Srgrimes#define i_atime i_din.di_atime 1021541Srgrimes#define i_blocks i_din.di_blocks 1031541Srgrimes#define i_ctime i_din.di_ctime 1041541Srgrimes#define i_db i_din.di_db 1051541Srgrimes#define i_flags i_din.di_flags 1061541Srgrimes#define i_gen i_din.di_gen 1071541Srgrimes#define i_gid i_din.di_gid 1081541Srgrimes#define i_ib i_din.di_ib 1091541Srgrimes#define i_mode i_din.di_mode 1101541Srgrimes#define i_mtime i_din.di_mtime 1111541Srgrimes#define i_nlink i_din.di_nlink 1121541Srgrimes#define i_rdev i_din.di_rdev 1131541Srgrimes#define i_shortlink i_din.di_shortlink 1141541Srgrimes#define i_size i_din.di_size 1151541Srgrimes#define i_uid i_din.di_uid 1161541Srgrimes 1171541Srgrimes/* These flags are kept in i_flag. */ 1181541Srgrimes#define IN_ACCESS 0x0001 /* Access time update request. */ 1191541Srgrimes#define IN_CHANGE 0x0002 /* Inode change time update request. */ 1201541Srgrimes#define IN_EXLOCK 0x0004 /* File has exclusive lock. */ 1211541Srgrimes#define IN_LOCKED 0x0008 /* Inode lock. */ 1221541Srgrimes#define IN_LWAIT 0x0010 /* Process waiting on file lock. */ 1231541Srgrimes#define IN_MODIFIED 0x0020 /* Inode has been modified. */ 1241541Srgrimes#define IN_RENAME 0x0040 /* Inode is being renamed. */ 1251541Srgrimes#define IN_SHLOCK 0x0080 /* File has shared lock. */ 1261541Srgrimes#define IN_UPDATE 0x0100 /* Modification time update request. */ 1271541Srgrimes#define IN_WANTED 0x0200 /* Inode is wanted by a process. */ 1281541Srgrimes 1291541Srgrimes#ifdef KERNEL 1301541Srgrimes/* 1311541Srgrimes * Structure used to pass around logical block paths generated by 1321541Srgrimes * ufs_getlbns and used by truncate and bmap code. 1331541Srgrimes */ 1341541Srgrimesstruct indir { 1351541Srgrimes daddr_t in_lbn; /* Logical block number. */ 1361541Srgrimes int in_off; /* Offset in buffer. */ 1371541Srgrimes int in_exists; /* Flag if the block exists. */ 1381541Srgrimes}; 1391541Srgrimes 1401541Srgrimes/* Convert between inode pointers and vnode pointers. */ 1411541Srgrimes#define VTOI(vp) ((struct inode *)(vp)->v_data) 1421541Srgrimes#define ITOV(ip) ((ip)->i_vnode) 1431541Srgrimes 1441541Srgrimes#define ITIMES(ip, t1, t2) { \ 1451541Srgrimes if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \ 1461541Srgrimes (ip)->i_flag |= IN_MODIFIED; \ 1471541Srgrimes if ((ip)->i_flag & IN_ACCESS) \ 1481541Srgrimes (ip)->i_atime.ts_sec = (t1)->tv_sec; \ 1491541Srgrimes if ((ip)->i_flag & IN_UPDATE) { \ 1501541Srgrimes (ip)->i_mtime.ts_sec = (t2)->tv_sec; \ 1511541Srgrimes (ip)->i_modrev++; \ 1521541Srgrimes } \ 1531541Srgrimes if ((ip)->i_flag & IN_CHANGE) \ 1541541Srgrimes (ip)->i_ctime.ts_sec = time.tv_sec; \ 1551541Srgrimes (ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ 1561541Srgrimes } \ 1571541Srgrimes} 1581541Srgrimes 1591541Srgrimes/* This overlays the fid structure (see mount.h). */ 1601541Srgrimesstruct ufid { 1611541Srgrimes u_short ufid_len; /* Length of structure. */ 1621541Srgrimes u_short ufid_pad; /* Force long alignment. */ 1631541Srgrimes ino_t ufid_ino; /* File number (ino). */ 1641541Srgrimes long ufid_gen; /* Generation number. */ 1651541Srgrimes}; 1662177Spaul 1672177Spaul#endif 1681541Srgrimes#endif /* KERNEL */ 169