inode.h revision 34266
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 * 3822521Sdyson * @(#)inode.h 8.9 (Berkeley) 5/14/95 3934266Sjulian * $Id: inode.h,v 1.20 1998/01/30 11:34:02 phk Exp $ 401541Srgrimes */ 411541Srgrimes 422177Spaul#ifndef _UFS_UFS_INODE_H_ 435247Sbde#define _UFS_UFS_INODE_H_ 442177Spaul 4531557Sjkh#include <sys/lock.h> 461541Srgrimes#include <ufs/ufs/dinode.h> 471541Srgrimes 481541Srgrimes/* 4934266Sjulian * The size of a logical block number. 5034266Sjulian */ 5134266Sjuliantypedef long ufs_lbn_t; 5234266Sjulian 5334266Sjulian/* 5424477Sbde * This must agree with the definition in <ufs/ufs/dir.h>. 5524477Sbde */ 5624477Sbde#define doff_t int32_t 5724477Sbde 5824477Sbde/* 5922521Sdyson * The inode is used to describe each active (or recently active) file in the 6022521Sdyson * UFS filesystem. It is composed of two types of information. The first part 6122521Sdyson * is the information that is needed only while the file is active (such as 6222521Sdyson * the identity of the file and linkage to speed its lookup). The second part 6322521Sdyson * is the permanent meta-data associated with the file which is read in 6422521Sdyson * from the permanent dinode from long term storage when the file becomes 6522521Sdyson * active, and is put back when the file is no longer being used. 661541Srgrimes */ 6722521Sdysonstruct inode { 6830513Sphk struct lock i_lock; /* Inode lock. >Keep this first< */ 6922521Sdyson LIST_ENTRY(inode) i_hash;/* Hash chain. */ 7022521Sdyson struct vnode *i_vnode;/* Vnode associated with this inode. */ 7122521Sdyson struct vnode *i_devvp;/* Vnode for block I/O. */ 7222521Sdyson u_int32_t i_flag; /* flags, see below */ 7322521Sdyson dev_t i_dev; /* Device associated with the inode. */ 7422521Sdyson ino_t i_number; /* The identity of the inode. */ 7534266Sjulian int i_effnlink; /* i_nlink when I/O completes */ 761541Srgrimes 771541Srgrimes union { /* Associated filesystem. */ 781541Srgrimes struct fs *fs; /* FFS */ 7912117Sdyson struct ext2_sb_info *e2fs; /* EXT2FS */ 801541Srgrimes } inode_u; 811541Srgrimes#define i_fs inode_u.fs 8212117Sdyson#define i_e2fs inode_u.e2fs 8322521Sdyson struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ 8422521Sdyson u_quad_t i_modrev; /* Revision level for NFS lease. */ 8522521Sdyson struct lockf *i_lockf;/* Head of byte-level lock list. */ 861541Srgrimes /* 871541Srgrimes * Side effects; used during directory lookup. 881541Srgrimes */ 8922521Sdyson int32_t i_count; /* Size of free slot in directory. */ 9022521Sdyson doff_t i_endoff; /* End of useful stuff in directory. */ 9122521Sdyson doff_t i_diroff; /* Offset in dir, where we found last entry. */ 9222521Sdyson doff_t i_offset; /* Offset of free space in directory. */ 9322521Sdyson ino_t i_ino; /* Inode number of found directory. */ 9422521Sdyson u_int32_t i_reclen; /* Size of found directory entry. */ 9527375Sbde int i_spare[5]; /* XXX actually non-spare (for ext2fs). */ 961541Srgrimes /* 971541Srgrimes * The on-disk dinode itself. 981541Srgrimes */ 991541Srgrimes struct dinode i_din; /* 128 bytes of the on-disk dinode. */ 1001541Srgrimes}; 1011541Srgrimes 1021541Srgrimes#define i_atime i_din.di_atime 10322521Sdyson#define i_atimensec i_din.di_atimensec 1041541Srgrimes#define i_blocks i_din.di_blocks 1051541Srgrimes#define i_ctime i_din.di_ctime 10622521Sdyson#define i_ctimensec i_din.di_ctimensec 1071541Srgrimes#define i_db i_din.di_db 1081541Srgrimes#define i_flags i_din.di_flags 1091541Srgrimes#define i_gen i_din.di_gen 1101541Srgrimes#define i_gid i_din.di_gid 1111541Srgrimes#define i_ib i_din.di_ib 1121541Srgrimes#define i_mode i_din.di_mode 1131541Srgrimes#define i_mtime i_din.di_mtime 11422521Sdyson#define i_mtimensec i_din.di_mtimensec 1151541Srgrimes#define i_nlink i_din.di_nlink 1161541Srgrimes#define i_rdev i_din.di_rdev 1171541Srgrimes#define i_shortlink i_din.di_shortlink 1181541Srgrimes#define i_size i_din.di_size 1191541Srgrimes#define i_uid i_din.di_uid 1201541Srgrimes 1211541Srgrimes/* These flags are kept in i_flag. */ 1221541Srgrimes#define IN_ACCESS 0x0001 /* Access time update request. */ 1231541Srgrimes#define IN_CHANGE 0x0002 /* Inode change time update request. */ 12422521Sdyson#define IN_UPDATE 0x0004 /* Modification time update request. */ 12522521Sdyson#define IN_MODIFIED 0x0008 /* Inode has been modified. */ 12622521Sdyson#define IN_RENAME 0x0010 /* Inode is being renamed. */ 12722521Sdyson#define IN_SHLOCK 0x0020 /* File has shared lock. */ 12822521Sdyson#define IN_EXLOCK 0x0040 /* File has exclusive lock. */ 12930418Sphk#define IN_HASHED 0x0080 /* Inode is on hash list */ 1301541Srgrimes 1311541Srgrimes#ifdef KERNEL 1321541Srgrimes/* 1331541Srgrimes * Structure used to pass around logical block paths generated by 1341541Srgrimes * ufs_getlbns and used by truncate and bmap code. 1351541Srgrimes */ 1361541Srgrimesstruct indir { 13722521Sdyson ufs_daddr_t in_lbn; /* Logical block number. */ 1381541Srgrimes int in_off; /* Offset in buffer. */ 1391541Srgrimes int in_exists; /* Flag if the block exists. */ 1401541Srgrimes}; 1411541Srgrimes 1421541Srgrimes/* Convert between inode pointers and vnode pointers. */ 1431541Srgrimes#define VTOI(vp) ((struct inode *)(vp)->v_data) 1441541Srgrimes#define ITOV(ip) ((ip)->i_vnode) 1451541Srgrimes 1465247Sbde/* 1475247Sbde * XXX this is too long to be a macro, and isn't used in any time-critical 1485247Sbde * place; in fact it is only used in ufs_vnops.c so it shouldn't be in a 1495247Sbde * header file. 1505247Sbde */ 1511541Srgrimes#define ITIMES(ip, t1, t2) { \ 1525247Sbde long tv_sec = time.tv_sec; \ 1531541Srgrimes if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \ 1541541Srgrimes (ip)->i_flag |= IN_MODIFIED; \ 1551541Srgrimes if ((ip)->i_flag & IN_ACCESS) \ 15622521Sdyson (ip)->i_atime \ 1575247Sbde = ((t1) == &time ? tv_sec : (t1)->tv_sec); \ 1581541Srgrimes if ((ip)->i_flag & IN_UPDATE) { \ 15922521Sdyson (ip)->i_mtime \ 1605247Sbde = ((t2) == &time ? tv_sec : (t2)->tv_sec); \ 1611541Srgrimes (ip)->i_modrev++; \ 1621541Srgrimes } \ 1631541Srgrimes if ((ip)->i_flag & IN_CHANGE) \ 16422521Sdyson (ip)->i_ctime = tv_sec; \ 1651541Srgrimes (ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ 1661541Srgrimes } \ 1671541Srgrimes} 1681541Srgrimes 16934266Sjulian/* Determine if soft dependencies are being done */ 17034266Sjulian#define DOINGSOFTDEP(vp) ((vp)->v_mount->mnt_flag & MNT_SOFTDEP) 17134266Sjulian 1721541Srgrimes/* This overlays the fid structure (see mount.h). */ 1731541Srgrimesstruct ufid { 17422521Sdyson u_int16_t ufid_len; /* Length of structure. */ 17522521Sdyson u_int16_t ufid_pad; /* Force 32-bit alignment. */ 17622521Sdyson ino_t ufid_ino; /* File number (ino). */ 17722521Sdyson int32_t ufid_gen; /* Generation number. */ 1781541Srgrimes}; 1795247Sbde#endif /* KERNEL */ 1802177Spaul 1815247Sbde#endif /* !_UFS_UFS_INODE_H_ */ 182