MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / v_geometry

Function v_geometry

dep/hfsutils/libhfs/volume.c:230–279  ·  view source on GitHub ↗

* NAME: vol->geometry() * DESCRIPTION: determine volume location and size (possibly in a partition) */

Source from the content-addressed store, hash-verified

228 * DESCRIPTION: determine volume location and size (possibly in a partition)
229 */
230int v_geometry(hfsvol *vol, int pnum)
231{
232 Partition map;
233 unsigned long bnum = 0;
234 int found;
235
236 vol->pnum = pnum;
237
238 if (pnum == 0)
239 {
240 vol->vstart = 0;
241 vol->vlen = b_size(vol);
242
243 if (vol->vlen == 0)
244 goto fail;
245 }
246 else
247 {
248 while (pnum--)
249 {
250 found = m_findpmentry(vol, "Apple_HFS", &map, &bnum);
251 if (found == -1 || ! found)
252 goto fail;
253 }
254
255 vol->vstart = map.pmPyPartStart;
256 vol->vlen = map.pmPartBlkCnt;
257
258 if (map.pmDataCnt)
259 {
260 if ((unsigned long) map.pmLgDataStart +
261 (unsigned long) map.pmDataCnt > vol->vlen)
262 ERROR(EINVAL, "partition data overflows partition");
263
264 vol->vstart += (unsigned long) map.pmLgDataStart;
265 vol->vlen = map.pmDataCnt;
266 }
267
268 if (vol->vlen == 0)
269 ERROR(EINVAL, "volume partition is empty");
270 }
271
272 if (vol->vlen < 800 * (1024 >> HFS_BLOCKSZ_BITS))
273 ERROR(EINVAL, "volume is smaller than 800K");
274
275 return 0;
276
277fail:
278 return -1;
279}
280
281/*
282 * NAME: vol->readmdb()

Callers 3

hfs_mountFunction · 0.85
hfs_zeroFunction · 0.85
hfs_formatFunction · 0.85

Calls 2

b_sizeFunction · 0.85
m_findpmentryFunction · 0.85

Tested by

no test coverage detected