Skip to content

pwd command fix - #7

Merged
lassedtu merged 2 commits into
mainfrom
pwd-fix
Aug 7, 2026
Merged

pwd command fix#7
lassedtu merged 2 commits into
mainfrom
pwd-fix

Conversation

@lassedtu

@lassedtu lassedtu commented Aug 7, 2026

Copy link
Copy Markdown
Owner

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)

- 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:36
@lassedtu lassedtu self-assigned this Aug 7, 2026
@lassedtu
lassedtu merged commit ab083ca 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 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_write plumbing (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_STAT metadata struct.
  • Fix pwd unused argv warning 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_ctime to 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_ctime to 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 thread src/fs/ext2/ext2.c
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 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 +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 +1917 to +1918
update_group_and_super_counts(volume, child_group, 0, 0, 1);
return true;
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