瀏覽代碼

Ext2FS: Rename allocate_inode() => find_a_free_inode()

Since this function doesn't actually mark the inode as allocated,
let's tone down the name a little bit.
Andreas Kling 5 年之前
父節點
當前提交
8ccbd7002b
共有 2 個文件被更改,包括 6 次插入10 次删除
  1. 5 9
      Kernel/FileSystem/Ext2FileSystem.cpp
  2. 1 1
      Kernel/FileSystem/Ext2FileSystem.h

+ 5 - 9
Kernel/FileSystem/Ext2FileSystem.cpp

@@ -1069,11 +1069,11 @@ Vector<Ext2FS::BlockIndex> Ext2FS::allocate_blocks(GroupIndex preferred_group_in
     return blocks;
     return blocks;
 }
 }
 
 
-unsigned Ext2FS::allocate_inode(GroupIndex preferred_group, off_t expected_size)
+unsigned Ext2FS::find_a_free_inode(GroupIndex preferred_group, off_t expected_size)
 {
 {
     LOCKER(m_lock);
     LOCKER(m_lock);
 #ifdef EXT2_DEBUG
 #ifdef EXT2_DEBUG
-    dbgprintf("Ext2FS: allocate_inode(preferredGroup: %u, expected_size: %u)\n", preferred_group, expected_size);
+    dbgprintf("Ext2FS: find_a_free_inode(preferred_group: %u, expected_size: %ld)\n", preferred_group, expected_size);
 #endif
 #endif
 
 
     unsigned needed_blocks = ceil_div(expected_size, block_size());
     unsigned needed_blocks = ceil_div(expected_size, block_size());
@@ -1101,12 +1101,12 @@ unsigned Ext2FS::allocate_inode(GroupIndex preferred_group, off_t expected_size)
     }
     }
 
 
     if (!group_index) {
     if (!group_index) {
-        kprintf("Ext2FS: allocate_inode: no suitable group found for new inode with %u blocks needed :(\n", needed_blocks);
+        kprintf("Ext2FS: find_a_free_inode: no suitable group found for new inode with %u blocks needed :(\n", needed_blocks);
         return 0;
         return 0;
     }
     }
 
 
 #ifdef EXT2_DEBUG
 #ifdef EXT2_DEBUG
-    dbgprintf("Ext2FS: allocate_inode: found suitable group [%u] for new inode with %u blocks needed :^)\n", group_index, needed_blocks);
+    dbgprintf("Ext2FS: find_a_free_inode: found suitable group [%u] for new inode with %u blocks needed :^)\n", group_index, needed_blocks);
 #endif
 #endif
 
 
     auto& bgd = group_descriptor(group_index);
     auto& bgd = group_descriptor(group_index);
@@ -1135,9 +1135,6 @@ unsigned Ext2FS::allocate_inode(GroupIndex preferred_group, off_t expected_size)
 #endif
 #endif
 
 
     ASSERT(get_inode_allocation_state(inode) == false);
     ASSERT(get_inode_allocation_state(inode) == false);
-
-    // FIXME: allocate blocks if needed!
-
     return inode;
     return inode;
 }
 }
 
 
@@ -1348,8 +1345,7 @@ RefPtr<Inode> Ext2FS::create_inode(InodeIdentifier parent_id, const String& name
     }
     }
 
 
     // NOTE: This doesn't commit the inode allocation just yet!
     // NOTE: This doesn't commit the inode allocation just yet!
-    // FIXME: Change the name of allocate_inode since it behaves differently than allocate_block
-    auto inode_id = allocate_inode(0, size);
+    auto inode_id = find_a_free_inode(0, size);
     if (!inode_id) {
     if (!inode_id) {
         kprintf("Ext2FS: create_inode: allocate_inode failed\n");
         kprintf("Ext2FS: create_inode: allocate_inode failed\n");
         error = -ENOSPC;
         error = -ENOSPC;

+ 1 - 1
Kernel/FileSystem/Ext2FileSystem.h

@@ -103,7 +103,7 @@ private:
     virtual void flush_writes() override;
     virtual void flush_writes() override;
 
 
     BlockIndex first_block_index() const;
     BlockIndex first_block_index() const;
-    InodeIndex allocate_inode(GroupIndex preferred_group, off_t expected_size);
+    InodeIndex find_a_free_inode(GroupIndex preferred_group, off_t expected_size);
     Vector<BlockIndex> allocate_blocks(GroupIndex preferred_group_index, int count);
     Vector<BlockIndex> allocate_blocks(GroupIndex preferred_group_index, int count);
     BlockIndex allocate_block(GroupIndex preferred_group_index);
     BlockIndex allocate_block(GroupIndex preferred_group_index);
     GroupIndex group_index_from_inode(InodeIndex) const;
     GroupIndex group_index_from_inode(InodeIndex) const;