]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
refactor: migrate pty and fat to inode_operations
authorTulio A M Mendes <[email protected]>
Sat, 14 Feb 2026 02:08:36 +0000 (23:08 -0300)
committerTulio A M Mendes <[email protected]>
Sat, 14 Feb 2026 02:08:36 +0000 (23:08 -0300)
- 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
src/kernel/pty.c

index 78641283cd66c0fca0ddd7c576c181e88bece5b9..b5e9eb0cb6f4432d8a055919d3a05a213fddc341 100644 (file)
@@ -487,12 +487,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,
@@ -522,11 +528,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;
@@ -1164,6 +1172,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;
 
index 24f2ff53a19c853629dd131be6a9b4f5fc662a1b..8efb64e0b4319be831a141c70361d02b575dccc6 100644 (file)
@@ -125,8 +125,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,
 };
 
@@ -249,6 +251,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);
 }