]> git.saurik.com Git - hfs.git/blob - newfs_hfs/newfs_hfs.h
Remove DebugStr (we aren't using pascal strings).
[hfs.git] / newfs_hfs / newfs_hfs.h
1 /*
2 * Copyright (c) 1999-2011 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 /*
27 * Mac OS Finder flags
28 */
29 enum {
30 kHasBeenInited = 0x0100, /* Files only */
31 /* Clear if the file contains desktop database */
32 /* bit 0x0200 was the letter bit for AOCE, but is now reserved for future use */
33 kHasCustomIcon = 0x0400, /* Files and folders */
34 kIsStationery = 0x0800, /* Files only */
35 kNameLocked = 0x1000, /* Files and folders */
36 kHasBundle = 0x2000, /* Files only */
37 kIsInvisible = 0x4000, /* Files and folders */
38 kIsAlias = 0x8000 /* Files only */
39 };
40
41
42 /* Finder types (mostly opaque in our usage) */
43 struct FInfo {
44 uint32_t fileType; /* The type of the file */
45 uint32_t fileCreator; /* The file's creator */
46 UInt16 finderFlags; /* ex: kHasBundle, kIsInvisible... */
47 UInt8 opaque[6]; /* If set to {0, 0}, the Finder will place the item automatically */
48 };
49 typedef struct FInfo FInfo;
50
51 struct FXInfo {
52 UInt8 opaque[16];
53 };
54 typedef struct FXInfo FXInfo;
55
56 struct DInfo {
57 UInt8 opaque[16];
58 };
59 typedef struct DInfo DInfo;
60
61 struct DXInfo {
62 UInt8 opaque[16];
63 };
64 typedef struct DXInfo DXInfo;
65
66
67 enum {
68 kMinHFSPlusVolumeSize = (512 * 1024),
69
70 kBytesPerSector = 512,
71 kBitsPerSector = 4096,
72 kBTreeHeaderUserBytes = 128,
73 kLog2SectorSize = 9,
74 kHFSNodeSize = 512,
75 kHFSMaxAllocationBlks = 65536,
76
77 kHFSPlusDataClumpFactor = 16,
78 kHFSPlusRsrcClumpFactor = 16,
79
80 kWriteSeqNum = 2,
81 kHeaderBlocks = 3,
82 kTailBlocks = 2,
83 kMDBStart = 2,
84 kVolBitMapStart = kHeaderBlocks,
85
86 /* Desktop DB, Desktop DF, Finder, System, ReadMe */
87 kWapperFileCount = 5,
88 /* Maximum wrapper size is 32MB */
89 kMaxWrapperSize = 1024 * 1024 * 32,
90 /* Maximum volume that can be wrapped is 256GB */
91 kMaxWrapableSectors = (kMaxWrapperSize/8) * (65536/512)
92 };
93
94 /* B-tree key descriptor */
95 #define KD_SKIP 0
96 #define KD_BYTE 1
97 #define KD_SIGNBYTE 2
98 #define KD_STRING 3
99 #define KD_WORD 4
100 #define KD_SIGNWORD 5
101 #define KD_LONG 6
102 #define KD_SIGNLONG 7
103 #define KD_FIXLENSTR 8
104 #define KD_DTDBSTR 9
105 #define KD_USEPROC 10
106
107
108 enum {
109 kTextEncodingMacRoman = 0L,
110 kTextEncodingMacJapanese = 1
111 };
112
113
114 /*
115 * The following constant sets the default block size.
116 * This constant must be a power of 2 and meet the following constraints:
117 * MINBSIZE <= DFL_BLKSIZE <= MAXBSIZE
118 * sectorsize <= DFL_BLKSIZE
119 */
120 #define HFSOPTIMALBLKSIZE 4096
121 #define HFSMINBSIZE 512
122 #define HFSMAXBSIZE 2147483648U
123 #define DFL_BLKSIZE HFSOPTIMALBLKSIZE
124
125
126 #define kDTDF_FileID 16
127 #define kDTDF_Name "Desktop DF"
128 #define kDTDF_Chars 10
129 #define kDTDF_Type 'DTFL'
130 #define kDTDF_Creator 'DMGR'
131
132 #define kDTDB_FileID 17
133 #define kDTDB_Name "Desktop DB"
134 #define kDTDB_Chars 10
135 #define kDTDB_Type 'BTFL'
136 #define kDTDB_Creator 'DMGR'
137 #define kDTDB_Size 1024
138
139 #define kReadMe_FileID 18
140 #define kReadMe_Name "ReadMe"
141 #define kReadMe_Chars 6
142 #define kReadMe_Type 'ttro'
143 #define kReadMe_Creator 'ttxt'
144
145 #define kFinder_FileID 19
146 #define kFinder_Name "Finder"
147 #define kFinder_Chars 6
148 #define kFinder_Type 'FNDR'
149 #define kFinder_Creator 'MACS'
150
151 #define kSystem_FileID 20
152 #define kSystem_Name "System"
153 #define kSystem_Chars 6
154 #define kSystem_Type 'zsys'
155 #define kSystem_Creator 'MACS'
156
157
158
159 #if !defined(FALSE) && !defined(TRUE)
160 enum {
161 FALSE = 0,
162 TRUE = 1
163 };
164 #endif
165
166
167 #define kDefaultVolumeNameStr "untitled"
168
169 /*
170 * This is the straight GMT conversion constant:
171 *
172 * 00:00:00 January 1, 1970 - 00:00:00 January 1, 1904
173 * (3600 * 24 * ((365 * (1970 - 1904)) + (((1970 - 1904) / 4) + 1)))
174 */
175 #define MAC_GMT_FACTOR 2082844800UL
176
177
178 /* sectorSize = kBytesPerSector = 512
179 sectorOffset and totalSectors are in terms of 512-byte sector size.
180 */
181 struct DriveInfo {
182 int fd;
183 uint32_t sectorSize;
184 uint32_t sectorOffset;
185 uint64_t totalSectors;
186
187 /* actual device info. physSectorSize is necessary to de-block
188 * while using the raw device.
189 */
190 uint32_t physSectorSize;
191 uint64_t physSectorsPerIO;
192 uint64_t physTotalSectors;
193 };
194 typedef struct DriveInfo DriveInfo;
195
196 enum {
197 kMakeHFSWrapper = 0x01,
198 kMakeMaxHFSBitmap = 0x02,
199 kMakeStandardHFS = 0x04,
200 kMakeCaseSensitive = 0x08,
201 kUseAccessPerms = 0x10,
202 kMakeContentProtect= 0x20,
203 };
204
205
206 struct hfsparams {
207 uint32_t flags; /* kMakeHFSWrapper, ... */
208 uint32_t blockSize;
209 uint32_t rsrcClumpSize;
210 uint32_t dataClumpSize;
211 uint32_t nextFreeFileID;
212
213 uint32_t catalogClumpSize;
214 uint32_t catalogNodeSize;
215 uint32_t catalogExtsCount;
216 uint32_t catalogStartBlock;
217
218 uint32_t extentsClumpSize;
219 uint32_t extentsNodeSize;
220 uint32_t extentsExtsCount;
221 uint32_t extentsStartBlock;
222
223 uint32_t attributesClumpSize;
224 uint32_t attributesNodeSize;
225 uint32_t attributesExtsCount;
226 uint32_t attributesStartBlock;
227
228 uint32_t allocationClumpSize;
229 uint32_t allocationExtsCount;
230 uint32_t allocationStartBlock;
231
232 uint32_t createDate; /* in UTC */
233 uint32_t hfsAlignment;
234 unsigned char volumeName[kHFSPlusMaxFileNameChars + 1]; /* in UTF-8 */
235 uint32_t encodingHint;
236 uint32_t journaledHFS;
237 uint32_t journalSize;
238 uint32_t journalInfoBlock;
239 uint32_t journalBlock;
240 char *journalDevice;
241 uid_t owner;
242 gid_t group;
243 mode_t mask;
244 #ifdef DEBUG_BUILD
245 uint16_t protectlevel;
246 #endif
247 uint32_t fsStartBlock; /* allocation block offset where the btree allocaiton should start */
248 uint32_t nextAllocBlock; /* Set VH nextAllocationBlock */
249 };
250 typedef struct hfsparams hfsparams_t;
251
252 extern int make_hfsplus(const DriveInfo *driveInfo, hfsparams_t *defaults);
253
254
255 #if __STDC__
256 void fatal(const char *fmt, ...);
257 #else
258 void fatal();
259 #endif