Skip to content

Add file and directory management functions to EXT2 filesystem - #6

Merged
lassedtu merged 1 commit into
mainfrom
fs-write-functionality
Aug 7, 2026
Merged

Add file and directory management functions to EXT2 filesystem#6
lassedtu merged 1 commit into
mainfrom
fs-write-functionality

Conversation

@lassedtu

@lassedtu lassedtu commented Aug 7, 2026

Copy link
Copy Markdown
Owner
  • Extend EXT2_VOLUME structure to include superblock and additional metadata
  • Implement functions for creating and removing files and directories in the EXT2 filesystem
  • Add support for renaming files and directories
  • Introduce fs_stat function to retrieve file metadata, including inode information and timestamps
  • Update VFS layer to provide high-level interfaces for the new file and directory operations: create, remove, rename, and stat

- Extend EXT2_VOLUME structure to include superblock and additional metadata
- Implement functions for creating and removing files and directories in the EXT2 filesystem
- Add support for renaming files and directories
- Introduce fs_stat function to retrieve file metadata, including inode information and timestamps
- Updated VFS layer to provide high-level interfaces for the new file and directory operations: create, remove, rename, and stat
Copilot AI lite review requested due to automatic review settings August 7, 2026 11:35
@lassedtu lassedtu self-assigned this Aug 7, 2026
@lassedtu
lassedtu merged commit 6dae258 into main Aug 7, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the kernel VFS/FS layers and the EXT2 driver to support filesystem mutation and metadata querying (create/remove/mkdir/rmdir/rename/stat), and adds block-device write support end-to-end (ATA + partition wrapper) so EXT2 can persist changes to disk.

Changes:

  • Added VFS and FS APIs for create/mkdir/remove/rmdir/rename/stat, including an FS_STAT/VFS_STAT metadata struct.
  • Extended the EXT2 volume state (cached superblock + counts) and implemented EXT2 mutation helpers for file/dir create/remove/rename.
  • Introduced block-device write plumbing (block_device_write) and implemented ATA + partition write backends.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/kernel/vfs/vfs.h Adds VFS-level APIs for create/mkdir/remove/rmdir/rename/stat and VFS_STAT alias.
src/kernel/vfs/vfs.c Implements VFS wrappers that dispatch to FS layer for new operations.
src/kernel/fs/fs.h Adds FS_STAT and declares new FS-level create/mkdir/remove/rmdir/rename/stat APIs.
src/kernel/fs/fs.c Implements FS wrappers mapping new operations to EXT2 driver functions; implements fs_stat.
src/fs/ext2/ext2.h Extends EXT2_VOLUME with cached superblock/counts and declares EXT2 mutation APIs.
src/fs/ext2/ext2.c Implements EXT2 on-disk mutation primitives (alloc/free, dir entry ops) and create/remove/rename.
src/drivers/disk/partition.c Adds partition-level write implementation and wires it into the partition block device.
src/drivers/disk/block_device.h Extends BLOCK_DEVICE with a write callback and declares block_device_write.
src/drivers/disk/block_device.c Implements block_device_write dispatcher with basic validation.
src/drivers/disk/ata.h Updates ATA init documentation to reflect write capability.
src/drivers/disk/ata.c Implements ATA LBA28 write path and wires it into the ATA block device.
Suppressed comments (1)

src/fs/ext2/ext2.c:1912

  • EXT2_CreateDir sets the parent directory’s mtime/ctime to 0 before writing the inode. This permanently overwrites on-disk timestamps with epoch values. If the kernel doesn’t yet have a real time source, avoid clobbering these fields and just update the link count.
    parent_inode.i_links_count++;
    parent_inode.i_mtime = 0;
    parent_inode.i_ctime = 0;
    if (!write_inode(volume, parent_inode_number, &parent_inode))

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/fs/ext2/ext2.c
Comment on lines +1828 to +1831
parent_inode.i_mtime = 0;
parent_inode.i_ctime = 0;
write_inode(volume, parent_inode_number, &parent_inode);
return true;
Comment thread src/fs/ext2/ext2.c
Comment on lines +2021 to +2022
update_group_and_super_counts(volume, child_group, 0, 0, -1);
return true;
Comment thread src/fs/ext2/ext2.c
Comment on lines +1917 to +1918
update_group_and_super_counts(volume, child_group, 0, 0, 1);
return true;
Comment thread src/fs/ext2/ext2.c
Comment on lines +1008 to +1020
entry = (EXT2_DIR_ENTRY *)(g_block_buffer + ext2_dir_entry_size(1u));
if (entry->name_len != 2u)
{
return false;
}

if (memcmp((uint8_t *)entry + header_size, "..", 2u) != 0)
{
return false;
}

entry->inode = parent_inode_number;
return write_block(volume, dir_inode.i_block[0], g_block_buffer);
Comment thread src/fs/ext2/ext2.c
Comment on lines +16 to +18
static bool inode_is_dir(const EXT2_INODE *inode);
static bool inode_is_regular(const EXT2_INODE *inode);
static bool inode_is_directory(const EXT2_INODE *inode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants