Commit | Line | Data |
---|---|---|
da7c5cc6 | 1 | /* |
ad0f93d2 KB |
2 | * Copyright (c) 1982, 1989, 1993 |
3 | * The Regents of the University of California. All rights reserved. | |
adb35f79 KB |
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. | |
da7c5cc6 | 9 | * |
b702c21d | 10 | * %sccs.include.redist.c% |
6d0f0ece | 11 | * |
6d6f2688 | 12 | * @(#)dinode.h 8.5 (Berkeley) %G% |
da7c5cc6 | 13 | */ |
d0064d3a | 14 | |
b5cc7ac7 KB |
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 | ||
6d6f2688 JSP |
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 | ||
d0064d3a | 31 | /* |
a3257f3c KM |
32 | * A dinode contains all the meta-data associated with a UFS file. |
33 | * This structure defines the on-disk format of a dinode. | |
d0064d3a | 34 | */ |
ad30fb67 | 35 | |
dbb7672a KB |
36 | #define NDADDR 12 /* Direct addresses in inode. */ |
37 | #define NIADDR 3 /* Indirect addresses in inode. */ | |
d0064d3a | 38 | |
ad30fb67 | 39 | struct dinode { |
993707aa KM |
40 | u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ |
41 | int16_t di_nlink; /* 2: File link count. */ | |
6259004b | 42 | union { |
993707aa KM |
43 | u_int16_t oldids[2]; /* 4: Ffs: old user and group ids. */ |
44 | ino_t inumber; /* 4: Lfs: inode number. */ | |
6259004b | 45 | } di_u; |
dbb7672a KB |
46 | u_quad_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. */ | |
993707aa KM |
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 */ | |
ad30fb67 KM |
58 | }; |
59 | ||
1471ece5 KM |
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 | */ | |
6259004b | 67 | #define di_inumber di_u.inumber |
dbb7672a KB |
68 | #define di_ogid di_u.oldids[1] |
69 | #define di_ouid di_u.oldids[0] | |
55a2aa38 | 70 | #define di_rdev di_db[0] |
dbb7672a | 71 | #define di_shortlink di_db |
8848cbc0 | 72 | #define MAXSYMLINKLEN ((NDADDR + NIADDR) * sizeof(daddr_t)) |
af0b24db | 73 | |
993707aa | 74 | /* File permissions. */ |
dbb7672a KB |
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. */ | |
dc9a2d80 | 81 | |
dbb7672a KB |
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. */ |