1*4a5d661aSToomas Soome /*- 2*4a5d661aSToomas Soome * Copyright (c) 2002 Networks Associates Technology, Inc. 3*4a5d661aSToomas Soome * All rights reserved. 4*4a5d661aSToomas Soome * 5*4a5d661aSToomas Soome * This software was developed for the FreeBSD Project by Marshall 6*4a5d661aSToomas Soome * Kirk McKusick and Network Associates Laboratories, the Security 7*4a5d661aSToomas Soome * Research Division of Network Associates, Inc. under DARPA/SPAWAR 8*4a5d661aSToomas Soome * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS 9*4a5d661aSToomas Soome * research program 10*4a5d661aSToomas Soome * 11*4a5d661aSToomas Soome * Redistribution and use in source and binary forms, with or without 12*4a5d661aSToomas Soome * modification, are permitted provided that the following conditions 13*4a5d661aSToomas Soome * are met: 14*4a5d661aSToomas Soome * 1. Redistributions of source code must retain the above copyright 15*4a5d661aSToomas Soome * notice, this list of conditions and the following disclaimer. 16*4a5d661aSToomas Soome * 2. Redistributions in binary form must reproduce the above copyright 17*4a5d661aSToomas Soome * notice, this list of conditions and the following disclaimer in the 18*4a5d661aSToomas Soome * documentation and/or other materials provided with the distribution. 19*4a5d661aSToomas Soome * 20*4a5d661aSToomas Soome * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21*4a5d661aSToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22*4a5d661aSToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23*4a5d661aSToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 24*4a5d661aSToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25*4a5d661aSToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26*4a5d661aSToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27*4a5d661aSToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28*4a5d661aSToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29*4a5d661aSToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30*4a5d661aSToomas Soome * SUCH DAMAGE. 31*4a5d661aSToomas Soome * 32*4a5d661aSToomas Soome * Copyright (c) 1982, 1989, 1993 33*4a5d661aSToomas Soome * The Regents of the University of California. All rights reserved. 34*4a5d661aSToomas Soome * (c) UNIX System Laboratories, Inc. 35*4a5d661aSToomas Soome * All or some portions of this file are derived from material licensed 36*4a5d661aSToomas Soome * to the University of California by American Telephone and Telegraph 37*4a5d661aSToomas Soome * Co. or Unix System Laboratories, Inc. and are reproduced herein with 38*4a5d661aSToomas Soome * the permission of UNIX System Laboratories, Inc. 39*4a5d661aSToomas Soome * 40*4a5d661aSToomas Soome * Redistribution and use in source and binary forms, with or without 41*4a5d661aSToomas Soome * modification, are permitted provided that the following conditions 42*4a5d661aSToomas Soome * are met: 43*4a5d661aSToomas Soome * 1. Redistributions of source code must retain the above copyright 44*4a5d661aSToomas Soome * notice, this list of conditions and the following disclaimer. 45*4a5d661aSToomas Soome * 2. Redistributions in binary form must reproduce the above copyright 46*4a5d661aSToomas Soome * notice, this list of conditions and the following disclaimer in the 47*4a5d661aSToomas Soome * documentation and/or other materials provided with the distribution. 48*4a5d661aSToomas Soome * 3. The names of the authors may not be used to endorse or promote 49*4a5d661aSToomas Soome * products derived from this software without specific prior written 50*4a5d661aSToomas Soome * permission. 51*4a5d661aSToomas Soome * 52*4a5d661aSToomas Soome * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 53*4a5d661aSToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 54*4a5d661aSToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 55*4a5d661aSToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 56*4a5d661aSToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 57*4a5d661aSToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 58*4a5d661aSToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 59*4a5d661aSToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 60*4a5d661aSToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 61*4a5d661aSToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62*4a5d661aSToomas Soome * SUCH DAMAGE. 63*4a5d661aSToomas Soome * 64*4a5d661aSToomas Soome * @(#)dinode.h 8.3 (Berkeley) 1/21/94 65*4a5d661aSToomas Soome * $FreeBSD$ 66*4a5d661aSToomas Soome */ 67*4a5d661aSToomas Soome 68*4a5d661aSToomas Soome #ifndef _UFS_UFS_DINODE_H_ 69*4a5d661aSToomas Soome #define _UFS_UFS_DINODE_H_ 70*4a5d661aSToomas Soome 71*4a5d661aSToomas Soome /* 72*4a5d661aSToomas Soome * The root inode is the root of the filesystem. Inode 0 can't be used for 73*4a5d661aSToomas Soome * normal purposes and historically bad blocks were linked to inode 1, thus 74*4a5d661aSToomas Soome * the root inode is 2. (Inode 1 is no longer used for this purpose, however 75*4a5d661aSToomas Soome * numerous dump tapes make this assumption, so we are stuck with it). 76*4a5d661aSToomas Soome */ 77*4a5d661aSToomas Soome #define ROOTINO ((ino_t)2) 78*4a5d661aSToomas Soome 79*4a5d661aSToomas Soome /* 80*4a5d661aSToomas Soome * The Whiteout inode# is a dummy non-zero inode number which will 81*4a5d661aSToomas Soome * never be allocated to a real file. It is used as a place holder 82*4a5d661aSToomas Soome * in the directory entry which has been tagged as a DT_WHT entry. 83*4a5d661aSToomas Soome * See the comments about ROOTINO above. 84*4a5d661aSToomas Soome */ 85*4a5d661aSToomas Soome #define WINO ((ino_t)1) 86*4a5d661aSToomas Soome 87*4a5d661aSToomas Soome /* 88*4a5d661aSToomas Soome * The size of physical and logical block numbers and time fields in UFS. 89*4a5d661aSToomas Soome */ 90*4a5d661aSToomas Soome typedef int32_t ufs1_daddr_t; 91*4a5d661aSToomas Soome typedef int64_t ufs2_daddr_t; 92*4a5d661aSToomas Soome typedef int64_t ufs_lbn_t; 93*4a5d661aSToomas Soome typedef int64_t ufs_time_t; 94*4a5d661aSToomas Soome 95*4a5d661aSToomas Soome /* File permissions. */ 96*4a5d661aSToomas Soome #define IEXEC 0000100 /* Executable. */ 97*4a5d661aSToomas Soome #define IWRITE 0000200 /* Writeable. */ 98*4a5d661aSToomas Soome #define IREAD 0000400 /* Readable. */ 99*4a5d661aSToomas Soome #define ISVTX 0001000 /* Sticky bit. */ 100*4a5d661aSToomas Soome #define ISGID 0002000 /* Set-gid. */ 101*4a5d661aSToomas Soome #define ISUID 0004000 /* Set-uid. */ 102*4a5d661aSToomas Soome 103*4a5d661aSToomas Soome /* File types. */ 104*4a5d661aSToomas Soome #define IFMT 0170000 /* Mask of file type. */ 105*4a5d661aSToomas Soome #define IFIFO 0010000 /* Named pipe (fifo). */ 106*4a5d661aSToomas Soome #define IFCHR 0020000 /* Character device. */ 107*4a5d661aSToomas Soome #define IFDIR 0040000 /* Directory file. */ 108*4a5d661aSToomas Soome #define IFBLK 0060000 /* Block device. */ 109*4a5d661aSToomas Soome #define IFREG 0100000 /* Regular file. */ 110*4a5d661aSToomas Soome #define IFLNK 0120000 /* Symbolic link. */ 111*4a5d661aSToomas Soome #define IFSOCK 0140000 /* UNIX domain socket. */ 112*4a5d661aSToomas Soome #define IFWHT 0160000 /* Whiteout. */ 113*4a5d661aSToomas Soome 114*4a5d661aSToomas Soome /* 115*4a5d661aSToomas Soome * A dinode contains all the meta-data associated with a UFS2 file. 116*4a5d661aSToomas Soome * This structure defines the on-disk format of a dinode. Since 117*4a5d661aSToomas Soome * this structure describes an on-disk structure, all its fields 118*4a5d661aSToomas Soome * are defined by types with precise widths. 119*4a5d661aSToomas Soome */ 120*4a5d661aSToomas Soome 121*4a5d661aSToomas Soome #define NXADDR 2 /* External addresses in inode. */ 122*4a5d661aSToomas Soome #define NDADDR 12 /* Direct addresses in inode. */ 123*4a5d661aSToomas Soome #define NIADDR 3 /* Indirect addresses in inode. */ 124*4a5d661aSToomas Soome 125*4a5d661aSToomas Soome struct ufs2_dinode { 126*4a5d661aSToomas Soome u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ 127*4a5d661aSToomas Soome int16_t di_nlink; /* 2: File link count. */ 128*4a5d661aSToomas Soome u_int32_t di_uid; /* 4: File owner. */ 129*4a5d661aSToomas Soome u_int32_t di_gid; /* 8: File group. */ 130*4a5d661aSToomas Soome u_int32_t di_blksize; /* 12: Inode blocksize. */ 131*4a5d661aSToomas Soome u_int64_t di_size; /* 16: File byte count. */ 132*4a5d661aSToomas Soome u_int64_t di_blocks; /* 24: Blocks actually held. */ 133*4a5d661aSToomas Soome ufs_time_t di_atime; /* 32: Last access time. */ 134*4a5d661aSToomas Soome ufs_time_t di_mtime; /* 40: Last modified time. */ 135*4a5d661aSToomas Soome ufs_time_t di_ctime; /* 48: Last inode change time. */ 136*4a5d661aSToomas Soome ufs_time_t di_birthtime; /* 56: Inode creation time. */ 137*4a5d661aSToomas Soome int32_t di_mtimensec; /* 64: Last modified time. */ 138*4a5d661aSToomas Soome int32_t di_atimensec; /* 68: Last access time. */ 139*4a5d661aSToomas Soome int32_t di_ctimensec; /* 72: Last inode change time. */ 140*4a5d661aSToomas Soome int32_t di_birthnsec; /* 76: Inode creation time. */ 141*4a5d661aSToomas Soome u_int32_t di_gen; /* 80: Generation number. */ 142*4a5d661aSToomas Soome u_int32_t di_kernflags; /* 84: Kernel flags. */ 143*4a5d661aSToomas Soome u_int32_t di_flags; /* 88: Status flags (chflags). */ 144*4a5d661aSToomas Soome u_int32_t di_extsize; /* 92: External attributes size. */ 145*4a5d661aSToomas Soome ufs2_daddr_t di_extb[NXADDR];/* 96: External attributes block. */ 146*4a5d661aSToomas Soome ufs2_daddr_t di_db[NDADDR]; /* 112: Direct disk blocks. */ 147*4a5d661aSToomas Soome ufs2_daddr_t di_ib[NIADDR]; /* 208: Indirect disk blocks. */ 148*4a5d661aSToomas Soome u_int64_t di_modrev; /* 232: i_modrev for NFSv4 */ 149*4a5d661aSToomas Soome uint32_t di_freelink; /* 240: SUJ: Next unlinked inode. */ 150*4a5d661aSToomas Soome uint32_t di_spare[3]; /* 244: Reserved; currently unused */ 151*4a5d661aSToomas Soome }; 152*4a5d661aSToomas Soome 153*4a5d661aSToomas Soome /* 154*4a5d661aSToomas Soome * The di_db fields may be overlaid with other information for 155*4a5d661aSToomas Soome * file types that do not have associated disk storage. Block 156*4a5d661aSToomas Soome * and character devices overlay the first data block with their 157*4a5d661aSToomas Soome * dev_t value. Short symbolic links place their path in the 158*4a5d661aSToomas Soome * di_db area. 159*4a5d661aSToomas Soome */ 160*4a5d661aSToomas Soome #define di_rdev di_db[0] 161*4a5d661aSToomas Soome 162*4a5d661aSToomas Soome /* 163*4a5d661aSToomas Soome * A UFS1 dinode contains all the meta-data associated with a UFS1 file. 164*4a5d661aSToomas Soome * This structure defines the on-disk format of a UFS1 dinode. Since 165*4a5d661aSToomas Soome * this structure describes an on-disk structure, all its fields 166*4a5d661aSToomas Soome * are defined by types with precise widths. 167*4a5d661aSToomas Soome */ 168*4a5d661aSToomas Soome struct ufs1_dinode { 169*4a5d661aSToomas Soome u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ 170*4a5d661aSToomas Soome int16_t di_nlink; /* 2: File link count. */ 171*4a5d661aSToomas Soome u_int16_t di_suid; /* 4: File owner. */ 172*4a5d661aSToomas Soome u_int16_t di_sgid; /* 6: File group. */ 173*4a5d661aSToomas Soome u_int64_t di_size; /* 8: File byte count. */ 174*4a5d661aSToomas Soome int32_t di_atime; /* 16: Last access time. */ 175*4a5d661aSToomas Soome int32_t di_atimensec; /* 20: Last access time. */ 176*4a5d661aSToomas Soome int32_t di_mtime; /* 24: Last modified time. */ 177*4a5d661aSToomas Soome int32_t di_mtimensec; /* 28: Last modified time. */ 178*4a5d661aSToomas Soome int32_t di_ctime; /* 32: Last inode change time. */ 179*4a5d661aSToomas Soome int32_t di_ctimensec; /* 36: Last inode change time. */ 180*4a5d661aSToomas Soome ufs1_daddr_t di_db[NDADDR]; /* 40: Direct disk blocks. */ 181*4a5d661aSToomas Soome ufs1_daddr_t di_ib[NIADDR]; /* 88: Indirect disk blocks. */ 182*4a5d661aSToomas Soome u_int32_t di_flags; /* 100: Status flags (chflags). */ 183*4a5d661aSToomas Soome u_int32_t di_blocks; /* 104: Blocks actually held. */ 184*4a5d661aSToomas Soome u_int32_t di_gen; /* 108: Generation number. */ 185*4a5d661aSToomas Soome u_int32_t di_shadow; /* 112: shadow inode */ 186*4a5d661aSToomas Soome u_int32_t di_uid; /* 116: long EFT version of uid */ 187*4a5d661aSToomas Soome u_int32_t di_gid; /* 120: long EFT version of gid */ 188*4a5d661aSToomas Soome u_int32_t di_oeftflag; /* 124: extended attr directory ino, 0 = none */ 189*4a5d661aSToomas Soome }; 190*4a5d661aSToomas Soome 191*4a5d661aSToomas Soome #endif /* _UFS_UFS_DINODE_H_ */ 192