Manually applied: Fix typos: super block -> superblock (#8974)
by: Przemysław Buczkowski <[email protected]>
This commit is contained in:
@@ -114,7 +114,7 @@ Journal::Journal(Volume* fsVolume, Volume* jVolume)
|
|||||||
fInitStatus = B_NO_MEMORY;
|
fInitStatus = B_NO_MEMORY;
|
||||||
else {
|
else {
|
||||||
fInitStatus = revokeManager->Init();
|
fInitStatus = revokeManager->Init();
|
||||||
|
|
||||||
if (fInitStatus == B_OK) {
|
if (fInitStatus == B_OK) {
|
||||||
fRevokeManager = revokeManager;
|
fRevokeManager = revokeManager;
|
||||||
fInitStatus = _LoadSuperBlock();
|
fInitStatus = _LoadSuperBlock();
|
||||||
@@ -270,7 +270,7 @@ Journal::Unlock(Transaction* owner, bool success)
|
|||||||
{
|
{
|
||||||
TRACE("Journal::Unlock(): Lock recursion: %ld\n",
|
TRACE("Journal::Unlock(): Lock recursion: %ld\n",
|
||||||
recursive_lock_get_recursion(&fLock));
|
recursive_lock_get_recursion(&fLock));
|
||||||
if (fSeparateSubTransactions
|
if (fSeparateSubTransactions
|
||||||
|| recursive_lock_get_recursion(&fLock) == 1) {
|
|| recursive_lock_get_recursion(&fLock) == 1) {
|
||||||
// we only end the transaction if we unlock it
|
// we only end the transaction if we unlock it
|
||||||
if (owner != NULL) {
|
if (owner != NULL) {
|
||||||
@@ -309,7 +309,7 @@ Journal::MapBlock(off_t logical, fsblock_t& physical)
|
|||||||
{
|
{
|
||||||
TRACE("Journal::MapBlock()\n");
|
TRACE("Journal::MapBlock()\n");
|
||||||
physical = logical;
|
physical = logical;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,7 +340,7 @@ Journal::TransactionID() const
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Journal::_WritePartialTransactionToLog(JournalHeader* descriptorBlock,
|
Journal::_WritePartialTransactionToLog(JournalHeader* descriptorBlock,
|
||||||
bool detached, uint8** _escapedData, uint32 &logBlock, off_t& blockNumber,
|
bool detached, uint8** _escapedData, uint32 &logBlock, off_t& blockNumber,
|
||||||
long& cookie, ArrayDeleter<uint8>& escapedDataDeleter, uint32& blockCount,
|
long& cookie, ArrayDeleter<uint8>& escapedDataDeleter, uint32& blockCount,
|
||||||
bool& finished)
|
bool& finished)
|
||||||
@@ -353,7 +353,7 @@ Journal::_WritePartialTransactionToLog(JournalHeader* descriptorBlock,
|
|||||||
JournalBlockTag* tag = (JournalBlockTag*)descriptorBlock->data;
|
JournalBlockTag* tag = (JournalBlockTag*)descriptorBlock->data;
|
||||||
JournalBlockTag* lastTag = (JournalBlockTag*)((uint8*)descriptorBlock
|
JournalBlockTag* lastTag = (JournalBlockTag*)((uint8*)descriptorBlock
|
||||||
+ fBlockSize - sizeof(JournalHeader));
|
+ fBlockSize - sizeof(JournalHeader));
|
||||||
|
|
||||||
finished = false;
|
finished = false;
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
|
|
||||||
@@ -430,11 +430,11 @@ Journal::_WritePartialTransactionToLog(JournalHeader* descriptorBlock,
|
|||||||
}
|
}
|
||||||
|
|
||||||
finished = status != B_OK;
|
finished = status != B_OK;
|
||||||
|
|
||||||
// Write descriptor block
|
// Write descriptor block
|
||||||
--tag;
|
--tag;
|
||||||
tag->SetLastTagFlag();
|
tag->SetLastTagFlag();
|
||||||
|
|
||||||
fsblock_t physicalBlock;
|
fsblock_t physicalBlock;
|
||||||
status = MapBlock(descriptorBlockPos, physicalBlock);
|
status = MapBlock(descriptorBlockPos, physicalBlock);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
@@ -493,14 +493,14 @@ Journal::_WriteTransactionToLog()
|
|||||||
if (size > FreeLogBlocks()) {
|
if (size > FreeLogBlocks()) {
|
||||||
TRACE("Journal::_WriteTransactionToLog(): Syncing block cache\n");
|
TRACE("Journal::_WriteTransactionToLog(): Syncing block cache\n");
|
||||||
cache_sync_transaction(fFilesystemBlockCache, fTransactionID);
|
cache_sync_transaction(fFilesystemBlockCache, fTransactionID);
|
||||||
|
|
||||||
if (size > FreeLogBlocks()) {
|
if (size > FreeLogBlocks()) {
|
||||||
panic("Transaction fits, but sync didn't result in enough"
|
panic("Transaction fits, but sync didn't result in enough"
|
||||||
"free space.\n\tGot %ld when at least %ld was expected.",
|
"free space.\n\tGot %ld when at least %ld was expected.",
|
||||||
FreeLogBlocks(), size);
|
FreeLogBlocks(), size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("Journal::_WriteTransactionToLog(): finished managing space for "
|
TRACE("Journal::_WriteTransactionToLog(): finished managing space for "
|
||||||
"the transaction\n");
|
"the transaction\n");
|
||||||
|
|
||||||
@@ -511,7 +511,7 @@ Journal::_WriteTransactionToLog()
|
|||||||
// Prepare Descriptor block
|
// Prepare Descriptor block
|
||||||
TRACE("Journal::_WriteTransactionToLog(): attempting to allocate space for "
|
TRACE("Journal::_WriteTransactionToLog(): attempting to allocate space for "
|
||||||
"the descriptor block, block size %lu\n", fBlockSize);
|
"the descriptor block, block size %lu\n", fBlockSize);
|
||||||
JournalHeader* descriptorBlock =
|
JournalHeader* descriptorBlock =
|
||||||
(JournalHeader*)new(std::nothrow) uint8[fBlockSize];
|
(JournalHeader*)new(std::nothrow) uint8[fBlockSize];
|
||||||
if (descriptorBlock == NULL) {
|
if (descriptorBlock == NULL) {
|
||||||
TRACE("Journal::_WriteTransactionToLog(): Failed to allocate a buffer "
|
TRACE("Journal::_WriteTransactionToLog(): Failed to allocate a buffer "
|
||||||
@@ -525,7 +525,7 @@ Journal::_WriteTransactionToLog()
|
|||||||
// Prepare Commit block
|
// Prepare Commit block
|
||||||
TRACE("Journal::_WriteTransactionToLog(): attempting to allocate space for "
|
TRACE("Journal::_WriteTransactionToLog(): attempting to allocate space for "
|
||||||
"the commit block, block size %lu\n", fBlockSize);
|
"the commit block, block size %lu\n", fBlockSize);
|
||||||
JournalHeader* commitBlock =
|
JournalHeader* commitBlock =
|
||||||
(JournalHeader*)new(std::nothrow) uint8[fBlockSize];
|
(JournalHeader*)new(std::nothrow) uint8[fBlockSize];
|
||||||
if (descriptorBlock == NULL) {
|
if (descriptorBlock == NULL) {
|
||||||
TRACE("Journal::_WriteTransactionToLog(): Failed to allocate a buffer "
|
TRACE("Journal::_WriteTransactionToLog(): Failed to allocate a buffer "
|
||||||
@@ -555,7 +555,7 @@ Journal::_WriteTransactionToLog()
|
|||||||
uint32 blockCount = 0;
|
uint32 blockCount = 0;
|
||||||
|
|
||||||
uint32 logBlock = _WrapAroundLog(fLogEnd);
|
uint32 logBlock = _WrapAroundLog(fLogEnd);
|
||||||
|
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
|
|
||||||
status = _WritePartialTransactionToLog(descriptorBlock, detached,
|
status = _WritePartialTransactionToLog(descriptorBlock, detached,
|
||||||
@@ -574,10 +574,10 @@ Journal::_WriteTransactionToLog()
|
|||||||
blockCount, finished);
|
blockCount, finished);
|
||||||
if (!finished && status != B_OK)
|
if (!finished && status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
// It is okay to write the commit blocks of the partial transactions
|
// It is okay to write the commit blocks of the partial transactions
|
||||||
// as long as the commit block of the first partial transaction isn't
|
// as long as the commit block of the first partial transaction isn't
|
||||||
// written. When it recovery reaches where the first commit should be
|
// written. When it recovery reaches where the first commit should be
|
||||||
// and doesn't find it, it considers it found the end of the log.
|
// and doesn't find it, it considers it found the end of the log.
|
||||||
|
|
||||||
fsblock_t physicalBlock;
|
fsblock_t physicalBlock;
|
||||||
@@ -586,7 +586,7 @@ Journal::_WriteTransactionToLog()
|
|||||||
return status;
|
return status;
|
||||||
|
|
||||||
off_t logOffset = physicalBlock * fBlockSize;
|
off_t logOffset = physicalBlock * fBlockSize;
|
||||||
|
|
||||||
TRACE("Journal::_WriteTransactionToLog(): Writting commit block to "
|
TRACE("Journal::_WriteTransactionToLog(): Writting commit block to "
|
||||||
"%lld\n", logOffset);
|
"%lld\n", logOffset);
|
||||||
off_t written = write_pos(fJournalVolume->Device(), logOffset,
|
off_t written = write_pos(fJournalVolume->Device(), logOffset,
|
||||||
@@ -598,7 +598,7 @@ Journal::_WriteTransactionToLog()
|
|||||||
|
|
||||||
commitBlock->IncrementSequence();
|
commitBlock->IncrementSequence();
|
||||||
blockCount++;
|
blockCount++;
|
||||||
|
|
||||||
logBlock = _WrapAroundLog(logBlock + 1);
|
logBlock = _WrapAroundLog(logBlock + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -617,7 +617,7 @@ Journal::_WriteTransactionToLog()
|
|||||||
TRACE("Failed to write journal commit block.\n");
|
TRACE("Failed to write journal commit block.\n");
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
blockCount++;
|
blockCount++;
|
||||||
fLogEnd = _WrapAroundLog(fLogEnd + blockCount);
|
fLogEnd = _WrapAroundLog(fLogEnd + blockCount);
|
||||||
|
|
||||||
@@ -670,7 +670,7 @@ Journal::_SaveSuperBlock()
|
|||||||
off_t superblockPos = physicalBlock * fBlockSize;
|
off_t superblockPos = physicalBlock * fBlockSize;
|
||||||
|
|
||||||
JournalSuperBlock superblock;
|
JournalSuperBlock superblock;
|
||||||
size_t bytesRead = read_pos(fJournalVolume->Device(), superblockPos,
|
size_t bytesRead = read_pos(fJournalVolume->Device(), superblockPos,
|
||||||
&superblock, sizeof(superblock));
|
&superblock, sizeof(superblock));
|
||||||
|
|
||||||
if (bytesRead != sizeof(superblock))
|
if (bytesRead != sizeof(superblock))
|
||||||
@@ -678,7 +678,7 @@ Journal::_SaveSuperBlock()
|
|||||||
|
|
||||||
superblock.SetFirstCommitID(fFirstCommitID);
|
superblock.SetFirstCommitID(fFirstCommitID);
|
||||||
superblock.SetLogStart(fLogStart);
|
superblock.SetLogStart(fLogStart);
|
||||||
|
|
||||||
TRACE("Journal::SaveSuperBlock(): Write to %lld\n", superblockPos);
|
TRACE("Journal::SaveSuperBlock(): Write to %lld\n", superblockPos);
|
||||||
size_t bytesWritten = write_pos(fJournalVolume->Device(), superblockPos,
|
size_t bytesWritten = write_pos(fJournalVolume->Device(), superblockPos,
|
||||||
&superblock, sizeof(superblock));
|
&superblock, sizeof(superblock));
|
||||||
@@ -701,10 +701,10 @@ Journal::_LoadSuperBlock()
|
|||||||
status_t status = MapBlock(0, superblockPos);
|
status_t status = MapBlock(0, superblockPos);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
TRACE("Journal::_LoadSuperBlock(): super block physical block: %llu\n",
|
TRACE("Journal::_LoadSuperBlock(): superblock physical block: %llu\n",
|
||||||
superblockPos);
|
superblockPos);
|
||||||
|
|
||||||
JournalSuperBlock superblock;
|
JournalSuperBlock superblock;
|
||||||
size_t bytesRead = read_pos(fJournalVolume->Device(), superblockPos
|
size_t bytesRead = read_pos(fJournalVolume->Device(), superblockPos
|
||||||
* fJournalVolume->BlockSize(), &superblock, sizeof(superblock));
|
* fJournalVolume->BlockSize(), &superblock, sizeof(superblock));
|
||||||
@@ -803,7 +803,7 @@ Journal::_CountTags(JournalHeader* descriptorBlock)
|
|||||||
|
|
||||||
if ((tags->Flags() & JOURNAL_FLAG_LAST_TAG) != 0)
|
if ((tags->Flags() & JOURNAL_FLAG_LAST_TAG) != 0)
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
TRACE("Journal::_CountTags(): counted tags: %lu\n", count);
|
TRACE("Journal::_CountTags(): counted tags: %lu\n", count);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
@@ -824,7 +824,7 @@ Journal::Recover()
|
|||||||
status_t status = _RecoverPassScan(lastCommitID);
|
status_t status = _RecoverPassScan(lastCommitID);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
status = _RecoverPassRevoke(lastCommitID);
|
status = _RecoverPassRevoke(lastCommitID);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
@@ -978,7 +978,7 @@ Journal::_RecoverPassReplay(uint32 lastCommitID)
|
|||||||
"data\n");
|
"data\n");
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayDeleter<uint8> dataDeleter(data);
|
ArrayDeleter<uint8> dataDeleter(data);
|
||||||
|
|
||||||
while (nextCommitID < lastCommitID) {
|
while (nextCommitID < lastCommitID) {
|
||||||
@@ -994,7 +994,7 @@ Journal::_RecoverPassReplay(uint32 lastCommitID)
|
|||||||
JournalBlockTag* last_tag = (JournalBlockTag*)((uint8*)header
|
JournalBlockTag* last_tag = (JournalBlockTag*)((uint8*)header
|
||||||
+ fBlockSize - sizeof(JournalBlockTag));
|
+ fBlockSize - sizeof(JournalBlockTag));
|
||||||
|
|
||||||
for (JournalBlockTag* tag = (JournalBlockTag*)header->data;
|
for (JournalBlockTag* tag = (JournalBlockTag*)header->data;
|
||||||
tag <= last_tag; ++tag) {
|
tag <= last_tag; ++tag) {
|
||||||
nextBlock = _WrapAroundLog(nextBlock + 1);
|
nextBlock = _WrapAroundLog(nextBlock + 1);
|
||||||
|
|
||||||
@@ -1002,7 +1002,7 @@ Journal::_RecoverPassReplay(uint32 lastCommitID)
|
|||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
if (!fRevokeManager->Lookup(tag->BlockNumber(),
|
if (!fRevokeManager->Lookup(tag->BlockNumber(),
|
||||||
nextCommitID)) {
|
nextCommitID)) {
|
||||||
// Block isn't revoked
|
// Block isn't revoked
|
||||||
size_t read = read_pos(fJournalVolume->Device(),
|
size_t read = read_pos(fJournalVolume->Device(),
|
||||||
@@ -1111,7 +1111,7 @@ Journal::_FlushLog(bool canWait, bool flushBlocks)
|
|||||||
TRACE("Journal::_FlushLog(): Finished. Releasing lock\n");
|
TRACE("Journal::_FlushLog(): Finished. Releasing lock\n");
|
||||||
|
|
||||||
recursive_lock_unlock(&fLock);
|
recursive_lock_unlock(&fLock);
|
||||||
|
|
||||||
TRACE("Journal::_FlushLog(): Done, final status: %s\n", strerror(status));
|
TRACE("Journal::_FlushLog(): Done, final status: %s\n", strerror(status));
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -1160,9 +1160,9 @@ Journal::_FullTransactionSize() const
|
|||||||
|
|
||||||
size_t count = cache_blocks_in_transaction(fFilesystemBlockCache,
|
size_t count = cache_blocks_in_transaction(fFilesystemBlockCache,
|
||||||
fTransactionID);
|
fTransactionID);
|
||||||
|
|
||||||
TRACE("\tFull transaction size: %ld\n", count);
|
TRACE("\tFull transaction size: %ld\n", count);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1174,9 +1174,9 @@ Journal::_MainTransactionSize() const
|
|||||||
|
|
||||||
size_t count = cache_blocks_in_main_transaction(fFilesystemBlockCache,
|
size_t count = cache_blocks_in_main_transaction(fFilesystemBlockCache,
|
||||||
fTransactionID);
|
fTransactionID);
|
||||||
|
|
||||||
TRACE("\tMain transaction size: %ld\n", count);
|
TRACE("\tMain transaction size: %ld\n", count);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1200,7 +1200,7 @@ Journal::_TransactionDone(bool success)
|
|||||||
TRACE("Journal::_TransactionDone(): returning B_OK\n");
|
TRACE("Journal::_TransactionDone(): returning B_OK\n");
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If possible, delay flushing the transaction
|
// If possible, delay flushing the transaction
|
||||||
uint32 size = _FullTransactionSize();
|
uint32 size = _FullTransactionSize();
|
||||||
TRACE("Journal::_TransactionDone(): full transaction size: %lu, max "
|
TRACE("Journal::_TransactionDone(): full transaction size: %lu, max "
|
||||||
@@ -1209,11 +1209,11 @@ Journal::_TransactionDone(bool success)
|
|||||||
if (fMaxTransactionSize > 0 && size < fMaxTransactionSize) {
|
if (fMaxTransactionSize > 0 && size < fMaxTransactionSize) {
|
||||||
TRACE("Journal::_TransactionDone(): delaying flush of transaction "
|
TRACE("Journal::_TransactionDone(): delaying flush of transaction "
|
||||||
"%ld\n", fTransactionID);
|
"%ld\n", fTransactionID);
|
||||||
|
|
||||||
// Make sure the transaction fits in the log
|
// Make sure the transaction fits in the log
|
||||||
if (size < FreeLogBlocks())
|
if (size < FreeLogBlocks())
|
||||||
cache_sync_transaction(fFilesystemBlockCache, fTransactionID);
|
cache_sync_transaction(fFilesystemBlockCache, fTransactionID);
|
||||||
|
|
||||||
fUnwrittenTransactions++;
|
fUnwrittenTransactions++;
|
||||||
TRACE("Journal::_TransactionDone(): returning B_OK\n");
|
TRACE("Journal::_TransactionDone(): returning B_OK\n");
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -1253,7 +1253,7 @@ Journal::_TransactionWritten(int32 transactionID, int32 event, void* _logEntry)
|
|||||||
if (journal->_SaveSuperBlock() != B_OK)
|
if (journal->_SaveSuperBlock() != B_OK)
|
||||||
panic("ext2: Failed to write journal superblock\n");
|
panic("ext2: Failed to write journal superblock\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("Journal::_TransactionWritten(): Removing log entry\n");
|
TRACE("Journal::_TransactionWritten(): Removing log entry\n");
|
||||||
journal->fLogEntries.Remove(logEntry);
|
journal->fLogEntries.Remove(logEntry);
|
||||||
|
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ class BlockRunHashtable : public Hashtable
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
memcpy(value,&run,sizeof(block_run));
|
memcpy(value,&run,sizeof(block_run));
|
||||||
|
|
||||||
if (Hashtable::Put(value,value))
|
if (Hashtable::Put(value,value))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
free(value);
|
free(value);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ collectFiles(Disk &disk)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
collectFiles(disk,root);
|
collectFiles(disk,root);
|
||||||
|
|
||||||
printf(" %7Ld files found.\n",gCount);
|
printf(" %7Ld files found.\n",gCount);
|
||||||
|
|
||||||
delete root;
|
delete root;
|
||||||
@@ -201,7 +201,7 @@ checkFiles(Disk &disk,BPlusTree &tree,char *attribute)
|
|||||||
{
|
{
|
||||||
runs[index++] = *run;
|
runs[index++] = *run;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort array to speed up disk access
|
// sort array to speed up disk access
|
||||||
qsort(runs,index,sizeof(block_run),(int (*)(const void *,const void *))compareBlockRuns);
|
qsort(runs,index,sizeof(block_run),(int (*)(const void *,const void *))compareBlockRuns);
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ checkFiles(Disk &disk,BPlusTree &tree,char *attribute)
|
|||||||
delete inode;
|
delete inode;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check indices not based on standard attributes
|
// check indices not based on standard attributes
|
||||||
if (sizeIndex)
|
if (sizeIndex)
|
||||||
{
|
{
|
||||||
@@ -422,7 +422,7 @@ main(int argc,char **argv)
|
|||||||
printUsage(toolName);
|
printUsage(toolName);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*++argv)
|
while (*++argv)
|
||||||
{
|
{
|
||||||
char *arg = *argv;
|
char *arg = *argv;
|
||||||
@@ -447,7 +447,7 @@ main(int argc,char **argv)
|
|||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *attribute = argv[0];
|
char *attribute = argv[0];
|
||||||
if (!gCheckAll && attribute == NULL)
|
if (!gCheckAll && attribute == NULL)
|
||||||
{
|
{
|
||||||
@@ -476,13 +476,13 @@ main(int argc,char **argv)
|
|||||||
fprintf(stderr,"Could not open device or file \"%s\": %s\n",info.device_name,strerror(status));
|
fprintf(stderr,"Could not open device or file \"%s\": %s\n",info.device_name,strerror(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disk.ValidateSuperBlock() < B_OK)
|
if (disk.ValidateSuperBlock() < B_OK)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"The disk's super block is corrupt!\n");
|
fprintf(stderr,"The disk's superblock is corrupt!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Directory *indices = (Directory *)Inode::Factory(&disk,disk.Indices());
|
Directory *indices = (Directory *)Inode::Factory(&disk,disk.Indices());
|
||||||
if (indices == NULL || (status = indices->InitCheck()) < B_OK)
|
if (indices == NULL || (status = indices->InitCheck()) < B_OK)
|
||||||
{
|
{
|
||||||
@@ -497,7 +497,7 @@ main(int argc,char **argv)
|
|||||||
delete indices;
|
delete indices;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
block_run run;
|
block_run run;
|
||||||
|
|
||||||
if (gCheckAll)
|
if (gCheckAll)
|
||||||
@@ -515,7 +515,7 @@ main(int argc,char **argv)
|
|||||||
fprintf(stderr," Could not find index directory for \"%s\"!\n",attribute);
|
fprintf(stderr," Could not find index directory for \"%s\"!\n",attribute);
|
||||||
|
|
||||||
delete indices;
|
delete indices;
|
||||||
|
|
||||||
gHashtable.MakeEmpty(HASH_EMPTY_NONE,HASH_EMPTY_FREE);
|
gHashtable.MakeEmpty(HASH_EMPTY_NONE,HASH_EMPTY_FREE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Copyright (c) 2001-2008 pinc Software. All Rights Reserved.
|
* Copyright (c) 2001-2008 pinc Software. All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//! Handles BFS super block, disk access etc.
|
//! Handles BFS superblock, disk access etc.
|
||||||
|
|
||||||
#include "Disk.h"
|
#include "Disk.h"
|
||||||
#include "dump.h"
|
#include "dump.h"
|
||||||
@@ -157,7 +157,7 @@ Disk::Disk(const char *deviceName, bool rawMode, off_t start, off_t stop)
|
|||||||
|
|
||||||
if (fBufferedFile->ReadAt(512 + fRawDiskOffset, &fSuperBlock,
|
if (fBufferedFile->ReadAt(512 + fRawDiskOffset, &fSuperBlock,
|
||||||
sizeof(disk_super_block)) < 1)
|
sizeof(disk_super_block)) < 1)
|
||||||
fprintf(stderr,"Disk: Could not read super block\n");
|
fprintf(stderr,"Disk: Could not read superblock\n");
|
||||||
|
|
||||||
//dump_super_block(&fSuperBlock);
|
//dump_super_block(&fSuperBlock);
|
||||||
}
|
}
|
||||||
@@ -277,21 +277,21 @@ Disk::ScanForSuperBlock(off_t start, off_t stop)
|
|||||||
printf("\n(%ld) *** BFS superblock found at: %Ld\n",superBlocks.CountItems() + 1,offset);
|
printf("\n(%ld) *** BFS superblock found at: %Ld\n",superBlocks.CountItems() + 1,offset);
|
||||||
dump_super_block(super);
|
dump_super_block(super);
|
||||||
|
|
||||||
// add a copy of the super block to the list
|
// add a copy of the superblock to the list
|
||||||
bfs_disk_info *info = (bfs_disk_info *)malloc(sizeof(bfs_disk_info));
|
bfs_disk_info *info = (bfs_disk_info *)malloc(sizeof(bfs_disk_info));
|
||||||
if (info == NULL)
|
if (info == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
memcpy(&info->super_block, super, sizeof(disk_super_block));
|
memcpy(&info->super_block, super, sizeof(disk_super_block));
|
||||||
info->offset = offset + i - 512;
|
info->offset = offset + i - 512;
|
||||||
/* location off the BFS super block is 512 bytes after the partition start */
|
/* location off the BFS superblock is 512 bytes after the partition start */
|
||||||
superBlocks.AddItem(info);
|
superBlocks.AddItem(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (superBlocks.CountItems() == 0) {
|
if (superBlocks.CountItems() == 0) {
|
||||||
puts("\nCouldn't find any BFS super blocks!");
|
puts("\nCouldn't find any BFS superblocks!");
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,7 +411,7 @@ Disk::RecreateSuperBlock()
|
|||||||
bfs_inode indexDir;
|
bfs_inode indexDir;
|
||||||
bfs_inode rootDir;
|
bfs_inode rootDir;
|
||||||
if (ScanForIndexAndRoot(&indexDir,&rootDir) < B_OK) {
|
if (ScanForIndexAndRoot(&indexDir,&rootDir) < B_OK) {
|
||||||
fprintf(stderr,"ERROR: Could not find root directory! Trying to recreate the super block will have no effect!\n\tSetting standard values for the root dir.\n");
|
fprintf(stderr,"ERROR: Could not find root directory! Trying to recreate the superblock will have no effect!\n\tSetting standard values for the root dir.\n");
|
||||||
rootDir.inode_num.allocation_group = 8;
|
rootDir.inode_num.allocation_group = 8;
|
||||||
rootDir.inode_num.start = 0;
|
rootDir.inode_num.start = 0;
|
||||||
rootDir.inode_num.length = 1;
|
rootDir.inode_num.length = 1;
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ struc BlockRun
|
|||||||
.length resw 1
|
.length resw 1
|
||||||
endstruc
|
endstruc
|
||||||
|
|
||||||
; BFS super block
|
; BFS superblock
|
||||||
struc SuperBlock
|
struc SuperBlock
|
||||||
.name resb 32
|
.name resb 32
|
||||||
.magic1 resd 1
|
.magic1 resd 1
|
||||||
@@ -665,7 +665,7 @@ kBootBlockSignature dw 0xaa55
|
|||||||
|
|
||||||
second_boot_block:
|
second_boot_block:
|
||||||
|
|
||||||
; first comes the BFS super block
|
; first comes the BFS superblock
|
||||||
superblock:
|
superblock:
|
||||||
%rep sizeof(SuperBlock)
|
%rep sizeof(SuperBlock)
|
||||||
db 0
|
db 0
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ count_bits(int value)
|
|||||||
count++;
|
count++;
|
||||||
value >>= 1;
|
value >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ main(int argc, const char *const *argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *fileName = argv[1];
|
const char *fileName = argv[1];
|
||||||
const char *patternString = (argc >= 3 ? argv[2] : "0f");
|
const char *patternString = (argc >= 3 ? argv[2] : "0f");
|
||||||
|
|
||||||
// skip leading "0x" in the pattern string
|
// skip leading "0x" in the pattern string
|
||||||
@@ -151,12 +151,12 @@ main(int argc, const char *const *argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read super block
|
// read superblock
|
||||||
disk_super_block superBlock;
|
disk_super_block superBlock;
|
||||||
read_from(fd, 512, &superBlock, sizeof(superBlock));
|
read_from(fd, 512, &superBlock, sizeof(superBlock));
|
||||||
|
|
||||||
if (superBlock.magic1 != SUPER_BLOCK_MAGIC1) {
|
if (superBlock.magic1 != SUPER_BLOCK_MAGIC1) {
|
||||||
fprintf(stderr, "Error: Bad super block magic. This is probably not a "
|
fprintf(stderr, "Error: Bad superblock magic. This is probably not a "
|
||||||
"BFS image.\n");
|
"BFS image.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -172,12 +172,12 @@ main(int argc, const char *const *argv)
|
|||||||
int64 blockCount = st.st_size / blockSize;
|
int64 blockCount = st.st_size / blockSize;
|
||||||
if (blockCount != superBlock.num_blocks) {
|
if (blockCount != superBlock.num_blocks) {
|
||||||
fprintf(stderr, "Error: Number of blocks in image and the number in "
|
fprintf(stderr, "Error: Number of blocks in image and the number in "
|
||||||
"the super block differ: %lld vs. %lld\n", blockCount,
|
"the superblock differ: %lld vs. %lld\n", blockCount,
|
||||||
superBlock.num_blocks);
|
superBlock.num_blocks);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// iterate through the block bitmap blocks and or the bytes with 0x0f
|
// iterate through the block bitmap blocks and or the bytes with 0x0f
|
||||||
uint8 *block = new uint8[blockSize];
|
uint8 *block = new uint8[blockSize];
|
||||||
int64 occupiedBlocks = 0;
|
int64 occupiedBlocks = 0;
|
||||||
@@ -206,10 +206,10 @@ main(int argc, const char *const *argv)
|
|||||||
|
|
||||||
printf("bfs_fragmenter: marked %lld blocks used\n", occupiedBlocks);
|
printf("bfs_fragmenter: marked %lld blocks used\n", occupiedBlocks);
|
||||||
|
|
||||||
// write back the super block
|
// write back the superblock
|
||||||
superBlock.used_blocks += occupiedBlocks;
|
superBlock.used_blocks += occupiedBlocks;
|
||||||
write_to(fd, 512, &superBlock, sizeof(superBlock));
|
write_to(fd, 512, &superBlock, sizeof(superBlock));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* This file may be used under the terms of the MIT License.
|
* This file may be used under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//! super block, mounting, etc.
|
//! superblock, mounting, etc.
|
||||||
|
|
||||||
|
|
||||||
#include "Debug.h"
|
#include "Debug.h"
|
||||||
@@ -73,7 +73,7 @@ DeviceOpener::~DeviceOpener()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
DeviceOpener::Open(const char *device, int mode)
|
DeviceOpener::Open(const char *device, int mode)
|
||||||
{
|
{
|
||||||
fDevice = open(device, mode);
|
fDevice = open(device, mode);
|
||||||
@@ -93,7 +93,7 @@ DeviceOpener::InitCache(off_t numBlocks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DeviceOpener::RemoveCache(int mode)
|
DeviceOpener::RemoveCache(int mode)
|
||||||
{
|
{
|
||||||
if (!fCached)
|
if (!fCached)
|
||||||
@@ -104,7 +104,7 @@ DeviceOpener::RemoveCache(int mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DeviceOpener::Keep()
|
DeviceOpener::Keep()
|
||||||
{
|
{
|
||||||
fDevice = -1;
|
fDevice = -1;
|
||||||
@@ -115,7 +115,7 @@ DeviceOpener::Keep()
|
|||||||
* to compute the size, or fstat() if that failed.
|
* to compute the size, or fstat() if that failed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DeviceOpener::GetSize(off_t *_size, uint32 *_blockSize)
|
DeviceOpener::GetSize(off_t *_size, uint32 *_blockSize)
|
||||||
{
|
{
|
||||||
device_geometry geometry;
|
device_geometry geometry;
|
||||||
@@ -257,7 +257,7 @@ Volume::IsValidSuperBlock()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Volume::Panic()
|
Volume::Panic()
|
||||||
{
|
{
|
||||||
FATAL(("we have to panic... switch to read-only mode!\n"));
|
FATAL(("we have to panic... switch to read-only mode!\n"));
|
||||||
@@ -313,13 +313,13 @@ Volume::Mount(const char *deviceName, uint32 flags)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// read the super block
|
// read the superblock
|
||||||
if (Identify(fDevice, &fSuperBlock) != B_OK) {
|
if (Identify(fDevice, &fSuperBlock) != B_OK) {
|
||||||
FATAL(("invalid super block!\n"));
|
FATAL(("invalid superblock!\n"));
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize short hands to the super block (to save byte swapping)
|
// initialize short hands to the superblock (to save byte swapping)
|
||||||
fBlockSize = fSuperBlock.BlockSize();
|
fBlockSize = fSuperBlock.BlockSize();
|
||||||
fBlockShift = fSuperBlock.BlockShift();
|
fBlockShift = fSuperBlock.BlockShift();
|
||||||
fAllocationGroupShift = fSuperBlock.AllocationGroupShift();
|
fAllocationGroupShift = fSuperBlock.AllocationGroupShift();
|
||||||
@@ -409,7 +409,7 @@ Volume::Unmount()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Volume::Sync()
|
Volume::Sync()
|
||||||
{
|
{
|
||||||
return fJournal->FlushLogAndBlocks();
|
return fJournal->FlushLogAndBlocks();
|
||||||
@@ -431,7 +431,7 @@ Volume::ValidateBlockRun(block_run run)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
block_run
|
block_run
|
||||||
Volume::ToBlockRun(off_t block) const
|
Volume::ToBlockRun(off_t block) const
|
||||||
{
|
{
|
||||||
block_run run;
|
block_run run;
|
||||||
@@ -456,14 +456,14 @@ Volume::CreateIndicesRoot(Transaction *transaction)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Volume::AllocateForInode(Transaction *transaction, const Inode *parent, mode_t type, block_run &run)
|
Volume::AllocateForInode(Transaction *transaction, const Inode *parent, mode_t type, block_run &run)
|
||||||
{
|
{
|
||||||
return fBlockAllocator.AllocateForInode(transaction, &parent->BlockRun(), type, run);
|
return fBlockAllocator.AllocateForInode(transaction, &parent->BlockRun(), type, run);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Volume::WriteSuperBlock()
|
Volume::WriteSuperBlock()
|
||||||
{
|
{
|
||||||
if (write_pos(fDevice, 512, &fSuperBlock, sizeof(disk_super_block)) != sizeof(disk_super_block))
|
if (write_pos(fDevice, 512, &fSuperBlock, sizeof(disk_super_block)) != sizeof(disk_super_block))
|
||||||
@@ -494,7 +494,7 @@ Volume::UpdateLiveQueries(Inode *inode, const char *attribute, int32 type, const
|
|||||||
* the queries - it wouldn't safe you anything in this case.
|
* the queries - it wouldn't safe you anything in this case.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Volume::CheckForLiveQuery(const char *attribute)
|
Volume::CheckForLiveQuery(const char *attribute)
|
||||||
{
|
{
|
||||||
// ToDo: check for a live query that depends on the specified attribute
|
// ToDo: check for a live query that depends on the specified attribute
|
||||||
@@ -502,7 +502,7 @@ Volume::CheckForLiveQuery(const char *attribute)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Volume::AddQuery(Query *query)
|
Volume::AddQuery(Query *query)
|
||||||
{
|
{
|
||||||
if (fQueryLock.Lock() < B_OK)
|
if (fQueryLock.Lock() < B_OK)
|
||||||
@@ -514,7 +514,7 @@ Volume::AddQuery(Query *query)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Volume::RemoveQuery(Query *query)
|
Volume::RemoveQuery(Query *query)
|
||||||
{
|
{
|
||||||
if (fQueryLock.Lock() < B_OK)
|
if (fQueryLock.Lock() < B_OK)
|
||||||
@@ -537,7 +537,7 @@ Volume::Identify(int fd, disk_super_block *superBlock)
|
|||||||
if (read_pos(fd, 0, buffer, sizeof(buffer)) != sizeof(buffer))
|
if (read_pos(fd, 0, buffer, sizeof(buffer)) != sizeof(buffer))
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
|
|
||||||
// Note: that does work only for x86, for PowerPC, the super block
|
// Note: that does work only for x86, for PowerPC, the superblock
|
||||||
// may be located at offset 0!
|
// may be located at offset 0!
|
||||||
memcpy(superBlock, buffer + 512, sizeof(disk_super_block));
|
memcpy(superBlock, buffer + 512, sizeof(disk_super_block));
|
||||||
if (!superBlock->IsValid()) {
|
if (!superBlock->IsValid()) {
|
||||||
@@ -583,11 +583,11 @@ Volume::Initialize(const char *device, const char *name, uint32 blockSize, uint3
|
|||||||
|
|
||||||
off_t numBlocks = deviceSize / blockSize;
|
off_t numBlocks = deviceSize / blockSize;
|
||||||
|
|
||||||
// create valid super block
|
// create valid superblock
|
||||||
|
|
||||||
fSuperBlock.Initialize(name, numBlocks, blockSize);
|
fSuperBlock.Initialize(name, numBlocks, blockSize);
|
||||||
|
|
||||||
// initialize short hands to the super block (to save byte swapping)
|
// initialize short hands to the superblock (to save byte swapping)
|
||||||
fBlockSize = fSuperBlock.BlockSize();
|
fBlockSize = fSuperBlock.BlockSize();
|
||||||
fBlockShift = fSuperBlock.BlockShift();
|
fBlockShift = fSuperBlock.BlockShift();
|
||||||
fAllocationGroupShift = fSuperBlock.AllocationGroupShift();
|
fAllocationGroupShift = fSuperBlock.AllocationGroupShift();
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
This file contains the code that will create a file system, mount
|
This file contains the code that will create a file system, mount
|
||||||
a file system and unmount a file system.
|
a file system and unmount a file system.
|
||||||
|
|
||||||
THIS CODE COPYRIGHT DOMINIC GIAMPAOLO. NO WARRANTY IS EXPRESSED
|
THIS CODE COPYRIGHT DOMINIC GIAMPAOLO. NO WARRANTY IS EXPRESSED
|
||||||
OR IMPLIED. YOU MAY USE THIS CODE AND FREELY DISTRIBUTE IT FOR
|
OR IMPLIED. YOU MAY USE THIS CODE AND FREELY DISTRIBUTE IT FOR
|
||||||
NON-COMMERCIAL USE AS LONG AS THIS NOTICE REMAINS ATTACHED.
|
NON-COMMERCIAL USE AS LONG AS THIS NOTICE REMAINS ATTACHED.
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ myfs_create_fs(char *device, char *name, int block_size, char *opts)
|
|||||||
printf("block_size %d is not a power of two!\n", block_size);
|
printf("block_size %d is not a power of two!\n", block_size);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
myfs = (myfs_info *)calloc(1, sizeof(myfs_info));
|
myfs = (myfs_info *)calloc(1, sizeof(myfs_info));
|
||||||
if (myfs == NULL) {
|
if (myfs == NULL) {
|
||||||
@@ -73,7 +73,7 @@ myfs_create_fs(char *device, char *name, int block_size, char *opts)
|
|||||||
myfs->fd = -1;
|
myfs->fd = -1;
|
||||||
|
|
||||||
myfs->nsid = (nspace_id)myfs; /* we can only do this when creating */
|
myfs->nsid = (nspace_id)myfs; /* we can only do this when creating */
|
||||||
|
|
||||||
myfs->dsb.magic1 = SUPER_BLOCK_MAGIC1;
|
myfs->dsb.magic1 = SUPER_BLOCK_MAGIC1;
|
||||||
myfs->dsb.magic2 = SUPER_BLOCK_MAGIC2;
|
myfs->dsb.magic2 = SUPER_BLOCK_MAGIC2;
|
||||||
myfs->dsb.magic3 = SUPER_BLOCK_MAGIC3;
|
myfs->dsb.magic3 = SUPER_BLOCK_MAGIC3;
|
||||||
@@ -84,7 +84,7 @@ myfs_create_fs(char *device, char *name, int block_size, char *opts)
|
|||||||
printf("can't create semaphore!\n");
|
printf("can't create semaphore!\n");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
myfs->fd = open(device, O_RDWR);
|
myfs->fd = open(device, O_RDWR);
|
||||||
if (myfs->fd < 0) {
|
if (myfs->fd < 0) {
|
||||||
@@ -126,7 +126,7 @@ myfs_create_fs(char *device, char *name, int block_size, char *opts)
|
|||||||
printf("create storage map failed\n");
|
printf("create storage map failed\n");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myfs_create_inodes(myfs) != 0) {
|
if (myfs_create_inodes(myfs) != 0) {
|
||||||
printf("create inodes failed\n");
|
printf("create inodes failed\n");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -150,7 +150,7 @@ myfs_create_fs(char *device, char *name, int block_size, char *opts)
|
|||||||
printf("creating superblock failed\n");
|
printf("creating superblock failed\n");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
return myfs;
|
return myfs;
|
||||||
|
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ cleanup:
|
|||||||
delete_sem(myfs->sem);
|
delete_sem(myfs->sem);
|
||||||
|
|
||||||
free(myfs);
|
free(myfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -191,13 +191,13 @@ super_block_is_sane(myfs_info *myfs)
|
|||||||
myfs->dsb.magic2 != SUPER_BLOCK_MAGIC2 ||
|
myfs->dsb.magic2 != SUPER_BLOCK_MAGIC2 ||
|
||||||
myfs->dsb.magic3 != SUPER_BLOCK_MAGIC3) {
|
myfs->dsb.magic3 != SUPER_BLOCK_MAGIC3) {
|
||||||
|
|
||||||
printf("warning: super block magic numbers are wrong:\n");
|
printf("warning: superblock magic numbers are wrong:\n");
|
||||||
printf("0x%x (0x%x) 0x%x (0x%x) 0x%x (0x%x)\n",
|
printf("0x%x (0x%x) 0x%x (0x%x) 0x%x (0x%x)\n",
|
||||||
myfs->dsb.magic1, SUPER_BLOCK_MAGIC1,
|
myfs->dsb.magic1, SUPER_BLOCK_MAGIC1,
|
||||||
myfs->dsb.magic2, SUPER_BLOCK_MAGIC2,
|
myfs->dsb.magic2, SUPER_BLOCK_MAGIC2,
|
||||||
myfs->dsb.magic3, SUPER_BLOCK_MAGIC3);
|
myfs->dsb.magic3, SUPER_BLOCK_MAGIC3);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((myfs->dsb.block_size % myfs->dev_block_size) != 0) {
|
if ((myfs->dsb.block_size % myfs->dev_block_size) != 0) {
|
||||||
@@ -214,7 +214,7 @@ super_block_is_sane(myfs_info *myfs)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make sure that the partition is as big as the super block
|
/* make sure that the partition is as big as the superblock
|
||||||
says it is */
|
says it is */
|
||||||
num_dev_blocks = get_num_device_blocks(myfs->fd);
|
num_dev_blocks = get_num_device_blocks(myfs->fd);
|
||||||
if (myfs->dsb.num_blocks * myfs->dsb.block_size >
|
if (myfs->dsb.num_blocks * myfs->dsb.block_size >
|
||||||
@@ -227,7 +227,7 @@ super_block_is_sane(myfs_info *myfs)
|
|||||||
|
|
||||||
if (myfs->dsb.block_size != (1 << myfs->dsb.block_shift)) {
|
if (myfs->dsb.block_size != (1 << myfs->dsb.block_shift)) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
printf("warning: block_shift %d does not match block size %d\n",
|
printf("warning: block_shift %d does not match block size %d\n",
|
||||||
myfs->dsb.block_shift, myfs->dsb.block_size);
|
myfs->dsb.block_shift, myfs->dsb.block_size);
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ myfs_mount(nspace_id nsid, const char *device, ulong flags,
|
|||||||
ret = ENOMEM;
|
ret = ENOMEM;
|
||||||
goto error0;
|
goto error0;
|
||||||
}
|
}
|
||||||
|
|
||||||
myfs->fd = open(device, oflags);
|
myfs->fd = open(device, oflags);
|
||||||
if (myfs->fd < 0) {
|
if (myfs->fd < 0) {
|
||||||
printf("could not open %s to try and mount a myfs\n", device);
|
printf("could not open %s to try and mount a myfs\n", device);
|
||||||
@@ -288,13 +288,13 @@ myfs_mount(nspace_id nsid, const char *device, ulong flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (read_super_block(myfs) != 0) {
|
if (read_super_block(myfs) != 0) {
|
||||||
printf("could not read super block on device %s\n", device);
|
printf("could not read superblock on device %s\n", device);
|
||||||
ret = EBADF;
|
ret = EBADF;
|
||||||
goto error2;
|
goto error2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (super_block_is_sane(myfs) == 0) {
|
if (super_block_is_sane(myfs) == 0) {
|
||||||
printf("bad super block\n");
|
printf("bad superblock\n");
|
||||||
ret = EBADF;
|
ret = EBADF;
|
||||||
goto error2;
|
goto error2;
|
||||||
}
|
}
|
||||||
@@ -377,15 +377,15 @@ myfs_mount(nspace_id nsid, const char *device, ulong flags,
|
|||||||
/*
|
/*
|
||||||
note that the order in which things are done here is *very*
|
note that the order in which things are done here is *very*
|
||||||
important. don't mess with it unless you know what you're doing
|
important. don't mess with it unless you know what you're doing
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
myfs_unmount(void *ns)
|
myfs_unmount(void *ns)
|
||||||
{
|
{
|
||||||
myfs_info *myfs = (myfs_info *)ns;
|
myfs_info *myfs = (myfs_info *)ns;
|
||||||
|
|
||||||
if (myfs == NULL)
|
if (myfs == NULL)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
sync_journal(myfs);
|
sync_journal(myfs);
|
||||||
|
|
||||||
myfs_shutdown_storage_map(myfs);
|
myfs_shutdown_storage_map(myfs);
|
||||||
@@ -405,7 +405,7 @@ myfs_unmount(void *ns)
|
|||||||
shutdown_tmp_blocks(myfs);
|
shutdown_tmp_blocks(myfs);
|
||||||
|
|
||||||
close(myfs->fd);
|
close(myfs->fd);
|
||||||
|
|
||||||
if (myfs->sem > 0)
|
if (myfs->sem > 0)
|
||||||
delete_sem(myfs->sem);
|
delete_sem(myfs->sem);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user