]> 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 d89ae56f7a4a5acf6e97af14d3fbb1e4c5ad23f6..cab38b81abe9397cc69b2e9e9d17546469c341b1 100644 (file)
@@ -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;
 
index b245f3f2cc9583ebbe1cb66cb61f844f2febf156..79b931b551d5c63ee729dcf3ea9b54db006eb043 100644 (file)
@@ -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);
 }