]> git.saurik.com Git - apple/hfs.git/blob - newfs_hfs/newfs_hfs.h
hfs-556.100.11.tar.gz
[apple/hfs.git] / newfs_hfs / newfs_hfs.h
1 /*
2 * Copyright (c) 1999-2015 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #include <CoreFoundation/CFBase.h>
25
26 enum {
27 kMinHFSPlusVolumeSize = (512 * 1024),
28
29 kBytesPerSector = 512,
30 kBitsPerSector = 4096,
31 kBTreeHeaderUserBytes = 128,
32 kLog2SectorSize = 9,
33 kHFSNodeSize = 512,
34 kHFSMaxAllocationBlks = 65536,
35
36 kHFSPlusDataClumpFactor = 16,
37 kHFSPlusRsrcClumpFactor = 16,
38
39 kWriteSeqNum = 2,
40 kHeaderBlocks = 3,
41 kTailBlocks = 2,
42 kMDBStart = 2,
43 kVolBitMapStart = kHeaderBlocks,
44
45 /* Desktop DB, Desktop DF, Finder, System, ReadMe */
46 kWapperFileCount = 5,
47 /* Maximum wrapper size is 32MB */
48 kMaxWrapperSize = 1024 * 1024 * 32,
49 /* Maximum volume that can be wrapped is 256GB */
50 kMaxWrapableSectors = (kMaxWrapperSize/8) * (65536/512)
51 };
52
53 /* B-tree key descriptor */
54 #define KD_SKIP 0
55 #define KD_BYTE 1
56 #define KD_SIGNBYTE 2
57 #define KD_STRING 3
58 #define KD_WORD 4
59 #define KD_SIGNWORD 5
60 #define KD_LONG 6
61 #define KD_SIGNLONG 7
62 #define KD_FIXLENSTR 8
63 #define KD_DTDBSTR 9
64 #define KD_USEPROC 10
65
66 /*
67 * The following constant sets the default block size.
68 * This constant must be a power of 2 and meet the following constraints:
69 * MINBSIZE <= DFL_BLKSIZE <= MAXBSIZE
70 * sectorsize <= DFL_BLKSIZE
71 */
72 #define HFSOPTIMALBLKSIZE 4096
73 #define HFSMINBSIZE 512
74 #define HFSMAXBSIZE 2147483648U
75 #define DFL_BLKSIZE HFSOPTIMALBLKSIZE
76
77
78 #define kDTDF_FileID 16
79 #define kDTDF_Name "Desktop DF"
80 #define kDTDF_Chars 10
81 #define kDTDF_Type 'DTFL'
82 #define kDTDF_Creator 'DMGR'
83
84 #define kDTDB_FileID 17
85 #define kDTDB_Name "Desktop DB"
86 #define kDTDB_Chars 10
87 #define kDTDB_Type 'BTFL'
88 #define kDTDB_Creator 'DMGR'
89 #define kDTDB_Size 1024
90
91 #define kReadMe_FileID 18
92 #define kReadMe_Name "ReadMe"
93 #define kReadMe_Chars 6
94 #define kReadMe_Type 'ttro'
95 #define kReadMe_Creator 'ttxt'
96
97 #define kFinder_FileID 19
98 #define kFinder_Name "Finder"
99 #define kFinder_Chars 6
100 #define kFinder_Type 'FNDR'
101 #define kFinder_Creator 'MACS'
102
103 #define kSystem_FileID 20
104 #define kSystem_Name "System"
105 #define kSystem_Chars 6
106 #define kSystem_Type 'zsys'
107 #define kSystem_Creator 'MACS'
108
109
110
111 #if !defined(FALSE) && !defined(TRUE)
112 enum {
113 FALSE = 0,
114 TRUE = 1
115 };
116 #endif
117
118
119 #define kDefaultVolumeNameStr "untitled"
120
121 /*
122 * This is the straight GMT conversion constant:
123 *
124 * 00:00:00 January 1, 1970 - 00:00:00 January 1, 1904
125 * (3600 * 24 * ((365 * (1970 - 1904)) + (((1970 - 1904) / 4) + 1)))
126 */
127 #define MAC_GMT_FACTOR 2082844800UL
128
129 /*
130 * Maximum number of bytes in an HFS+ filename.
131 * It's 255 characters; a UTF16 character may translate
132 * to 3 bytes. Plus one for NUL.
133 */
134
135 #define kHFSPlusMaxFileNameBytes (3 * 255 + 1)
136
137 /* sectorSize = kBytesPerSector = 512
138 sectorOffset and totalSectors are in terms of 512-byte sector size.
139 */
140 struct DriveInfo {
141 int fd;
142 uint32_t sectorSize;
143 uint32_t sectorOffset;
144 uint64_t totalSectors;
145
146 /* actual device info. physSectorSize is necessary to de-block
147 * while using the raw device.
148 */
149 uint32_t physSectorSize;
150 uint64_t physSectorsPerIO;
151 uint64_t physTotalSectors;
152 };
153 typedef struct DriveInfo DriveInfo;
154
155 enum {
156 kMakeHFSWrapper = 0x01,
157 kMakeMaxHFSBitmap = 0x02,
158 kMakeStandardHFS = 0x04,
159 kMakeCaseSensitive = 0x08,
160 kUseAccessPerms = 0x10,
161 kMakeContentProtect= 0x20,
162 };
163
164
165 struct hfsparams {
166 uint32_t flags; /* kMakeHFSWrapper, ... */
167 uint32_t blockSize;
168 uint32_t rsrcClumpSize;
169 uint32_t dataClumpSize;
170 uint32_t nextFreeFileID;
171
172 uint32_t catalogClumpSize;
173 uint32_t catalogInitialSize;
174 uint32_t catalogNodeSize;
175 uint32_t catalogExtsCount;
176 uint32_t catalogStartBlock;
177
178 uint32_t extentsClumpSize;
179 uint32_t extentsInitialSize;
180 uint32_t extentsNodeSize;
181 uint32_t extentsExtsCount;
182 uint32_t extentsStartBlock;
183
184 uint32_t attributesClumpSize;
185 uint32_t attributesInitialSize;
186 uint32_t attributesNodeSize;
187 uint32_t attributesExtsCount;
188 uint32_t attributesStartBlock;
189
190 uint32_t allocationClumpSize;
191 uint32_t allocationExtsCount;
192 uint32_t allocationStartBlock;
193
194 uint32_t createDate; /* in UTC */
195 uint32_t hfsAlignment;
196 unsigned char *volumeName; /* In UTF8, but we need to allocate space for it. */
197 uint32_t journaledHFS;
198 uint32_t journalSize;
199 uint32_t journalInfoBlock;
200 uint32_t journalBlock;
201 char *journalDevice;
202 uid_t owner;
203 gid_t group;
204 mode_t mask;
205 #ifdef DEBUG_BUILD
206 uint16_t protectlevel;
207 #endif
208 uint32_t fsStartBlock; /* allocation block offset where the btree allocaiton should start */
209 uint32_t nextAllocBlock; /* Set VH nextAllocationBlock */
210 };
211 typedef struct hfsparams hfsparams_t;
212
213 extern int make_hfsplus(const DriveInfo *driveInfo, hfsparams_t *defaults);
214
215
216 #if __STDC__
217 void fatal(const char *fmt, ...);
218 #else
219 void fatal();
220 #endif