From 8d5a0a8ff133f2d334f0ad021d4a67a2d60e0d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Mon, 1 Nov 2010 16:33:25 +0000 Subject: [PATCH] fixed warnings, added a better label for >1TB sized volumes git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39253 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../file_systems/ext2/DirectoryIterator.cpp | 20 +++++++------- .../file_systems/ext2/DirectoryIterator.h | 2 +- .../file_systems/ext2/HTreeEntryIterator.cpp | 10 +++---- .../file_systems/ext2/HTreeEntryIterator.h | 4 +-- .../kernel/file_systems/ext2/Volume.cpp | 27 ++++++++++--------- 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/add-ons/kernel/file_systems/ext2/DirectoryIterator.cpp b/src/add-ons/kernel/file_systems/ext2/DirectoryIterator.cpp index 0d6f6f7e3f..f5420c354c 100644 --- a/src/add-ons/kernel/file_systems/ext2/DirectoryIterator.cpp +++ b/src/add-ons/kernel/file_systems/ext2/DirectoryIterator.cpp @@ -100,9 +100,8 @@ DirectoryIterator::Get(char* name, size_t* _nameLength, ino_t* _id) size_t length = entry->NameLength(); TRACE("block %lu, displacement %lu: entry ino %lu, length %u, " - "name length %lu, type %lu\n", fLogicalBlock, fDisplacement, - entry->InodeID(), entry->Length(), (uint32)length, - (uint32)entry->FileType()); + "name length %lu, type %u\n", fLogicalBlock, fDisplacement, + entry->InodeID(), entry->Length(), length, entry->FileType()); if (*_nameLength > 0) { if (*_nameLength < length) @@ -145,7 +144,7 @@ DirectoryIterator::Next() entry = (ext2_dir_entry*)(block + fDisplacement); do { - TRACE("Checking entry at block %lu, displacement %lu\n", fPhysicalBlock, + TRACE("Checking entry at block %llu, displacement %lu\n", fPhysicalBlock, fDisplacement); if (entry->Length() == 0) { @@ -215,7 +214,7 @@ void DirectoryIterator::Restart() { TRACE("DirectoryIterator::Restart(): (logical, physical, displacement): " - "current: (%lu, %lu, %lu), start: (%lu, %lu, %lu)\n", fLogicalBlock, + "current: (%lu, %llu, %lu), start: (%lu, %llu, %lu)\n", fLogicalBlock, fPhysicalBlock, fDisplacement, fStartLogicalBlock, fStartPhysicalBlock, fStartDisplacement); fLogicalBlock = fStartLogicalBlock; @@ -442,7 +441,7 @@ DirectoryIterator::_AllocateBestEntryInBlock(uint8 nameLength, uint16& pos, return B_DEVICE_FULL; TRACE("DirectoryIterator::_AllocateBestEntryInBlock(): Found a suitable " - "location: %lu\n", (uint32)bestPos); + "location: %u\n", bestPos); pos = bestPos; newLength = bestRealLength; @@ -455,9 +454,8 @@ DirectoryIterator::_AddEntry(Transaction& transaction, const char* name, uint8 nameLength, ino_t id, uint8 type, uint16 newLength, uint16 pos, bool hasPrevious) { - TRACE("DirectoryIterator::_AddEntry(%s, %d, %d, %d, %d, %d, %c)\n", - name, (int)nameLength, (int)id, (int)type, (int)newLength, (int)pos, - hasPrevious ? 't' : 'f'); + TRACE("DirectoryIterator::_AddEntry(%s, %d, %llu, %d, %d, %d, %c)\n", + name, nameLength, id, type, newLength, pos, hasPrevious ? 't' : 'f'); CachedBlock cached(fVolume); uint8* block = cached.SetToWritable(transaction, fPhysicalBlock); @@ -492,8 +490,8 @@ DirectoryIterator::_SplitIndexedBlock(Transaction& transaction, uint32 newBlocksPos, bool firstSplit) { // Block is full, split required - TRACE("DirectoryIterator::_SplitIndexedBlock(.., %s, %u, %lu, %lu, %c)\n", - name, (unsigned int)nameLength, (uint32)id, newBlocksPos, + TRACE("DirectoryIterator::_SplitIndexedBlock(.., %s, %u, %llu, %lu, %c)\n", + name, nameLength, id, newBlocksPos, firstSplit ? 't' : 'f'); // Allocate a buffer for the entries in the block diff --git a/src/add-ons/kernel/file_systems/ext2/DirectoryIterator.h b/src/add-ons/kernel/file_systems/ext2/DirectoryIterator.h index 7652ceff9f..cc8e1f169c 100644 --- a/src/add-ons/kernel/file_systems/ext2/DirectoryIterator.h +++ b/src/add-ons/kernel/file_systems/ext2/DirectoryIterator.h @@ -70,7 +70,7 @@ protected: uint32 fDisplacement; uint32 fPreviousDisplacement; - uint32 fStartPhysicalBlock; + off_t fStartPhysicalBlock; uint32 fStartLogicalBlock; uint32 fStartDisplacement; diff --git a/src/add-ons/kernel/file_systems/ext2/HTreeEntryIterator.cpp b/src/add-ons/kernel/file_systems/ext2/HTreeEntryIterator.cpp index 1693496511..a7d47c8bbf 100644 --- a/src/add-ons/kernel/file_systems/ext2/HTreeEntryIterator.cpp +++ b/src/add-ons/kernel/file_systems/ext2/HTreeEntryIterator.cpp @@ -269,7 +269,7 @@ HTreeEntryIterator::GetNext(uint32& childBlock) uint32 HTreeEntryIterator::BlocksNeededForNewEntry() { - TRACE("HTreeEntryIterator::BlocksNeededForNewEntry(): block num: %lu, " + TRACE("HTreeEntryIterator::BlocksNeededForNewEntry(): block num: %llu, " "volume: %p\n", fBlockNum, fVolume); CachedBlock cached(fVolume); @@ -303,9 +303,9 @@ HTreeEntryIterator::BlocksNeededForNewEntry() status_t HTreeEntryIterator::InsertEntry(Transaction& transaction, uint32 hash, - uint32 blockNum, uint32 newBlocksPos, bool hasCollision) + off_t blockNum, off_t newBlocksPos, bool hasCollision) { - TRACE("HTreeEntryIterator::InsertEntry(): block num: %lu\n", fBlockNum); + TRACE("HTreeEntryIterator::InsertEntry(): block num: %llu\n", fBlockNum); CachedBlock cached(fVolume); uint8* blockData = cached.SetToWritable(transaction, fBlockNum); @@ -345,10 +345,10 @@ HTreeEntryIterator::InsertEntry(Transaction& transaction, uint32 hash, } TRACE("HTreeEntryIterator::InsertEntry(): Inserting node. Count: %u, " - "current entry: %lu\n", (uint16)count, (uint32)fCurrentEntry); + "current entry: %u\n", count, fCurrentEntry); if (count > 0) { - TRACE("HTreeEntryIterator::InsertEntry(): memmove(%lu, %lu, %lu)\n", + TRACE("HTreeEntryIterator::InsertEntry(): memmove(%u, %u, %u)\n", fCurrentEntry + 2, fCurrentEntry + 1, count + fFirstEntry - fCurrentEntry - 1); memmove(&entries[fCurrentEntry + 2], &entries[fCurrentEntry + 1], diff --git a/src/add-ons/kernel/file_systems/ext2/HTreeEntryIterator.h b/src/add-ons/kernel/file_systems/ext2/HTreeEntryIterator.h index 13508222a2..d41d598c64 100644 --- a/src/add-ons/kernel/file_systems/ext2/HTreeEntryIterator.h +++ b/src/add-ons/kernel/file_systems/ext2/HTreeEntryIterator.h @@ -34,8 +34,8 @@ public: uint32 BlocksNeededForNewEntry(); status_t InsertEntry(Transaction& transaction, - uint32 hash, uint32 block, - uint32 newBlocksPos, bool hasCollision); + uint32 hash, off_t block, + off_t newBlocksPos, bool hasCollision); private: HTreeEntryIterator(uint32 block, uint32 blockSize, Inode* directory, diff --git a/src/add-ons/kernel/file_systems/ext2/Volume.cpp b/src/add-ons/kernel/file_systems/ext2/Volume.cpp index a727f3cedf..b86b708e53 100644 --- a/src/add-ons/kernel/file_systems/ext2/Volume.cpp +++ b/src/add-ons/kernel/file_systems/ext2/Volume.cpp @@ -184,7 +184,7 @@ DeviceOpener::GetSize(off_t* _size, uint32* _blockSize) } if (_size) { - *_size = 1LL * geometry.head_count * geometry.cylinder_count + *_size = 1ULL * geometry.head_count * geometry.cylinder_count * geometry.sectors_per_track * geometry.bytes_per_sector; } if (_blockSize) @@ -420,11 +420,15 @@ Volume::Mount(const char* deviceName, uint32 flags) if (!fSuperBlock.name[0]) { // generate a more or less descriptive volume name - uint32 divisor = 1UL << 30; - char unit = 'G'; + off_t divisor = 1ULL << 40; + char unit = 'T'; if (diskSize < divisor) { - divisor = 1UL << 20; - unit = 'M'; + divisor = 1UL << 30; + unit = 'G'; + if (diskSize < divisor) { + divisor = 1UL << 20; + unit = 'M'; + } } double size = double((10 * diskSize + divisor - 1) / divisor); @@ -558,13 +562,12 @@ Volume::GetBlockGroup(int32 index, ext2_block_group** _group) return B_NO_MEMORY; memcpy(fGroupBlocks[blockIndex], block, fBlockSize); - - TRACE("group [%ld]: inode table %ld\n", index, - (fGroupBlocks[blockIndex] + index % fGroupsPerBlock)->InodeTable()); } *_group = (ext2_block_group*)(fGroupBlocks[blockIndex] + (index % fGroupsPerBlock) * fGroupDescriptorSize); + TRACE("group [%ld]: inode table %lld\n", index, + (*_group)->InodeTable(Has64bitFeature())); return B_OK; } @@ -760,10 +763,10 @@ Volume::FreeBlocks(Transaction& transaction, off_t start, uint32 length) if (status != B_OK) return status; - TRACE("Volume::FreeBlocks(): number of free blocks (before): %lu\n", + TRACE("Volume::FreeBlocks(): number of free blocks (before): %llu\n", fFreeBlocks); fFreeBlocks += length; - TRACE("Volume::FreeBlocks(): number of free blocks (after): %lu\n", + TRACE("Volume::FreeBlocks(): number of free blocks (after): %llu\n", fFreeBlocks); return WriteSuperBlock(transaction); @@ -799,8 +802,8 @@ Volume::WriteSuperBlock(Transaction& transaction) fSuperBlock.SetFreeInodes(fFreeInodes); // TODO: Rest of fields that can be modified - TRACE("Volume::WriteSuperBlock(): free blocks: %lu, free inodes: %lu\n", - fSuperBlock.FreeBlocks(), fSuperBlock.FreeInodes()); + TRACE("Volume::WriteSuperBlock(): free blocks: %llu, free inodes: %lu\n", + fSuperBlock.FreeBlocks(Has64bitFeature()), fSuperBlock.FreeInodes()); CachedBlock cached(this); uint8* block = cached.SetToWritable(transaction, fFirstDataBlock);