1/*
2 * hfsutils - tools for reading and writing Macintosh HFS volumes
3 * Copyright (C) 1996, 1997 Robert Leslie
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20typedef struct {
21  Integer	sbSig;		/* device signature (should be 0x4552) */
22  Integer	sbBlkSize;	/* block size of the device (in bytes) */
23  LongInt	sbBlkCount;	/* number of blocks on the device */
24  Integer	sbDevType;	/* reserved */
25  Integer	sbDevId;	/* reserved */
26  LongInt	sbData;		/* reserved */
27  Integer	sbDrvrCount;	/* number of driver descriptor entries */
28  LongInt	ddBlock;	/* first driver's starting block */
29  Integer	ddSize;		/* size of the driver, in 512-byte blocks */
30  Integer	ddType;		/* driver operating system type (MacOS = 1) */
31  Integer	ddPad[243];	/* additional drivers, if any */
32} Block0;
33
34typedef struct {
35  Integer	bbID;		/* boot blocks signature */
36  LongInt	bbEntry;	/* entry point to boot code */
37  Integer	bbVersion;	/* boot blocks version number */
38  Integer	bbPageFlags;	/* used internally */
39  Str15		bbSysName;	/* System filename */
40  Str15		bbShellName;	/* Finder filename */
41  Str15		bbDbg1Name;	/* debugger filename */
42  Str15		bbDbg2Name;	/* debugger filename */
43  Str15		bbScreenName;	/* name of startup screen */
44  Str15		bbHelloName;	/* name of startup program */
45  Str15		bbScrapName;	/* name of system scrap file */
46  Integer	bbCntFCBs;	/* number of FCBs to allocate */
47  Integer	bbCntEvts;	/* number of event queue elements */
48  LongInt	bb128KSHeap;	/* system heap size on 128K Mac */
49  LongInt	bb256KSHeap;	/* used internally */
50  LongInt	bbSysHeapSize;	/* system heap size on all machines */
51  Integer	filler;		/* reserved */
52  LongInt	bbSysHeapExtra;	/* additional system heap space */
53  LongInt	bbSysHeapFract;	/* fraction of RAM for system heap */
54} BootBlkHdr;
55
56typedef struct {
57  Integer	pmSig;		/* partition signature (0x504d or 0x5453) */
58  Integer	pmSigPad;	/* reserved */
59  LongInt	pmMapBlkCnt;	/* number of blocks in partition map */
60  LongInt	pmPyPartStart;	/* first physical block of partition */
61  LongInt	pmPartBlkCnt;	/* number of blocks in partition */
62  Char		pmPartName[33];	/* partition name */
63  Char		pmParType[33];	/* partition type */
64  /*
65   * Apple_partition_map	partition map
66   * Apple_Driver		device driver
67   * Apple_Driver43		SCSI Manager 4.3 device driver
68   * Apple_MFS			Macintosh 64K ROM filesystem
69   * Apple_HFS			Macintosh hierarchical filesystem
70   * Apple_Unix_SVR2		Unix filesystem
71   * Apple_PRODOS		ProDOS filesystem
72   * Apple_Free			unused
73   * Apple_Scratch		empty
74   */
75  LongInt	pmLgDataStart;	/* first logical block of data area */
76  LongInt	pmDataCnt;	/* number of blocks in data area */
77  LongInt	pmPartStatus;	/* partition status information */
78  LongInt	pmLgBootStart;	/* first logical block of boot code */
79  LongInt	pmBootSize;	/* size of boot code, in bytes */
80  LongInt	pmBootAddr;	/* boot code load address */
81  LongInt	pmBootAddr2;	/* reserved */
82  LongInt	pmBootEntry;	/* boot code entry point */
83  LongInt	pmBootEntry2;	/* reserved */
84  LongInt	pmBootCksum;	/* boot code checksum */
85  Char		pmProcessor[17];/* processor type */
86  Integer	pmPad[188];	/* reserved */
87} Partition;
88
89int l_lockvol(hfsvol *);
90
91int l_readblock0(hfsvol *);
92int l_readpm(hfsvol *);
93
94int l_readmdb(hfsvol *);
95int l_writemdb(hfsvol *);
96
97int l_readvbm(hfsvol *);
98int l_writevbm(hfsvol *);
99