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