Exemplo n.º 1
0
void CondInfoPop(               // POP COND_INFO STACK
    void )
{
    COND_STK* stk = PstkPopElement( &stack_cond_blks );
    stk = stk;
    _Dump( stk, "POP" );
}
Exemplo n.º 2
0
std::wostream& touchmind::model::node::NodeModel::DumpAll(std::wostream& out)
{
    out << "NodeModel::DumpAll start <<" << std::endl;
    _Dump(out, 0, shared_from_this());
    out << "NodeModel::DumpAll end >>" << std::endl;
    return out;
}
Exemplo n.º 3
0
void touchmind::model::node::NodeModel::_Dump(std::wostream &out, int indent,
                                              const std::shared_ptr<touchmind::model::node::NodeModel> &node) {
  _Indent(out, indent);
  node->Dump(out);
  out << std::endl;
  for (size_t i = 0; i < node->GetActualChildrenCount(); ++i) {
    auto child = node->GetChild(i);
    _Dump(out, indent + 1, child);
  }
}
Exemplo n.º 4
0
void CondInfoPop(               // POP COND_INFO STACK
    void )
{
#ifndef NDEBUG
    COND_STK* stk = PstkPopElement( &stack_cond_blks );
    _Dump( stk, "POP" );
#else
    PstkPopElement( &stack_cond_blks );
#endif
}
Exemplo n.º 5
0
static void callBackFalse(      // CALL-BACK: start of false block
    void* data )                // - COND_STK entry
{
    COND_STK* info = data;      // - COND_STK entry
    SE* posn;                   // - last position

    posn = info->posn_last;
    info->posn_false = callBackCurrent( info );
    FstabSetSvSe( posn );
    _Dump( info, "CallBack(false)" );
}
Exemplo n.º 6
0
static void callBackTrue(       // CALL-BACK: start of true block
    void* data )                // - COND_STK entry
{
    COND_STK* info = data;      // - COND_STK entry
    SE* posn;                   // - current position

    posn = callBackCurrent( info );
    info->posn_true = posn;
    info->posn_false = posn;
    _Dump( info, "CallBack(true)" );
}
Exemplo n.º 7
0
status_t
CDDBLookup::Lookup(CDDBServer& server, const dev_t device, bool dumpOnly,
	bool verbose)
{
	scsi_toc_toc* toc = (scsi_toc_toc*)malloc(kMaxTocSize);
	if (toc == NULL)
		return B_NO_MEMORY;

	uint32 cddbID;
	if (!_ReadTOC(device, &cddbID, toc)) {
		free(toc);
		fprintf(stderr, "Skipping device with id %" B_PRId32 ".\n", device);
		return B_BAD_TYPE;
	}

	printf("Looking up CD with CDDB Id %08" B_PRIx32 ".\n", cddbID);

	BObjectList<QueryResponseData> queryResponses(10, true);
	status_t result = server.Query(cddbID, toc, queryResponses);
	if (result != B_OK) {
		fprintf(stderr, "Error when querying CD: %s\n", strerror(result));
		free(toc);
		return result;
	}

	free(toc);

	const QueryResponseData* diskData = _SelectResult(queryResponses);
	if (diskData == NULL) {
		fprintf(stderr, "Could not find any CD entries in query response.\n");
		return B_BAD_INDEX;
	}

	ReadResponseData readResponse;
	result = server.Read(*diskData, readResponse, verbose);
	if (result != B_OK) {
		fprintf(stderr, "Could not read detailed CD entry from server: %s\n",
			strerror(result));
		return result;
	}

	if (dumpOnly)
		_Dump(readResponse);

	if (!dumpOnly) {
		result = _WriteCDData(device, *diskData, readResponse);
		if (result == B_OK)
			printf("CD data saved.\n");
		else
			fprintf(stderr, "Error writing CD data: %s\n", strerror(result));
	}
	return B_OK;
}
Exemplo n.º 8
0
static void callBackNewCtorEnd( // CALL-BACK: end of new ctor
    void* data )                // - COND_STK entry
{
    COND_STK* cond = data;      // - COND_STK entry

    _Dump( cond, "CallBack(END-NEW_CTOR)" );
    if( cond->posn_true == FstabActualPosn() ) {
        FstabRemove();
        cond->mask_set = 0;
        cond->mask_clr = NOT_BITARR_MASK( 0 );
    }
    callBackFini( cond );
};
Exemplo n.º 9
0
void CondInfoPush(              // PUSH COND_INFO STACK
    FN_CTL* fctl )              // - function control
{
    COND_STK* stk = CarveAlloc( carveInfo );
    stk->offset = FnCtlCondFlagNext( fctl );
    stk->handle_set = NULL;
    stk->handle_clr = NULL;
    stk->mask_set = 0;
    stk->mask_clr = NOT_BITARR_MASK( 0 );
    stk->posn_last = 0;
    stk->posn_true = 0;
    stk->posn_false = 0;
    PstkPush( &stack_cond_blks, stk );
    _Dump( stk, "PUSH" );
}
Exemplo n.º 10
0
status_t
CDDBLookup::Dump(CDDBServer& server, const char* category, const char* cddbID,
	bool verbose)
{
	ReadResponseData readResponse;
	status_t status = server.Read(category, cddbID, "", readResponse, verbose);
	if (status != B_OK) {
		fprintf(stderr, "Could not read detailed CD entry from server: %s\n",
			strerror(status));
		return status;
	}

	_Dump(readResponse);
	return B_OK;
}
Exemplo n.º 11
0
Header::Header(uint64 lastBlock, uint32 blockSize)
	:
	fBlockSize(blockSize),
	fStatus(B_NO_INIT),
	fEntries(NULL)
{
	TRACE(("EFI::Header: Initialize GPT, block size %" B_PRIu32 "\n",
		blockSize));

	// Initialize to an empty header
	memcpy(fHeader.header, EFI_PARTITION_HEADER, sizeof(fHeader.header));
	fHeader.SetRevision(EFI_TABLE_REVISION);
	fHeader.SetHeaderSize(sizeof(fHeader));
	fHeader.SetHeaderCRC(0);
	fHeader.SetAbsoluteBlock(EFI_HEADER_LOCATION);
	fHeader.SetAlternateBlock(lastBlock);
	uuid_t uuid;
	uuid_generate_random(uuid);
	memcpy((uint8*)&fHeader.disk_guid, uuid, sizeof(guid_t));
	fHeader.SetEntriesBlock(EFI_PARTITION_ENTRIES_BLOCK);
	fHeader.SetEntryCount(EFI_PARTITION_ENTRY_COUNT);
	fHeader.SetEntrySize(EFI_PARTITION_ENTRY_SIZE);
	fHeader.SetEntriesCRC(0);

	size_t arraySize = _EntryArraySize();
	fEntries = new (std::nothrow) uint8[arraySize];
	if (fEntries == NULL) {
		fStatus = B_NO_MEMORY;
		return;
	}

	memset(fEntries, 0, arraySize);
		// TODO: initialize the entry guids

	uint32 entryBlocks = (arraySize + fBlockSize - 1) / fBlockSize;
	fHeader.SetFirstUsableBlock(EFI_PARTITION_ENTRIES_BLOCK + entryBlocks);
	fHeader.SetLastUsableBlock(lastBlock - 1 - entryBlocks);

	_SetBackupHeaderFromPrimary(lastBlock);

#ifdef TRACE_EFI_GPT
	_Dump(fHeader);
	_DumpPartitions();
#endif

	fStatus = B_OK;
}
Exemplo n.º 12
0
static void callBackEnd(        // CALL-BACK: end of condition block
    void* data )                // - COND_STK entry
{
    COND_STK* cond = data;      // - COND_STK entry
    SE* posn;                   // - current position

    _Dump( cond, "CallBack(END)" );
    posn = FstabCurrPosn();
#if 0
    if( posn == cond->posn_true
     && posn == cond->posn_false ) {
        cond->mask_set = 0;
        cond->mask_clr = NOT_BITARR_MASK( 0 );
        BlkPosnTempBegSet( posn );
    } else {
#else
    {
#endif
        SE* test = FstabTestFlag( cond->offset
                                , cond->posn_last
                                , posn );
        FstabAdd( test );
        BlkPosnTempBegSet( test );
    }
    callBackFini( cond );
}


static void callBackNewCtorBeg( // CALL-BACK: start of new ctor
    void* data )                // - COND_STK entry
{
    COND_STK* cond = data;      // - COND_STK entry
    SE* posn;                   // - current position
    SE* se;                     // - new test_flag entry

    posn = callBackCurrent( cond );
    DbgVerify( NULL != posn, "callBackNewCtorBeg -- no delete SE" );
    se = FstabTestFlag( cond->offset, posn, FstabPrevious( posn ) );
    cond->posn_true = se;
    FstabAdd( se );
    BlkPosnTempBegSet( se );
}
Exemplo n.º 13
0
Header::Header(int fd, uint64 lastBlock, uint32 blockSize)
	:
	fBlockSize(blockSize),
	fStatus(B_NO_INIT),
	fEntries(NULL)
{
	// TODO: check the correctness of the protective MBR and warn if invalid

	// Read and check the partition table header

	fStatus = _Read(fd, (uint64)EFI_HEADER_LOCATION * blockSize,
		&fHeader, sizeof(efi_table_header));
	if (fStatus == B_OK) {
		if (!_IsHeaderValid(fHeader, EFI_HEADER_LOCATION))
			fStatus = B_BAD_DATA;
	}

	if (fStatus == B_OK && lastBlock != fHeader.AlternateBlock()) {
		dprintf("gpt: alternate header not in last block (%" B_PRIu64 " vs. %"
			B_PRIu64 ")\n", fHeader.AlternateBlock(), lastBlock);
		lastBlock = fHeader.AlternateBlock();
	}

	// Read backup header, too
	status_t status = _Read(fd, lastBlock * blockSize, &fBackupHeader,
		sizeof(efi_table_header));
	if (status == B_OK) {
		if (!_IsHeaderValid(fBackupHeader, lastBlock))
			status = B_BAD_DATA;
	}

	// If both headers are invalid, bail out -- this is probably not a GPT disk
	if (status != B_OK && fStatus != B_OK)
		return;

	if (fStatus != B_OK) {
		// Recreate primary header from the backup
		fHeader = fBackupHeader;
		fHeader.SetAbsoluteBlock(EFI_HEADER_LOCATION);
		fHeader.SetEntriesBlock(EFI_PARTITION_ENTRIES_BLOCK);
		fHeader.SetAlternateBlock(lastBlock);
	} else if (status != B_OK) {
		// Recreate backup header from primary
		_SetBackupHeaderFromPrimary(lastBlock);
	}

	// allocate, read, and check partition entry array

	fEntries = new (std::nothrow) uint8[_EntryArraySize()];
	if (fEntries == NULL) {
		// TODO: if there cannot be allocated enough (ie. the boot loader's
		//	heap is limited), try a smaller size before failing
		fStatus = B_NO_MEMORY;
		return;
	}

	fStatus = _Read(fd, fHeader.EntriesBlock() * blockSize,
		fEntries, _EntryArraySize());
	if (fStatus != B_OK || !_ValidateEntriesCRC()) {
		// Read backup entries instead
		fStatus = _Read(fd, fBackupHeader.EntriesBlock() * blockSize,
			fEntries, _EntryArraySize());
		if (fStatus != B_OK)
			return;

		if (!_ValidateEntriesCRC()) {
			fStatus = B_BAD_DATA;
			return;
		}
	}

	// TODO: check overlapping or out of range partitions

#ifdef TRACE_EFI_GPT
	_Dump(fHeader);
	_Dump(fBackupHeader);
	_DumpPartitions();
#endif

	fStatus = B_OK;
}