1139825Simp/*- 298542Smckusick * Copyright (c) 2002 Networks Associates Technology, Inc. 398542Smckusick * All rights reserved. 498542Smckusick * 598542Smckusick * This software was developed for the FreeBSD Project by Marshall 698542Smckusick * Kirk McKusick and Network Associates Laboratories, the Security 798542Smckusick * Research Division of Network Associates, Inc. under DARPA/SPAWAR 898542Smckusick * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS 998542Smckusick * research program 1098542Smckusick * 11136721Srwatson * Redistribution and use in source and binary forms, with or without 12136721Srwatson * modification, are permitted provided that the following conditions 13136721Srwatson * are met: 14136721Srwatson * 1. Redistributions of source code must retain the above copyright 15136721Srwatson * notice, this list of conditions and the following disclaimer. 16136721Srwatson * 2. Redistributions in binary form must reproduce the above copyright 17136721Srwatson * notice, this list of conditions and the following disclaimer in the 18136721Srwatson * documentation and/or other materials provided with the distribution. 19136721Srwatson * 20136721Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21136721Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22136721Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23136721Srwatson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 24136721Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25136721Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26136721Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27136721Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28136721Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29136721Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30136721Srwatson * SUCH DAMAGE. 31136721Srwatson * 321541Srgrimes * Copyright (c) 1982, 1989, 1993 331541Srgrimes * The Regents of the University of California. All rights reserved. 341541Srgrimes * (c) UNIX System Laboratories, Inc. 351541Srgrimes * All or some portions of this file are derived from material licensed 361541Srgrimes * to the University of California by American Telephone and Telegraph 371541Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with 381541Srgrimes * the permission of UNIX System Laboratories, Inc. 391541Srgrimes * 401541Srgrimes * Redistribution and use in source and binary forms, with or without 411541Srgrimes * modification, are permitted provided that the following conditions 421541Srgrimes * are met: 431541Srgrimes * 1. Redistributions of source code must retain the above copyright 441541Srgrimes * notice, this list of conditions and the following disclaimer. 451541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 461541Srgrimes * notice, this list of conditions and the following disclaimer in the 471541Srgrimes * documentation and/or other materials provided with the distribution. 4898542Smckusick * 3. The names of the authors may not be used to endorse or promote 4998542Smckusick * products derived from this software without specific prior written 5098542Smckusick * permission. 511541Srgrimes * 5298542Smckusick * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 531541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 541541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 5598542Smckusick * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 561541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 571541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 581541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 591541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 601541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 611541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 621541Srgrimes * SUCH DAMAGE. 631541Srgrimes * 641541Srgrimes * @(#)dinode.h 8.3 (Berkeley) 1/21/94 6550477Speter * $FreeBSD$ 661541Srgrimes */ 671541Srgrimes 682177Spaul#ifndef _UFS_UFS_DINODE_H_ 6998542Smckusick#define _UFS_UFS_DINODE_H_ 702177Spaul 711541Srgrimes/* 7296755Strhodes * The root inode is the root of the filesystem. Inode 0 can't be used for 731541Srgrimes * normal purposes and historically bad blocks were linked to inode 1, thus 741541Srgrimes * the root inode is 2. (Inode 1 is no longer used for this purpose, however 751541Srgrimes * numerous dump tapes make this assumption, so we are stuck with it). 761541Srgrimes */ 771541Srgrimes#define ROOTINO ((ino_t)2) 781541Srgrimes 791541Srgrimes/* 8022521Sdyson * The Whiteout inode# is a dummy non-zero inode number which will 8122521Sdyson * never be allocated to a real file. It is used as a place holder 82158801Smaxim * in the directory entry which has been tagged as a DT_WHT entry. 8322521Sdyson * See the comments about ROOTINO above. 8422521Sdyson */ 8522521Sdyson#define WINO ((ino_t)1) 8622521Sdyson 8722521Sdyson/* 8898542Smckusick * The size of physical and logical block numbers and time fields in UFS. 8998542Smckusick */ 9098542Smckusicktypedef int32_t ufs1_daddr_t; 9198542Smckusicktypedef int64_t ufs2_daddr_t; 9298542Smckusicktypedef int64_t ufs_lbn_t; 9398542Smckusicktypedef int64_t ufs_time_t; 9498542Smckusick 9598542Smckusick/* File permissions. */ 9698542Smckusick#define IEXEC 0000100 /* Executable. */ 9798542Smckusick#define IWRITE 0000200 /* Writeable. */ 9898542Smckusick#define IREAD 0000400 /* Readable. */ 9998542Smckusick#define ISVTX 0001000 /* Sticky bit. */ 10098542Smckusick#define ISGID 0002000 /* Set-gid. */ 10198542Smckusick#define ISUID 0004000 /* Set-uid. */ 10298542Smckusick 10398542Smckusick/* File types. */ 10498542Smckusick#define IFMT 0170000 /* Mask of file type. */ 10598542Smckusick#define IFIFO 0010000 /* Named pipe (fifo). */ 10698542Smckusick#define IFCHR 0020000 /* Character device. */ 10798542Smckusick#define IFDIR 0040000 /* Directory file. */ 10898542Smckusick#define IFBLK 0060000 /* Block device. */ 10998542Smckusick#define IFREG 0100000 /* Regular file. */ 11098542Smckusick#define IFLNK 0120000 /* Symbolic link. */ 11198542Smckusick#define IFSOCK 0140000 /* UNIX domain socket. */ 11298542Smckusick#define IFWHT 0160000 /* Whiteout. */ 11398542Smckusick 11498542Smckusick/* 11598542Smckusick * A dinode contains all the meta-data associated with a UFS2 file. 11622521Sdyson * This structure defines the on-disk format of a dinode. Since 11722521Sdyson * this structure describes an on-disk structure, all its fields 11822521Sdyson * are defined by types with precise widths. 1191541Srgrimes */ 1201541Srgrimes 12198542Smckusick#define NXADDR 2 /* External addresses in inode. */ 1221541Srgrimes#define NDADDR 12 /* Direct addresses in inode. */ 1231541Srgrimes#define NIADDR 3 /* Indirect addresses in inode. */ 1241541Srgrimes 12598542Smckusickstruct ufs2_dinode { 12622521Sdyson u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ 12722521Sdyson int16_t di_nlink; /* 2: File link count. */ 12898542Smckusick u_int32_t di_uid; /* 4: File owner. */ 12998542Smckusick u_int32_t di_gid; /* 8: File group. */ 13098542Smckusick u_int32_t di_blksize; /* 12: Inode blocksize. */ 13198542Smckusick u_int64_t di_size; /* 16: File byte count. */ 132158802Smaxim u_int64_t di_blocks; /* 24: Blocks actually held. */ 13398542Smckusick ufs_time_t di_atime; /* 32: Last access time. */ 13498542Smckusick ufs_time_t di_mtime; /* 40: Last modified time. */ 13598542Smckusick ufs_time_t di_ctime; /* 48: Last inode change time. */ 136100201Smckusick ufs_time_t di_birthtime; /* 56: Inode creation time. */ 13798542Smckusick int32_t di_mtimensec; /* 64: Last modified time. */ 13898542Smckusick int32_t di_atimensec; /* 68: Last access time. */ 13998542Smckusick int32_t di_ctimensec; /* 72: Last inode change time. */ 140100201Smckusick int32_t di_birthnsec; /* 76: Inode creation time. */ 141252435Spfg u_int32_t di_gen; /* 80: Generation number. */ 14298542Smckusick u_int32_t di_kernflags; /* 84: Kernel flags. */ 14398542Smckusick u_int32_t di_flags; /* 88: Status flags (chflags). */ 14498542Smckusick int32_t di_extsize; /* 92: External attributes block. */ 14598542Smckusick ufs2_daddr_t di_extb[NXADDR];/* 96: External attributes block. */ 14698542Smckusick ufs2_daddr_t di_db[NDADDR]; /* 112: Direct disk blocks. */ 14798542Smckusick ufs2_daddr_t di_ib[NIADDR]; /* 208: Indirect disk blocks. */ 148191564Srmacklem u_int64_t di_modrev; /* 232: i_modrev for NFSv4 */ 149227382Sgleb uint32_t di_freelink; /* 240: SUJ: Next unlinked inode. */ 150207141Sjeff uint32_t di_spare[3]; /* 244: Reserved; currently unused */ 15198542Smckusick}; 15298542Smckusick 15398542Smckusick/* 15498542Smckusick * The di_db fields may be overlaid with other information for 15598542Smckusick * file types that do not have associated disk storage. Block 15698542Smckusick * and character devices overlay the first data block with their 157130761Sbde * dev_t value. Short symbolic links place their path in the 15898542Smckusick * di_db area. 15998542Smckusick */ 16098542Smckusick#define di_rdev di_db[0] 16198542Smckusick 16298542Smckusick/* 16398542Smckusick * A UFS1 dinode contains all the meta-data associated with a UFS1 file. 16498542Smckusick * This structure defines the on-disk format of a UFS1 dinode. Since 16598542Smckusick * this structure describes an on-disk structure, all its fields 16698542Smckusick * are defined by types with precise widths. 16798542Smckusick */ 16898542Smckusickstruct ufs1_dinode { 16998542Smckusick u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ 17098542Smckusick int16_t di_nlink; /* 2: File link count. */ 171227382Sgleb uint32_t di_freelink; /* 4: SUJ: Next unlinked inode. */ 17222521Sdyson u_int64_t di_size; /* 8: File byte count. */ 17322521Sdyson int32_t di_atime; /* 16: Last access time. */ 17422521Sdyson int32_t di_atimensec; /* 20: Last access time. */ 17522521Sdyson int32_t di_mtime; /* 24: Last modified time. */ 17622521Sdyson int32_t di_mtimensec; /* 28: Last modified time. */ 17722521Sdyson int32_t di_ctime; /* 32: Last inode change time. */ 17822521Sdyson int32_t di_ctimensec; /* 36: Last inode change time. */ 17998542Smckusick ufs1_daddr_t di_db[NDADDR]; /* 40: Direct disk blocks. */ 18098542Smckusick ufs1_daddr_t di_ib[NIADDR]; /* 88: Indirect disk blocks. */ 18122521Sdyson u_int32_t di_flags; /* 100: Status flags (chflags). */ 18222521Sdyson int32_t di_blocks; /* 104: Blocks actually held. */ 183252435Spfg u_int32_t di_gen; /* 108: Generation number. */ 18422521Sdyson u_int32_t di_uid; /* 112: File owner. */ 18522521Sdyson u_int32_t di_gid; /* 116: File group. */ 186191564Srmacklem u_int64_t di_modrev; /* 120: i_modrev for NFSv4 */ 1871541Srgrimes}; 1881541Srgrimes 18998542Smckusick#endif /* _UFS_UFS_DINODE_H_ */ 190