1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:37:35 +00:00

Fix bug where allocating a new inode forgot that inodes are 1-based.

This commit is contained in:
Andreas Kling 2018-10-15 02:39:55 +02:00
parent b0eaca436c
commit 5c50d02c2e
3 changed files with 7 additions and 5 deletions

View file

@ -390,7 +390,7 @@ bool Ext2FileSystem::enumerateDirectoryInode(InodeIdentifier inode, std::functio
if (entry->inode != 0) { if (entry->inode != 0) {
memcpy(namebuf, entry->name, entry->name_len); memcpy(namebuf, entry->name, entry->name_len);
namebuf[entry->name_len] = 0; namebuf[entry->name_len] = 0;
#ifndef EXT2_DEBUG #ifdef EXT2_DEBUG
printf("inode: %u, name_len: %u, rec_len: %u, file_type: %u, name: %s\n", entry->inode, entry->name_len, entry->rec_len, entry->file_type, namebuf); printf("inode: %u, name_len: %u, rec_len: %u, file_type: %u, name: %s\n", entry->inode, entry->name_len, entry->rec_len, entry->file_type, namebuf);
#endif #endif
if (!callback({ namebuf, { id(), entry->inode }, entry->file_type })) if (!callback({ namebuf, { id(), entry->inode }, entry->file_type }))
@ -598,7 +598,7 @@ void Ext2FileSystem::traverseInodeBitmap(unsigned groupIndex, F callback) const
for (unsigned i = 0; i < blockCount; ++i) { for (unsigned i = 0; i < blockCount; ++i) {
auto block = readBlock(bgd.bg_inode_bitmap + i); auto block = readBlock(bgd.bg_inode_bitmap + i);
ASSERT(block); ASSERT(block);
bool shouldContinue = callback(i * (blockSize() / 8), Bitmap::wrap(block.pointer(), inodesInGroup)); bool shouldContinue = callback(i * (blockSize() / 8) + 1, Bitmap::wrap(block.pointer(), inodesInGroup));
if (!shouldContinue) if (!shouldContinue)
break; break;
} }
@ -793,7 +793,7 @@ InodeIdentifier Ext2FileSystem::createInode(InodeIdentifier parentInode, const S
e2inode->i_mtime = timestamp; e2inode->i_mtime = timestamp;
e2inode->i_dtime = 0; e2inode->i_dtime = 0;
e2inode->i_gid = 0; e2inode->i_gid = 0;
e2inode->i_links_count = 2; e2inode->i_links_count = 1;
e2inode->i_blocks = 0; e2inode->i_blocks = 0;
e2inode->i_flags = 0; e2inode->i_flags = 0;
success = writeExt2Inode(inode, *e2inode); success = writeExt2Inode(inode, *e2inode);

Binary file not shown.

View file

@ -38,8 +38,10 @@ int main(int c, char** v)
return 1; return 1;
} }
//auto newFile = vfs.create("/empty"); #if 1
//printf("vfs.create: %p\n", newFile.ptr()); auto newFile = vfs.create("/empty");
printf("vfs.create: %p\n", newFile.ptr());
#endif
//return 0; //return 0;
if (!strcmp(v[0], "./vcat")) { if (!strcmp(v[0], "./vcat")) {