From 2c857234cfbaa00829b77961ebfa34e8050bab4a Mon Sep 17 00:00:00 2001 From: Tulio A M Mendes Date: Fri, 13 Feb 2026 23:08:36 -0300 Subject: [PATCH] refactor: migrate pty and fat to inode_operations - pty: pty_pts_dir_iops with lookup/readdir; pty_pts_dir_fops now empty - fat: fat_dir_iops with lookup/readdir/create/mkdir/unlink/rmdir/rename; fat_file_iops with truncate; fat_dir_fops and fat_file_fops keep only close and read/write/close respectively - ext2 has no VFS integration yet, no migration needed All node creation sites wire both f_ops and i_ops. 20/20 smoke tests pass. --- src/kernel/fat.c | 11 ++++++++++- src/kernel/pty.c | 7 +++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/kernel/fat.c b/src/kernel/fat.c index d89ae56f..cab38b81 100644 --- a/src/kernel/fat.c +++ b/src/kernel/fat.c @@ -496,12 +496,18 @@ static const struct file_operations fat_file_fops = { .read = fat_file_read, .write = fat_file_write, .close = fat_close_impl, +}; + +static const struct inode_operations fat_file_iops = { .truncate = fat_truncate_impl, }; static const struct file_operations fat_dir_fops = { .close = fat_close_impl, - .finddir = fat_finddir, +}; + +static const struct inode_operations fat_dir_iops = { + .lookup = fat_finddir, .readdir = fat_readdir_impl, .create = fat_create_impl, .mkdir = fat_mkdir_impl, @@ -531,11 +537,13 @@ static struct fat_node* fat_make_node(const struct fat_dirent* de, uint32_t pare fn->vfs.length = 0; fn->vfs.inode = fn->first_cluster; fn->vfs.f_ops = &fat_dir_fops; + fn->vfs.i_ops = &fat_dir_iops; } else { fn->vfs.flags = FS_FILE; fn->vfs.length = de->file_size; fn->vfs.inode = fn->first_cluster; fn->vfs.f_ops = &fat_file_fops; + fn->vfs.i_ops = &fat_file_iops; } return fn; @@ -1173,6 +1181,7 @@ fs_node_t* fat_mount(int drive, uint32_t partition_lba) { g_fat_root.parent_cluster = 0; g_fat_root.dir_entry_offset = 0; g_fat_root.vfs.f_ops = &fat_dir_fops; + g_fat_root.vfs.i_ops = &fat_dir_iops; g_fat_ready = 1; diff --git a/src/kernel/pty.c b/src/kernel/pty.c index b245f3f2..79b931b5 100644 --- a/src/kernel/pty.c +++ b/src/kernel/pty.c @@ -134,8 +134,10 @@ static const struct file_operations pty_ptmx_fops = { .poll = pty_master_poll_fn, }; -static const struct file_operations pty_pts_dir_fops = { - .finddir = pty_pts_finddir, +static const struct file_operations pty_pts_dir_fops = {0}; + +static const struct inode_operations pty_pts_dir_iops = { + .lookup = pty_pts_finddir, .readdir = pty_pts_readdir, }; @@ -258,6 +260,7 @@ void pty_init(void) { g_dev_pts_dir_node.flags = FS_DIRECTORY; g_dev_pts_dir_node.inode = 5; g_dev_pts_dir_node.f_ops = &pty_pts_dir_fops; + g_dev_pts_dir_node.i_ops = &pty_pts_dir_iops; devfs_register_device(&g_dev_pts_dir_node); } -- 2.43.0