* NAME: vol->geometry() * DESCRIPTION: determine volume location and size (possibly in a partition) */
| 228 | * DESCRIPTION: determine volume location and size (possibly in a partition) |
| 229 | */ |
| 230 | int 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 | |
| 277 | fail: |
| 278 | return -1; |
| 279 | } |
| 280 | |
| 281 | /* |
| 282 | * NAME: vol->readmdb() |
no test coverage detected