2007-03-27 17:47:10 +00:00
|
|
|
/*
|
|
|
|
* CiderPress
|
|
|
|
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
|
|
|
|
* See the file LICENSE for distribution terms.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* The "MicroDrive" DiskFS is a container class for multiple ProDOS and HFS
|
|
|
|
* volumes. It represents a partitioned disk device, such as a hard
|
|
|
|
* drive or CF card, that has been formatted for use with ///SHH Systeme's
|
|
|
|
* MicroDrive card for the Apple II.
|
|
|
|
*/
|
|
|
|
#include "StdAfx.h"
|
|
|
|
#include "DiskImgPriv.h"
|
|
|
|
|
|
|
|
|
|
|
|
const int kBlkSize = 512;
|
2014-11-04 00:26:53 +00:00
|
|
|
const int kPartMapBlock = 0; // partition map lives here
|
2014-11-24 20:56:19 +00:00
|
|
|
const uint32_t kPartSizeMask = 0x00ffffff;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Format of partition map. It resides in the first 256 bytes of block 0.
|
|
|
|
* All values are in little-endian order.
|
|
|
|
*
|
|
|
|
* The layout was discovered through reverse-engineering. Additional notes:
|
|
|
|
*
|
2014-11-04 00:26:53 +00:00
|
|
|
From Joachim Lange:
|
|
|
|
|
|
|
|
Below, this is the configuration block as it is used in all
|
|
|
|
MicroDrive cards. Please verify that my ID shortcut can be
|
|
|
|
found at offset 0, otherwise the partition info is not
|
|
|
|
valid. Most of the other parms are not useful, some are
|
|
|
|
historic and not useful anymore. As a second security
|
|
|
|
measure, verify that the first partition starts at
|
|
|
|
absolute block 256. This is also a fixed value used in all
|
|
|
|
MicroDrive cards. Of course the partition size is not two
|
|
|
|
bytes long but three (not four), the 4th byte is used for
|
|
|
|
switching drives in a two-drive configuration. So, for
|
|
|
|
completeness, when reading partition sizes, perform a
|
|
|
|
partitionLength[..] & 0x00FFFFFF, or at least issue a
|
|
|
|
warning that something may be wrong. The offset
|
|
|
|
(partitionStart) could reach into the 4th byte.
|
|
|
|
I have attached the config block in a zip file because
|
|
|
|
the mailer would probably re-format the source text.
|
2007-03-27 17:47:10 +00:00
|
|
|
*/
|
|
|
|
const int kMaxNumParts = 8;
|
|
|
|
typedef struct DiskFSMicroDrive::PartitionMap {
|
2014-11-24 20:56:19 +00:00
|
|
|
uint16_t magic; // partition signature
|
|
|
|
uint16_t cylinders; // #of cylinders
|
|
|
|
uint16_t reserved1; // ??
|
|
|
|
uint16_t heads; // #of heads/cylinder
|
|
|
|
uint16_t sectors; // #of sectors/track
|
|
|
|
uint16_t reserved2; // ??
|
|
|
|
uint8_t numPart1; // #of partitions in first chunk
|
|
|
|
uint8_t numPart2; // #of partitions in second chunk
|
|
|
|
uint8_t reserved3[10]; // bytes 0x0e-0x17
|
|
|
|
uint16_t romVersion; // IIgs ROM01 or ROM03
|
|
|
|
uint8_t reserved4[6]; // bytes 0x1a-0x1f
|
|
|
|
uint32_t partitionStart1[kMaxNumParts]; // bytes 0x20-0x3f
|
|
|
|
uint32_t partitionLength1[kMaxNumParts]; // bytes 0x40-0x5f
|
|
|
|
uint8_t reserved5[32]; // bytes 0x60-0x7f
|
|
|
|
uint32_t partitionStart2[kMaxNumParts]; // bytes 0x80-0x9f
|
|
|
|
uint32_t partitionLength2[kMaxNumParts]; // bytes 0xa0-0xbf
|
|
|
|
|
|
|
|
uint8_t padding[320];
|
2007-03-27 17:47:10 +00:00
|
|
|
} PartitionMap;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Figure out if this is a MicroDrive partition.
|
|
|
|
*
|
|
|
|
* The "imageOrder" parameter has no use here, because (in the current
|
|
|
|
* version) embedded parent volumes are implicitly ProDOS-ordered.
|
|
|
|
*/
|
2014-11-24 20:56:19 +00:00
|
|
|
/*static*/ DIError DiskFSMicroDrive::TestImage(DiskImg* pImg,
|
|
|
|
DiskImg::SectorOrder imageOrder)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
DIError dierr = kDIErrNone;
|
2014-11-24 20:56:19 +00:00
|
|
|
uint8_t blkBuf[kBlkSize];
|
2014-11-04 00:26:53 +00:00
|
|
|
int partCount1, partCount2;
|
|
|
|
|
|
|
|
assert(sizeof(PartitionMap) == kBlkSize);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See if block 0 is a MicroDrive partition map.
|
|
|
|
*/
|
|
|
|
dierr = pImg->ReadBlockSwapped(kPartMapBlock, blkBuf, imageOrder,
|
|
|
|
DiskImg::kSectorOrderProDOS);
|
|
|
|
if (dierr != kDIErrNone)
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
if (GetShortLE(&blkBuf[0x00]) != kPartitionSignature) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" MicroDrive partition signature not found in first part block");
|
2014-11-04 00:26:53 +00:00
|
|
|
dierr = kDIErrFilesystemNotFound;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
/* might assert that partCount2 be zero unless partCount1 == 8? */
|
|
|
|
partCount1 = blkBuf[0x0c];
|
|
|
|
partCount2 = blkBuf[0x0d];
|
|
|
|
if (partCount1 == 0 || partCount1 > kMaxNumParts ||
|
|
|
|
partCount2 > kMaxNumParts)
|
|
|
|
{
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" MicroDrive unreasonable partCount values %d/%d",
|
2014-11-04 00:26:53 +00:00
|
|
|
partCount1, partCount2);
|
|
|
|
dierr = kDIErrFilesystemNotFound;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* consider testing other fields */
|
|
|
|
|
|
|
|
// success!
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" MicroDrive partition map count = %d/%d", partCount1, partCount2);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
return dierr;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unpack a partition map block into a partition map data structure.
|
|
|
|
*/
|
2014-11-24 20:56:19 +00:00
|
|
|
/*static*/ void DiskFSMicroDrive::UnpackPartitionMap(const uint8_t* buf,
|
2014-11-04 00:26:53 +00:00
|
|
|
PartitionMap* pMap)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
pMap->magic = GetShortLE(&buf[0x00]);
|
|
|
|
pMap->cylinders = GetShortLE(&buf[0x02]);
|
|
|
|
pMap->reserved1 = GetShortLE(&buf[0x04]);
|
|
|
|
pMap->heads = GetShortLE(&buf[0x06]);
|
|
|
|
pMap->sectors = GetShortLE(&buf[0x08]);
|
|
|
|
pMap->reserved2 = GetShortLE(&buf[0x0a]);
|
|
|
|
pMap->numPart1 = buf[0x0c];
|
|
|
|
pMap->numPart2 = buf[0x0d];
|
|
|
|
memcpy(pMap->reserved3, &buf[0x0e], sizeof(pMap->reserved3));
|
|
|
|
pMap->romVersion = GetShortLE(&buf[0x18]);
|
|
|
|
memcpy(pMap->reserved4, &buf[0x1a], sizeof(pMap->reserved4));
|
|
|
|
|
|
|
|
for (int i = 0; i < kMaxNumParts; i++) {
|
|
|
|
pMap->partitionStart1[i] = GetLongLE(&buf[0x20] + i * 4);
|
|
|
|
pMap->partitionLength1[i] = GetLongLE(&buf[0x40] + i * 4) & kPartSizeMask;
|
|
|
|
pMap->partitionStart2[i] = GetLongLE(&buf[0x80] + i * 4);
|
|
|
|
pMap->partitionLength2[i] = GetLongLE(&buf[0xa0] + i * 4) & kPartSizeMask;
|
|
|
|
}
|
|
|
|
memcpy(pMap->reserved5, &buf[0x60], sizeof(pMap->reserved5));
|
|
|
|
memcpy(pMap->padding, &buf[0x80], sizeof(pMap->padding));
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Debug: dump the contents of the partition map.
|
|
|
|
*/
|
2014-11-24 20:56:19 +00:00
|
|
|
/*static*/ void DiskFSMicroDrive::DumpPartitionMap(const PartitionMap* pMap)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" MicroDrive partition map:");
|
|
|
|
LOGI(" cyls=%d res1=%d heads=%d sects=%d",
|
2014-11-04 00:26:53 +00:00
|
|
|
pMap->cylinders, pMap->reserved1, pMap->heads, pMap->sectors);
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" res2=%d numPart1=%d numPart2=%d",
|
2014-11-04 00:26:53 +00:00
|
|
|
pMap->reserved2, pMap->numPart1, pMap->numPart2);
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" romVersion=ROM%02d", pMap->romVersion);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
int i, parts;
|
|
|
|
|
|
|
|
parts = pMap->numPart1;
|
|
|
|
assert(parts <= kMaxNumParts);
|
|
|
|
for (i = 0; i < parts; i++) {
|
2014-12-12 00:04:35 +00:00
|
|
|
LOGI(" %2d: startLBA=%8d length=%d",
|
2014-11-04 00:26:53 +00:00
|
|
|
i, pMap->partitionStart1[i], pMap->partitionLength1[i]);
|
|
|
|
}
|
|
|
|
parts = pMap->numPart2;
|
|
|
|
assert(parts <= kMaxNumParts);
|
|
|
|
for (i = 0; i < parts; i++) {
|
2014-12-12 00:04:35 +00:00
|
|
|
LOGI(" %2d: startLBA=%8d length=%d",
|
2014-11-04 00:26:53 +00:00
|
|
|
i+8, pMap->partitionStart2[i], pMap->partitionLength2[i]);
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open up a sub-volume.
|
|
|
|
*/
|
2014-11-24 20:56:19 +00:00
|
|
|
DIError DiskFSMicroDrive::OpenSubVolume(long startBlock, long numBlocks)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
DIError dierr = kDIErrNone;
|
2014-11-18 05:13:13 +00:00
|
|
|
DiskFS* pNewFS = NULL;
|
|
|
|
DiskImg* pNewImg = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
//bool tweaked = false;
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Adding %ld +%ld", startBlock, numBlocks);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
if (startBlock > fpImg->GetNumBlocks()) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("MicroDrive start block out of range (%ld vs %ld)",
|
2014-11-04 00:26:53 +00:00
|
|
|
startBlock, fpImg->GetNumBlocks());
|
|
|
|
return kDIErrBadPartition;
|
|
|
|
}
|
|
|
|
if (startBlock + numBlocks > fpImg->GetNumBlocks()) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("MicroDrive partition too large (%ld vs %ld avail)",
|
2014-11-04 00:26:53 +00:00
|
|
|
numBlocks, fpImg->GetNumBlocks() - startBlock);
|
|
|
|
fpImg->AddNote(DiskImg::kNoteInfo,
|
|
|
|
"Reduced partition from %ld blocks to %ld.\n",
|
|
|
|
numBlocks, fpImg->GetNumBlocks() - startBlock);
|
|
|
|
numBlocks = fpImg->GetNumBlocks() - startBlock;
|
|
|
|
//tweaked = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
pNewImg = new DiskImg;
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pNewImg == NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
dierr = kDIErrMalloc;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
dierr = pNewImg->OpenImage(fpImg, startBlock, numBlocks);
|
|
|
|
if (dierr != kDIErrNone) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" MicroDriveSub: OpenImage(%ld,%ld) failed (err=%d)",
|
2014-11-04 00:26:53 +00:00
|
|
|
startBlock, numBlocks, dierr);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
//LOGI(" +++ CFFASub: new image has ro=%d (parent=%d)",
|
2014-11-04 00:26:53 +00:00
|
|
|
// pNewImg->GetReadOnly(), pImg->GetReadOnly());
|
|
|
|
|
|
|
|
/* figure out what the format is */
|
|
|
|
dierr = pNewImg->AnalyzeImage();
|
|
|
|
if (dierr != kDIErrNone) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" MicroDriveSub: analysis failed (err=%d)", dierr);
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we allow unrecognized partitions */
|
|
|
|
if (pNewImg->GetFSFormat() == DiskImg::kFormatUnknown ||
|
|
|
|
pNewImg->GetSectorOrder() == DiskImg::kSectorOrderUnknown)
|
|
|
|
{
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" MicroDriveSub (%ld,%ld): unable to identify filesystem",
|
2014-11-04 00:26:53 +00:00
|
|
|
startBlock, numBlocks);
|
|
|
|
DiskFSUnknown* pUnknownFS = new DiskFSUnknown;
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pUnknownFS == NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
dierr = kDIErrInternal;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
//pUnknownFS->SetVolumeInfo((const char*)pMap->pmParType);
|
|
|
|
pNewFS = pUnknownFS;
|
|
|
|
//pNewImg->AddNote(DiskImg::kNoteInfo, "Partition name='%s' type='%s'.",
|
|
|
|
// pMap->pmPartName, pMap->pmParType);
|
|
|
|
} else {
|
|
|
|
/* open a DiskFS for the sub-image */
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" MicroDriveSub (%ld,%ld) analyze succeeded!", startBlock, numBlocks);
|
2014-11-04 00:26:53 +00:00
|
|
|
pNewFS = pNewImg->OpenAppropriateDiskFS(true);
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pNewFS == NULL) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" MicroDriveSub: OpenAppropriateDiskFS failed");
|
2014-11-04 00:26:53 +00:00
|
|
|
dierr = kDIErrUnsupportedFSFmt;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we encapsulate arbitrary stuff, so encourage child to scan */
|
|
|
|
pNewFS->SetScanForSubVolumes(kScanSubEnabled);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Load the files from the sub-image. When doing our initial tests,
|
|
|
|
* or when loading data for the volume copier, we don't want to dig
|
|
|
|
* into our sub-volumes, just figure out what they are and where.
|
|
|
|
*
|
|
|
|
* If "initialize" fails, the sub-volume won't get added to the list.
|
|
|
|
* It's important that a failure at this stage doesn't cause the whole
|
|
|
|
* thing to fall over.
|
|
|
|
*/
|
|
|
|
InitMode initMode;
|
|
|
|
if (GetScanForSubVolumes() == kScanSubContainerOnly)
|
|
|
|
initMode = kInitHeaderOnly;
|
|
|
|
else
|
|
|
|
initMode = kInitFull;
|
|
|
|
dierr = pNewFS->Initialize(pNewImg, initMode);
|
|
|
|
if (dierr != kDIErrNone) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" MicroDriveSub: error %d reading list of files from disk", dierr);
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add it to the list */
|
|
|
|
AddSubVolumeToList(pNewImg, pNewFS);
|
2014-11-18 05:13:13 +00:00
|
|
|
pNewImg = NULL;
|
|
|
|
pNewFS = NULL;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
delete pNewFS;
|
|
|
|
delete pNewImg;
|
|
|
|
return dierr;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check to see if this is a MicroDrive volume.
|
|
|
|
*/
|
2014-11-24 20:56:19 +00:00
|
|
|
/*static*/ DIError DiskFSMicroDrive::TestFS(DiskImg* pImg, DiskImg::SectorOrder* pOrder,
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImg::FSFormat* pFormat, FSLeniency leniency)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
if (pImg->GetNumBlocks() < kMinInterestingBlocks)
|
|
|
|
return kDIErrFilesystemNotFound;
|
|
|
|
if (pImg->GetIsEmbedded()) // don't look for partitions inside
|
|
|
|
return kDIErrFilesystemNotFound;
|
|
|
|
|
|
|
|
/* assume ProDOS -- shouldn't matter, since it's embedded */
|
|
|
|
if (TestImage(pImg, DiskImg::kSectorOrderProDOS) == kDIErrNone) {
|
|
|
|
*pFormat = DiskImg::kFormatMicroDrive;
|
|
|
|
*pOrder = DiskImg::kSectorOrderProDOS;
|
|
|
|
return kDIErrNone;
|
|
|
|
}
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" FS didn't find valid MicroDrive");
|
2014-11-04 00:26:53 +00:00
|
|
|
return kDIErrFilesystemNotFound;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prep the MicroDrive "container" for use.
|
|
|
|
*/
|
2014-11-24 20:56:19 +00:00
|
|
|
DIError DiskFSMicroDrive::Initialize(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
DIError dierr = kDIErrNone;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("MicroDrive initializing (scanForSub=%d)", fScanForSubVolumes);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
/* seems pointless *not* to, but we just do what we're told */
|
|
|
|
if (fScanForSubVolumes != kScanSubDisabled) {
|
|
|
|
dierr = FindSubVolumes();
|
|
|
|
if (dierr != kDIErrNone)
|
|
|
|
return dierr;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
/* blank out the volume usage map */
|
|
|
|
SetVolumeUsageMap();
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return dierr;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the various sub-volumes and open them.
|
|
|
|
*/
|
2014-11-24 20:56:19 +00:00
|
|
|
DIError DiskFSMicroDrive::FindSubVolumes(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
DIError dierr = kDIErrNone;
|
2014-11-24 20:56:19 +00:00
|
|
|
uint8_t buf[kBlkSize];
|
2014-11-04 00:26:53 +00:00
|
|
|
PartitionMap map;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
dierr = fpImg->ReadBlock(kPartMapBlock, buf);
|
|
|
|
if (dierr != kDIErrNone)
|
|
|
|
goto bail;
|
|
|
|
UnpackPartitionMap(buf, &map);
|
|
|
|
DumpPartitionMap(&map);
|
|
|
|
|
|
|
|
/* first part of the table */
|
|
|
|
for (i = 0; i < map.numPart1; i++) {
|
|
|
|
dierr = OpenVol(i,
|
|
|
|
map.partitionStart1[i], map.partitionLength1[i]);
|
|
|
|
if (dierr != kDIErrNone)
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* second part of the table */
|
|
|
|
for (i = 0; i < map.numPart2; i++) {
|
|
|
|
dierr = OpenVol(i + kMaxNumParts,
|
|
|
|
map.partitionStart2[i], map.partitionLength2[i]);
|
|
|
|
if (dierr != kDIErrNone)
|
|
|
|
goto bail;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
return dierr;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open the volume. If it fails, open a placeholder instead. (If *that*
|
|
|
|
* fails, return with an error.)
|
|
|
|
*/
|
2014-11-24 20:56:19 +00:00
|
|
|
DIError DiskFSMicroDrive::OpenVol(int idx, long startBlock, long numBlocks)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
DIError dierr;
|
|
|
|
|
|
|
|
dierr = OpenSubVolume(startBlock, numBlocks);
|
|
|
|
if (dierr != kDIErrNone) {
|
|
|
|
if (dierr == kDIErrCancelled)
|
|
|
|
goto bail;
|
2014-11-18 05:13:13 +00:00
|
|
|
DiskFS* pNewFS = NULL;
|
|
|
|
DiskImg* pNewImg = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-24 20:56:19 +00:00
|
|
|
LOGW(" MicroDrive failed opening sub-volume %d", idx);
|
2014-11-04 00:26:53 +00:00
|
|
|
dierr = CreatePlaceholder(startBlock, numBlocks, NULL, NULL,
|
|
|
|
&pNewImg, &pNewFS);
|
|
|
|
if (dierr == kDIErrNone) {
|
|
|
|
AddSubVolumeToList(pNewImg, pNewFS);
|
|
|
|
} else {
|
2014-11-24 20:56:19 +00:00
|
|
|
LOGE(" MicroDrive unable to create placeholder (err=%d)",
|
2014-11-04 00:26:53 +00:00
|
|
|
dierr);
|
|
|
|
// fall out with error
|
|
|
|
}
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
return dierr;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|