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