]>
git.saurik.com Git - apple/xnu.git/blob - bsd/ufs/ufs/dinode.h
2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
23 * @APPLE_LICENSE_HEADER_END@
25 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
27 * Copyright (c) 1982, 1989, 1993
28 * The Regents of the University of California. All rights reserved.
29 * (c) UNIX System Laboratories, Inc.
30 * All or some portions of this file are derived from material licensed
31 * to the University of California by American Telephone and Telegraph
32 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
33 * the permission of UNIX System Laboratories, Inc.
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 * notice, this list of conditions and the following disclaimer in the
42 * documentation and/or other materials provided with the distribution.
43 * 3. All advertising materials mentioning features or use of this software
44 * must display the following acknowledgement:
45 * This product includes software developed by the University of
46 * California, Berkeley and its contributors.
47 * 4. Neither the name of the University nor the names of its contributors
48 * may be used to endorse or promote products derived from this software
49 * without specific prior written permission.
51 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
52 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * @(#)dinode.h 8.9 (Berkeley) 3/29/95
65 #ifndef _UFS_DINODE_H_
66 #define _UFS_DINODE_H_
68 #include <sys/appleapiopts.h>
71 #ifdef __APPLE_API_UNSTABLE
73 * The root inode is the root of the file system. Inode 0 can't be used for
74 * normal purposes and historically bad blocks were linked to inode 1, thus
75 * the root inode is 2. (Inode 1 is no longer used for this purpose, however
76 * numerous dump tapes make this assumption, so we are stuck with it).
78 #define ROOTINO ((ino_t)2)
81 * The Whiteout inode# is a dummy non-zero inode number which will
82 * never be allocated to a real file. It is used as a place holder
83 * in the directory entry which has been tagged as a DT_W entry.
84 * See the comments about ROOTINO above.
86 #define WINO ((ino_t)1)
89 * A dinode contains all the meta-data associated with a UFS file.
90 * This structure defines the on-disk format of a dinode. Since
91 * this structure describes an on-disk structure, all its fields
92 * are defined by types with precise widths.
95 #define NDADDR 12 /* Direct addresses in inode. */
96 #define NIADDR 3 /* Indirect addresses in inode. */
98 typedef int32_t ufs_daddr_t
;
101 u_int16_t di_mode
; /* 0: IFMT, permissions; see below. */
102 int16_t di_nlink
; /* 2: File link count. */
104 u_int16_t oldids
[2]; /* 4: Ffs: old user and group ids. */
105 int32_t inumber
; /* 4: Lfs: inode number. */
107 u_int64_t di_size
; /* 8: File byte count. */
108 int32_t di_atime
; /* 16: Last access time. */
109 int32_t di_atimensec
; /* 20: Last access time. */
110 int32_t di_mtime
; /* 24: Last modified time. */
111 int32_t di_mtimensec
; /* 28: Last modified time. */
112 int32_t di_ctime
; /* 32: Last inode change time. */
113 int32_t di_ctimensec
; /* 36: Last inode change time. */
114 ufs_daddr_t di_db
[NDADDR
]; /* 40: Direct disk blocks. */
115 ufs_daddr_t di_ib
[NIADDR
]; /* 88: Indirect disk blocks. */
116 u_int32_t di_flags
; /* 100: Status flags (chflags). */
117 u_int32_t di_blocks
; /* 104: Blocks actually held. */
118 int32_t di_gen
; /* 108: Generation number. */
119 u_int32_t di_uid
; /* 112: File owner. */
120 u_int32_t di_gid
; /* 116: File group. */
121 int32_t di_spare
[2]; /* 120: Reserved; currently unused */
125 * The di_db fields may be overlaid with other information for
126 * file types that do not have associated disk storage. Block
127 * and character devices overlay the first data block with their
128 * dev_t value. Short symbolic links place their path in the
131 #define di_inumber di_u.inumber
132 #define di_ogid di_u.oldids[1]
133 #define di_ouid di_u.oldids[0]
134 #define di_rdev di_db[0]
135 #define di_shortlink di_db
136 #define MAXSYMLINKLEN ((NDADDR + NIADDR) * sizeof(ufs_daddr_t))
138 /* File permissions. */
139 #define IEXEC 0000100 /* Executable. */
140 #define IWRITE 0000200 /* Writeable. */
141 #define IREAD 0000400 /* Readable. */
142 #define ISVTX 0001000 /* Sticky bit. */
143 #define ISGID 0002000 /* Set-gid. */
144 #define ISUID 0004000 /* Set-uid. */
147 #define IFMT 0170000 /* Mask of file type. */
148 #define IFIFO 0010000 /* Named pipe (fifo). */
149 #define IFCHR 0020000 /* Character device. */
150 #define IFDIR 0040000 /* Directory file. */
151 #define IFBLK 0060000 /* Block device. */
152 #define IFREG 0100000 /* Regular file. */
153 #define IFLNK 0120000 /* Symbolic link. */
154 #define IFSOCK 0140000 /* UNIX domain socket. */
155 #define IFWHT 0160000 /* Whiteout. */
157 #endif /* __APPLE_API_UNSTABLE */
158 #endif /* ! _UFS_DINODE_H_ */