chore: fix almost *ALL* warnings.
[lunaix-os.git] / lunaix-os / kernel / fs / iso9660 / inode.c
index e5649106e46d920cf391de660ddb33d2c37ba0f1..fa3337b88f5d993f9d4dc3e6907b4d1f1ed3ba69 100644 (file)
@@ -1,9 +1,12 @@
 #include <klibc/string.h>
 #include <lunaix/fs.h>
 #include <lunaix/fs/iso9660.h>
+#include <lunaix/mm/cake.h>
 #include <lunaix/mm/valloc.h>
 #include <lunaix/spike.h>
 
+extern struct cake_pile* drec_cache_pile;
+
 static struct v_inode_ops iso_inode_ops = {
     .dir_lookup = iso9660_dir_lookup,
     .open = iso9660_open,
@@ -17,10 +20,27 @@ static struct v_file_ops iso_file_ops = { .close = iso9660_close,
                                           .seek = iso9660_seek,
                                           .readdir = iso9660_readdir };
 
+void
+iso9660_inode_destruct(struct v_inode* inode)
+{
+    struct iso_inode* isoino = inode->data;
+
+    struct iso_drecache *pos, *n;
+    llist_for_each(pos, n, &isoino->drecaches, caches)
+    {
+        cake_release(drec_cache_pile, pos);
+    }
+
+    vfree(isoino);
+}
+
 void
 iso9660_init_inode(struct v_superblock* vsb, struct v_inode* inode)
 {
-    inode->data = vzalloc(sizeof(struct iso_inode));
+    struct iso_inode* isoino = vzalloc(sizeof(struct iso_inode));
+    llist_init_head(&isoino->drecaches);
+    inode->data = isoino;
+    inode->destruct = iso9660_inode_destruct;
 }
 
 int