mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:18:12 +00:00
Kernel: Use klog() instead of kprintf()
Also, duplicate data in dbg() and klog() calls were removed. In addition, leakage of virtual address to kernel log is prevented. This is done by replacing kprintf() calls to dbg() calls with the leaked data instead. Also, other kprintf() calls were replaced with klog().
This commit is contained in:
parent
19aa53e1f9
commit
0fc60e41dd
53 changed files with 397 additions and 573 deletions
|
@ -125,7 +125,7 @@ DiskBackedFS::~DiskBackedFS()
|
|||
bool DiskBackedFS::write_block(unsigned index, const u8* data, FileDescription* description)
|
||||
{
|
||||
#ifdef DBFS_DEBUG
|
||||
kprintf("DiskBackedFileSystem::write_block %u, size=%u\n", index, data.size());
|
||||
klog() << "DiskBackedFileSystem::write_block " << index << ", size=" << data.size();
|
||||
#endif
|
||||
|
||||
bool allow_cache = !description || !description->is_direct();
|
||||
|
@ -149,7 +149,7 @@ bool DiskBackedFS::write_block(unsigned index, const u8* data, FileDescription*
|
|||
bool DiskBackedFS::write_blocks(unsigned index, unsigned count, const u8* data, FileDescription* description)
|
||||
{
|
||||
#ifdef DBFS_DEBUG
|
||||
kprintf("DiskBackedFileSystem::write_blocks %u x%u\n", index, count);
|
||||
klog() << "DiskBackedFileSystem::write_blocks " << index << " x%u" << count;
|
||||
#endif
|
||||
for (unsigned i = 0; i < count; ++i)
|
||||
write_block(index + i, data + i * block_size(), description);
|
||||
|
@ -159,7 +159,7 @@ bool DiskBackedFS::write_blocks(unsigned index, unsigned count, const u8* data,
|
|||
bool DiskBackedFS::read_block(unsigned index, u8* buffer, FileDescription* description) const
|
||||
{
|
||||
#ifdef DBFS_DEBUG
|
||||
kprintf("DiskBackedFileSystem::read_block %u\n", index);
|
||||
klog() << "DiskBackedFileSystem::read_block " << index;
|
||||
#endif
|
||||
|
||||
bool allow_cache = !description || !description->is_direct();
|
||||
|
|
|
@ -100,20 +100,20 @@ bool Ext2FS::initialize()
|
|||
|
||||
auto& super_block = this->super_block();
|
||||
#ifdef EXT2_DEBUG
|
||||
kprintf("ext2fs: super block magic: %x (super block size: %u)\n", super_block.s_magic, sizeof(ext2_super_block));
|
||||
klog() << "ext2fs: super block magic: " << String::format("%x", super_block.s_magic) << " (super block size: " << sizeof(ext2_super_block) << ")";
|
||||
#endif
|
||||
if (super_block.s_magic != EXT2_SUPER_MAGIC)
|
||||
return false;
|
||||
|
||||
#ifdef EXT2_DEBUG
|
||||
kprintf("ext2fs: %u inodes, %u blocks\n", super_block.s_inodes_count, super_block.s_blocks_count);
|
||||
kprintf("ext2fs: block size = %u\n", EXT2_BLOCK_SIZE(&super_block));
|
||||
kprintf("ext2fs: first data block = %u\n", super_block.s_first_data_block);
|
||||
kprintf("ext2fs: inodes per block = %u\n", inodes_per_block());
|
||||
kprintf("ext2fs: inodes per group = %u\n", inodes_per_group());
|
||||
kprintf("ext2fs: free inodes = %u\n", super_block.s_free_inodes_count);
|
||||
kprintf("ext2fs: desc per block = %u\n", EXT2_DESC_PER_BLOCK(&super_block));
|
||||
kprintf("ext2fs: desc size = %u\n", EXT2_DESC_SIZE(&super_block));
|
||||
klog() << "ext2fs: " << super_block.s_inodes_count << " inodes, " << super_block.s_blocks_count << " blocks";
|
||||
klog() << "ext2fs: block size = " << EXT2_BLOCK_SIZE(&super_block);
|
||||
klog() << "ext2fs: first data block = " << super_block.s_first_data_block;
|
||||
klog() << "ext2fs: inodes per block = " << inodes_per_block();
|
||||
klog() << "ext2fs: inodes per group = " << inodes_per_group();
|
||||
klog() << "ext2fs: free inodes = " << super_block.s_free_inodes_count;
|
||||
klog() << "ext2fs: desc per block = " << EXT2_DESC_PER_BLOCK(&super_block);
|
||||
klog() << "ext2fs: desc size = " << EXT2_DESC_SIZE(&super_block);
|
||||
#endif
|
||||
|
||||
set_block_size(EXT2_BLOCK_SIZE(&super_block));
|
||||
|
@ -123,7 +123,7 @@ bool Ext2FS::initialize()
|
|||
m_block_group_count = ceil_div(super_block.s_blocks_count, super_block.s_blocks_per_group);
|
||||
|
||||
if (m_block_group_count == 0) {
|
||||
kprintf("ext2fs: no block groups :(\n");
|
||||
klog() << "ext2fs: no block groups :(";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -135,11 +135,7 @@ bool Ext2FS::initialize()
|
|||
#ifdef EXT2_DEBUG
|
||||
for (unsigned i = 1; i <= m_block_group_count; ++i) {
|
||||
auto& group = group_descriptor(i);
|
||||
kprintf("ext2fs: group[%u] { block_bitmap: %u, inode_bitmap: %u, inode_table: %u }\n",
|
||||
i,
|
||||
group.bg_block_bitmap,
|
||||
group.bg_inode_bitmap,
|
||||
group.bg_inode_table);
|
||||
klog() << "ext2fs: group[" << i << "] { block_bitmap: " << group.bg_block_bitmap << ", inode_bitmap: " << group.bg_inode_bitmap << ", inode_table: " << group.bg_inode_table << " }";
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -662,7 +658,7 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, u8* buffer, FileDes
|
|||
m_block_list = fs().block_list_for_inode(m_raw_inode);
|
||||
|
||||
if (m_block_list.is_empty()) {
|
||||
kprintf("ext2fs: read_bytes: empty block list for inode %u\n", index());
|
||||
klog() << "ext2fs: read_bytes: empty block list for inode " << index();
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -690,7 +686,7 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, u8* buffer, FileDes
|
|||
ASSERT(block_index);
|
||||
bool success = fs().read_block(block_index, block, description);
|
||||
if (!success) {
|
||||
kprintf("ext2fs: read_bytes: read_block(%u) failed (lbi: %u)\n", block_index, bi);
|
||||
klog() << "ext2fs: read_bytes: read_block(" << block_index << ") failed (lbi: " << bi << ")";
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -1182,7 +1178,7 @@ unsigned Ext2FS::find_a_free_inode(GroupIndex preferred_group, off_t expected_si
|
|||
}
|
||||
|
||||
if (!group_index) {
|
||||
kprintf("Ext2FS: find_a_free_inode: no suitable group found for new inode with %u blocks needed :(\n", needed_blocks);
|
||||
klog() << "Ext2FS: find_a_free_inode: no suitable group found for new inode with " << needed_blocks << " blocks needed :(";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1206,7 +1202,7 @@ unsigned Ext2FS::find_a_free_inode(GroupIndex preferred_group, off_t expected_si
|
|||
}
|
||||
|
||||
if (!first_free_inode_in_group) {
|
||||
kprintf("Ext2FS: first_free_inode_in_group returned no inode, despite bgd claiming there are inodes :(\n");
|
||||
klog() << "Ext2FS: first_free_inode_in_group returned no inode, despite bgd claiming there are inodes :(";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1433,7 +1429,7 @@ KResultOr<NonnullRefPtr<Inode>> Ext2FS::create_inode(InodeIdentifier parent_id,
|
|||
// NOTE: This doesn't commit the inode allocation just yet!
|
||||
auto inode_id = find_a_free_inode(0, size);
|
||||
if (!inode_id) {
|
||||
kprintf("Ext2FS: create_inode: allocate_inode failed\n");
|
||||
klog() << "Ext2FS: create_inode: allocate_inode failed";
|
||||
return KResult(-ENOSPC);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,12 +78,12 @@ void FIFO::attach(Direction direction)
|
|||
if (direction == Direction::Reader) {
|
||||
++m_readers;
|
||||
#ifdef FIFO_DEBUG
|
||||
kprintf("open reader (%u)\n", m_readers);
|
||||
klog() << "open reader (" << m_readers << ")";
|
||||
#endif
|
||||
} else if (direction == Direction::Writer) {
|
||||
++m_writers;
|
||||
#ifdef FIFO_DEBUG
|
||||
kprintf("open writer (%u)\n", m_writers);
|
||||
klog() << "open writer (" << m_writers << ")";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -92,13 +92,13 @@ void FIFO::detach(Direction direction)
|
|||
{
|
||||
if (direction == Direction::Reader) {
|
||||
#ifdef FIFO_DEBUG
|
||||
kprintf("close reader (%u - 1)\n", m_readers);
|
||||
klog() << "close reader (" << m_readers << " - 1)";
|
||||
#endif
|
||||
ASSERT(m_readers);
|
||||
--m_readers;
|
||||
} else if (direction == Direction::Writer) {
|
||||
#ifdef FIFO_DEBUG
|
||||
kprintf("close writer (%u - 1)\n", m_writers);
|
||||
klog() << "close writer (" << m_writers << " - 1)";
|
||||
#endif
|
||||
ASSERT(m_writers);
|
||||
--m_writers;
|
||||
|
|
|
@ -79,7 +79,7 @@ ByteBuffer Inode::read_entire(FileDescription* descriptor) const
|
|||
break;
|
||||
}
|
||||
if (nread < 0) {
|
||||
kprintf("Inode::read_entire: ERROR: %d\n", nread);
|
||||
klog() << "Inode::read_entire: ERROR: " << nread;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ VFS& VFS::the()
|
|||
VFS::VFS()
|
||||
{
|
||||
#ifdef VFS_DEBUG
|
||||
kprintf("VFS: Constructing VFS\n");
|
||||
klog() << "VFS: Constructing VFS";
|
||||
#endif
|
||||
s_the = this;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ KResult VFS::unmount(InodeIdentifier guest_inode_id)
|
|||
bool VFS::mount_root(FS& file_system)
|
||||
{
|
||||
if (m_root_inode) {
|
||||
kprintf("VFS: mount_root can't mount another root\n");
|
||||
klog() << "VFS: mount_root can't mount another root";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ bool VFS::mount_root(FS& file_system)
|
|||
auto root_inode_id = mount.guest().fs()->root_inode();
|
||||
auto root_inode = mount.guest().fs()->get_inode(root_inode_id);
|
||||
if (!root_inode->is_directory()) {
|
||||
kprintf("VFS: root inode (%02u:%08u) for / is not a directory :(\n", root_inode_id.fsid(), root_inode_id.index());
|
||||
klog() << "VFS: root inode (" << String::format("%02u", root_inode_id.fsid()) << ":" << String::format("%08u", root_inode_id.index()) << ") for / is not a directory :(";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ bool VFS::mount_root(FS& file_system)
|
|||
} else {
|
||||
sprintf(device_name, "not-a-disk");
|
||||
}
|
||||
kprintf("VFS: mounted root on %s (%s)\n", m_root_inode->fs().class_name(), device_name);
|
||||
klog() << "VFS: mounted root on " << m_root_inode->fs().class_name() << " (" << device_name << ")";
|
||||
|
||||
m_mounts.append(move(mount));
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue