File: sequoia.h

package info (click to toggle)
hfsutils 3.1-4
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,408 kB
  • ctags: 1,340
  • sloc: ansic: 12,976; tcl: 1,894; makefile: 595; sh: 152; perl: 29
file content (336 lines) | stat: -rw-r--r-- 12,185 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/*
 * libhfs - library for reading and writing Macintosh HFS volumes
 * Copyright (C) 1996, 1997 Robert Leslie
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * $Id: sequoia.h,v 1.2 1997/11/11 21:20:16 rob Exp $
 */

typedef unsigned char	UInt8;
typedef unsigned short	UInt16;
typedef unsigned long	UInt32;
typedef UInt32		UInt64[2];

typedef signed char	SInt8;
typedef signed short	SInt16;
typedef signed long	SInt32;
typedef SInt32		SInt64[2];

typedef UInt16 UniChar;
struct UniStr255 {
  UInt16	length;		/* number of unicode characters */
  UniChar	unicode[255];	/* unicode characters */
};
typedef struct UniStr255 UniStr255;
typedef const UniStr255 *ConstUniStr255Param;

typedef UInt32 CatalogNodeID;

/* Signatures used to differentiate between HFS and Sequoia volumes */
enum {
  kHFSSigWord		= 0x4244,
  kHFSPlusSigWord	= 0x4438	/* this will change! */
};

/* Large extent descriptor (Sequoia only) */
struct LargeExtentDescriptor {
  UInt32	startBlock;	/* first allocation block */
  UInt32	blockCount;	/* number of allocation blocks */
};
typedef struct LargeExtentDescriptor LargeExtentDescriptor;

/* Large extent record (Sequoia only) */
typedef LargeExtentDescriptor LargeExtentRecord[8];

/* Fork data info (Sequoia only) - 80 bytes */
struct ForkData {
  UInt64	logicalSize;	/* fork's logical size in bytes */
  UInt32	clumpSize;	/* fork's clump size in bytes */
  UInt32	totalBlocks;	/* total allocation blocks
				   used by this fork */
  LargeExtentRecord
  		extents;	/* initial set of extents */
};
typedef struct ForkData ForkData;

/* VolumeHeader (Sequoia only) - 512 bytes */
/* Stored at sector #0 (1st sector) and last sector */
struct VolumeHeader {
  UInt16	signature;	/* volume signature == kHFSPlusSigWord */
  UInt16	version;	/* version is 1.0 ($0100) */
  UInt32	attributes;	/* volume attributes */
  UInt32	createDate;	/* date and time of volume creation */
  UInt32	modifyDate;	/* date and time of last modification */
  UInt32	backupDate;	/* date and time of last backup */
  UInt32	checkedDate;	/* date and time of last disk check */
  UInt32	fileCount;	/* number of files in volume */
  UInt32	folderCount;	/* number of directories in volume */
  UInt32	blockSize;	/* size (in bytes) of allocation blocks */
  UInt32	totalBlocks;	/* number of allocation blocks in volume
				   (includes this header and VBM)*/
  UInt32	freeBlocks;	/* number of unused allocation blocks */
  UInt32	nextAllocation;	/* start of next allocation search */
  UInt32	rsrcClumpSize;	/* default resource fork clump size */
  UInt32	dataClumpSize;	/* default data fork clump size */
  CatalogNodeID	nextCatalogID;	/* next unused catalog node ID */
  UInt32	writeCount;	/* volume write count */
  UInt64	encodingsBitmap;
  				/* which encodings have been used
				   on this volume */
  UInt8		finderInfo[32];	/* information used by the Finder */
  ForkData	allocationFile;	/* allocation bitmap file */
  ForkData	extentsFile;	/* extents B-tree file */
  ForkData	catalogFile;	/* catalog B-tree file */
  ForkData	attributesFile;	/* extended attributes B-tree file */
  ForkData	startupFile;	/* boot file */
  UInt32	reserved[2];	/* reserved - set to zero */
};
typedef struct VolumeHeader VolumeHeader;

/* Bits 0-6 are reserved (always cleared by MountVol call) */
enum {
  kVolumeHardwareLockBit	= 7,	/* volume is locked by hardware */
  kVolumeUnmountedBit		= 8,	/* volume was successfully unmounted */
  kVolumeSparedBlocksBit	= 9,	/* volume has bad blocks spared */
  kVolumeNoCacheRequiredBit	= 10,	/* don't cache volume blocks */
  kBootVolumeInconsistentBit	= 11,	/* boot volume is inconsistent
					   (System 7.6) */

  /* Bits 12-14 are reserved for future use */
  kVolumeHardLinksBit		= 12,	/* volume has hard links */
  kVolumeSoftwareLockBit	= 15,	/* volume is locked by software */
};

typedef struct {
  UInt32	fLink;		/* forward link */
  UInt32	bLink;		/* backward link */
  SInt8		type;		/* node type */
  SInt8		nHeight;	/* node level */
  UInt16	nRecs;		/* number of records in node */
  UInt16	resv2;		/* reserved */
} BTNodeDescriptor;

typedef struct {
  BTNodeDescriptor
  		node;
  UInt16	treeDepth;
  UInt32	rootNode;
  UInt32 	eafRecords;
  UInt32	firstLeafNode;
  UInt32	lastLeafNode;
  UInt16	nodeSize;
  UInt16	maxKeyLength;
  UInt32	totalNodes;
  UInt32	freeNodes;
  UInt16	reserved1;
  UInt32	clumpSize;	/* misaligned */
  UInt8		btreeType;
  UInt8		reserved2;
  UInt32	attributes;	/* long aligned again */
  UInt32	reserved3[16];
} HeaderRec, *HeaderPtr;

typedef enum {
  kBTBadCloseMask		= 0x00000001,
  kBTBigKeysMask		= 0x00000002,
  kBTVariableIndexKeysMask	= 0x00000004
} BTreeAttributes;

/* Large Catalog key (Sequoia only) */
struct LargeCatalogKey {
  UInt16	keyLength;	/* key length (excluding the length field) */
  CatalogNodeID	parentID;	/* parent folder ID */
  UniStr255	nodeName;	/* catalog node name */
};
typedef struct LargeCatalogKey LargeCatalogKey;

/* Large Extent key (Sequoia only) */
struct LargeExtentKey {
  SInt8		keyLength;	/* length of key, excluding this field */
  SInt8		forkType;	/* 0 = data fork, -1 = resource fork */
  SInt16	pad;		/* make the other fields align on
				   32-bit boundary */
  CatalogNodeID	fileID;		/* file ID */
  UInt32	startBlock;	/* first file allocation block number
				   in this extent */
};
typedef struct LargeExtentKey LargeExtentKey;

/* Key for records in the attributes file. Data is user-defined. */
enum {
  kAttrDontExchangeMask = 0x8000,	/* If set, this property will not be
					   exchanged via ExchangeFiles*/
  kAttrDontExchangeBit = 15
};

struct AttributeKey {
  UInt16	length;		/* must set kBTBigKeysMask in BTree
				   header's attributes */
  UInt16	flags;
  CatalogNodeID	cnid;
  UInt32	creator;
  UInt32	selector;
};
typedef struct AttributeKey AttributeKey;

struct SmallCatalogFolder {
  SInt16	flags;		/* directory flags */
  UInt16	val;		/* directory valence */
  UInt32	dirID;		/* directory ID */
  SInt32	crDat;		/* date and time of creation */
  SInt32	mdDat;		/* date and time of last modification */
  SInt32	bkDat;		/* date and time of last backup */
  DInfo		usrInfo;	/* Finder information */
  DXInfo	fndrInfo;	/* additional Finder information */
  SInt32	resrv[4];	/* reserved */
};
typedef struct SmallCatalogFolder SmallCatalogFolder;

struct SmallCatalogFile {
  SInt8		flags;		/* file flags */
  SInt8		typ;		/* file type */
  FInfo		usrWds;		/* Finder information */
  UInt32	flNum;		/* file ID */
  UInt16	stBlk;		/* first alloc block of data fork */
  UInt32	lgLen;		/* logical EOF of data fork */
  UInt32	pyLen;		/* physical EOF of data fork */
  UInt16	rStBlk;		/* first alloc block of resource fork */
  UInt32	rLgLen;		/* logical EOF of resource fork */
  UInt32	rPyLen;		/* physical EOF of resource fork */
  SInt32	crDat;		/* date and time of creation */
  SInt32	mdDat;		/* date and time of last modification */
  SInt32	bkDat;		/* date and time of last backup */
  FXInfo	fndrInfo;	/* additional Finder information */
  UInt16	clpSize;	/* file clump size */
  ExtDataRec	extRec;		/* first data fork extent record */
  ExtDataRec	rExtRec;	/* first resource fork extent record */
  SInt32	resrv;		/* reserved */
};
typedef struct SmallCatalogFile SmallCatalogFile;

struct SmallCatalogThread {
  SInt32	resrv[2];	/* reserved */
  UInt32	parID;		/* parent ID for this directory */
  Str31		cName;		/* name of this directory */
};
typedef struct SmallCatalogThread SmallCatalogThread;

/* Permissions info (Sequoia only) - 16 bytes */
struct Permissions {
  UInt32	ownerID;	/* user or group ID of file/folder owner */
  UInt32	groupID;	/* additional user of group ID */
  UInt32	permissions;	/* permissions
				   (bytes: unused, owner, group, everyone) */
  UInt32	specialDevice;	/* UNIX: device for
				   character or block special file */
};
typedef struct Permissions Permissions;

/* Large catalog folder record (Sequoia only) - 88 bytes */
struct LargeCatalogFolder {
  SInt16	recordType;	/* record type = Sequoia folder record */
  UInt16	flags;		/* file flags */
  UInt32	valence;	/* folder's valence
				   (limited to 2^16 in Mac OS) */
  CatalogNodeID	folderID;	/* folder ID */
  UInt32	createDate;	/* date and time of creation */
  UInt32	contentModDate;	/* date and time of last
				   content modification */
  UInt32	attributeModDate;
  				/* date and time of last
				   attribute modification */
  UInt32	accessDate;	/* date and time of last
				   access (Rhapsody only) */
  UInt32	backupDate;	/* date and time of last backup */
  Permissions	permissions;	/* permissions (for Rhapsody) */
  DInfo		userInfo;	/* Finder information */
  DXInfo	finderInfo;	/* additional Finder information */
  UInt32	textEncoding;	/* hint for name conversions */
  UInt32	reserved;	/* reserved - set to zero */
};
typedef struct LargeCatalogFolder LargeCatalogFolder;

/* Large catalog file record (Sequoia only) - 248 bytes */
struct LargeCatalogFile {
  SInt16	recordType;	/* record type = Sequoia file record */
  UInt16	flags;		/* file flags */
  UInt32	linkCount;	/* reserved - set to zero */
  CatalogNodeID	fileID;		/* file ID */
  UInt32	createDate;	/* date and time of creation */
  UInt32	contentModDate;	/* date and time of last content
				   (fork) modification */
  UInt32	attributeModDate;
  				/* date and time of last attribute
				   modification */
  UInt32	accessDate;	/* date and time of last access
				   (Rhapsody only) */
  UInt32	backupDate;	/* date and time of last backup */
  Permissions	permissions;	/* permissions (for Rhapsody) */
  FInfo		userInfo;	/* Finder information */
  FXInfo	finderInfo;	/* additional Finder information */
  UInt32	textEncoding;	/* hint for name conversions */
  UInt32	reserved2;	/* reserved - set to zero */

  /* start on double long (64 bit) boundary */
  ForkData	dataFork;	/* size and block data for data fork */
  ForkData	resourceFork;	/* size and block data for resource fork */
};
typedef struct LargeCatalogFile LargeCatalogFile;

/* Catalog file record flags */
enum {
  kFileLockedBit	= 0x0000,	/* file is locked and
					   cannot be written to */
  kFileLockedMask	= 0x0001,
  kFileThreadExistsBit	= 0x0001,	/* a file thread record exists
					   for this file */
  kFileThreadExistsMask	= 0x0002
};

/* Large catalog thread record (Sequoia only) -- 264 bytes */
/* This structure is used for both file and folder thread records. */
struct LargeCatalogThread {
  SInt16	recordType;		/* record type */
  SInt16	reserved;		/* reserved - set to zero */
  CatalogNodeID	parentID;		/* parent ID for this catalog node */
  UniStr255	nodeName;		/* name of this catalog node
					   (variable length) */
};
typedef struct LargeCatalogThread LargeCatalogThread;

union CatalogRecord {
  SInt16		recordType;	/* record type */

  SmallCatalogFolder	smallFolder;	/* HFS folder record */
  SmallCatalogFile	smallFile;	/* HFS file record */
  SmallCatalogThread	smallThread;	/* HFS thread record */

  LargeCatalogFolder	largeFolder;
  LargeCatalogFile	largeFile;
  LargeCatalogThread	largeThread;
};

enum {
  rtypeSeqFolder	= 0x0001,	/* Sequoia Folder record */
  rtypeSeqFile		= 0x0002,	/* Sequoia File record */
  rtypeSeqFoldThread	= 0x0003,	/* Sequoia Folder thread record */
  rtypeSeqFileThread	= 0x0004,	/* Sequoia File thread record */

  rtypeHFSFolder	= 0x0100,	/* Classic HFS Folder record */
  rtypeHFSFile		= 0x0200,	/* Classic HFS File record */
  rtypeHFSFoldThread	= 0x0300,	/* Classic HFS Folder thread record */
  rtypeHFSFileThread	= 0x0400	/* Classic HFS File thread record */
};