Home | History | Annotate | Line # | Download | only in lfs
ulfs_inode.h revision 1.3
      1  1.3  dholland /*	$NetBSD: ulfs_inode.h,v 1.3 2013/06/06 00:48:04 dholland Exp $	*/
      2  1.1  dholland /*  from NetBSD: inode.h,v 1.64 2012/11/19 00:36:21 jakllsch Exp  */
      3  1.1  dholland 
      4  1.1  dholland /*
      5  1.1  dholland  * Copyright (c) 1982, 1989, 1993
      6  1.1  dholland  *	The Regents of the University of California.  All rights reserved.
      7  1.1  dholland  * (c) UNIX System Laboratories, Inc.
      8  1.1  dholland  * All or some portions of this file are derived from material licensed
      9  1.1  dholland  * to the University of California by American Telephone and Telegraph
     10  1.1  dholland  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
     11  1.1  dholland  * the permission of UNIX System Laboratories, Inc.
     12  1.1  dholland  *
     13  1.1  dholland  * Redistribution and use in source and binary forms, with or without
     14  1.1  dholland  * modification, are permitted provided that the following conditions
     15  1.1  dholland  * are met:
     16  1.1  dholland  * 1. Redistributions of source code must retain the above copyright
     17  1.1  dholland  *    notice, this list of conditions and the following disclaimer.
     18  1.1  dholland  * 2. Redistributions in binary form must reproduce the above copyright
     19  1.1  dholland  *    notice, this list of conditions and the following disclaimer in the
     20  1.1  dholland  *    documentation and/or other materials provided with the distribution.
     21  1.1  dholland  * 3. Neither the name of the University nor the names of its contributors
     22  1.1  dholland  *    may be used to endorse or promote products derived from this software
     23  1.1  dholland  *    without specific prior written permission.
     24  1.1  dholland  *
     25  1.1  dholland  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     26  1.1  dholland  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     27  1.1  dholland  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     28  1.1  dholland  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     29  1.1  dholland  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     30  1.1  dholland  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     31  1.1  dholland  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     32  1.1  dholland  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     33  1.1  dholland  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     34  1.1  dholland  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     35  1.1  dholland  * SUCH DAMAGE.
     36  1.1  dholland  *
     37  1.1  dholland  *	@(#)inode.h	8.9 (Berkeley) 5/14/95
     38  1.1  dholland  */
     39  1.1  dholland 
     40  1.3  dholland #ifndef _UFS_LFS_ULFS_INODE_H_
     41  1.3  dholland #define	_UFS_LFS_ULFS_INODE_H_
     42  1.1  dholland 
     43  1.1  dholland #include <sys/vnode.h>
     44  1.2  dholland #include <ufs/lfs/ulfs_dinode.h>
     45  1.2  dholland #include <ufs/lfs/ulfs_dir.h>
     46  1.2  dholland #include <ufs/lfs/ulfs_quotacommon.h>
     47  1.1  dholland #include <ufs/ext2fs/ext2fs_dinode.h>
     48  1.1  dholland #include <miscfs/genfs/genfs_node.h>
     49  1.1  dholland 
     50  1.1  dholland /*
     51  1.1  dholland  * Lookup result state (other than the result inode). This is
     52  1.1  dholland  * currently stashed in the vnode between VOP_LOOKUP and directory
     53  1.1  dholland  * operation VOPs, which is gross.
     54  1.1  dholland  *
     55  1.1  dholland  * XXX ulr_diroff is a lookup hint from the previos call of VOP_LOOKUP.
     56  1.1  dholland  * probably it should not be here.
     57  1.1  dholland  */
     58  1.3  dholland struct ulfs_lookup_results {
     59  1.1  dholland 	int32_t	  ulr_count;	/* Size of free slot in directory. */
     60  1.1  dholland 	doff_t	  ulr_endoff;	/* End of useful stuff in directory. */
     61  1.1  dholland 	doff_t	  ulr_diroff;	/* Offset in dir, where we found last entry. */
     62  1.1  dholland 	doff_t	  ulr_offset;	/* Offset of free space in directory. */
     63  1.1  dholland 	u_int32_t ulr_reclen;	/* Size of found directory entry. */
     64  1.1  dholland };
     65  1.1  dholland 
     66  1.1  dholland /* notyet XXX */
     67  1.3  dholland #define ULFS_CHECK_CRAPCOUNTER(dp) ((void)(dp)->i_crapcounter)
     68  1.1  dholland 
     69  1.1  dholland /*
     70  1.1  dholland  * Per-filesystem inode extensions.
     71  1.1  dholland  */
     72  1.1  dholland struct ffs_inode_ext {
     73  1.1  dholland 	daddr_t *ffs_snapblklist;	/* Collect expunged snapshot blocks. */
     74  1.1  dholland 	/* follow two fields are used by contiguous allocation code only. */
     75  1.1  dholland 	daddr_t ffs_first_data_blk;	/* first data block on disk. */
     76  1.1  dholland 	daddr_t ffs_first_indir_blk;	/* first indirect block on disk. */
     77  1.1  dholland };
     78  1.1  dholland 
     79  1.1  dholland struct ext2fs_inode_ext {
     80  1.1  dholland 	daddr_t ext2fs_last_lblk;	/* last logical block allocated */
     81  1.1  dholland 	daddr_t ext2fs_last_blk;	/* last block allocated on disk */
     82  1.1  dholland };
     83  1.1  dholland 
     84  1.1  dholland struct lfs_inode_ext;
     85  1.1  dholland 
     86  1.1  dholland /*
     87  1.1  dholland  * The inode is used to describe each active (or recently active) file in the
     88  1.3  dholland  * ULFS filesystem. It is composed of two types of information. The first part
     89  1.1  dholland  * is the information that is needed only while the file is active (such as
     90  1.1  dholland  * the identity of the file and linkage to speed its lookup). The second part
     91  1.1  dholland  * is the permanent meta-data associated with the file which is read in
     92  1.1  dholland  * from the permanent dinode from long term storage when the file becomes
     93  1.1  dholland  * active, and is put back when the file is no longer being used.
     94  1.1  dholland  */
     95  1.1  dholland struct inode {
     96  1.1  dholland 	struct genfs_node i_gnode;
     97  1.1  dholland 	LIST_ENTRY(inode) i_hash;/* Hash chain. */
     98  1.1  dholland 	TAILQ_ENTRY(inode) i_nextsnap; /* snapshot file list. */
     99  1.1  dholland 	struct	vnode *i_vnode;	/* Vnode associated with this inode. */
    100  1.3  dholland 	struct  ulfsmount *i_ump; /* Mount point associated with this inode. */
    101  1.1  dholland 	struct	vnode *i_devvp;	/* Vnode for block I/O. */
    102  1.1  dholland 	u_int32_t i_flag;	/* flags, see below */
    103  1.1  dholland 	dev_t	  i_dev;	/* Device associated with the inode. */
    104  1.1  dholland 	ino_t	  i_number;	/* The identity of the inode. */
    105  1.1  dholland 
    106  1.1  dholland 	union {			/* Associated filesystem. */
    107  1.1  dholland 		struct	fs *fs;		/* FFS */
    108  1.1  dholland 		struct	lfs *lfs;	/* LFS */
    109  1.1  dholland 		struct	m_ext2fs *e2fs;	/* EXT2FS */
    110  1.1  dholland 	} inode_u;
    111  1.1  dholland #define	i_fs	inode_u.fs
    112  1.1  dholland #define	i_lfs	inode_u.lfs
    113  1.1  dholland #define	i_e2fs	inode_u.e2fs
    114  1.1  dholland 
    115  1.1  dholland 	void	*i_unused1;	/* Unused. */
    116  1.3  dholland 	struct	 dquot *i_dquot[ULFS_MAXQUOTAS]; /* Dquot structures. */
    117  1.1  dholland 	u_quad_t i_modrev;	/* Revision level for NFS lease. */
    118  1.1  dholland 	struct	 lockf *i_lockf;/* Head of byte-level lock list. */
    119  1.1  dholland 
    120  1.1  dholland 	/*
    121  1.1  dholland 	 * Side effects; used during (and after) directory lookup.
    122  1.1  dholland 	 * XXX should not be here.
    123  1.1  dholland 	 */
    124  1.3  dholland 	struct ulfs_lookup_results i_crap;
    125  1.1  dholland 	unsigned i_crapcounter;	/* serial number for i_crap */
    126  1.1  dholland 
    127  1.1  dholland 	/*
    128  1.1  dholland 	 * Inode extensions
    129  1.1  dholland 	 */
    130  1.1  dholland 	union {
    131  1.1  dholland 		/* Other extensions could go here... */
    132  1.1  dholland 		struct	ffs_inode_ext ffs;
    133  1.1  dholland 		struct	ext2fs_inode_ext e2fs;
    134  1.1  dholland 		struct  lfs_inode_ext *lfs;
    135  1.1  dholland 	} inode_ext;
    136  1.1  dholland #define	i_snapblklist		inode_ext.ffs.ffs_snapblklist
    137  1.1  dholland #define	i_ffs_first_data_blk	inode_ext.ffs.ffs_first_data_blk
    138  1.1  dholland #define	i_ffs_first_indir_blk	inode_ext.ffs.ffs_first_indir_blk
    139  1.1  dholland #define	i_e2fs_last_lblk	inode_ext.e2fs.ext2fs_last_lblk
    140  1.1  dholland #define	i_e2fs_last_blk		inode_ext.e2fs.ext2fs_last_blk
    141  1.1  dholland 	/*
    142  1.1  dholland 	 * Copies from the on-disk dinode itself.
    143  1.1  dholland 	 *
    144  1.1  dholland 	 * These fields are currently only used by FFS and LFS,
    145  1.1  dholland 	 * do NOT use them with ext2fs.
    146  1.1  dholland 	 */
    147  1.1  dholland 	u_int16_t i_mode;	/* IFMT, permissions; see below. */
    148  1.1  dholland 	int16_t   i_nlink;	/* File link count. */
    149  1.1  dholland 	u_int64_t i_size;	/* File byte count. */
    150  1.1  dholland 	u_int32_t i_flags;	/* Status flags (chflags). */
    151  1.1  dholland 	int32_t   i_gen;	/* Generation number. */
    152  1.1  dholland 	u_int32_t i_uid;	/* File owner. */
    153  1.1  dholland 	u_int32_t i_gid;	/* File group. */
    154  1.3  dholland 	u_int16_t i_omode;	/* Old mode, for ulfs_reclaim. */
    155  1.1  dholland 
    156  1.1  dholland 	struct dirhash *i_dirhash;	/* Hashing for large directories */
    157  1.1  dholland 
    158  1.1  dholland 	/*
    159  1.1  dholland 	 * The on-disk dinode itself.
    160  1.1  dholland 	 */
    161  1.1  dholland 	union {
    162  1.3  dholland 		struct	ulfs1_dinode *ffs1_din;	/* 128 bytes of the on-disk dinode. */
    163  1.3  dholland 		struct	ulfs2_dinode *ffs2_din;
    164  1.1  dholland 		struct	ext2fs_dinode *e2fs_din; /* 128 bytes of the on-disk
    165  1.1  dholland 						   dinode. */
    166  1.1  dholland 	} i_din;
    167  1.1  dholland };
    168  1.1  dholland 
    169  1.1  dholland #define	i_ffs1_atime		i_din.ffs1_din->di_atime
    170  1.1  dholland #define	i_ffs1_atimensec	i_din.ffs1_din->di_atimensec
    171  1.1  dholland #define	i_ffs1_blocks		i_din.ffs1_din->di_blocks
    172  1.1  dholland #define	i_ffs1_ctime		i_din.ffs1_din->di_ctime
    173  1.1  dholland #define	i_ffs1_ctimensec	i_din.ffs1_din->di_ctimensec
    174  1.1  dholland #define	i_ffs1_db		i_din.ffs1_din->di_db
    175  1.1  dholland #define	i_ffs1_flags		i_din.ffs1_din->di_flags
    176  1.1  dholland #define	i_ffs1_gen		i_din.ffs1_din->di_gen
    177  1.1  dholland #define	i_ffs1_gid		i_din.ffs1_din->di_gid
    178  1.1  dholland #define	i_ffs1_ib		i_din.ffs1_din->di_ib
    179  1.1  dholland #define	i_ffs1_mode		i_din.ffs1_din->di_mode
    180  1.1  dholland #define	i_ffs1_mtime		i_din.ffs1_din->di_mtime
    181  1.1  dholland #define	i_ffs1_mtimensec	i_din.ffs1_din->di_mtimensec
    182  1.1  dholland #define	i_ffs1_nlink		i_din.ffs1_din->di_nlink
    183  1.1  dholland #define	i_ffs1_rdev		i_din.ffs1_din->di_rdev
    184  1.1  dholland #define	i_ffs1_size		i_din.ffs1_din->di_size
    185  1.1  dholland #define	i_ffs1_uid		i_din.ffs1_din->di_uid
    186  1.1  dholland #define	i_ffs1_ouid		i_din.ffs1_din->di_u.oldids[0]
    187  1.1  dholland #define	i_ffs1_ogid		i_din.ffs1_din->di_u.oldids[1]
    188  1.1  dholland 
    189  1.1  dholland #define	i_ffs2_atime		i_din.ffs2_din->di_atime
    190  1.1  dholland #define	i_ffs2_atimensec	i_din.ffs2_din->di_atimensec
    191  1.1  dholland #define	i_ffs2_birthtime	i_din.ffs2_din->di_birthtime
    192  1.1  dholland #define	i_ffs2_birthnsec	i_din.ffs2_din->di_birthnsec
    193  1.1  dholland #define	i_ffs2_blocks		i_din.ffs2_din->di_blocks
    194  1.1  dholland #define	i_ffs2_blksize		i_din.ffs2_din->di_blksize
    195  1.1  dholland #define	i_ffs2_ctime		i_din.ffs2_din->di_ctime
    196  1.1  dholland #define	i_ffs2_ctimensec	i_din.ffs2_din->di_ctimensec
    197  1.1  dholland #define	i_ffs2_db		i_din.ffs2_din->di_db
    198  1.1  dholland #define	i_ffs2_flags		i_din.ffs2_din->di_flags
    199  1.1  dholland #define	i_ffs2_gen		i_din.ffs2_din->di_gen
    200  1.1  dholland #define	i_ffs2_gid		i_din.ffs2_din->di_gid
    201  1.1  dholland #define	i_ffs2_ib		i_din.ffs2_din->di_ib
    202  1.1  dholland #define	i_ffs2_mode		i_din.ffs2_din->di_mode
    203  1.1  dholland #define	i_ffs2_mtime		i_din.ffs2_din->di_mtime
    204  1.1  dholland #define	i_ffs2_mtimensec	i_din.ffs2_din->di_mtimensec
    205  1.1  dholland #define	i_ffs2_nlink		i_din.ffs2_din->di_nlink
    206  1.1  dholland #define	i_ffs2_rdev		i_din.ffs2_din->di_rdev
    207  1.1  dholland #define	i_ffs2_size		i_din.ffs2_din->di_size
    208  1.1  dholland #define	i_ffs2_uid		i_din.ffs2_din->di_uid
    209  1.1  dholland #define	i_ffs2_kernflags	i_din.ffs2_din->di_kernflags
    210  1.1  dholland #define	i_ffs2_extsize		i_din.ffs2_din->di_extsize
    211  1.1  dholland #define	i_ffs2_extb		i_din.ffs2_din->di_extb
    212  1.1  dholland 
    213  1.1  dholland #define	i_e2fs_mode		i_din.e2fs_din->e2di_mode
    214  1.1  dholland #define	i_e2fs_uid		i_din.e2fs_din->e2di_uid
    215  1.1  dholland #define	i_e2fs_size		i_din.e2fs_din->e2di_size
    216  1.1  dholland #define	i_e2fs_atime		i_din.e2fs_din->e2di_atime
    217  1.1  dholland #define	i_e2fs_ctime		i_din.e2fs_din->e2di_ctime
    218  1.1  dholland #define	i_e2fs_mtime		i_din.e2fs_din->e2di_mtime
    219  1.1  dholland #define	i_e2fs_dtime		i_din.e2fs_din->e2di_dtime
    220  1.1  dholland #define	i_e2fs_gid		i_din.e2fs_din->e2di_gid
    221  1.1  dholland #define	i_e2fs_nlink		i_din.e2fs_din->e2di_nlink
    222  1.1  dholland #define	i_e2fs_nblock		i_din.e2fs_din->e2di_nblock
    223  1.1  dholland #define	i_e2fs_flags		i_din.e2fs_din->e2di_flags
    224  1.1  dholland #define	i_e2fs_version		i_din.e2fs_din->e2di_version
    225  1.1  dholland #define	i_e2fs_blocks		i_din.e2fs_din->e2di_blocks
    226  1.1  dholland #define	i_e2fs_rdev		i_din.e2fs_din->e2di_rdev
    227  1.1  dholland #define	i_e2fs_gen		i_din.e2fs_din->e2di_gen
    228  1.1  dholland #define	i_e2fs_facl		i_din.e2fs_din->e2di_facl
    229  1.1  dholland #define	i_e2fs_dacl		i_din.e2fs_din->e2di_dacl
    230  1.1  dholland #define	i_e2fs_faddr		i_din.e2fs_din->e2di_faddr
    231  1.1  dholland #define	i_e2fs_nblock_high	i_din.e2fs_din->e2di_nblock_high
    232  1.1  dholland #define	i_e2fs_facl_high	i_din.e2fs_din->e2di_facl_high
    233  1.1  dholland #define	i_e2fs_uid_high		i_din.e2fs_din->e2di_uid_high
    234  1.1  dholland #define	i_e2fs_gid_high		i_din.e2fs_din->e2di_gid_high
    235  1.1  dholland 
    236  1.1  dholland /* These flags are kept in i_flag. */
    237  1.1  dholland #define	IN_ACCESS	0x0001		/* Access time update request. */
    238  1.1  dholland #define	IN_CHANGE	0x0002		/* Inode change time update request. */
    239  1.1  dholland #define	IN_UPDATE	0x0004		/* Inode was written to; update mtime. */
    240  1.1  dholland #define	IN_MODIFY	0x2000		/* Modification time update request. */
    241  1.1  dholland #define	IN_MODIFIED	0x0008		/* Inode has been modified. */
    242  1.1  dholland #define	IN_ACCESSED	0x0010		/* Inode has been accessed. */
    243  1.1  dholland /* #define	IN_UNUSED	0x0020 */	/* unused, was IN_RENAME */
    244  1.1  dholland #define	IN_SHLOCK	0x0040		/* File has shared lock. */
    245  1.1  dholland #define	IN_EXLOCK	0x0080		/* File has exclusive lock. */
    246  1.1  dholland #define	IN_CLEANING	0x0100		/* LFS: file is being cleaned */
    247  1.1  dholland #define	IN_ADIROP	0x0200		/* LFS: dirop in progress */
    248  1.1  dholland #define	IN_SPACECOUNTED	0x0400		/* Blocks to be freed in free count. */
    249  1.1  dholland #define	IN_PAGING       0x1000		/* LFS: file is on paging queue */
    250  1.1  dholland #define IN_CDIROP       0x4000          /* LFS: dirop completed pending i/o */
    251  1.1  dholland #if defined(_KERNEL)
    252  1.1  dholland 
    253  1.1  dholland /*
    254  1.1  dholland  * The DIP macro is used to access fields in the dinode that are
    255  1.1  dholland  * not cached in the inode itself.
    256  1.1  dholland  */
    257  1.1  dholland #define	DIP(ip, field) \
    258  1.3  dholland 	(((ip)->i_ump->um_fstype == ULFS1) ? \
    259  1.1  dholland 	(ip)->i_ffs1_##field : (ip)->i_ffs2_##field)
    260  1.1  dholland 
    261  1.1  dholland #define	DIP_ASSIGN(ip, field, value)					\
    262  1.1  dholland 	do {								\
    263  1.3  dholland 		if ((ip)->i_ump->um_fstype == ULFS1)			\
    264  1.1  dholland 			(ip)->i_ffs1_##field = (value);			\
    265  1.1  dholland 		else							\
    266  1.1  dholland 			(ip)->i_ffs2_##field = (value);			\
    267  1.1  dholland 	} while(0)
    268  1.1  dholland 
    269  1.1  dholland #define	DIP_ADD(ip, field, value)					\
    270  1.1  dholland 	do {								\
    271  1.3  dholland 		if ((ip)->i_ump->um_fstype == ULFS1)			\
    272  1.1  dholland 			(ip)->i_ffs1_##field += (value);		\
    273  1.1  dholland 		else							\
    274  1.1  dholland 			(ip)->i_ffs2_##field += (value);		\
    275  1.1  dholland 	} while(0)
    276  1.1  dholland 
    277  1.1  dholland #define	 SHORTLINK(ip) \
    278  1.3  dholland 	(((ip)->i_ump->um_fstype == ULFS1) ? \
    279  1.1  dholland 	(void *)(ip)->i_ffs1_db : (void *)(ip)->i_ffs2_db)
    280  1.1  dholland 
    281  1.1  dholland 
    282  1.1  dholland /*
    283  1.1  dholland  * Structure used to pass around logical block paths generated by
    284  1.3  dholland  * ulfs_getlbns and used by truncate and bmap code.
    285  1.1  dholland  */
    286  1.1  dholland struct indir {
    287  1.1  dholland 	daddr_t in_lbn;		/* Logical block number. */
    288  1.1  dholland 	int	in_off;			/* Offset in buffer. */
    289  1.1  dholland 	int	in_exists;		/* Flag if the block exists. */
    290  1.1  dholland };
    291  1.1  dholland 
    292  1.1  dholland /* Convert between inode pointers and vnode pointers. */
    293  1.1  dholland #define	VTOI(vp)	((struct inode *)(vp)->v_data)
    294  1.1  dholland #define	ITOV(ip)	((ip)->i_vnode)
    295  1.1  dholland 
    296  1.1  dholland /* This overlays the fid structure (see fstypes.h). */
    297  1.1  dholland struct ufid {
    298  1.1  dholland 	u_int16_t ufid_len;	/* Length of structure. */
    299  1.1  dholland 	u_int16_t ufid_pad;	/* Force 32-bit alignment. */
    300  1.1  dholland 	u_int32_t ufid_ino;	/* File number (ino). */
    301  1.1  dholland 	int32_t	  ufid_gen;	/* Generation number. */
    302  1.1  dholland };
    303  1.1  dholland #endif /* _KERNEL */
    304  1.1  dholland 
    305  1.3  dholland #endif /* !_UFS_LFS_ULFS_INODE_H_ */
    306