1139778Simp/*- 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 * 4. Neither the name of the University nor the names of its contributors 191541Srgrimes * may be used to endorse or promote products derived from this software 201541Srgrimes * without specific prior written permission. 211541Srgrimes * 221541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 231541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 241541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 251541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 261541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 271541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 281541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 291541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 301541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 311541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 321541Srgrimes * SUCH DAMAGE. 331541Srgrimes * 3422521Sdyson * @(#)inode.h 8.9 (Berkeley) 5/14/95 3550477Speter * $FreeBSD: stable/11/sys/fs/ext2fs/inode.h 322711 2017-08-20 01:08:23Z pfg $ 361541Srgrimes */ 371541Srgrimes 38202283Slulf#ifndef _FS_EXT2FS_INODE_H_ 39202283Slulf#define _FS_EXT2FS_INODE_H_ 402177Spaul 41254260Spfg#include <sys/param.h> 4231557Sjkh#include <sys/lock.h> 43254260Spfg#include <sys/mutex.h> 4444512Sbde#include <sys/queue.h> 451541Srgrimes 46254260Spfg#include <fs/ext2fs/ext2_extents.h> 47254260Spfg 4834266Sjulian/* 4924477Sbde * This must agree with the definition in <ufs/ufs/dir.h>. 5024477Sbde */ 5124477Sbde#define doff_t int32_t 5224477Sbde 53251809Spfg#define NDADDR 12 /* Direct addresses in inode. */ 54251809Spfg#define NIADDR 3 /* Indirect addresses in inode. */ 55251809Spfg 5624477Sbde/* 57254283Spfg * The size of physical and logical block numbers in EXT2FS. 58252103Spfg */ 59311231Spfgtypedef uint32_t e2fs_daddr_t; 60311231Spfgtypedef int64_t e2fs_lbn_t; 61311231Spfgtypedef int64_t e4fs_daddr_t; 62311231Spfg 63252103Spfg/* 6422521Sdyson * The inode is used to describe each active (or recently active) file in the 6596596Siedowse * EXT2FS filesystem. It is composed of two types of information. The first 6696596Siedowse * part is the information that is needed only while the file is active (such 6796596Siedowse * as the identity of the file and linkage to speed its lookup). The second 6896596Siedowse * part is the permanent meta-data associated with the file which is read in 6922521Sdyson * from the permanent dinode from long term storage when the file becomes 7022521Sdyson * active, and is put back when the file is no longer being used. 711541Srgrimes */ 7222521Sdysonstruct inode { 7322521Sdyson struct vnode *i_vnode;/* Vnode associated with this inode. */ 74202283Slulf struct ext2mount *i_ump; 75221126Sjhb uint32_t i_flag; /* flags, see below */ 7622521Sdyson ino_t i_number; /* The identity of the inode. */ 771541Srgrimes 78202283Slulf struct m_ext2fs *i_e2fs; /* EXT2FS */ 7922521Sdyson u_quad_t i_modrev; /* Revision level for NFS lease. */ 801541Srgrimes /* 811541Srgrimes * Side effects; used during directory lookup. 821541Srgrimes */ 83221126Sjhb int32_t i_count; /* Size of free slot in directory. */ 84221126Sjhb doff_t i_endoff; /* End of useful stuff in directory. */ 85221126Sjhb doff_t i_diroff; /* Offset in dir, where we found last entry. */ 86221126Sjhb doff_t i_offset; /* Offset of free space in directory. */ 8779561Siedowse 88221126Sjhb uint32_t i_block_group; 89221126Sjhb uint32_t i_next_alloc_block; 90221126Sjhb uint32_t i_next_alloc_goal; 9196596Siedowse 9296596Siedowse /* Fields from struct dinode in UFS. */ 93221126Sjhb uint16_t i_mode; /* IFMT, permissions; see below. */ 9496596Siedowse int16_t i_nlink; /* File link count. */ 95254260Spfg uint32_t i_uid; /* File owner. */ 96254260Spfg uint32_t i_gid; /* File group. */ 97221126Sjhb uint64_t i_size; /* File byte count. */ 98254260Spfg uint64_t i_blocks; /* Blocks actually held. */ 9996596Siedowse int32_t i_atime; /* Last access time. */ 10096596Siedowse int32_t i_mtime; /* Last modified time. */ 101231168Spfg int32_t i_ctime; /* Last inode change time. */ 102231168Spfg int32_t i_birthtime; /* Inode creation time. */ 10396596Siedowse int32_t i_mtimensec; /* Last modified time. */ 104231168Spfg int32_t i_atimensec; /* Last access time. */ 10596596Siedowse int32_t i_ctimensec; /* Last inode change time. */ 106231168Spfg int32_t i_birthnsec; /* Inode creation time. */ 107254260Spfg uint32_t i_gen; /* Generation number. */ 108322711Spfg uint64_t i_facl; /* EA block number. */ 109254260Spfg uint32_t i_flags; /* Status flags (chflags). */ 110245820Spfg uint32_t i_db[NDADDR]; /* Direct disk blocks. */ 111245820Spfg uint32_t i_ib[NIADDR]; /* Indirect disk blocks. */ 112254260Spfg 113254260Spfg struct ext4_extent_cache i_ext_cache; /* cache for ext4 extent */ 1141541Srgrimes}; 1151541Srgrimes 11696596Siedowse/* 11796596Siedowse * The di_db fields may be overlaid with other information for 11896596Siedowse * file types that do not have associated disk storage. Block 11996596Siedowse * and character devices overlay the first data block with their 120130763Sbde * dev_t value. Short symbolic links place their path in the 12196596Siedowse * di_db area. 12296596Siedowse */ 12396596Siedowse#define i_shortlink i_db 12496596Siedowse#define i_rdev i_db[0] 1251541Srgrimes 12696596Siedowse/* File permissions. */ 12796596Siedowse#define IEXEC 0000100 /* Executable. */ 12896596Siedowse#define IWRITE 0000200 /* Writeable. */ 12996596Siedowse#define IREAD 0000400 /* Readable. */ 13096596Siedowse#define ISVTX 0001000 /* Sticky bit. */ 13196596Siedowse#define ISGID 0002000 /* Set-gid. */ 13296596Siedowse#define ISUID 0004000 /* Set-uid. */ 13396596Siedowse 13496596Siedowse/* File types. */ 13596596Siedowse#define IFMT 0170000 /* Mask of file type. */ 13696596Siedowse#define IFIFO 0010000 /* Named pipe (fifo). */ 13796596Siedowse#define IFCHR 0020000 /* Character device. */ 13896596Siedowse#define IFDIR 0040000 /* Directory file. */ 13996596Siedowse#define IFBLK 0060000 /* Block device. */ 14096596Siedowse#define IFREG 0100000 /* Regular file. */ 14196596Siedowse#define IFLNK 0120000 /* Symbolic link. */ 14296596Siedowse#define IFSOCK 0140000 /* UNIX domain socket. */ 14396596Siedowse#define IFWHT 0160000 /* Whiteout. */ 14496596Siedowse 1451541Srgrimes/* These flags are kept in i_flag. */ 1461541Srgrimes#define IN_ACCESS 0x0001 /* Access time update request. */ 1471541Srgrimes#define IN_CHANGE 0x0002 /* Inode change time update request. */ 14822521Sdyson#define IN_UPDATE 0x0004 /* Modification time update request. */ 14922521Sdyson#define IN_MODIFIED 0x0008 /* Inode has been modified. */ 15022521Sdyson#define IN_RENAME 0x0010 /* Inode is being renamed. */ 15176357Smckusick#define IN_HASHED 0x0020 /* Inode is on hash list */ 15276357Smckusick#define IN_LAZYMOD 0x0040 /* Modified, but don't write yet. */ 15376357Smckusick#define IN_SPACECOUNTED 0x0080 /* Blocks to be freed in free count. */ 154262623Spfg#define IN_LAZYACCESS 0x0100 /* Process IN_ACCESS after the 155202283Slulf suspension finished */ 156217582Sjhb 157260988Spfg/* 158260988Spfg * These are translation flags for some attributes that Ext4 159260988Spfg * passes as inode flags but that we cannot pass directly. 160260988Spfg */ 161294655Spfg#define IN_E3INDEX 0x010000 162261235Spfg#define IN_E4EXTENTS 0x020000 163260988Spfg 164217582Sjhb#define i_devvp i_ump->um_devvp 165217582Sjhb 16655206Speter#ifdef _KERNEL 1671541Srgrimes/* 1681541Srgrimes * Structure used to pass around logical block paths generated by 16996877Siedowse * ext2_getlbns and used by truncate and bmap code. 1701541Srgrimes */ 1711541Srgrimesstruct indir { 172252103Spfg e2fs_lbn_t in_lbn; /* Logical block number. */ 1731541Srgrimes int in_off; /* Offset in buffer. */ 1741541Srgrimes}; 1751541Srgrimes 1761541Srgrimes/* Convert between inode pointers and vnode pointers. */ 1771541Srgrimes#define VTOI(vp) ((struct inode *)(vp)->v_data) 1781541Srgrimes#define ITOV(ip) ((ip)->i_vnode) 1791541Srgrimes 1801541Srgrimes/* This overlays the fid structure (see mount.h). */ 1811541Srgrimesstruct ufid { 182311231Spfg uint16_t ufid_len; /* Length of structure. */ 183311231Spfg uint16_t ufid_pad; /* Force 32-bit alignment. */ 184311231Spfg ino_t ufid_ino; /* File number (ino). */ 185311231Spfg uint32_t ufid_gen; /* Generation number. */ 1861541Srgrimes}; 187311231Spfg#endif /* _KERNEL */ 1882177Spaul 189311231Spfg#endif /* !_FS_EXT2FS_INODE_H_ */ 190