From 2a8d81c2913b3e23f9ea101b5a188411830a3dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Fri, 10 May 2013 19:31:22 +0200 Subject: [PATCH] bfsinfo: fixes 64 bit warnings --- src/bin/bfs_tools/bfsinfo.cpp | 46 ++++++----- src/bin/bfs_tools/lib/BPlusTree.cpp | 13 +-- src/bin/bfs_tools/lib/Bitmap.cpp | 8 +- src/bin/bfs_tools/lib/Disk.cpp | 54 +++++++----- src/bin/bfs_tools/lib/Inode.cpp | 21 ++--- src/bin/bfs_tools/lib/bfs.h | 2 +- src/bin/bfs_tools/lib/dump.cpp | 124 +++++++++++++++------------- 7 files changed, 149 insertions(+), 119 deletions(-) diff --git a/src/bin/bfs_tools/bfsinfo.cpp b/src/bin/bfs_tools/bfsinfo.cpp index 44b64ccda4..4c9a565daf 100644 --- a/src/bin/bfs_tools/bfsinfo.cpp +++ b/src/bin/bfs_tools/bfsinfo.cpp @@ -37,10 +37,10 @@ dump_bplustree(Disk &disk, BPositionIO *file, off_t size, bool hexDump) dump_bplustree_header(header); bplustree_node *node = (bplustree_node *)(buffer + nodeSize); - while ((int32)node < (int32)buffer + size) { + while ((addr_t)node < (addr_t)buffer + size) { printf("\n\n-------------------\n" - "** node at offset: %ld\n** used: %ld bytes\n", - int32(node) - int32(buffer), node->Used()); + "** node at offset: %" B_PRIuADDR "\n** used: %" B_PRId32 " bytes" + "\n", (addr_t)node - (addr_t)buffer, node->Used()); dump_bplustree_node(node, header, &disk); if (hexDump) { @@ -48,7 +48,7 @@ dump_bplustree(Disk &disk, BPositionIO *file, off_t size, bool hexDump) dump_block((char *)node, header->node_size, 0); } - node = (bplustree_node *)(int32(node) + nodeSize); + node = (bplustree_node *)((addr_t)node + nodeSize); } } @@ -79,11 +79,11 @@ dump_indirect_stream(Disk &disk, bfs_inode *node, bool showOffsets) if (runs[i].IsZero()) return; - printf(" indirect[%02ld] = ", i); + printf(" indirect[%02" B_PRId32 "] = ", i); char buffer[256]; if (showOffsets) - snprintf(buffer, sizeof(buffer), " %16lld", offset); + snprintf(buffer, sizeof(buffer), " %16" B_PRIdOFF, offset); else buffer[0] = '\0'; @@ -184,25 +184,27 @@ main(int argc, char **argv) printf(" Name:\t\t\t\"%s\"\n", disk.SuperBlock()->name); printf(" (disk is %s)\n\n", disk.ValidateSuperBlock() == B_OK ? "valid" : "invalid!!"); - printf(" Block Size:\t\t%ld bytes\n", disk.BlockSize()); - printf(" Number of Blocks:\t%12Lu\t%10g MB\n", disk.NumBlocks(), - disk.NumBlocks() * disk.BlockSize() / (1024.0*1024)); + printf(" Block Size:\t\t%" B_PRIu32 " bytes\n", disk.BlockSize()); + printf(" Number of Blocks:\t%12" B_PRIdOFF "\t%10g MB\n", + disk.NumBlocks(), disk.NumBlocks() * disk.BlockSize() + / (1024.0*1024)); if (disk.BlockBitmap() != NULL) { - printf(" Used Blocks:\t\t%12Lu\t%10g MB\n", + printf(" Used Blocks:\t\t%12" B_PRIdOFF "\t%10g MB\n", disk.BlockBitmap()->UsedBlocks(), disk.BlockBitmap()->UsedBlocks() * disk.BlockSize() / (1024.0*1024)); - printf(" Free Blocks:\t\t%12Lu\t%10g MB\n", + printf(" Free Blocks:\t\t%12" B_PRIdOFF "\t%10g MB\n", disk.BlockBitmap()->FreeBlocks(), disk.BlockBitmap()->FreeBlocks() * disk.BlockSize() / (1024.0*1024)); } int32 size = (disk.AllocationGroups() * disk.SuperBlock()->blocks_per_ag); - printf(" Bitmap Size:\t\t%ld bytes (%ld blocks, %ld per allocation " - "group)\n", disk.BlockSize() * size, size, + printf(" Bitmap Size:\t\t%" B_PRIu32 " bytes (%" B_PRId32 " blocks, %" + B_PRId32 " per allocation group)\n", disk.BlockSize() * size, size, disk.SuperBlock()->blocks_per_ag); - printf(" Allocation Groups:\t%lu\n\n", disk.AllocationGroups()); + printf(" Allocation Groups:\t%" B_PRIu32 "\n\n", + disk.AllocationGroups()); dump_block_run(" Log:\t\t\t", disk.Log()); printf(" (was %s)\n\n", disk.SuperBlock()->flags == SUPER_BLOCK_CLEAN ? "cleanly unmounted" : "not unmounted cleanly!"); @@ -260,8 +262,8 @@ main(int argc, char **argv) } if (dumpInode) { - printf("Inode at block %Ld:\n-----------------------------------------" - "\n", disk.ToBlock(run)); + printf("Inode at block %" B_PRIdOFF ":\n------------------------------" + "-----------\n", disk.ToBlock(run)); dump_inode(inode, (bfs_inode *)buffer, showOffsets); dump_indirect_stream(disk, (bfs_inode *)buffer, showOffsets); dump_small_data(inode); @@ -269,8 +271,8 @@ main(int argc, char **argv) } if (dumpBTree && inode) { - printf("B+Tree at block %Ld:\n----------------------------------------" - "-\n", disk.ToBlock(run)); + printf("B+Tree at block %" B_PRIdOFF ":\n-----------------------------" + "------------\n", disk.ToBlock(run)); if (inode->IsDirectory() || inode->IsAttributeDirectory()) { dump_bplustree(disk, (Directory *)inode, inode->Size(), dumpHex); putchar('\n'); @@ -279,8 +281,8 @@ main(int argc, char **argv) } if (validateBTree && inode) { - printf("Validating B+Tree at block %Ld:\n-----------------------------" - "------------\n", disk.ToBlock(run)); + printf("Validating B+Tree at block %" B_PRIdOFF ":\n------------------" + "-----------------------\n", disk.ToBlock(run)); if (inode->IsDirectory() || inode->IsAttributeDirectory()) { BPlusTree *tree; if (((Directory *)inode)->GetTree(&tree) == B_OK) { @@ -294,8 +296,8 @@ main(int argc, char **argv) } if (dumpHex) { - printf("Hexdump from inode at block %Ld:\n-----------------------------" - "------------\n", disk.ToBlock(run)); + printf("Hexdump from inode at block %" B_PRIdOFF ":\n-----------------" + "------------------------\n", disk.ToBlock(run)); dump_block(buffer, disk.BlockSize()); putchar('\n'); } diff --git a/src/bin/bfs_tools/lib/BPlusTree.cpp b/src/bin/bfs_tools/lib/BPlusTree.cpp index 9493593332..60255ebd4f 100644 --- a/src/bin/bfs_tools/lib/BPlusTree.cpp +++ b/src/bin/bfs_tools/lib/BPlusTree.cpp @@ -250,14 +250,14 @@ BPlusTree::Validate(bool verbose) while (true) { if (!stack.Pop(&info)) { if (verbose) { - printf(" %ld B+tree node(s) processed (%ld free node(s)).\n", - count, freeCount); + printf(" %" B_PRId32 " B+tree node(s) processed (%" B_PRId32 + " free node(s)).\n", count, freeCount); } return B_OK; } if (!info.free && verbose && ++count % 10 == 0) - printf(" %ld%s1A\n", count, escape); + printf(" %" B_PRId32 "%s1A\n", count, escape); else if (info.free) freeCount++; @@ -265,7 +265,9 @@ BPlusTree::Validate(bool verbose) if ((node = fCache.Get(info.offset)) == NULL || !info.free && !CheckNode(node)) { if (verbose) { - fprintf(stderr," B+Tree: Could not get data at position %Ld (referenced by node at %Ld)\n",info.offset,info.from); + fprintf(stderr," B+Tree: Could not get data at position %" + B_PRIdOFF " (referenced by node at %" B_PRIdOFF ")\n", + info.offset, info.from); if ((node = fCache.Get(info.from)) != NULL) dump_bplustree_node(node,fHeader); } @@ -350,7 +352,8 @@ status_t BPlusTree::Goto(int8 to) else { if (node->all_key_length > fNodeSize - || (uint32)node->Values() > (uint32)node + fNodeSize - 8 * node->all_key_count) + || (addr_t)node->Values() > (addr_t)node + fNodeSize + - 8 * node->all_key_count) return B_ERROR; pos = *node->Values(); diff --git a/src/bin/bfs_tools/lib/Bitmap.cpp b/src/bin/bfs_tools/lib/Bitmap.cpp index 53567dadca..8fbe8c439c 100644 --- a/src/bin/bfs_tools/lib/Bitmap.cpp +++ b/src/bin/bfs_tools/lib/Bitmap.cpp @@ -138,8 +138,8 @@ Bitmap::BackupSetAt(off_t block, bool used) { uint32 index = block / 32; if (index > fByteSize / 4) { - fprintf(stderr, "Bitmap::BackupSetAt(): Block %Ld outside bitmap!\n", - block); + fprintf(stderr, "Bitmap::BackupSetAt(): Block %" B_PRIdOFF " outside " + "bitmap!\n", block); return false; } @@ -251,7 +251,9 @@ Bitmap::CompareWithBackup() { for (int32 i = fByteSize / 4;i-- > 0;) { if (fBitmap[i] != fBackupBitmap[i]) { - printf("differ at %ld (block %ld) -> bitmap = %08lx, backup = %08lx\n",i,i*32,fBitmap[i],fBackupBitmap[i]); + printf("differ at %" B_PRId32 " (block %" B_PRId32 ") -> bitmap = " + "%08" B_PRIx32 ", backup = %08" B_PRIx32 "\n", i, i * 32, + fBitmap[i], fBackupBitmap[i]); } } return B_OK; diff --git a/src/bin/bfs_tools/lib/Disk.cpp b/src/bin/bfs_tools/lib/Disk.cpp index 5d0fd07f73..b082938ea6 100644 --- a/src/bin/bfs_tools/lib/Disk.cpp +++ b/src/bin/bfs_tools/lib/Disk.cpp @@ -147,8 +147,10 @@ Disk::Disk(const char *deviceName, bool rawMode, off_t start, off_t stop) } close(device); - if (fSize == 0LL) - fprintf(stderr,"Disk: Invalid file size (%Ld bytes)!\n",fSize); + if (fSize == 0LL) { + fprintf(stderr,"Disk: Invalid file size (%" B_PRIdOFF " bytes)!\n", + fSize); + } if (rawMode && ScanForSuperBlock(start, stop) < B_OK) { fFile.Unset(); @@ -240,7 +242,8 @@ Disk::DumpBootBlockToFile() status_t Disk::ScanForSuperBlock(off_t start, off_t stop) { - printf("Disk size %Ld bytes, %.2f GB\n", fSize, 1.0 * fSize / (1024*1024*1024)); + printf("Disk size %" B_PRIdOFF " bytes, %.2f GB\n", fSize, 1.0 * fSize + / (1024*1024*1024)); uint32 blockSize = 4096; char buffer[blockSize + 1024]; @@ -252,12 +255,15 @@ Disk::ScanForSuperBlock(off_t start, off_t stop) BList superBlocks; - printf("Scanning Disk from %Ld to %Ld\n", start, stop); + printf("Scanning Disk from %" B_PRIdOFF " to %" B_PRIdOFF "\n", start, + stop); for (off_t offset = start; offset < stop; offset += blockSize) { - if (((offset-start) % (blockSize * 100)) == 0) - printf(" %12Ld, %.2f GB %s1A\n",offset,1.0 * offset / (1024*1024*1024),escape); + if (((offset-start) % (blockSize * 100)) == 0) { + printf(" %12" B_PRIdOFF ", %.2f GB %s1A\n", offset, + 1.0 * offset / (1024*1024*1024),escape); + } ssize_t bytes = fBufferedFile->ReadAt(offset, buffer, blockSize + 1024); if (bytes < B_OK) @@ -274,7 +280,8 @@ Disk::ScanForSuperBlock(off_t start, off_t stop) && super->magic2 == (int32)SUPER_BLOCK_MAGIC2 && super->magic3 == (int32)SUPER_BLOCK_MAGIC3) { - printf("\n(%ld) *** BFS superblock found at: %Ld\n",superBlocks.CountItems() + 1,offset); + printf("\n(%" B_PRId32 ") *** BFS superblock found at: %" + B_PRIdOFF "\n", superBlocks.CountItems() + 1, offset); dump_super_block(super); // add a copy of the superblock to the list @@ -302,9 +309,10 @@ Disk::ScanForSuperBlock(off_t start, off_t stop) for (int32 i = 0; i < superBlocks.CountItems(); i++) { bfs_disk_info *info = (bfs_disk_info *)superBlocks.ItemAt(i); - printf("%ld) %s, offset %Ld, size %g GB (%svalid)\n", i + 1, - info->super_block.name, info->offset, - 1.0 * info->super_block.num_blocks * info->super_block.block_size / (1024*1024*1024), + printf("%" B_PRId32 ") %s, offset %" B_PRIdOFF ", size %g GB (%svalid)" + "\n", i + 1, info->super_block.name, info->offset, + 1.0 * info->super_block.num_blocks * info->super_block.block_size + / (1024*1024*1024), ValidateSuperBlock(info->super_block) < B_OK ? "in" : ""); } @@ -375,7 +383,7 @@ Disk::ValidateSuperBlock() status_t Disk::RecreateSuperBlock() { - memset(&fSuperBlock,0,sizeof(disk_super_block)); + memset(&fSuperBlock, 0, sizeof(disk_super_block)); puts("\n*** Determine block size"); @@ -383,7 +391,7 @@ Disk::RecreateSuperBlock() if (status < B_OK) return status; - printf("\tblock size = %ld\n",BlockSize()); + printf("\tblock size = %" B_PRId32 "\n", BlockSize()); strcpy(fSuperBlock.name,"recovered"); fSuperBlock.magic1 = SUPER_BLOCK_MAGIC1; @@ -450,7 +458,7 @@ Disk::RecreateSuperBlock() if (fLogStart != ((indexDir.inode_num.allocation_group << fSuperBlock.ag_shift) + indexDir.inode_num.start - LogSize())) { fprintf(stderr,"ERROR: start of logging area doesn't fit assumed value " - "(%Ld blocks before indices)!\n", LogSize()); + "(%" B_PRIdOFF " blocks before indices)!\n", LogSize()); //gErrors++; } @@ -492,8 +500,8 @@ Disk::DetermineBlockSize() // read a quarter of the drive at maximum for (; offset < (fSize >> 2); offset += 1024) { if (fBufferedFile->ReadAt(offset, buffer, sizeof(buffer)) < B_OK) { - fprintf(stderr, "could not read from device (offset = %Ld, " - "size = %ld)!\n", offset, sizeof(buffer)); + fprintf(stderr, "could not read from device (offset = %" B_PRIdOFF + ", size = %ld)!\n", offset, sizeof(buffer)); status = B_IO_ERROR; break; } @@ -551,7 +559,8 @@ Disk::GetNextSpecialInode(char *buffer, off_t *_offset, off_t end, for (; offset < end; offset += BlockSize()) { if (fBufferedFile->ReadAt(offset, buffer, 1024) < B_OK) { - fprintf(stderr,"could not read from device (offset = %Ld, size = %d)!\n",offset,1024); + fprintf(stderr,"could not read from device (offset = %" B_PRIdOFF + ", size = %d)!\n", offset, 1024); *_offset = offset; return B_IO_ERROR; } @@ -576,7 +585,7 @@ Disk::GetNextSpecialInode(char *buffer, off_t *_offset, off_t end, // is the inode a special root inode (parent == self)? if (!memcmp(&inode->parent, &inode->inode_num, sizeof(inode_addr))) { - printf("\t special inode found at %Ld\n", offset); + printf("\t special inode found at %" B_PRIdOFF "\n", offset); *_offset = offset; return B_OK; @@ -596,10 +605,12 @@ Disk::SaveInode(bfs_inode *inode, bool *indices, bfs_inode *indexDir, printf("\troot node found!\n"); if (inode->inode_num.allocation_group != 8 || inode->inode_num.start != 0 - || inode->inode_num.length != 1) - printf("WARNING: root node has unexpected position: (ag = %ld, " - "start = %d, length = %d)\n", inode->inode_num.allocation_group, + || inode->inode_num.length != 1) { + printf("WARNING: root node has unexpected position: (ag = %" + B_PRId32 ", start = %d, length = %d)\n", + inode->inode_num.allocation_group, inode->inode_num.start, inode->inode_num.length); + } if (rootDir) memcpy(rootDir, inode, sizeof(bfs_inode)); } else if (inode->mode & S_INDEX_DIR) { @@ -662,7 +673,8 @@ Disk::ScanForIndexAndRoot(bfs_inode *indexDir,bfs_inode *rootDir) { SaveInode(inode,&indices,indexDir,&root,rootDir); - printf("root node at: 0x%Lx (DiskProbe)\n",logOffset / 512); + printf("root node at: 0x%" B_PRIxOFF " (DiskProbe)\n", + logOffset / 512); //fBufferedFile->ReadAt(logOffset + BlockSize(),buffer,1024); //if (*(uint32 *)buffer == BPLUSTREE_MAGIC) //{ diff --git a/src/bin/bfs_tools/lib/Inode.cpp b/src/bin/bfs_tools/lib/Inode.cpp index 4fab2fd07b..f13b615cc9 100644 --- a/src/bin/bfs_tools/lib/Inode.cpp +++ b/src/bin/bfs_tools/lib/Inode.cpp @@ -276,17 +276,18 @@ Inode::SetName(const char *name) int32 oldLength = nameData == NULL ? 0 : nameData->data_size; int32 newLength = strlen(name) + (nameData == NULL ? sizeof(small_data) + 5 : 0); - if (int32(data) + newLength - oldLength >= (int32)(fInode + fDisk->BlockSize())) + if ((addr_t)data + newLength - oldLength >= (addr_t)(fInode + + fDisk->BlockSize())) return B_NO_MEMORY; if (nameData == NULL) { memmove(newLength + (uint8 *)fInode->small_data_start, fInode->small_data_start, - int32(data) - int32(fInode->small_data_start)); + (addr_t)data - (addr_t)fInode->small_data_start); nameData = fInode->small_data_start; } else { memmove(newLength + (uint8 *)nameData, nameData, - int32(data) - int32(fInode->small_data_start)); + (addr_t)data - (addr_t)fInode->small_data_start); } memset(nameData, 0, sizeof(small_data) + 5 + strlen(name)); @@ -766,7 +767,7 @@ DataStream::ReadAt(off_t pos, void *buffer, size_t size) //printf("DataStream::ReadAt(pos = %Ld,buffer = %p,size = %ld);\n",pos,buffer,size); // truncate size to read - if (pos + size > fInode->data.size) { + if (pos + (off_t)size > fInode->data.size) { if (pos > fInode->data.size) // reading outside the file return B_ERROR; @@ -782,14 +783,14 @@ DataStream::ReadAt(off_t pos, void *buffer, size_t size) if (status < B_OK) return status; - ssize_t bytes = min_c(size, fRunBlockEnd - pos); + ssize_t bytes = min_c((off_t)size, fRunBlockEnd - pos); //printf("### read %ld bytes from %Ld\n### --\n",bytes,fDisk->ToOffset(fRun) + pos - fRunFileOffset); bytes = fDisk->ReadAt(fDisk->ToOffset(fRun) + pos - fRunFileOffset, buffer, bytes); if (bytes <= 0) { if (bytes == 0) { - printf("could not read bytes at: %ld,%d\n", + printf("could not read bytes at: %" B_PRId32 ",%d\n", fRun.allocation_group, fRun.start); } return bytes < 0 ? bytes : B_BAD_DATA; @@ -813,7 +814,7 @@ DataStream::WriteAt(off_t pos, const void *buffer, size_t size) NodeGetter _(this); // FIXME: truncate size -> should enlargen the file - if (pos + size > fInode->data.size) { + if (pos + (off_t)size > fInode->data.size) { if (pos > fInode->data.size) // writing outside the file return B_ERROR; @@ -829,7 +830,7 @@ DataStream::WriteAt(off_t pos, const void *buffer, size_t size) if (status < B_OK) return status; - ssize_t bytes = min_c(size,fRunBlockEnd - pos); + ssize_t bytes = min_c((off_t)size, fRunBlockEnd - pos); //printf("### write %ld bytes to %Ld\n### --\n",bytes,fDisk->ToOffset(fRun) + pos - fRunFileOffset); bytes = fDisk->WriteAt(fDisk->ToOffset(fRun) + pos - fRunFileOffset,buffer,bytes); @@ -959,8 +960,8 @@ File::CopyTo(const char *root, bool fullPath, Inode::Source *source) << (int32)BlockRun().start; path.Append(sub.String()); } - printf("%ld,%d -> %s\n", BlockRun().allocation_group, BlockRun().start, - path.Path()); + printf("%" B_PRId32 ",%d -> %s\n", BlockRun().allocation_group, + BlockRun().start, path.Path()); BFile file; status = file.SetTo(path.Path(), diff --git a/src/bin/bfs_tools/lib/bfs.h b/src/bin/bfs_tools/lib/bfs.h index f2ac852b4b..224e3a0ef3 100644 --- a/src/bin/bfs_tools/lib/bfs.h +++ b/src/bin/bfs_tools/lib/bfs.h @@ -251,7 +251,7 @@ inline small_data *small_data::Next() inline bool small_data::IsLast(bfs_inode *inode) { - return (uint32)this > (uint32)inode + inode->inode_size - sizeof(small_data) + return (addr_t)this > (addr_t)inode + inode->inode_size - sizeof(small_data) || name_size == 0; } diff --git a/src/bin/bfs_tools/lib/dump.cpp b/src/bin/bfs_tools/lib/dump.cpp index 651eeda5fa..caaf851562 100644 --- a/src/bin/bfs_tools/lib/dump.cpp +++ b/src/bin/bfs_tools/lib/dump.cpp @@ -38,7 +38,7 @@ get_tupel(uint32 id) void dump_block_run(const char *prefix, const block_run &run, const char *postfix) { - Print("%s(%ld, %d, %d)%s\n", prefix, run.allocation_group, + Print("%s(%" B_PRId32 ", %d, %d)%s\n", prefix, run.allocation_group, run.start, run.length, postfix); } @@ -48,29 +48,29 @@ dump_super_block(const disk_super_block *superBlock) { Print("disk_super_block:\n"); Print(" name = %s\n", superBlock->name); - Print(" magic1 = %#08lx (%s) %s\n", superBlock->magic1, + Print(" magic1 = %#08" B_PRIx32 " (%s) %s\n", superBlock->magic1, get_tupel(superBlock->magic1), superBlock->magic1 == SUPER_BLOCK_MAGIC1 ? "valid" : "INVALID"); - Print(" fs_byte_order = %#08lx (%s, %s endian)\n", + Print(" fs_byte_order = %#08" B_PRIx32 " (%s, %s endian)\n", superBlock->fs_byte_order, get_tupel(superBlock->fs_byte_order), superBlock->fs_byte_order == SUPER_BLOCK_FS_LENDIAN ? "little" : "big"); - Print(" block_size = %lu\n", superBlock->block_size); - Print(" block_shift = %lu\n", superBlock->block_shift); - Print(" num_blocks = %Lu\n", superBlock->num_blocks); - Print(" used_blocks = %Lu\n", superBlock->used_blocks); - Print(" inode_size = %lu\n", superBlock->inode_size); - Print(" magic2 = %#08lx (%s) %s\n", superBlock->magic2, + Print(" block_size = %" B_PRIu32 "\n", superBlock->block_size); + Print(" block_shift = %" B_PRIu32 "\n", superBlock->block_shift); + Print(" num_blocks = %" B_PRIdOFF "\n", superBlock->num_blocks); + Print(" used_blocks = %" B_PRIdOFF "\n", superBlock->used_blocks); + Print(" inode_size = %" B_PRId32 "\n", superBlock->inode_size); + Print(" magic2 = %#08" B_PRIx32 " (%s) %s\n", superBlock->magic2, get_tupel(superBlock->magic2), superBlock->magic2 == (int)SUPER_BLOCK_MAGIC2 ? "valid" : "INVALID"); - Print(" blocks_per_ag = %lu\n", superBlock->blocks_per_ag); - Print(" ag_shift = %lu\n", superBlock->ag_shift); - Print(" num_ags = %lu\n", superBlock->num_ags); - Print(" flags = %#08lx (%s)\n", superBlock->flags, + Print(" blocks_per_ag = %" B_PRId32 "\n", superBlock->blocks_per_ag); + Print(" ag_shift = %" B_PRId32 "\n", superBlock->ag_shift); + Print(" num_ags = %" B_PRId32 "\n", superBlock->num_ags); + Print(" flags = %#08" B_PRIx32 " (%s)\n", superBlock->flags, get_tupel(superBlock->flags)); dump_block_run(" log_blocks = ", superBlock->log_blocks); - Print(" log_start = %Lu\n", superBlock->log_start); - Print(" log_end = %Lu\n", superBlock->log_end); - Print(" magic3 = %#08lx (%s) %s\n", superBlock->magic3, + Print(" log_start = %" B_PRIdOFF "\n", superBlock->log_start); + Print(" log_end = %" B_PRIdOFF "\n", superBlock->log_end); + Print(" magic3 = %#08" B_PRIx32 " (%s) %s\n", superBlock->magic3, get_tupel(superBlock->magic3), superBlock->magic3 == SUPER_BLOCK_MAGIC3 ? "valid" : "INVALID"); dump_block_run(" root_dir = ", superBlock->root_dir); @@ -91,7 +91,7 @@ dump_data_stream(const bfs_inode *inode, const data_stream *stream, bool showOff char buffer[256]; if (showOffsets) - snprintf(buffer, sizeof(buffer), " %16lld", offset); + snprintf(buffer, sizeof(buffer), " %16" B_PRIdOFF, offset); else buffer[0] = '\0'; @@ -100,21 +100,23 @@ dump_data_stream(const bfs_inode *inode, const data_stream *stream, bool showOff offset += stream->direct[i].length * inode->inode_size; } } - Print(" max_direct_range = %Lu\n", stream->max_direct_range); + Print(" max_direct_range = %" B_PRIdOFF "\n", + stream->max_direct_range); if (!stream->indirect.IsZero()) dump_block_run(" indirect = ", stream->indirect); - Print(" max_indirect_range = %Lu\n", stream->max_indirect_range); + Print(" max_indirect_range = %" B_PRIdOFF "\n", + stream->max_indirect_range); if (!stream->double_indirect.IsZero()) { dump_block_run(" double_indirect = ", stream->double_indirect); } - Print(" max_double_indirect_range = %Lu\n", + Print(" max_double_indirect_range = %" B_PRIdOFF "\n", stream->max_double_indirect_range); - Print(" size = %Lu\n", stream->size); + Print(" size = %" B_PRIdOFF "\n", stream->size); } @@ -126,13 +128,14 @@ dump_inode(const Inode *nameNode, const bfs_inode *inode, bool showOffsets) else Print("inode:\n"); - Print(" magic1 = %08lx (%s) %s\n",inode->magic1, - get_tupel(inode->magic1), (inode->magic1 == INODE_MAGIC1 ? "valid" : "INVALID")); + Print(" magic1 = %08" B_PRIx32 " (%s) %s\n",inode->magic1, + get_tupel(inode->magic1), + (inode->magic1 == INODE_MAGIC1 ? "valid" : "INVALID")); dump_block_run( " inode_num = ",inode->inode_num); - Print(" uid = %lu\n",inode->uid); - Print(" gid = %lu\n",inode->gid); - Print(" mode = %10lo (octal)\n",inode->mode); - Print(" flags = %08lx\n",inode->flags); + Print(" uid = %" B_PRIu32 "\n",inode->uid); + Print(" gid = %" B_PRIu32 "\n",inode->gid); + Print(" mode = %10" B_PRIo32 " (octal)\n",inode->mode); + Print(" flags = %08" B_PRIx32 "\n",inode->flags); time_t time; time = (time_t)(inode->create_time >> 16); @@ -142,9 +145,9 @@ dump_inode(const Inode *nameNode, const bfs_inode *inode, bool showOffsets) dump_block_run( " parent = ",inode->parent); dump_block_run( " attributes = ",inode->attributes); - Print(" type = %lu\n",inode->type); - Print(" inode_size = %lu\n",inode->inode_size); - Print(" etc = %#08lx\n",inode->etc); + Print(" type = %" B_PRIu32 "\n",inode->type); + Print(" inode_size = %" B_PRId32 "\n",inode->inode_size); + Print(" etc = %#08" B_PRIx32 "\n",inode->etc); Print(" short_symlink = %s\n", S_ISLNK(inode->mode) && (inode->flags & INODE_LONG_SYMLINK) == 0 ? inode->short_symlink : "-"); @@ -172,7 +175,8 @@ dump_small_data(Inode *inode) inode->InodeBuffer()->inode_size - sizeof(struct bfs_inode)); while (inode->GetNextSmallData(&item) == B_OK) { - printf("%#08lx (%s), name = \"%s\", ", item->type, get_tupel(item->type), item->Name()); + printf("%#08" B_PRIx32 " (%s), name = \"%s\", ", item->type, + get_tupel(item->type), item->Name()); if (item->type == FILE_NAME_TYPE || item->type == B_STRING_TYPE || item->type == B_MIME_STRING_TYPE) @@ -187,15 +191,19 @@ void dump_bplustree_header(const bplustree_header* header) { printf("bplustree_header:\n"); - printf(" magic = %#08lx (%s) %s\n", header->magic, - get_tupel(header->magic), + printf(" magic = %#08" B_PRIx32 " (%s) %s\n", + header->magic, get_tupel(header->magic), header->magic == BPLUSTREE_MAGIC ? "valid" : "INVALID"); - printf(" node_size = %lu\n", header->node_size); - printf(" max_number_of_levels = %lu\n", header->max_number_of_levels); - printf(" data_type = %lu\n", header->data_type); - printf(" root_node_pointer = %Ld\n", header->root_node_pointer); - printf(" free_node_pointer = %Ld\n", header->free_node_pointer); - printf(" maximum_size = %Lu\n", header->maximum_size); + printf(" node_size = %" B_PRIu32 "\n", header->node_size); + printf(" max_number_of_levels = %" B_PRIu32 "\n", + header->max_number_of_levels); + printf(" data_type = %" B_PRIu32 "\n", header->data_type); + printf(" root_node_pointer = %" B_PRIdOFF "\n", + header->root_node_pointer); + printf(" free_node_pointer = %" B_PRIdOFF "\n", + header->free_node_pointer); + printf(" maximum_size = %" B_PRIdOFF "\n", + header->maximum_size); } @@ -205,9 +213,9 @@ dump_bplustree_node(const bplustree_node* node, const bplustree_header* header, { Print("bplustree_node (%s node):\n", node->overflow_link == BPLUSTREE_NULL ? "leaf" : "index"); - Print(" left_link = %Ld\n", node->left_link); - Print(" right_link = %Ld\n", node->right_link); - Print(" overflow_link = %Ld\n", node->overflow_link); + Print(" left_link = %" B_PRIdOFF "\n", node->left_link); + Print(" right_link = %" B_PRIdOFF "\n", node->right_link); + Print(" overflow_link = %" B_PRIdOFF "\n", node->overflow_link); Print(" all_key_count = %u\n", node->all_key_count); Print(" all_key_length = %u\n", node->all_key_length); @@ -226,7 +234,7 @@ dump_bplustree_node(const bplustree_node* node, const bplustree_header* header, uint16 length; char* key = (char *)node->KeyAt(i, &length); if (length > 255) { - Print(" %2ld. Invalid length (%u)!!\n", i, length); + Print(" %2" B_PRId32 ". Invalid length (%u)!!\n", i, length); dump_block((char *)node, header->node_size, sizeof(off_t)); break; } @@ -236,33 +244,35 @@ dump_bplustree_node(const bplustree_node* node, const bplustree_header* header, buffer[length] = '\0'; off_t *value = node->Values() + i; - if ((uint32)value < (uint32)node || (uint32)value > (uint32)node + header->node_size) - Print(" %2ld. Invalid Offset!!\n",i); - else { - Print(" %2ld. ",i); + if ((addr_t)value < (addr_t)node + || (addr_t)value > (addr_t)node + header->node_size) { + Print(" %2" B_PRId32 ". Invalid Offset!!\n", i); + } else { + Print(" %2" B_PRId32 ". ",i); if (header->data_type == BPLUSTREE_STRING_TYPE) Print("\"%s\"",buffer); else if (header->data_type == BPLUSTREE_INT32_TYPE) { - Print("int32 = %ld (0x%lx)", *(int32 *)&buffer, - *(int32 *)&buffer); + Print("int32 = %" B_PRId32 " (0x%" B_PRIx32 ")", + *(int32 *)&buffer, *(int32 *)&buffer); } else if (header->data_type == BPLUSTREE_UINT32_TYPE) { - Print("uint32 = %lu (0x%lx)", *(uint32 *)&buffer, - *(uint32 *)&buffer); + Print("uint32 = %" B_PRIu32 " (0x%" B_PRIx32 ")", + *(uint32 *)&buffer, *(uint32 *)&buffer); } else if (header->data_type == BPLUSTREE_INT64_TYPE) { - Print("int64 = %Ld (0x%Lx)", *(int64 *)&buffer, - *(int64 *)&buffer); + Print("int64 = %" B_PRId64 " (0x%" B_PRIx64 ")", + *(int64 *)&buffer, *(int64 *)&buffer); } else Print("???"); off_t offset = *value & 0x3fffffffffffffffLL; - Print(" (%d bytes) -> %Ld",length,offset); + Print(" (%d bytes) -> %" B_PRIdOFF,length,offset); if (disk != NULL) { block_run run = disk->ToBlockRun(offset); - Print(" (%ld, %d)", run.allocation_group, run.start); + Print(" (%" B_PRId32 ", %d)", run.allocation_group, run.start); } if (bplustree_node::LinkType(*value) == BPLUSTREE_DUPLICATE_FRAGMENT) { - Print(" (duplicate fragment %Ld)\n", *value & 0x3ff); + Print(" (duplicate fragment %" B_PRIdOFF ")\n", + *value & 0x3ff); } else if (bplustree_node::LinkType(*value) == BPLUSTREE_DUPLICATE_NODE) { Print(" (duplicate node)\n"); @@ -310,7 +320,7 @@ dump_block(const char *buffer, uint32 size, int8 valueSize) for (uint32 offset = start; offset < start + kBlockSize; offset += valueSize) { if (valueSize == sizeof(off_t)) - Print("%s%Ld", offset == start ? "" : ", ", + Print("%s%" B_PRIdOFF, offset == start ? "" : ", ", *(off_t *)(buffer + offset)); } Print(")");