1 /* 2 * Copyright (c) 1982, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)dinode.h 8.2 (Berkeley) 09/21/93 8 */ 9 10 /* 11 * The root inode is the root of the file system. Inode 0 can't be used for 12 * normal purposes and historically bad blocks were linked to inode 1, thus 13 * the root inode is 2. (Inode 1 is no longer used for this purpose, however 14 * numerous dump tapes make this assumption, so we are stuck with it). 15 */ 16 #define ROOTINO ((ino_t)2) 17 18 /* 19 * A dinode contains all the meta-data associated with a UFS file. 20 * This structure defines the on-disk format of a dinode. 21 */ 22 23 #define NDADDR 12 /* Direct addresses in inode. */ 24 #define NIADDR 3 /* Indirect addresses in inode. */ 25 26 struct dinode { 27 u_short di_mode; /* 0: IFMT and permissions. */ 28 short di_nlink; /* 2: File link count. */ 29 union { 30 u_short oldids[2]; /* 4: Ffs: old user and group ids. */ 31 ino_t inumber; /* 4: Lfs: inode number. */ 32 } di_u; 33 u_quad_t di_size; /* 8: File byte count. */ 34 struct timespec di_atime; /* 16: Last access time. */ 35 struct timespec di_mtime; /* 24: Last modified time. */ 36 struct timespec di_ctime; /* 32: Last inode change time. */ 37 daddr_t di_db[NDADDR]; /* 40: Direct disk blocks. */ 38 daddr_t di_ib[NIADDR]; /* 88: Indirect disk blocks. */ 39 u_long di_flags; /* 100: Status flags (chflags). */ 40 long di_blocks; /* 104: Blocks actually held. */ 41 long di_gen; /* 108: Generation number. */ 42 u_long di_uid; /* 112: File owner. */ 43 u_long di_gid; /* 116: File group. */ 44 long di_spare[2]; /* 120: Reserved; currently unused */ 45 }; 46 47 /* 48 * The di_db fields may be overlaid with other information for 49 * file types that do not have associated disk storage. Block 50 * and character devices overlay the first data block with their 51 * dev_t value. Short symbolic links place their path in the 52 * di_db area. 53 */ 54 #define di_inumber di_u.inumber 55 #define di_ogid di_u.oldids[1] 56 #define di_ouid di_u.oldids[0] 57 #define di_rdev di_db[0] 58 #define di_shortlink di_db 59 #define MAXSYMLINKLEN ((NDADDR + NIADDR) * sizeof(daddr_t)) 60 61 /* File modes. */ 62 #define IEXEC 0000100 /* Executable. */ 63 #define IWRITE 0000200 /* Writeable. */ 64 #define IREAD 0000400 /* Readable. */ 65 #define ISVTX 0001000 /* Sticky bit. */ 66 #define ISGID 0002000 /* Set-gid. */ 67 #define ISUID 0004000 /* Set-uid. */ 68 69 /* File types. */ 70 #define IFMT 0170000 /* Mask of file type. */ 71 #define IFIFO 0010000 /* Named pipe (fifo). */ 72 #define IFCHR 0020000 /* Character device. */ 73 #define IFDIR 0040000 /* Directory file. */ 74 #define IFBLK 0060000 /* Block device. */ 75 #define IFREG 0100000 /* Regular file. */ 76 #define IFLNK 0120000 /* Symbolic link. */ 77 #define IFSOCK 0140000 /* UNIX domain socket. */ 78