Home | History | Annotate | Line # | Download | only in lfs
lfs_inode.h revision 1.3
      1 /*	$NetBSD: lfs_inode.h,v 1.3 2013/06/08 23:12:51 dholland Exp $	*/
      2 /*  from NetBSD: ulfs_inode.h,v 1.5 2013/06/06 00:51:50 dholland Exp  */
      3 /*  from NetBSD: inode.h,v 1.64 2012/11/19 00:36:21 jakllsch Exp  */
      4 
      5 /*
      6  * Copyright (c) 1982, 1989, 1993
      7  *	The Regents of the University of California.  All rights reserved.
      8  * (c) UNIX System Laboratories, Inc.
      9  * All or some portions of this file are derived from material licensed
     10  * to the University of California by American Telephone and Telegraph
     11  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
     12  * the permission of UNIX System Laboratories, Inc.
     13  *
     14  * Redistribution and use in source and binary forms, with or without
     15  * modification, are permitted provided that the following conditions
     16  * are met:
     17  * 1. Redistributions of source code must retain the above copyright
     18  *    notice, this list of conditions and the following disclaimer.
     19  * 2. Redistributions in binary form must reproduce the above copyright
     20  *    notice, this list of conditions and the following disclaimer in the
     21  *    documentation and/or other materials provided with the distribution.
     22  * 3. Neither the name of the University nor the names of its contributors
     23  *    may be used to endorse or promote products derived from this software
     24  *    without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  * SUCH DAMAGE.
     37  *
     38  *	@(#)inode.h	8.9 (Berkeley) 5/14/95
     39  */
     40 
     41 #ifndef _UFS_LFS_LFS_INODE_H_
     42 #define	_UFS_LFS_LFS_INODE_H_
     43 
     44 /*
     45  * Some of the userlevel code (fsck, newfs, lfs_cleanerd) wants to use
     46  * the in-memory inode structure in a faked-up kernel environment.
     47  * This header file provides a reasonably sanitized version of the
     48  * structures and definitions needed for that purpose.
     49  */
     50 
     51 #include <miscfs/genfs/genfs_node.h>
     52 #include <ufs/lfs/lfs.h>
     53 
     54 /*
     55  * The following constants define the usage of the quota file array in the
     56  * ulfsmount structure and dquot array in the inode structure.  The semantics
     57  * of the elements of these arrays are defined in the routine lfs_getinoquota;
     58  * the remainder of the quota code treats them generically and need not be
     59  * inspected when changing the size of the array.
     60  */
     61 #define	ULFS_MAXQUOTAS	2
     62 #define	ULFS_USRQUOTA	0	/* element used for user quotas */
     63 #define	ULFS_GRPQUOTA	1	/* element used for group quotas */
     64 
     65 /*
     66  * Lookup result state (other than the result inode). This is
     67  * currently stashed in the vnode between VOP_LOOKUP and directory
     68  * operation VOPs, which is gross.
     69  *
     70  * XXX ulr_diroff is a lookup hint from the previos call of VOP_LOOKUP.
     71  * probably it should not be here.
     72  */
     73 struct ulfs_lookup_results {
     74 	int32_t	  ulr_count;	/* Size of free slot in directory. */
     75 	doff_t	  ulr_endoff;	/* End of useful stuff in directory. */
     76 	doff_t	  ulr_diroff;	/* Offset in dir, where we found last entry. */
     77 	doff_t	  ulr_offset;	/* Offset of free space in directory. */
     78 	u_int32_t ulr_reclen;	/* Size of found directory entry. */
     79 };
     80 
     81 /* notyet XXX */
     82 #define ULFS_CHECK_CRAPCOUNTER(dp) ((void)(dp)->i_crapcounter)
     83 
     84 /*
     85  * Per-filesystem inode extensions.
     86  */
     87 struct lfs_inode_ext;
     88 
     89 /*
     90  * The inode is used to describe each active (or recently active) file in the
     91  * ULFS filesystem. It is composed of two types of information. The first part
     92  * is the information that is needed only while the file is active (such as
     93  * the identity of the file and linkage to speed its lookup). The second part
     94  * is the permanent meta-data associated with the file which is read in
     95  * from the permanent dinode from long term storage when the file becomes
     96  * active, and is put back when the file is no longer being used.
     97  */
     98 struct inode {
     99 	struct genfs_node i_gnode;
    100 	LIST_ENTRY(inode) i_hash;/* Hash chain. */
    101 	TAILQ_ENTRY(inode) i_nextsnap; /* snapshot file list. */
    102 	struct	vnode *i_vnode;	/* Vnode associated with this inode. */
    103 	struct  ulfsmount *i_ump; /* Mount point associated with this inode. */
    104 	struct	vnode *i_devvp;	/* Vnode for block I/O. */
    105 	u_int32_t i_flag;	/* flags, see below */
    106 	dev_t	  i_dev;	/* Device associated with the inode. */
    107 	ino_t	  i_number;	/* The identity of the inode. */
    108 
    109 	struct lfs *i_lfs;	/* The LFS volume we belong to. */
    110 
    111 	void	*i_unused1;	/* Unused. */
    112 	struct	 dquot *i_dquot[ULFS_MAXQUOTAS]; /* Dquot structures. */
    113 	u_quad_t i_modrev;	/* Revision level for NFS lease. */
    114 	struct	 lockf *i_lockf;/* Head of byte-level lock list. */
    115 
    116 	/*
    117 	 * Side effects; used during (and after) directory lookup.
    118 	 * XXX should not be here.
    119 	 */
    120 	struct ulfs_lookup_results i_crap;
    121 	unsigned i_crapcounter;	/* serial number for i_crap */
    122 
    123 	/*
    124 	 * Inode extensions
    125 	 */
    126 	union {
    127 		/* Other extensions could go here... */
    128 		struct  lfs_inode_ext *lfs;
    129 	} inode_ext;
    130 	/*
    131 	 * Copies from the on-disk dinode itself.
    132 	 *
    133 	 * These fields are currently only used by LFS.
    134 	 */
    135 	u_int16_t i_mode;	/* IFMT, permissions; see below. */
    136 	int16_t   i_nlink;	/* File link count. */
    137 	u_int64_t i_size;	/* File byte count. */
    138 	u_int32_t i_flags;	/* Status flags (chflags). */
    139 	int32_t   i_gen;	/* Generation number. */
    140 	u_int32_t i_uid;	/* File owner. */
    141 	u_int32_t i_gid;	/* File group. */
    142 	u_int16_t i_omode;	/* Old mode, for ulfs_reclaim. */
    143 
    144 	struct dirhash *i_dirhash;	/* Hashing for large directories */
    145 
    146 	/*
    147 	 * The on-disk dinode itself.
    148 	 */
    149 	union {
    150 		struct	ulfs1_dinode *ffs1_din;	/* 128 bytes of the on-disk dinode. */
    151 		struct	ulfs2_dinode *ffs2_din;
    152 	} i_din;
    153 };
    154 
    155 #define	i_ffs1_atime		i_din.ffs1_din->di_atime
    156 #define	i_ffs1_atimensec	i_din.ffs1_din->di_atimensec
    157 #define	i_ffs1_blocks		i_din.ffs1_din->di_blocks
    158 #define	i_ffs1_ctime		i_din.ffs1_din->di_ctime
    159 #define	i_ffs1_ctimensec	i_din.ffs1_din->di_ctimensec
    160 #define	i_ffs1_db		i_din.ffs1_din->di_db
    161 #define	i_ffs1_flags		i_din.ffs1_din->di_flags
    162 #define	i_ffs1_gen		i_din.ffs1_din->di_gen
    163 #define	i_ffs1_gid		i_din.ffs1_din->di_gid
    164 #define	i_ffs1_ib		i_din.ffs1_din->di_ib
    165 #define	i_ffs1_mode		i_din.ffs1_din->di_mode
    166 #define	i_ffs1_mtime		i_din.ffs1_din->di_mtime
    167 #define	i_ffs1_mtimensec	i_din.ffs1_din->di_mtimensec
    168 #define	i_ffs1_nlink		i_din.ffs1_din->di_nlink
    169 #define	i_ffs1_rdev		i_din.ffs1_din->di_rdev
    170 #define	i_ffs1_size		i_din.ffs1_din->di_size
    171 #define	i_ffs1_uid		i_din.ffs1_din->di_uid
    172 
    173 #define	i_ffs2_atime		i_din.ffs2_din->di_atime
    174 #define	i_ffs2_atimensec	i_din.ffs2_din->di_atimensec
    175 #define	i_ffs2_birthtime	i_din.ffs2_din->di_birthtime
    176 #define	i_ffs2_birthnsec	i_din.ffs2_din->di_birthnsec
    177 #define	i_ffs2_blocks		i_din.ffs2_din->di_blocks
    178 #define	i_ffs2_blksize		i_din.ffs2_din->di_blksize
    179 #define	i_ffs2_ctime		i_din.ffs2_din->di_ctime
    180 #define	i_ffs2_ctimensec	i_din.ffs2_din->di_ctimensec
    181 #define	i_ffs2_db		i_din.ffs2_din->di_db
    182 #define	i_ffs2_flags		i_din.ffs2_din->di_flags
    183 #define	i_ffs2_gen		i_din.ffs2_din->di_gen
    184 #define	i_ffs2_gid		i_din.ffs2_din->di_gid
    185 #define	i_ffs2_ib		i_din.ffs2_din->di_ib
    186 #define	i_ffs2_mode		i_din.ffs2_din->di_mode
    187 #define	i_ffs2_mtime		i_din.ffs2_din->di_mtime
    188 #define	i_ffs2_mtimensec	i_din.ffs2_din->di_mtimensec
    189 #define	i_ffs2_nlink		i_din.ffs2_din->di_nlink
    190 #define	i_ffs2_rdev		i_din.ffs2_din->di_rdev
    191 #define	i_ffs2_size		i_din.ffs2_din->di_size
    192 #define	i_ffs2_uid		i_din.ffs2_din->di_uid
    193 #define	i_ffs2_kernflags	i_din.ffs2_din->di_kernflags
    194 #define	i_ffs2_extsize		i_din.ffs2_din->di_extsize
    195 #define	i_ffs2_extb		i_din.ffs2_din->di_extb
    196 
    197 /* These flags are kept in i_flag. */
    198 #define	IN_ACCESS	0x0001		/* Access time update request. */
    199 #define	IN_CHANGE	0x0002		/* Inode change time update request. */
    200 #define	IN_UPDATE	0x0004		/* Inode was written to; update mtime. */
    201 #define	IN_MODIFY	0x2000		/* Modification time update request. */
    202 #define	IN_MODIFIED	0x0008		/* Inode has been modified. */
    203 #define	IN_ACCESSED	0x0010		/* Inode has been accessed. */
    204 /* #define	IN_UNUSED	0x0020 */	/* unused, was IN_RENAME */
    205 #define	IN_SHLOCK	0x0040		/* File has shared lock. */
    206 #define	IN_EXLOCK	0x0080		/* File has exclusive lock. */
    207 #define	IN_CLEANING	0x0100		/* LFS: file is being cleaned */
    208 #define	IN_ADIROP	0x0200		/* LFS: dirop in progress */
    209 #define	IN_SPACECOUNTED	0x0400		/* Blocks to be freed in free count. */
    210 #define	IN_PAGING       0x1000		/* LFS: file is on paging queue */
    211 #define IN_CDIROP       0x4000          /* LFS: dirop completed pending i/o */
    212 
    213 #endif /* _UFS_LFS_LFS_INODE_H_ */
    214