ext2: replace bitmap search with intrinsic func

This commit is contained in:
Michael Shaw 2024-02-01 00:31:19 -05:00
commit 66cb9b03ac

View file

@ -461,7 +461,6 @@ static long ext2_alloc_inode(struct fs *vfs, uint32_t mode)
/* iterate over the inode bitmap to find a free inode */ /* iterate over the inode bitmap to find a free inode */
uint32_t byte = 0; uint32_t byte = 0;
uint32_t bit = 0;
uint8_t *byte_ptr = inode_bitmap + byte; uint8_t *byte_ptr = inode_bitmap + byte;
while (*byte_ptr == 0xFF) { while (*byte_ptr == 0xFF) {
@ -469,10 +468,7 @@ static long ext2_alloc_inode(struct fs *vfs, uint32_t mode)
byte_ptr = inode_bitmap + byte; byte_ptr = inode_bitmap + byte;
} }
while (*byte_ptr & (1 << bit)) { uint32_t bit = __builtin_ffs(~byte) - 1;
bit++;
}
*byte_ptr |= (1 << bit); *byte_ptr |= (1 << bit);
ino_t inode_no = (i * fs->sb.inodes_per_group) + (byte * 8) + bit + 1; ino_t inode_no = (i * fs->sb.inodes_per_group) + (byte * 8) + bit + 1;