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.7 (Berkeley) 01/02/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. 34 */ 35 36 #define NDADDR 12 /* Direct addresses in inode. */ 37 #define NIADDR 3 /* Indirect addresses in inode. */ 38 39 struct dinode { 40 u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ 41 int16_t di_nlink; /* 2: File link count. */ 42 union { 43 u_int16_t oldids[2]; /* 4: Ffs: old user and group ids. */ 44 ino_t inumber; /* 4: Lfs: inode number. */ 45 } di_u; 46 u_int64_t di_size; /* 8: File byte count. */ 47 struct timespec di_atime; /* 16: Last access time. */ 48 struct timespec di_mtime; /* 24: Last modified time. */ 49 struct timespec di_ctime; /* 32: Last inode change time. */ 50 daddr_t di_db[NDADDR]; /* 40: Direct disk blocks. */ 51 daddr_t di_ib[NIADDR]; /* 88: Indirect disk blocks. */ 52 u_int32_t di_flags; /* 100: Status flags (chflags). */ 53 int32_t di_blocks; /* 104: Blocks actually held. */ 54 int32_t di_gen; /* 108: Generation number. */ 55 u_int32_t di_uid; /* 112: File owner. */ 56 u_int32_t di_gid; /* 116: File group. */ 57 int32_t di_spare[2]; /* 120: Reserved; currently unused */ 58 }; 59 60 /* 61 * The di_db fields may be overlaid with other information for 62 * file types that do not have associated disk storage. Block 63 * and character devices overlay the first data block with their 64 * dev_t value. Short symbolic links place their path in the 65 * di_db area. 66 */ 67 #define di_inumber di_u.inumber 68 #define di_ogid di_u.oldids[1] 69 #define di_ouid di_u.oldids[0] 70 #define di_rdev di_db[0] 71 #define di_shortlink di_db 72 #define MAXSYMLINKLEN ((NDADDR + NIADDR) * sizeof(daddr_t)) 73 74 /* File permissions. */ 75 #define IEXEC 0000100 /* Executable. */ 76 #define IWRITE 0000200 /* Writeable. */ 77 #define IREAD 0000400 /* Readable. */ 78 #define ISVTX 0001000 /* Sticky bit. */ 79 #define ISGID 0002000 /* Set-gid. */ 80 #define ISUID 0004000 /* Set-uid. */ 81 82 /* File types. */ 83 #define IFMT 0170000 /* Mask of file type. */ 84 #define IFIFO 0010000 /* Named pipe (fifo). */ 85 #define IFCHR 0020000 /* Character device. */ 86 #define IFDIR 0040000 /* Directory file. */ 87 #define IFBLK 0060000 /* Block device. */ 88 #define IFREG 0100000 /* Regular file. */ 89 #define IFLNK 0120000 /* Symbolic link. */ 90 #define IFSOCK 0140000 /* UNIX domain socket. */ 91 #define IFWHT 0160000 /* Whiteout. */ 92