From dec5683e9c5edd9259e2bcebc2b5804d1fdd4082 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 31 Oct 2018 20:10:39 +0100 Subject: [PATCH] Snazz up the kprintf() output a bit by giving it its own color. --- ELFLoader/ELFLoader.cpp | 14 ++-- ELFLoader/ExecSpace.cpp | 2 +- Kernel/IDEDiskDevice.cpp | 2 +- Kernel/MemoryManager.cpp | 18 +++-- Kernel/VirtualConsole.cpp | 5 +- Kernel/init.cpp | 4 +- LibC/pwd.cpp | 1 + VirtualFileSystem/Ext2FileSystem.cpp | 90 +++++++++++------------ VirtualFileSystem/SyntheticFileSystem.cpp | 6 +- VirtualFileSystem/VirtualFileSystem.cpp | 22 +++--- 10 files changed, 86 insertions(+), 78 deletions(-) diff --git a/ELFLoader/ELFLoader.cpp b/ELFLoader/ELFLoader.cpp index a4b4614e16..5bac37265e 100644 --- a/ELFLoader/ELFLoader.cpp +++ b/ELFLoader/ELFLoader.cpp @@ -37,7 +37,7 @@ bool ELFLoader::load() bool ELFLoader::layout() { #ifdef ELFLOADER_DEBUG - kprintf("[ELFLoader] Layout\n"); + kprintf("ELFLoader: Layout\n"); #endif bool failed = false; dword highestOffset = 0; @@ -49,13 +49,13 @@ bool ELFLoader::layout() } }); #ifdef ELFLOADER_DEBUG - kprintf("[ELFLoader] Highest section offset: %u, Size needed: %u\n", highestOffset, sizeNeeded); + kprintf("ELFLoader: Highest section offset: %u, Size needed: %u\n", highestOffset, sizeNeeded); #endif m_execSpace.allocateUniverse(sizeNeeded); m_image->forEachSectionOfType(SHT_PROGBITS, [this, &failed] (const ELFImage::Section& section) { #ifdef ELFLOADER_DEBUG - kprintf("[ELFLoader] Allocating progbits section: %s\n", section.name()); + kprintf("ELFLoader: Allocating progbits section: %s\n", section.name()); #endif if (!section.size()) return true; @@ -71,7 +71,7 @@ bool ELFLoader::layout() }); m_image->forEachSectionOfType(SHT_NOBITS, [this, &failed] (const ELFImage::Section& section) { #ifdef ELFLOADER_DEBUG - kprintf("[ELFLoader] Allocating nobits section: %s\n", section.name()); + kprintf("ELFLoader: Allocating nobits section: %s\n", section.name()); #endif if (!section.size()) return true; @@ -111,7 +111,7 @@ char* ELFLoader::areaForSectionName(const char* name) bool ELFLoader::performRelocations() { #ifdef ELFLOADER_DEBUG - kprintf("[ELFLoader] Performing relocations\n"); + kprintf("ELFLoader: Performing relocations\n"); #endif bool failed = false; @@ -134,7 +134,7 @@ bool ELFLoader::performRelocations() } ptrdiff_t relativeOffset = (char*)targetPtr - ((char*)&patchPtr + 4); #ifdef ELFLOADER_DEBUG - kprintf("[ELFLoader] Relocate PC32: offset=%x, symbol=%u(%s) value=%x target=%p, offset=%d\n", + kprintf("ELFLoader: Relocate PC32: offset=%x, symbol=%u(%s) value=%x target=%p, offset=%d\n", relocation.offset(), symbol.index(), symbol.name(), @@ -148,7 +148,7 @@ bool ELFLoader::performRelocations() } case R_386_32: { #ifdef ELFLOADER_DEBUG - kprintf("[ELFLoader] Relocate Abs32: symbol=%u(%s), value=%x, section=%s\n", + kprintf("ELFLoader: Relocate Abs32: symbol=%u(%s), value=%x, section=%s\n", symbol.index(), symbol.name(), symbol.value(), diff --git a/ELFLoader/ExecSpace.cpp b/ELFLoader/ExecSpace.cpp index 9a751495e0..135627db38 100644 --- a/ELFLoader/ExecSpace.cpp +++ b/ELFLoader/ExecSpace.cpp @@ -46,7 +46,7 @@ bool ExecSpace::loadELF(MappedFile&& file) if (!loader.load()) return false; #ifdef EXECSPACE_DEBUG - kprintf("[ExecSpace] ELF loaded, symbol map now:\n"); + kprintf("ExecSpace: ELF loaded, symbol map now:\n"); for (auto& s : m_symbols) { kprintf("> %p: %s (%u)\n", s.value.ptr, diff --git a/Kernel/IDEDiskDevice.cpp b/Kernel/IDEDiskDevice.cpp index 0ad82540ca..b30a2147a6 100644 --- a/Kernel/IDEDiskDevice.cpp +++ b/Kernel/IDEDiskDevice.cpp @@ -34,7 +34,7 @@ bool IDEDiskDevice::writeBlock(unsigned index, const byte* data) { (void) index; (void) data; - kprintf("[IDEDiskDevice] writeBlock not implemented()\n"); + kprintf("IDEDiskDevice: writeBlock not implemented()\n"); notImplemented(); return false; } diff --git a/Kernel/MemoryManager.cpp b/Kernel/MemoryManager.cpp index 9a23f9da56..0f655acdbd 100644 --- a/Kernel/MemoryManager.cpp +++ b/Kernel/MemoryManager.cpp @@ -34,7 +34,9 @@ void MemoryManager::initializePaging() memset(m_pageTableOne, 0, 4096); memset(m_pageDirectory, 0, 4096); - kprintf("[MM] Page directory @ %p\n", m_pageDirectory); +#ifdef MM_DEBUG + kprintf("MM: Page directory @ %p\n", m_pageDirectory); +#endif // Make null dereferences crash. protectMap(LinearAddress(0), 4 * KB); @@ -69,7 +71,9 @@ auto MemoryManager::ensurePTE(LinearAddress linearAddress) -> PageTableEntry PageDirectoryEntry pde = PageDirectoryEntry(&m_pageDirectory[pageDirectoryIndex]); if (!pde.isPresent()) { - kprintf("[MM] PDE %u not present, allocating\n", pageDirectoryIndex); +#ifdef MM_DEBUG + kprintf("MM: PDE %u not present, allocating\n", pageDirectoryIndex); +#endif if (pageDirectoryIndex == 0) { pde.setPageTableBase((dword)m_pageTableZero); pde.setUserAllowed(true); @@ -82,7 +86,7 @@ auto MemoryManager::ensurePTE(LinearAddress linearAddress) -> PageTableEntry pde.setWritable(true); } else { auto* pageTable = allocatePageTable(); - kprintf("[MM] Allocated page table #%u (for laddr=%p) at %p\n", pageDirectoryIndex, linearAddress.get(), pageTable); + kprintf("MM: Allocated page table #%u (for laddr=%p) at %p\n", pageDirectoryIndex, linearAddress.get(), pageTable); memset(pageTable, 0, 4096); pde.setPageTableBase((dword)pageTable); pde.setUserAllowed(true); @@ -131,7 +135,7 @@ void MemoryManager::initialize() PageFaultResponse MemoryManager::handlePageFault(const PageFault& fault) { ASSERT_INTERRUPTS_DISABLED(); - kprintf("[MM] handlePageFault(%w) at laddr=%p\n", fault.code(), fault.address().get()); + kprintf("MM: handlePageFault(%w) at laddr=%p\n", fault.code(), fault.address().get()); if (fault.isNotPresent()) { kprintf(" >> NP fault!\n"); } else if (fault.isProtectionViolation()) { @@ -169,7 +173,7 @@ RetainPtr MemoryManager::createZone(size_t size) InterruptDisabler disabler; auto pages = allocatePhysicalPages(ceilDiv(size, PAGE_SIZE)); if (pages.isEmpty()) { - kprintf("[MM] createZone: no physical pages for size %u\n", size); + kprintf("MM: createZone: no physical pages for size %u\n", size); return nullptr; } return adopt(*new Zone(move(pages))); @@ -192,7 +196,7 @@ byte* MemoryManager::quickMapOnePage(PhysicalAddress physicalAddress) { ASSERT_INTERRUPTS_DISABLED(); auto pte = ensurePTE(LinearAddress(4 * MB)); - kprintf("[MM] quickmap %x @ %x {pte @ %p}\n", physicalAddress.get(), 4*MB, pte.ptr()); + kprintf("MM: quickmap %x @ %x {pte @ %p}\n", physicalAddress.get(), 4*MB, pte.ptr()); pte.setPhysicalPageBase(physicalAddress.pageBase()); pte.setPresent(true); pte.setWritable(true); @@ -319,7 +323,7 @@ bool MemoryManager::mapRegionsForTask(Task& task) bool copyToZone(Zone& zone, const void* data, size_t size) { if (zone.size() < size) { - kprintf("[MM] copyToZone: can't fit %u bytes into zone with size %u\n", size, zone.size()); + kprintf("MM: copyToZone: can't fit %u bytes into zone with size %u\n", size, zone.size()); return false; } diff --git a/Kernel/VirtualConsole.cpp b/Kernel/VirtualConsole.cpp index 3a3dcc77bb..eea5bb2bb7 100644 --- a/Kernel/VirtualConsole.cpp +++ b/Kernel/VirtualConsole.cpp @@ -44,7 +44,7 @@ void VirtualConsole::switchTo(unsigned index) { if ((int)index == s_activeConsole) return; - dbgprintf("[VC] Switch to %u (%p)\n", index, s_consoles[index]); + dbgprintf("VC: Switch to %u (%p)\n", index, s_consoles[index]); ASSERT(index < 6); ASSERT(s_consoles[index]); InterruptDisabler disabler; @@ -387,7 +387,10 @@ void VirtualConsole::onKeyPress(byte ch) void VirtualConsole::onConsoleReceive(byte ch) { + auto old_attribute = m_currentAttribute; + m_currentAttribute = 0x03; onChar(ch, false); + m_currentAttribute = old_attribute; } void VirtualConsole::onTTYWrite(byte ch) diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 115eafe35c..ea510179bf 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -100,8 +100,6 @@ static void undertaker_main() static void init_stage2() NORETURN; static void init_stage2() { - kprintf("init stage2...\n"); - Syscall::initialize(); Disk::initialize(); @@ -229,6 +227,8 @@ void init() tty3 = new VirtualConsole(3); VirtualConsole::switchTo(0); + kprintf("Starting Serenity Operating System...\n"); + MemoryManager::initialize(); VirtualFileSystem::initializeGlobals(); diff --git a/LibC/pwd.cpp b/LibC/pwd.cpp index 5ce0c360c1..99325ff516 100644 --- a/LibC/pwd.cpp +++ b/LibC/pwd.cpp @@ -25,6 +25,7 @@ void setpwent() } else { __pwdb_stream = fopen("/etc/passwd", "r"); __pwdb_entry = (struct passwd_with_strings*)mmap(nullptr, getpagesize()); + set_mmap_name(__pwdb_entry, getpagesize(), "setpwent"); } } diff --git a/VirtualFileSystem/Ext2FileSystem.cpp b/VirtualFileSystem/Ext2FileSystem.cpp index 24c9bdd2ba..efcabe46dc 100644 --- a/VirtualFileSystem/Ext2FileSystem.cpp +++ b/VirtualFileSystem/Ext2FileSystem.cpp @@ -92,8 +92,8 @@ const ext2_group_desc& Ext2FileSystem::blockGroupDescriptor(unsigned groupIndex) unsigned blocksToRead = ceilDiv(m_blockGroupCount * (unsigned)sizeof(ext2_group_desc), blockSize()); unsigned firstBlockOfBGDT = blockSize() == 1024 ? 2 : 1; #ifdef EXT2_DEBUG - kprintf("[ext2fs] block group count: %u, blocks-to-read: %u\n", m_blockGroupCount, blocksToRead); - kprintf("[ext2fs] first block of BGDT: %u\n", firstBlockOfBGDT); + kprintf("ext2fs: block group count: %u, blocks-to-read: %u\n", m_blockGroupCount, blocksToRead); + kprintf("ext2fs: first block of BGDT: %u\n", firstBlockOfBGDT); #endif m_cachedBlockGroupDescriptorTable = readBlocks(firstBlockOfBGDT, blocksToRead); } @@ -104,20 +104,20 @@ bool Ext2FileSystem::initialize() { auto& superBlock = this->superBlock(); #ifdef EXT2_DEBUG - kprintf("[ext2fs] super block magic: %x (super block size: %u)\n", superBlock.s_magic, sizeof(ext2_super_block)); + kprintf("ext2fs: super block magic: %x (super block size: %u)\n", superBlock.s_magic, sizeof(ext2_super_block)); #endif if (superBlock.s_magic != EXT2_SUPER_MAGIC) return false; #ifdef EXT2_DEBUG - kprintf("[ext2fs] %u inodes, %u blocks\n", superBlock.s_inodes_count, superBlock.s_blocks_count); - kprintf("[ext2fs] block size = %u\n", EXT2_BLOCK_SIZE(&superBlock)); - kprintf("[ext2fs] first data block = %u\n", superBlock.s_first_data_block); - kprintf("[ext2fs] inodes per block = %u\n", inodesPerBlock()); - kprintf("[ext2fs] inodes per group = %u\n", inodesPerGroup()); - kprintf("[ext2fs] free inodes = %u\n", superBlock.s_free_inodes_count); - kprintf("[ext2fs] desc per block = %u\n", EXT2_DESC_PER_BLOCK(&superBlock)); - kprintf("[ext2fs] desc size = %u\n", EXT2_DESC_SIZE(&superBlock)); + kprintf("ext2fs: %u inodes, %u blocks\n", superBlock.s_inodes_count, superBlock.s_blocks_count); + kprintf("ext2fs: block size = %u\n", EXT2_BLOCK_SIZE(&superBlock)); + kprintf("ext2fs: first data block = %u\n", superBlock.s_first_data_block); + kprintf("ext2fs: inodes per block = %u\n", inodesPerBlock()); + kprintf("ext2fs: inodes per group = %u\n", inodesPerGroup()); + kprintf("ext2fs: free inodes = %u\n", superBlock.s_free_inodes_count); + kprintf("ext2fs: desc per block = %u\n", EXT2_DESC_PER_BLOCK(&superBlock)); + kprintf("ext2fs: desc size = %u\n", EXT2_DESC_SIZE(&superBlock)); #endif setBlockSize(EXT2_BLOCK_SIZE(&superBlock)); @@ -125,14 +125,14 @@ bool Ext2FileSystem::initialize() m_blockGroupCount = ceilDiv(superBlock.s_blocks_count, superBlock.s_blocks_per_group); if (m_blockGroupCount == 0) { - kprintf("[ext2fs] no block groups :(\n"); + kprintf("ext2fs: no block groups :(\n"); return false; } #ifdef EXT2_DEBUG for (unsigned i = 1; i <= m_blockGroupCount; ++i) { auto& group = blockGroupDescriptor(i); - kprintf("[ext2fs] group[%u] { block_bitmap: %u, inode_bitmap: %u, inode_table: %u }\n", + kprintf("ext2fs: group[%u] { block_bitmap: %u, inode_bitmap: %u, inode_table: %u }\n", i, group.bg_block_bitmap, group.bg_inode_bitmap, @@ -314,7 +314,7 @@ Unix::ssize_t Ext2FileSystem::readInodeBytes(InodeIdentifier inode, Unix::off_t auto e2inode = lookupExt2Inode(inode.index()); if (!e2inode) { - kprintf("[ext2fs] readInodeBytes: metadata lookup for inode %u failed\n", inode.index()); + kprintf("ext2fs: readInodeBytes: metadata lookup for inode %u failed\n", inode.index()); return -EIO; } @@ -340,7 +340,7 @@ Unix::ssize_t Ext2FileSystem::readInodeBytes(InodeIdentifier inode, Unix::off_t // It needs to be cached! auto list = blockListForInode(*e2inode); if (list.isEmpty()) { - kprintf("[ext2fs] readInodeBytes: empty block list for inode %u\n", inode.index()); + kprintf("ext2fs: readInodeBytes: empty block list for inode %u\n", inode.index()); return -EIO; } @@ -362,7 +362,7 @@ Unix::ssize_t Ext2FileSystem::readInodeBytes(InodeIdentifier inode, Unix::off_t for (dword bi = firstBlockLogicalIndex; bi <= lastBlockLogicalIndex; ++bi) { auto block = readBlock(list[bi]); if (!block) { - kprintf("[ext2fs] readInodeBytes: readBlock(%u) failed (lbi: %u)\n", list[bi], bi); + kprintf("ext2fs: readInodeBytes: readBlock(%u) failed (lbi: %u)\n", list[bi], bi); return -EIO; } @@ -389,7 +389,7 @@ bool Ext2FileSystem::writeInode(InodeIdentifier inode, const ByteBuffer& data) auto e2inode = lookupExt2Inode(inode.index()); if (!e2inode) { - kprintf("[ext2fs] writeInode: metadata lookup for inode %u failed\n", inode.index()); + kprintf("ext2fs: writeInode: metadata lookup for inode %u failed\n", inode.index()); return false; } @@ -404,7 +404,7 @@ bool Ext2FileSystem::writeInode(InodeIdentifier inode, const ByteBuffer& data) auto list = blockListForInode(*e2inode); if (list.isEmpty()) { - kprintf("[ext2fs] writeInode: empty block list for inode %u\n", inode.index()); + kprintf("ext2fs: writeInode: empty block list for inode %u\n", inode.index()); return false; } @@ -424,7 +424,7 @@ bool Ext2FileSystem::enumerateDirectoryInode(InodeIdentifier inode, Functioni_mode)); //#ifdef EXT2_DEBUG - kprintf("[ext2fs] Adding inode %u with name '%s' to directory %u\n", inode, name.characters(), directoryInode); + kprintf("ext2fs: Adding inode %u with name '%s' to directory %u\n", inode, name.characters(), directoryInode); //#endif Vector entries; @@ -469,7 +469,7 @@ bool Ext2FileSystem::addInodeToDirectory(unsigned directoryInode, unsigned inode return true; }); if (nameAlreadyExists) { - kprintf("[ext2fs] Name '%s' already exists in directory inode %u\n", name.characters(), directoryInode); + kprintf("ext2fs: Name '%s' already exists in directory inode %u\n", name.characters(), directoryInode); return false; } @@ -480,7 +480,7 @@ bool Ext2FileSystem::addInodeToDirectory(unsigned directoryInode, unsigned inode bool Ext2FileSystem::writeDirectoryInode(unsigned directoryInode, Vector&& entries) { - kprintf("[ext2fs] New directory inode %u contents to write:\n", directoryInode); + kprintf("ext2fs: New directory inode %u contents to write:\n", directoryInode); unsigned directorySize = 0; for (auto& entry : entries) { @@ -491,7 +491,7 @@ bool Ext2FileSystem::writeDirectoryInode(unsigned directoryInode, Vector Ext2FileSystem::allocateBlocks(unsigned group, unsigned count) { - kprintf("[ext2fs] allocateBlocks(group: %u, count: %u)\n", group, count); + kprintf("ext2fs: allocateBlocks(group: %u, count: %u)\n", group, count); auto& bgd = blockGroupDescriptor(group); if (bgd.bg_free_blocks_count < count) { - kprintf("[ext2fs] allocateBlocks can't allocate out of group %u, wanted %u but only %u available\n", group, count, bgd.bg_free_blocks_count); + kprintf("ext2fs: allocateBlocks can't allocate out of group %u, wanted %u but only %u available\n", group, count, bgd.bg_free_blocks_count); return { }; } @@ -695,7 +695,7 @@ Vector Ext2FileSystem::allocateBlocks(unsigned group } return true; }); - kprintf("[ext2fs] allocateBlock found these blocks:\n"); + kprintf("ext2fs: allocateBlock found these blocks:\n"); for (auto& bi : blocks) { kprintf(" > %u\n", bi); } @@ -705,11 +705,11 @@ Vector Ext2FileSystem::allocateBlocks(unsigned group unsigned Ext2FileSystem::allocateInode(unsigned preferredGroup, unsigned expectedSize) { - kprintf("[ext2fs] allocateInode(preferredGroup: %u, expectedSize: %u)\n", preferredGroup, expectedSize); + kprintf("ext2fs: allocateInode(preferredGroup: %u, expectedSize: %u)\n", preferredGroup, expectedSize); unsigned neededBlocks = ceilDiv(expectedSize, blockSize()); - kprintf("[ext2fs] minimum needed blocks: %u\n", neededBlocks); + kprintf("ext2fs: minimum needed blocks: %u\n", neededBlocks); unsigned groupIndex = 0; @@ -728,11 +728,11 @@ unsigned Ext2FileSystem::allocateInode(unsigned preferredGroup, unsigned expecte } if (!groupIndex) { - kprintf("[ext2fs] allocateInode: no suitable group found for new inode with %u blocks needed :(\n", neededBlocks); + kprintf("ext2fs: allocateInode: no suitable group found for new inode with %u blocks needed :(\n", neededBlocks); return 0; } - kprintf("[ext2fs] allocateInode: found suitable group [%u] for new inode with %u blocks needed :^)\n", groupIndex, neededBlocks); + kprintf("ext2fs: allocateInode: found suitable group [%u] for new inode with %u blocks needed :^)\n", groupIndex, neededBlocks); unsigned firstFreeInodeInGroup = 0; traverseInodeBitmap(groupIndex, [&firstFreeInodeInGroup] (unsigned firstInodeInBitmap, const Bitmap& bitmap) { @@ -746,12 +746,12 @@ unsigned Ext2FileSystem::allocateInode(unsigned preferredGroup, unsigned expecte }); if (!firstFreeInodeInGroup) { - kprintf("[ext2fs] firstFreeInodeInGroup returned no inode, despite bgd claiming there are inodes :(\n"); + kprintf("ext2fs: firstFreeInodeInGroup returned no inode, despite bgd claiming there are inodes :(\n"); return 0; } unsigned inode = firstFreeInodeInGroup; - kprintf("[ext2fs] found suitable inode %u\n", inode); + kprintf("ext2fs: found suitable inode %u\n", inode); // FIXME: allocate blocks if needed! @@ -777,7 +777,7 @@ bool Ext2FileSystem::setInodeAllocationState(unsigned inode, bool newState) ASSERT(block); auto bitmap = Bitmap::wrap(block.pointer(), block.size()); bool currentState = bitmap.get(bitIndex); - kprintf("[ext2fs] setInodeAllocationState(%u) %u -> %u\n", inode, currentState, newState); + kprintf("ext2fs: setInodeAllocationState(%u) %u -> %u\n", inode, currentState, newState); if (currentState == newState) return true; @@ -787,7 +787,7 @@ bool Ext2FileSystem::setInodeAllocationState(unsigned inode, bool newState) // Update superblock auto& sb = *reinterpret_cast(m_cachedSuperBlock.pointer()); - kprintf("[ext2fs] superblock free inode count %u -> %u\n", sb.s_free_inodes_count, sb.s_free_inodes_count - 1); + kprintf("ext2fs: superblock free inode count %u -> %u\n", sb.s_free_inodes_count, sb.s_free_inodes_count - 1); if (newState) --sb.s_free_inodes_count; else @@ -800,7 +800,7 @@ bool Ext2FileSystem::setInodeAllocationState(unsigned inode, bool newState) --mutableBGD.bg_free_inodes_count; else ++mutableBGD.bg_free_inodes_count; - kprintf("[ext2fs] group free inode count %u -> %u\n", bgd.bg_free_inodes_count, bgd.bg_free_inodes_count - 1); + kprintf("ext2fs: group free inode count %u -> %u\n", bgd.bg_free_inodes_count, bgd.bg_free_inodes_count - 1); unsigned blocksToWrite = ceilDiv(m_blockGroupCount * (unsigned)sizeof(ext2_group_desc), blockSize()); unsigned firstBlockOfBGDT = blockSize() == 1024 ? 2 : 1; @@ -821,7 +821,7 @@ bool Ext2FileSystem::setBlockAllocationState(GroupIndex group, BlockIndex bi, bo ASSERT(block); auto bitmap = Bitmap::wrap(block.pointer(), block.size()); bool currentState = bitmap.get(bitIndex); - kprintf("[ext2fs] setBlockAllocationState(%u) %u -> %u\n", block, currentState, newState); + kprintf("ext2fs: setBlockAllocationState(%u) %u -> %u\n", block, currentState, newState); if (currentState == newState) return true; @@ -831,7 +831,7 @@ bool Ext2FileSystem::setBlockAllocationState(GroupIndex group, BlockIndex bi, bo // Update superblock auto& sb = *reinterpret_cast(m_cachedSuperBlock.pointer()); - kprintf("[ext2fs] superblock free block count %u -> %u\n", sb.s_free_blocks_count, sb.s_free_blocks_count - 1); + kprintf("ext2fs: superblock free block count %u -> %u\n", sb.s_free_blocks_count, sb.s_free_blocks_count - 1); if (newState) --sb.s_free_blocks_count; else @@ -844,7 +844,7 @@ bool Ext2FileSystem::setBlockAllocationState(GroupIndex group, BlockIndex bi, bo --mutableBGD.bg_free_blocks_count; else ++mutableBGD.bg_free_blocks_count; - kprintf("[ext2fs] group free block count %u -> %u\n", bgd.bg_free_blocks_count, bgd.bg_free_blocks_count - 1); + kprintf("ext2fs: group free block count %u -> %u\n", bgd.bg_free_blocks_count, bgd.bg_free_blocks_count - 1); unsigned blocksToWrite = ceilDiv(m_blockGroupCount * (unsigned)sizeof(ext2_group_desc), blockSize()); unsigned firstBlockOfBGDT = blockSize() == 1024 ? 2 : 1; @@ -869,7 +869,7 @@ InodeIdentifier Ext2FileSystem::makeDirectory(InodeIdentifier parentInode, const if (!inode.isValid()) return { }; - kprintf("[ext2fs] makeDirectory: created new directory named '%s' with inode %u\n", name.characters(), inode.index()); + kprintf("ext2fs: makeDirectory: created new directory named '%s' with inode %u\n", name.characters(), inode.index()); Vector entries; entries.append({ ".", inode, EXT2_FT_DIR }); @@ -883,7 +883,7 @@ InodeIdentifier Ext2FileSystem::makeDirectory(InodeIdentifier parentInode, const auto& bgd = const_cast(blockGroupDescriptor(groupIndexFromInode(inode.index()))); ++bgd.bg_used_dirs_count; - kprintf("[ext2fs] incremented bg_used_dirs_count %u -> %u\n", bgd.bg_used_dirs_count - 1, bgd.bg_used_dirs_count); + kprintf("ext2fs: incremented bg_used_dirs_count %u -> %u\n", bgd.bg_used_dirs_count - 1, bgd.bg_used_dirs_count); unsigned blocksToWrite = ceilDiv(m_blockGroupCount * (unsigned)sizeof(ext2_group_desc), blockSize()); unsigned firstBlockOfBGDT = blockSize() == 1024 ? 2 : 1; @@ -898,19 +898,19 @@ InodeIdentifier Ext2FileSystem::createInode(InodeIdentifier parentInode, const S ASSERT(isDirectoryInode(parentInode.index())); //#ifdef EXT2_DEBUG - kprintf("[ext2fs] Adding inode '%s' (mode %o) to parent directory %u:\n", name.characters(), mode, parentInode.index()); + kprintf("ext2fs: Adding inode '%s' (mode %o) to parent directory %u:\n", name.characters(), mode, parentInode.index()); //#endif // NOTE: This doesn't commit the inode allocation just yet! auto inode = allocateInode(0, 0); if (!inode) { - kprintf("[ext2fs] createInode: allocateInode failed\n"); + kprintf("ext2fs: createInode: allocateInode failed\n"); return { }; } auto blocks = allocateBlocks(groupIndexFromInode(inode), ceilDiv(size, blockSize())); if (blocks.isEmpty()) { - kprintf("[ext2fs] createInode: allocateBlocks failed\n"); + kprintf("ext2fs: createInode: allocateBlocks failed\n"); return { }; } @@ -933,7 +933,7 @@ InodeIdentifier Ext2FileSystem::createInode(InodeIdentifier parentInode, const S // Try adding it to the directory first, in case the name is already in use. bool success = addInodeToDirectory(parentInode.index(), inode, name, fileType); if (!success) { - kprintf("[ext2fs] failed to add inode to directory :(\n"); + kprintf("ext2fs: failed to add inode to directory :(\n"); return { }; } diff --git a/VirtualFileSystem/SyntheticFileSystem.cpp b/VirtualFileSystem/SyntheticFileSystem.cpp index 6f91fa252a..a6bbe1afea 100644 --- a/VirtualFileSystem/SyntheticFileSystem.cpp +++ b/VirtualFileSystem/SyntheticFileSystem.cpp @@ -137,7 +137,7 @@ bool SyntheticFileSystem::enumerateDirectoryInode(InodeIdentifier inode, Functio InterruptDisabler disabler; ASSERT(inode.fileSystemID() == id()); #ifdef SYNTHFS_DEBUG - kprintf("[synthfs] enumerateDirectoryInode %u\n", inode.index()); + kprintf("synthfs: enumerateDirectoryInode %u\n", inode.index()); #endif auto it = m_inodes.find(inode.index()); @@ -160,7 +160,7 @@ InodeMetadata SyntheticFileSystem::inodeMetadata(InodeIdentifier inode) const InterruptDisabler disabler; ASSERT(inode.fileSystemID() == id()); #ifdef SYNTHFS_DEBUG - kprintf("[synthfs] inodeMetadata(%u)\n", inode.index()); + kprintf("synthfs: inodeMetadata(%u)\n", inode.index()); #endif auto it = m_inodes.find(inode.index()); @@ -198,7 +198,7 @@ Unix::ssize_t SyntheticFileSystem::readInodeBytes(InodeIdentifier inode, Unix::o ASSERT(inode.fileSystemID() == id()); #ifdef SYNTHFS_DEBUG - kprintf("[synthfs] readInode %u\n", inode.index()); + kprintf("synthfs: readInode %u\n", inode.index()); #endif ASSERT(offset >= 0); ASSERT(buffer); diff --git a/VirtualFileSystem/VirtualFileSystem.cpp b/VirtualFileSystem/VirtualFileSystem.cpp index ea2bf78d02..8c71e8a40e 100644 --- a/VirtualFileSystem/VirtualFileSystem.cpp +++ b/VirtualFileSystem/VirtualFileSystem.cpp @@ -36,7 +36,7 @@ void VirtualFileSystem::initializeGlobals() VirtualFileSystem::VirtualFileSystem() { #ifdef VFS_DEBUG - kprintf("[VFS] Constructing VFS\n"); + kprintf("VFS: Constructing VFS\n"); #endif s_the = this; m_maxNodeCount = 16; @@ -49,7 +49,7 @@ VirtualFileSystem::VirtualFileSystem() VirtualFileSystem::~VirtualFileSystem() { - kprintf("[VFS] ~VirtualFileSystem with %u nodes allocated\n", allocatedNodeCount()); + kprintf("VFS: ~VirtualFileSystem with %u nodes allocated\n", allocatedNodeCount()); // FIXME: m_nodes is never freed. Does it matter though? } @@ -65,7 +65,7 @@ auto VirtualFileSystem::makeNode(InodeIdentifier inode) -> RetainPtr if (it != m_characterDevices.end()) { characterDevice = (*it).value; } else { - kprintf("[VFS] makeNode() no such character device %u,%u\n", metadata.majorDevice, metadata.minorDevice); + kprintf("VFS: makeNode() no such character device %u,%u\n", metadata.majorDevice, metadata.minorDevice); return nullptr; } } @@ -126,11 +126,11 @@ bool VirtualFileSystem::mount(RetainPtr&& fileSystem, const String& int error; auto inode = resolvePath(path, error); if (!inode.isValid()) { - kprintf("[VFS] mount can't resolve mount point '%s'\n", path.characters()); + kprintf("VFS: mount can't resolve mount point '%s'\n", path.characters()); return false; } - kprintf("mounting %s{%p} at %s (inode: %u)\n", fileSystem->className(), fileSystem.ptr(), path.characters(), inode.index()); + kprintf("VFS: mounting %s{%p} at %s (inode: %u)\n", fileSystem->className(), fileSystem.ptr(), path.characters(), inode.index()); // FIXME: check that this is not already a mount point auto mount = make(inode, move(fileSystem)); m_mounts.append(move(mount)); @@ -140,7 +140,7 @@ bool VirtualFileSystem::mount(RetainPtr&& fileSystem, const String& bool VirtualFileSystem::mountRoot(RetainPtr&& fileSystem) { if (m_rootNode) { - kprintf("[VFS] mountRoot can't mount another root\n"); + kprintf("VFS: mountRoot can't mount another root\n"); return false; } @@ -148,17 +148,17 @@ bool VirtualFileSystem::mountRoot(RetainPtr&& fileSystem) auto node = makeNode(mount->guest()); if (!node->inUse()) { - kprintf("[VFS] root inode for / is not in use :(\n"); + kprintf("VFS: root inode for / is not in use :(\n"); return false; } if (!node->inode.metadata().isDirectory()) { - kprintf("[VFS] root inode for / is not in use :(\n"); + kprintf("VFS: root inode for / is not in use :(\n"); return false; } m_rootNode = move(node); - kprintf("[VFS] mountRoot mounted %s{%p}\n", + kprintf("VFS: mounted root on %s{%p}\n", m_rootNode->fileSystem()->className(), m_rootNode->fileSystem()); @@ -170,7 +170,7 @@ auto VirtualFileSystem::allocateNode() -> RetainPtr { if (m_nodeFreeList.isEmpty()) { - kprintf("[VFS] allocateNode has no nodes left\n"); + kprintf("VFS: allocateNode has no nodes left\n"); return nullptr; } auto* node = m_nodeFreeList.takeLast(); @@ -261,7 +261,7 @@ void VirtualFileSystem::listDirectory(const String& path) if (!directoryInode.isValid()) return; - kprintf("[VFS] ls %s -> %s %02u:%08u\n", path.characters(), directoryInode.fileSystem()->className(), directoryInode.fileSystemID(), directoryInode.index()); + kprintf("VFS: ls %s -> %s %02u:%08u\n", path.characters(), directoryInode.fileSystem()->className(), directoryInode.fileSystemID(), directoryInode.index()); enumerateDirectoryInode(directoryInode, [&] (const FileSystem::DirectoryEntry& entry) { const char* nameColorBegin = ""; const char* nameColorEnd = "";