Conversation
- 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
There was a problem hiding this comment.
Pull request overview
This PR expands the storage/filesystem stack to support EXT2 mutations (create/mkdir/remove/rmdir/rename/stat) via new FS/VFS wrappers and block-device write support, and also silences an unused-parameter warning in pwd.
Changes:
- Add
block_device_writeplumbing (BLOCK_DEVICE write function pointer, ATA/partition implementations). - Introduce FS/VFS APIs for create/mkdir/remove/rmdir/rename/stat plus a new
FS_STAT/VFS_STATmetadata struct. - Fix
pwdunusedargvwarning by explicitly casting it to void.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/kernel/vfs/vfs.h | Adds VFS_STAT typedef and new VFS mutation/stat function declarations. |
| src/kernel/vfs/vfs.c | Implements VFS mutation/stat wrappers over fs_*. |
| src/kernel/fs/fs.h | Adds FS_STAT struct and FS mutation/stat API declarations. |
| src/kernel/fs/fs.c | Implements FS mutation/stat wrappers over EXT2 plus inode→FS type mapping for stat. |
| src/kernel/commands/pwd/pwd.c | Casts argv to void to silence unused parameter warning. |
| src/fs/ext2/ext2.h | Extends EXT2 volume state and adds mutation function declarations. |
| src/fs/ext2/ext2.c | Implements EXT2 create/mkdir/remove/rmdir/rename and supporting write/bitmap helpers. |
| src/drivers/disk/partition.c | Adds partition-backed write_blocks implementation and wires it up. |
| src/drivers/disk/block_device.h | Adds BlockWriteFn and write_blocks to BLOCK_DEVICE, plus write API declaration. |
| src/drivers/disk/block_device.c | Implements block_device_write dispatch with basic validation. |
| src/drivers/disk/ata.h | Updates ATA init docstring to include write support. |
| src/drivers/disk/ata.c | Adds ATA write-sector path and wires write_blocks into ATA block device. |
Suppressed comments (4)
src/fs/ext2/ext2.c:906
- EXT2 allows 255-byte directory entry names; this check rejects
new_name_len == 255(new_name_len >= 255).
if (!volume || !old_name || !new_name || new_name_len == 0 || new_name_len >= 255)
{
return false;
}
src/fs/ext2/ext2.c:1912
- This resets the parent directory’s
i_mtime/i_ctimeto 0 when creating a directory, which clobbers existing timestamps on valid EXT2 volumes. Prefer leaving timestamps unchanged unless you can set them to a meaningful value.
parent_inode.i_links_count++;
parent_inode.i_mtime = 0;
parent_inode.i_ctime = 0;
if (!write_inode(volume, parent_inode_number, &parent_inode))
src/fs/ext2/ext2.c:2012
- This resets the parent directory’s
i_mtime/i_ctimeto 0 during rmdir, which clobbers existing timestamps on valid EXT2 volumes. Prefer leaving timestamps unchanged unless you can set them meaningfully.
parent_inode.i_links_count--;
parent_inode.i_mtime = 0;
parent_inode.i_ctime = 0;
write_inode(volume, parent_inode_number, &parent_inode);
src/fs/ext2/ext2.c:2022
- The result of
update_group_and_super_counts(...)is ignored, so this can return success even if writing the group descriptor/superblock fails. Propagate the return value so callers can detect disk write failures.
update_group_and_super_counts(volume, child_group, 0, 0, -1);
return true;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+798
to
+801
| if (!volume || !parent_inode || !name || name_len == 0 || name_len >= 255) | ||
| { | ||
| return false; | ||
| } |
| int argc, | ||
| char **argv) | ||
| { | ||
| (void)argv; // unused parameter |
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 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 on lines
+1917
to
+1918
| update_group_and_super_counts(volume, child_group, 0, 0, 1); | ||
| return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Very small fix to pwd which gets rid of the compiler warning for an unused parameter **argv (pwd doesen't have any arguments but argv must be a part of the function due to the interface of shell commands)