]>
Commit | Line | Data |
---|---|---|
04fee52e A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
db839b1d | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
04fee52e | 7 | * |
db839b1d A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
04fee52e A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
db839b1d A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
04fee52e A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* $NetBSD: ext2fs_dinode.h,v 1.6 2000/01/26 16:21:33 bouyer Exp $ */ | |
26 | /* | |
27 | * Copyright (c) 1997 Manuel Bouyer. | |
28 | * Copyright (c) 1982, 1989, 1993 | |
29 | * The Regents of the University of California. All rights reserved. | |
30 | * (c) UNIX System Laboratories, Inc. | |
31 | * All or some portions of this file are derived from material licensed | |
32 | * to the University of California by American Telephone and Telegraph | |
33 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | |
34 | * the permission of UNIX System Laboratories, Inc. | |
35 | * | |
36 | * Redistribution and use in source and binary forms, with or without | |
37 | * modification, are permitted provided that the following conditions | |
38 | * are met: | |
39 | * 1. Redistributions of source code must retain the above copyright | |
40 | * notice, this list of conditions and the following disclaimer. | |
41 | * 2. Redistributions in binary form must reproduce the above copyright | |
42 | * notice, this list of conditions and the following disclaimer in the | |
43 | * documentation and/or other materials provided with the distribution. | |
44 | * 3. All advertising materials mentioning features or use of this software | |
45 | * must display the following acknowledgement: | |
46 | * This product includes software developed by the University of | |
47 | * California, Berkeley and its contributors. | |
48 | * 4. Neither the name of the University nor the names of its contributors | |
49 | * may be used to endorse or promote products derived from this software | |
50 | * without specific prior written permission. | |
51 | * | |
52 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
53 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
54 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
55 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
56 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
57 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
58 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
59 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
60 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
61 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
62 | * SUCH DAMAGE. | |
63 | * | |
64 | * @(#)dinode.h 8.6 (Berkeley) 9/13/94 | |
65 | * Modified for ext2fs by Manuel Bouyer. | |
66 | */ | |
67 | /* | |
68 | * ext2fs_dinode.h - Headers for Ext2 disk inode structures. | |
69 | * | |
70 | * Copyright (c) 2000 Apple Computer, Inc. | |
71 | * | |
72 | * DRI: Josh de Cesare | |
73 | */ | |
74 | ||
75 | /* | |
76 | * The root inode is the root of the file system. Inode 0 can't be used for | |
77 | * normal purposes and bad blocks are normally linked to inode 1, thus | |
78 | * the root inode is 2. | |
79 | * Inode 3 to 10 are reserved in ext2fs. | |
80 | */ | |
81 | #define EXT2_ROOTINO ((ino_t)2) | |
82 | #define EXT2_FIRSTINO ((ino_t)11) | |
83 | ||
84 | /* | |
85 | * A dinode contains all the meta-data associated with a UFS file. | |
86 | * This structure defines the on-disk format of a dinode. Since | |
87 | * this structure describes an on-disk structure, all its fields | |
88 | * are defined by types with precise widths. | |
89 | */ | |
90 | ||
91 | #define NDADDR 12 /* Direct addresses in inode. */ | |
92 | #define NIADDR 3 /* Indirect addresses in inode. */ | |
93 | ||
94 | #define EXT2_MAXSYMLINKLEN ((NDADDR+NIADDR) * sizeof (u_int32_t)) | |
95 | ||
96 | struct ext2fs_dinode { | |
97 | u_int16_t e2di_mode; /* 0: IFMT, permissions; see below. */ | |
98 | u_int16_t e2di_uid; /* 2: Owner UID */ | |
99 | u_int32_t e2di_size; /* 4: Size (in bytes) */ | |
100 | u_int32_t e2di_atime; /* 8: Acces time */ | |
101 | u_int32_t e2di_ctime; /* 12: Create time */ | |
102 | u_int32_t e2di_mtime; /* 16: Modification time */ | |
103 | u_int32_t e2di_dtime; /* 20: Deletion time */ | |
104 | u_int16_t e2di_gid; /* 24: Owner GID */ | |
105 | u_int16_t e2di_nlink; /* 26: File link count */ | |
106 | u_int32_t e2di_nblock; /* 28: Blocks count */ | |
107 | u_int32_t e2di_flags; /* 32: Status flags (chflags) */ | |
108 | u_int32_t e2di_linux_reserved1; /* 36 */ | |
109 | u_int32_t e2di_blocks[NDADDR+NIADDR]; /* 40: disk blocks */ | |
110 | u_int32_t e2di_gen; /* 100: generation number */ | |
111 | u_int32_t e2di_facl; /* 104: file ACL (not implemented) */ | |
112 | u_int32_t e2di_dacl; /* 108: dir ACL (not implemented) */ | |
113 | u_int32_t e2di_faddr; /* 112: fragment address */ | |
114 | u_int8_t e2di_nfrag; /* 116: fragment number */ | |
115 | u_int8_t e2di_fsize; /* 117: fragment size */ | |
116 | u_int16_t e2di_linux_reserved2; /* 118 */ | |
117 | u_int32_t e2di_linux_reserved3[2]; /* 120 */ | |
118 | }; | |
119 | ||
120 | ||
121 | ||
122 | #define E2MAXSYMLINKLEN ((NDADDR + NIADDR) * sizeof(u_int32_t)) | |
123 | ||
124 | /* File permissions. */ | |
125 | #define EXT2_IEXEC 0000100 /* Executable. */ | |
126 | #define EXT2_IWRITE 0000200 /* Writeable. */ | |
127 | #define EXT2_IREAD 0000400 /* Readable. */ | |
128 | #define EXT2_ISVTX 0001000 /* Sticky bit. */ | |
129 | #define EXT2_ISGID 0002000 /* Set-gid. */ | |
130 | #define EXT2_ISUID 0004000 /* Set-uid. */ | |
131 | ||
132 | /* File types. */ | |
133 | #define EXT2_IFMT 0170000 /* Mask of file type. */ | |
134 | #define EXT2_IFIFO 0010000 /* Named pipe (fifo). */ | |
135 | #define EXT2_IFCHR 0020000 /* Character device. */ | |
136 | #define EXT2_IFDIR 0040000 /* Directory file. */ | |
137 | #define EXT2_IFBLK 0060000 /* Block device. */ | |
138 | #define EXT2_IFREG 0100000 /* Regular file. */ | |
139 | #define EXT2_IFLNK 0120000 /* Symbolic link. */ | |
140 | #define EXT2_IFSOCK 0140000 /* UNIX domain socket. */ | |
141 | ||
142 | /* file flags */ | |
143 | #define EXT2_SECRM 0x00000001 /* Secure deletion */ | |
144 | #define EXT2_UNRM 0x00000002 /* Undelete */ | |
145 | #define EXT2_COMPR 0x00000004 /* Compress file */ | |
146 | #define EXT2_SYNC 0x00000008 /* Synchronous updates */ | |
147 | #define EXT2_IMMUTABLE 0x00000010 /* Immutable file */ | |
148 | #define EXT2_APPEND 0x00000020 /* writes to file may only append */ | |
149 | #define EXT2_NODUMP 0x00000040 /* do not dump file */ | |
150 | ||
151 | /* Size of on-disk inode. */ | |
152 | #define EXT2_DINODE_SIZE (sizeof(struct ext2fs_dinode)) /* 128 */ | |
153 | ||
154 | /* | |
155 | * The e2di_blocks fields may be overlaid with other information for | |
156 | * file types that do not have associated disk storage. Block | |
157 | * and character devices overlay the first data block with their | |
158 | * dev_t value. Short symbolic links place their path in the | |
159 | * di_db area. | |
160 | */ | |
161 | ||
162 | #define e2di_rdev e2di_blocks[0] | |
163 | #define e2di_shortlink e2di_blocks | |
164 | ||
165 | /* e2fs needs byte swapping on big-endian systems */ | |
166 | #if BYTE_ORDER == LITTLE_ENDIAN | |
167 | # define e2fs_iload(old, new) memcpy((new),(old),sizeof(struct ext2fs_dinode)) | |
168 | # define e2fs_isave(old, new) memcpy((new),(old),sizeof(struct ext2fs_dinode)) | |
169 | #else | |
170 | void e2fs_i_bswap __P((struct ext2fs_dinode *, struct ext2fs_dinode *)); | |
171 | # define e2fs_iload(old, new) e2fs_i_bswap((old), (new)) | |
172 | # define e2fs_isave(old, new) e2fs_i_bswap((old), (new)) | |
173 | #endif |