2 * libhfs - library for reading and writing Macintosh HFS volumes
3 * Copyright (C) 1996-1998, 2001 Robert Leslie
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.
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.
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., 51 Franklin Street - Fifth Floor, Boston,
20 * $Id: low.c,v 1.8 1998/11/02 22:09:03 rob Exp $
31 * NAME: low->getpmentry()
32 * DESCRIPTION: read a partition map entry
34 int l_getpmentry(hfsvol *vol, Partition *map, unsigned long bnum)
40 if (b_readpb(vol, bnum, &b, 1) == -1)
43 d_fetchsw(&ptr, &map->pmSig);
44 d_fetchsw(&ptr, &map->pmSigPad);
45 d_fetchsl(&ptr, &map->pmMapBlkCnt);
46 d_fetchsl(&ptr, &map->pmPyPartStart);
47 d_fetchsl(&ptr, &map->pmPartBlkCnt);
49 strncpy((char *) map->pmPartName, (const char *) ptr, 32);
50 map->pmPartName[32] = 0;
53 strncpy((char *) map->pmParType, (const char *) ptr, 32);
54 map->pmParType[32] = 0;
57 d_fetchsl(&ptr, &map->pmLgDataStart);
58 d_fetchsl(&ptr, &map->pmDataCnt);
59 d_fetchsl(&ptr, &map->pmPartStatus);
60 d_fetchsl(&ptr, &map->pmLgBootStart);
61 d_fetchsl(&ptr, &map->pmBootSize);
62 d_fetchsl(&ptr, &map->pmBootAddr);
63 d_fetchsl(&ptr, &map->pmBootAddr2);
64 d_fetchsl(&ptr, &map->pmBootEntry);
65 d_fetchsl(&ptr, &map->pmBootEntry2);
66 d_fetchsl(&ptr, &map->pmBootCksum);
68 strncpy((char *) map->pmProcessor, (const char *) ptr, 16);
69 map->pmProcessor[16] = 0;
72 for (i = 0; i < 188; ++i)
73 d_fetchsw(&ptr, &map->pmPad[i]);
75 ASSERT(ptr - b == HFS_BLOCKSZ);
86 * DESCRIPTION: read a master directory block
88 int l_getmdb(hfsvol *vol, MDB *mdb, int backup)
94 if (b_readlb(vol, backup ? vol->vlen - 2 : 2, &b) == -1)
97 d_fetchsw(&ptr, &mdb->drSigWord);
98 d_fetchsl(&ptr, &mdb->drCrDate);
99 d_fetchsl(&ptr, &mdb->drLsMod);
100 d_fetchsw(&ptr, &mdb->drAtrb);
101 d_fetchuw(&ptr, &mdb->drNmFls);
102 d_fetchuw(&ptr, &mdb->drVBMSt);
103 d_fetchuw(&ptr, &mdb->drAllocPtr);
104 d_fetchuw(&ptr, &mdb->drNmAlBlks);
105 d_fetchul(&ptr, &mdb->drAlBlkSiz);
106 d_fetchul(&ptr, &mdb->drClpSiz);
107 d_fetchuw(&ptr, &mdb->drAlBlSt);
108 d_fetchsl(&ptr, &mdb->drNxtCNID);
109 d_fetchuw(&ptr, &mdb->drFreeBks);
111 d_fetchstr(&ptr, mdb->drVN, sizeof(mdb->drVN));
113 ASSERT(ptr - b == 64);
115 d_fetchsl(&ptr, &mdb->drVolBkUp);
116 d_fetchsw(&ptr, &mdb->drVSeqNum);
117 d_fetchul(&ptr, &mdb->drWrCnt);
118 d_fetchul(&ptr, &mdb->drXTClpSiz);
119 d_fetchul(&ptr, &mdb->drCTClpSiz);
120 d_fetchuw(&ptr, &mdb->drNmRtDirs);
121 d_fetchul(&ptr, &mdb->drFilCnt);
122 d_fetchul(&ptr, &mdb->drDirCnt);
124 for (i = 0; i < 8; ++i)
125 d_fetchsl(&ptr, &mdb->drFndrInfo[i]);
127 ASSERT(ptr - b == 124);
129 d_fetchuw(&ptr, &mdb->drEmbedSigWord);
130 d_fetchuw(&ptr, &mdb->drEmbedExtent.xdrStABN);
131 d_fetchuw(&ptr, &mdb->drEmbedExtent.xdrNumABlks);
133 d_fetchul(&ptr, &mdb->drXTFlSize);
135 for (i = 0; i < 3; ++i)
137 d_fetchuw(&ptr, &mdb->drXTExtRec[i].xdrStABN);
138 d_fetchuw(&ptr, &mdb->drXTExtRec[i].xdrNumABlks);
141 ASSERT(ptr - b == 146);
143 d_fetchul(&ptr, &mdb->drCTFlSize);
145 for (i = 0; i < 3; ++i)
147 d_fetchuw(&ptr, &mdb->drCTExtRec[i].xdrStABN);
148 d_fetchuw(&ptr, &mdb->drCTExtRec[i].xdrNumABlks);
151 ASSERT(ptr - b == 162);