ulfs_dinode.h revision 1.2
11.2Sdholland/* $NetBSD: ulfs_dinode.h,v 1.2 2013/06/06 00:48:04 dholland Exp $ */ 21.1Sdholland/* from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp */ 31.1Sdholland 41.1Sdholland/* 51.1Sdholland * Copyright (c) 2002 Networks Associates Technology, Inc. 61.1Sdholland * All rights reserved. 71.1Sdholland * 81.1Sdholland * This software was developed for the FreeBSD Project by Marshall 91.1Sdholland * Kirk McKusick and Network Associates Laboratories, the Security 101.1Sdholland * Research Division of Network Associates, Inc. under DARPA/SPAWAR 111.1Sdholland * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS 121.1Sdholland * research program 131.1Sdholland * 141.1Sdholland * Copyright (c) 1982, 1989, 1993 151.1Sdholland * The Regents of the University of California. All rights reserved. 161.1Sdholland * (c) UNIX System Laboratories, Inc. 171.1Sdholland * All or some portions of this file are derived from material licensed 181.1Sdholland * to the University of California by American Telephone and Telegraph 191.1Sdholland * Co. or Unix System Laboratories, Inc. and are reproduced herein with 201.1Sdholland * the permission of UNIX System Laboratories, Inc. 211.1Sdholland * 221.1Sdholland * Redistribution and use in source and binary forms, with or without 231.1Sdholland * modification, are permitted provided that the following conditions 241.1Sdholland * are met: 251.1Sdholland * 1. Redistributions of source code must retain the above copyright 261.1Sdholland * notice, this list of conditions and the following disclaimer. 271.1Sdholland * 2. Redistributions in binary form must reproduce the above copyright 281.1Sdholland * notice, this list of conditions and the following disclaimer in the 291.1Sdholland * documentation and/or other materials provided with the distribution. 301.1Sdholland * 3. Neither the name of the University nor the names of its contributors 311.1Sdholland * may be used to endorse or promote products derived from this software 321.1Sdholland * without specific prior written permission. 331.1Sdholland * 341.1Sdholland * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 351.1Sdholland * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 361.1Sdholland * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 371.1Sdholland * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 381.1Sdholland * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 391.1Sdholland * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 401.1Sdholland * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 411.1Sdholland * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 421.1Sdholland * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 431.1Sdholland * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 441.1Sdholland * SUCH DAMAGE. 451.1Sdholland * 461.1Sdholland * @(#)dinode.h 8.9 (Berkeley) 3/29/95 471.1Sdholland */ 481.1Sdholland 491.1Sdholland/* 501.1Sdholland * NOTE: COORDINATE ON-DISK FORMAT CHANGES WITH THE FREEBSD PROJECT. 511.1Sdholland */ 521.1Sdholland 531.2Sdholland#ifndef _UFS_LFS_ULFS_DINODE_H_ 541.2Sdholland#define _UFS_LFS_ULFS_DINODE_H_ 551.1Sdholland 561.1Sdholland/* 571.1Sdholland * The root inode is the root of the file system. Inode 0 can't be used for 581.1Sdholland * normal purposes and historically bad blocks were linked to inode 1, thus 591.1Sdholland * the root inode is 2. (Inode 1 is no longer used for this purpose, however 601.1Sdholland * numerous dump tapes make this assumption, so we are stuck with it). 611.1Sdholland */ 621.2Sdholland#define ULFS_ROOTINO ((ino_t)2) 631.1Sdholland 641.1Sdholland/* 651.1Sdholland * The Whiteout inode# is a dummy non-zero inode number which will 661.1Sdholland * never be allocated to a real file. It is used as a place holder 671.1Sdholland * in the directory entry which has been tagged as a DT_W entry. 681.2Sdholland * See the comments about ULFS_ROOTINO above. 691.1Sdholland */ 701.2Sdholland#define ULFS_WINO ((ino_t)1) 711.1Sdholland 721.1Sdholland/* 731.2Sdholland * A dinode contains all the meta-data associated with a ULFS file. 741.1Sdholland * This structure defines the on-disk format of a dinode. Since 751.1Sdholland * this structure describes an on-disk structure, all its fields 761.1Sdholland * are defined by types with precise widths. 771.1Sdholland */ 781.1Sdholland 791.2Sdholland#define ULFS_NXADDR 2 801.2Sdholland#define ULFS_NDADDR 12 /* Direct addresses in inode. */ 811.2Sdholland#define ULFS_NIADDR 3 /* Indirect addresses in inode. */ 821.1Sdholland 831.2Sdhollandstruct ulfs1_dinode { 841.1Sdholland u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ 851.1Sdholland int16_t di_nlink; /* 2: File link count. */ 861.1Sdholland union { 871.1Sdholland u_int16_t oldids[2]; /* 4: Ffs: old user and group ids. */ 881.1Sdholland u_int32_t inumber; /* 4: Lfs: inode number. */ 891.1Sdholland } di_u; 901.1Sdholland u_int64_t di_size; /* 8: File byte count. */ 911.1Sdholland int32_t di_atime; /* 16: Last access time. */ 921.1Sdholland int32_t di_atimensec; /* 20: Last access time. */ 931.1Sdholland int32_t di_mtime; /* 24: Last modified time. */ 941.1Sdholland int32_t di_mtimensec; /* 28: Last modified time. */ 951.1Sdholland int32_t di_ctime; /* 32: Last inode change time. */ 961.1Sdholland int32_t di_ctimensec; /* 36: Last inode change time. */ 971.2Sdholland int32_t di_db[ULFS_NDADDR]; /* 40: Direct disk blocks. */ 981.2Sdholland int32_t di_ib[ULFS_NIADDR]; /* 88: Indirect disk blocks. */ 991.1Sdholland u_int32_t di_flags; /* 100: Status flags (chflags). */ 1001.1Sdholland u_int32_t di_blocks; /* 104: Blocks actually held. */ 1011.1Sdholland int32_t di_gen; /* 108: Generation number. */ 1021.1Sdholland u_int32_t di_uid; /* 112: File owner. */ 1031.1Sdholland u_int32_t di_gid; /* 116: File group. */ 1041.1Sdholland u_int64_t di_modrev; /* 120: i_modrev for NFSv4 */ 1051.1Sdholland}; 1061.1Sdholland 1071.2Sdhollandstruct ulfs2_dinode { 1081.1Sdholland u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ 1091.1Sdholland int16_t di_nlink; /* 2: File link count. */ 1101.1Sdholland u_int32_t di_uid; /* 4: File owner. */ 1111.1Sdholland u_int32_t di_gid; /* 8: File group. */ 1121.1Sdholland u_int32_t di_blksize; /* 12: Inode blocksize. */ 1131.1Sdholland u_int64_t di_size; /* 16: File byte count. */ 1141.1Sdholland u_int64_t di_blocks; /* 24: Bytes actually held. */ 1151.1Sdholland int64_t di_atime; /* 32: Last access time. */ 1161.1Sdholland int64_t di_mtime; /* 40: Last modified time. */ 1171.1Sdholland int64_t di_ctime; /* 48: Last inode change time. */ 1181.1Sdholland int64_t di_birthtime; /* 56: Inode creation time. */ 1191.1Sdholland int32_t di_mtimensec; /* 64: Last modified time. */ 1201.1Sdholland int32_t di_atimensec; /* 68: Last access time. */ 1211.1Sdholland int32_t di_ctimensec; /* 72: Last inode change time. */ 1221.1Sdholland int32_t di_birthnsec; /* 76: Inode creation time. */ 1231.1Sdholland int32_t di_gen; /* 80: Generation number. */ 1241.1Sdholland u_int32_t di_kernflags; /* 84: Kernel flags. */ 1251.1Sdholland u_int32_t di_flags; /* 88: Status flags (chflags). */ 1261.1Sdholland int32_t di_extsize; /* 92: External attributes block. */ 1271.2Sdholland int64_t di_extb[ULFS_NXADDR];/* 96: External attributes block. */ 1281.2Sdholland int64_t di_db[ULFS_NDADDR]; /* 112: Direct disk blocks. */ 1291.2Sdholland int64_t di_ib[ULFS_NIADDR]; /* 208: Indirect disk blocks. */ 1301.1Sdholland u_int64_t di_modrev; /* 232: i_modrev for NFSv4 */ 1311.1Sdholland int64_t di_spare[2]; /* 240: Reserved; currently unused */ 1321.1Sdholland}; 1331.1Sdholland 1341.1Sdholland/* 1351.1Sdholland * The di_db fields may be overlaid with other information for 1361.1Sdholland * file types that do not have associated disk storage. Block 1371.1Sdholland * and character devices overlay the first data block with their 1381.1Sdholland * dev_t value. Short symbolic links place their path in the 1391.1Sdholland * di_db area. 1401.1Sdholland */ 1411.1Sdholland#define di_inumber di_u.inumber 1421.1Sdholland#define di_ogid di_u.oldids[1] 1431.1Sdholland#define di_ouid di_u.oldids[0] 1441.1Sdholland#define di_rdev di_db[0] 1451.2Sdholland#define ULFS1_MAXSYMLINKLEN ((ULFS_NDADDR + ULFS_NIADDR) * sizeof(int32_t)) 1461.2Sdholland#define ULFS2_MAXSYMLINKLEN ((ULFS_NDADDR + ULFS_NIADDR) * sizeof(int64_t)) 1471.1Sdholland 1481.2Sdholland#define ULFS_MAXSYMLINKLEN(ip) \ 1491.2Sdholland ((ip)->i_ump->um_fstype == ULFS1) ? \ 1501.2Sdholland ULFS1_MAXSYMLINKLEN : ULFS2_MAXSYMLINKLEN 1511.1Sdholland 1521.1Sdholland/* NeXT used to keep short symlinks in the inode even when using 1531.1Sdholland * FS_42INODEFMT. In that case fs->fs_maxsymlinklen is probably -1, 1541.1Sdholland * but short symlinks were stored in inodes shorter than this: 1551.1Sdholland */ 1561.1Sdholland#define APPLEUFS_MAXSYMLINKLEN 60 1571.1Sdholland 1581.1Sdholland/* File permissions. */ 1591.1Sdholland#define IEXEC 0000100 /* Executable. */ 1601.1Sdholland#define IWRITE 0000200 /* Writable. */ 1611.1Sdholland#define IREAD 0000400 /* Readable. */ 1621.1Sdholland#define ISVTX 0001000 /* Sticky bit. */ 1631.1Sdholland#define ISGID 0002000 /* Set-gid. */ 1641.1Sdholland#define ISUID 0004000 /* Set-uid. */ 1651.1Sdholland 1661.1Sdholland/* File types. */ 1671.1Sdholland#define IFMT 0170000 /* Mask of file type. */ 1681.1Sdholland#define IFIFO 0010000 /* Named pipe (fifo). */ 1691.1Sdholland#define IFCHR 0020000 /* Character device. */ 1701.1Sdholland#define IFDIR 0040000 /* Directory file. */ 1711.1Sdholland#define IFBLK 0060000 /* Block device. */ 1721.1Sdholland#define IFREG 0100000 /* Regular file. */ 1731.1Sdholland#define IFLNK 0120000 /* Symbolic link. */ 1741.1Sdholland#define IFSOCK 0140000 /* UNIX domain socket. */ 1751.1Sdholland#define IFWHT 0160000 /* Whiteout. */ 1761.1Sdholland 1771.1Sdholland/* Size of the on-disk inode. */ 1781.2Sdholland#define DINODE1_SIZE (sizeof(struct ulfs1_dinode)) /* 128 */ 1791.2Sdholland#define DINODE2_SIZE (sizeof(struct ulfs2_dinode)) 1801.1Sdholland 1811.2Sdholland#endif /* !_UFS_LFS_ULFS_DINODE_H_ */ 182