2005-01-06 18:27:30 +00:00
|
|
|
/*-
|
1994-05-24 10:09:53 +00:00
|
|
|
* Copyright (c) 1982, 1989, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
* (c) UNIX System Laboratories, Inc.
|
|
|
|
* All or some portions of this file are derived from material licensed
|
|
|
|
* to the University of California by American Telephone and Telegraph
|
|
|
|
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
|
|
|
* the permission of UNIX System Laboratories, Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1997-02-10 02:22:35 +00:00
|
|
|
* @(#)inode.h 8.9 (Berkeley) 5/14/95
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
2010-01-14 14:30:54 +00:00
|
|
|
#ifndef _FS_EXT2FS_INODE_H_
|
|
|
|
#define _FS_EXT2FS_INODE_H_
|
1994-08-21 07:19:45 +00:00
|
|
|
|
2013-08-12 21:34:48 +00:00
|
|
|
#include <sys/param.h>
|
1997-12-05 13:43:47 +00:00
|
|
|
#include <sys/lock.h>
|
2013-08-12 21:34:48 +00:00
|
|
|
#include <sys/mutex.h>
|
1999-03-06 05:21:09 +00:00
|
|
|
#include <sys/queue.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2013-08-12 21:34:48 +00:00
|
|
|
#include <fs/ext2fs/ext2_extents.h>
|
|
|
|
|
1997-04-01 08:02:00 +00:00
|
|
|
/*
|
|
|
|
* This must agree with the definition in <ufs/ufs/dir.h>.
|
|
|
|
*/
|
|
|
|
#define doff_t int32_t
|
|
|
|
|
2013-06-16 16:10:45 +00:00
|
|
|
#define NDADDR 12 /* Direct addresses in inode. */
|
|
|
|
#define NIADDR 3 /* Indirect addresses in inode. */
|
|
|
|
|
2013-06-23 02:44:42 +00:00
|
|
|
/*
|
2013-08-13 15:40:43 +00:00
|
|
|
* The size of physical and logical block numbers in EXT2FS.
|
2013-06-23 02:44:42 +00:00
|
|
|
*/
|
2013-08-13 15:40:43 +00:00
|
|
|
typedef uint32_t e2fs_daddr_t;
|
|
|
|
typedef int64_t e2fs_lbn_t;
|
|
|
|
typedef int64_t e4fs_daddr_t;
|
2013-06-23 02:44:42 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* The inode is used to describe each active (or recently active) file in the
|
2002-05-14 17:14:01 +00:00
|
|
|
* EXT2FS filesystem. It is composed of two types of information. The first
|
|
|
|
* part is the information that is needed only while the file is active (such
|
|
|
|
* as the identity of the file and linkage to speed its lookup). The second
|
|
|
|
* part is the permanent meta-data associated with the file which is read in
|
1997-02-10 02:22:35 +00:00
|
|
|
* from the permanent dinode from long term storage when the file becomes
|
|
|
|
* active, and is put back when the file is no longer being used.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
struct inode {
|
1997-02-10 02:22:35 +00:00
|
|
|
struct vnode *i_vnode;/* Vnode associated with this inode. */
|
2010-01-14 14:30:54 +00:00
|
|
|
struct ext2mount *i_ump;
|
2011-04-27 18:15:34 +00:00
|
|
|
uint32_t i_flag; /* flags, see below */
|
1997-02-10 02:22:35 +00:00
|
|
|
ino_t i_number; /* The identity of the inode. */
|
2002-05-14 17:14:01 +00:00
|
|
|
|
2010-01-14 14:30:54 +00:00
|
|
|
struct m_ext2fs *i_e2fs; /* EXT2FS */
|
1997-02-10 02:22:35 +00:00
|
|
|
u_quad_t i_modrev; /* Revision level for NFS lease. */
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Side effects; used during directory lookup.
|
|
|
|
*/
|
2011-04-27 18:15:34 +00:00
|
|
|
int32_t i_count; /* Size of free slot in directory. */
|
|
|
|
doff_t i_endoff; /* End of useful stuff in directory. */
|
|
|
|
doff_t i_diroff; /* Offset in dir, where we found last entry. */
|
|
|
|
doff_t i_offset; /* Offset of free space in directory. */
|
2001-07-10 21:21:29 +00:00
|
|
|
|
2011-04-27 18:15:34 +00:00
|
|
|
uint32_t i_block_group;
|
|
|
|
uint32_t i_next_alloc_block;
|
|
|
|
uint32_t i_next_alloc_goal;
|
2002-05-14 17:14:01 +00:00
|
|
|
|
|
|
|
/* Fields from struct dinode in UFS. */
|
2011-04-27 18:15:34 +00:00
|
|
|
uint16_t i_mode; /* IFMT, permissions; see below. */
|
2002-05-14 17:14:01 +00:00
|
|
|
int16_t i_nlink; /* File link count. */
|
2013-08-12 21:34:48 +00:00
|
|
|
uint32_t i_uid; /* File owner. */
|
|
|
|
uint32_t i_gid; /* File group. */
|
2011-04-27 18:15:34 +00:00
|
|
|
uint64_t i_size; /* File byte count. */
|
2013-08-12 21:34:48 +00:00
|
|
|
uint64_t i_blocks; /* Blocks actually held. */
|
2002-05-14 17:14:01 +00:00
|
|
|
int32_t i_atime; /* Last access time. */
|
|
|
|
int32_t i_mtime; /* Last modified time. */
|
|
|
|
int32_t i_ctime; /* Last inode change time. */
|
2012-02-07 22:31:28 +00:00
|
|
|
int32_t i_birthtime; /* Inode creation time. */
|
|
|
|
int32_t i_mtimensec; /* Last modified time. */
|
|
|
|
int32_t i_atimensec; /* Last access time. */
|
2002-05-14 17:14:01 +00:00
|
|
|
int32_t i_ctimensec; /* Last inode change time. */
|
2012-02-07 22:31:28 +00:00
|
|
|
int32_t i_birthnsec; /* Inode creation time. */
|
2013-08-12 21:34:48 +00:00
|
|
|
uint32_t i_gen; /* Generation number. */
|
|
|
|
uint32_t i_flags; /* Status flags (chflags). */
|
2013-01-22 18:54:03 +00:00
|
|
|
uint32_t i_db[NDADDR]; /* Direct disk blocks. */
|
|
|
|
uint32_t i_ib[NIADDR]; /* Indirect disk blocks. */
|
2013-08-12 21:34:48 +00:00
|
|
|
|
|
|
|
struct ext4_extent_cache i_ext_cache; /* cache for ext4 extent */
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
|
|
|
|
2002-05-14 17:14:01 +00:00
|
|
|
/*
|
|
|
|
* The di_db fields may be overlaid with other information for
|
|
|
|
* file types that do not have associated disk storage. Block
|
|
|
|
* and character devices overlay the first data block with their
|
2004-06-20 03:36:31 +00:00
|
|
|
* dev_t value. Short symbolic links place their path in the
|
2002-05-14 17:14:01 +00:00
|
|
|
* di_db area.
|
|
|
|
*/
|
|
|
|
#define i_shortlink i_db
|
|
|
|
#define i_rdev i_db[0]
|
|
|
|
|
|
|
|
/* File permissions. */
|
|
|
|
#define IEXEC 0000100 /* Executable. */
|
|
|
|
#define IWRITE 0000200 /* Writeable. */
|
|
|
|
#define IREAD 0000400 /* Readable. */
|
|
|
|
#define ISVTX 0001000 /* Sticky bit. */
|
|
|
|
#define ISGID 0002000 /* Set-gid. */
|
|
|
|
#define ISUID 0004000 /* Set-uid. */
|
|
|
|
|
|
|
|
/* File types. */
|
|
|
|
#define IFMT 0170000 /* Mask of file type. */
|
|
|
|
#define IFIFO 0010000 /* Named pipe (fifo). */
|
|
|
|
#define IFCHR 0020000 /* Character device. */
|
|
|
|
#define IFDIR 0040000 /* Directory file. */
|
|
|
|
#define IFBLK 0060000 /* Block device. */
|
|
|
|
#define IFREG 0100000 /* Regular file. */
|
|
|
|
#define IFLNK 0120000 /* Symbolic link. */
|
|
|
|
#define IFSOCK 0140000 /* UNIX domain socket. */
|
|
|
|
#define IFWHT 0160000 /* Whiteout. */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/* These flags are kept in i_flag. */
|
|
|
|
#define IN_ACCESS 0x0001 /* Access time update request. */
|
|
|
|
#define IN_CHANGE 0x0002 /* Inode change time update request. */
|
1997-02-10 02:22:35 +00:00
|
|
|
#define IN_UPDATE 0x0004 /* Modification time update request. */
|
|
|
|
#define IN_MODIFIED 0x0008 /* Inode has been modified. */
|
|
|
|
#define IN_RENAME 0x0010 /* Inode is being renamed. */
|
2001-05-08 07:42:20 +00:00
|
|
|
#define IN_HASHED 0x0020 /* Inode is on hash list */
|
|
|
|
#define IN_LAZYMOD 0x0040 /* Modified, but don't write yet. */
|
|
|
|
#define IN_SPACECOUNTED 0x0080 /* Blocks to be freed in free count. */
|
2014-02-28 21:25:32 +00:00
|
|
|
#define IN_LAZYACCESS 0x0100 /* Process IN_ACCESS after the
|
2010-01-14 14:30:54 +00:00
|
|
|
suspension finished */
|
2011-01-19 16:46:13 +00:00
|
|
|
|
2014-01-21 19:06:29 +00:00
|
|
|
/*
|
|
|
|
* These are translation flags for some attributes that Ext4
|
|
|
|
* passes as inode flags but that we cannot pass directly.
|
|
|
|
*/
|
2014-01-28 14:39:05 +00:00
|
|
|
#define IN_E4INDEX 0x010000
|
|
|
|
#define IN_E4EXTENTS 0x020000
|
2014-01-21 19:06:29 +00:00
|
|
|
|
2011-01-19 16:46:13 +00:00
|
|
|
#define i_devvp i_ump->um_devvp
|
|
|
|
|
1999-12-29 05:07:58 +00:00
|
|
|
#ifdef _KERNEL
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Structure used to pass around logical block paths generated by
|
2002-05-18 19:12:38 +00:00
|
|
|
* ext2_getlbns and used by truncate and bmap code.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
struct indir {
|
2013-06-23 02:44:42 +00:00
|
|
|
e2fs_lbn_t in_lbn; /* Logical block number. */
|
1994-05-24 10:09:53 +00:00
|
|
|
int in_off; /* Offset in buffer. */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Convert between inode pointers and vnode pointers. */
|
|
|
|
#define VTOI(vp) ((struct inode *)(vp)->v_data)
|
|
|
|
#define ITOV(ip) ((ip)->i_vnode)
|
|
|
|
|
|
|
|
/* This overlays the fid structure (see mount.h). */
|
|
|
|
struct ufid {
|
2011-04-27 18:15:34 +00:00
|
|
|
uint16_t ufid_len; /* Length of structure. */
|
|
|
|
uint16_t ufid_pad; /* Force 32-bit alignment. */
|
|
|
|
ino_t ufid_ino; /* File number (ino). */
|
2013-01-22 18:54:03 +00:00
|
|
|
uint32_t ufid_gen; /* Generation number. */
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1999-12-29 05:07:58 +00:00
|
|
|
#endif /* _KERNEL */
|
1994-12-27 13:59:14 +00:00
|
|
|
|
2010-01-14 14:30:54 +00:00
|
|
|
#endif /* !_FS_EXT2FS_INODE_H_ */
|