1 /* 2 * Copyright (c) 1982, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. 9 * 10 * %sccs.include.redist.c% 11 * 12 * @(#)dinode.h 8.8 (Berkeley) 03/21/95 13 */ 14 15 /* 16 * The root inode is the root of the file system. Inode 0 can't be used for 17 * normal purposes and historically bad blocks were linked to inode 1, thus 18 * the root inode is 2. (Inode 1 is no longer used for this purpose, however 19 * numerous dump tapes make this assumption, so we are stuck with it). 20 */ 21 #define ROOTINO ((ino_t)2) 22 23 /* 24 * The Whiteout inode# is a dummy non-zero inode number which will 25 * never be allocated to a real file. It is used as a place holder 26 * in the directory entry which has been tagged as a DT_W entry. 27 * See the comments about ROOTINO above. 28 */ 29 #define WINO ((ino_t)1) 30 31 /* 32 * A dinode contains all the meta-data associated with a UFS file. 33 * This structure defines the on-disk format of a dinode. Since 34 * this structure describes an on-disk structure, all its fields 35 * are defined by types with precise widths. 36 */ 37 38 typedef int32_t ufs_daddr_t; 39 #define NDADDR 12 /* Direct addresses in inode. */ 40 #define NIADDR 3 /* Indirect addresses in inode. */ 41 42 struct dinode { 43 u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ 44 int16_t di_nlink; /* 2: File link count. */ 45 union { 46 u_int16_t oldids[2]; /* 4: Ffs: old user and group ids. */ 47 int32_t inumber; /* 4: Lfs: inode number. */ 48 } di_u; 49 u_int64_t di_size; /* 8: File byte count. */ 50 int32_t di_atime; /* 16: Last access time. */ 51 int32_t di_atimensec; /* 20: Last access time. */ 52 int32_t di_mtime; /* 24: Last modified time. */ 53 int32_t di_mtimensec; /* 28: Last modified time. */ 54 int32_t di_ctime; /* 32: Last inode change time. */ 55 int32_t di_ctimensec; /* 36: Last inode change time. */ 56 ufs_daddr_t di_db[NDADDR]; /* 40: Direct disk blocks. */ 57 ufs_daddr_t di_ib[NIADDR]; /* 88: Indirect disk blocks. */ 58 u_int32_t di_flags; /* 100: Status flags (chflags). */ 59 int32_t di_blocks; /* 104: Blocks actually held. */ 60 int32_t di_gen; /* 108: Generation number. */ 61 u_int32_t di_uid; /* 112: File owner. */ 62 u_int32_t di_gid; /* 116: File group. */ 63 int32_t di_spare[2]; /* 120: Reserved; currently unused */ 64 }; 65 66 /* 67 * The di_db fields may be overlaid with other information for 68 * file types that do not have associated disk storage. Block 69 * and character devices overlay the first data block with their 70 * dev_t value. Short symbolic links place their path in the 71 * di_db area. 72 */ 73 #define di_inumber di_u.inumber 74 #define di_ogid di_u.oldids[1] 75 #define di_ouid di_u.oldids[0] 76 #define di_rdev di_db[0] 77 #define di_shortlink di_db 78 #define MAXSYMLINKLEN ((NDADDR + NIADDR) * sizeof(ufs_daddr_t)) 79 80 /* File permissions. */ 81 #define IEXEC 0000100 /* Executable. */ 82 #define IWRITE 0000200 /* Writeable. */ 83 #define IREAD 0000400 /* Readable. */ 84 #define ISVTX 0001000 /* Sticky bit. */ 85 #define ISGID 0002000 /* Set-gid. */ 86 #define ISUID 0004000 /* Set-uid. */ 87 88 /* File types. */ 89 #define IFMT 0170000 /* Mask of file type. */ 90 #define IFIFO 0010000 /* Named pipe (fifo). */ 91 #define IFCHR 0020000 /* Character device. */ 92 #define IFDIR 0040000 /* Directory file. */ 93 #define IFBLK 0060000 /* Block device. */ 94 #define IFREG 0100000 /* Regular file. */ 95 #define IFLNK 0120000 /* Symbolic link. */ 96 #define IFSOCK 0140000 /* UNIX domain socket. */ 97 #define IFWHT 0160000 /* Whiteout. */ 98