feat: fstat now handle symbolic link
[lunaix-os.git] / lunaix-os / kernel / fs / iso9660 / mount.c
index f6bb2fc66a1935f77bfdcea62d690a4eecc6bcf4..25150e5efe990aa73807f0f885c7bda9bc8d822c 100644 (file)
@@ -11,7 +11,7 @@ struct cake_pile* drec_cache_pile;
 extern void
 iso9660_init_inode(struct v_superblock* vsb, struct v_inode* inode);
 
 extern void
 iso9660_init_inode(struct v_superblock* vsb, struct v_inode* inode);
 
-uint32_t
+u32_t
 iso9660_rd_capacity(struct v_superblock* vsb)
 {
     struct iso_superblock* isovsb = (struct iso_superblock*)vsb->data;
 iso9660_rd_capacity(struct v_superblock* vsb)
 {
     struct iso_superblock* isovsb = (struct iso_superblock*)vsb->data;
@@ -24,9 +24,10 @@ iso9660_mount(struct v_superblock* vsb, struct v_dnode* mount_point)
     struct device* dev = vsb->dev;
     struct iso_vol* vdesc = (struct iso_vol*)valloc(ISO9660_BLKSZ);
     struct iso_vol_primary* vprim = NULL;
     struct device* dev = vsb->dev;
     struct iso_vol* vdesc = (struct iso_vol*)valloc(ISO9660_BLKSZ);
     struct iso_vol_primary* vprim = NULL;
+    u32_t lba = 16;
     int errno = 0;
     do {
     int errno = 0;
     do {
-        errno = dev->read(dev, vdesc, ISO9660_BLKSZ * 16, ISO9660_BLKSZ);
+        errno = dev->ops.read(dev, vdesc, ISO9660_BLKSZ * lba, ISO9660_BLKSZ);
         if (errno < 0) {
             errno = EIO;
             goto done;
         if (errno < 0) {
             errno = EIO;
             goto done;
@@ -39,7 +40,7 @@ iso9660_mount(struct v_superblock* vsb, struct v_dnode* mount_point)
             vprim = (struct iso_vol_primary*)vdesc;
             break;
         }
             vprim = (struct iso_vol_primary*)vdesc;
             break;
         }
-
+        lba++;
     } while (vdesc->type != ISO_VOLTERM);
 
     if (!vprim) {
     } while (vdesc->type != ISO_VOLTERM);
 
     if (!vprim) {
@@ -54,10 +55,11 @@ iso9660_mount(struct v_superblock* vsb, struct v_dnode* mount_point)
     vsb->data = isovsb;
     vsb->ops.init_inode = iso9660_init_inode;
     vsb->ops.read_capacity = iso9660_rd_capacity;
     vsb->data = isovsb;
     vsb->ops.init_inode = iso9660_init_inode;
     vsb->ops.read_capacity = iso9660_rd_capacity;
+    vsb->blksize = ISO9660_BLKSZ;
 
     struct v_inode* rootino = vfs_i_alloc(vsb);
 
     struct v_inode* rootino = vfs_i_alloc(vsb);
-    struct iso_drecord* dir =
-      iso9660_get_drecord((struct iso_var_mdu*)vprim->root_record);
+    struct iso_var_mdu* mdu = (struct iso_var_mdu*)vprim->root_record;
+    struct iso_drecord* dir = iso9660_get_drecord(mdu);
 
     if (!dir) {
         vfree(isovsb);
 
     if (!dir) {
         vfree(isovsb);
@@ -66,7 +68,7 @@ iso9660_mount(struct v_superblock* vsb, struct v_dnode* mount_point)
     }
 
     struct iso_drecache drecache;
     }
 
     struct iso_drecache drecache;
-    iso9660_fill_drecache(&drecache, dir);
+    iso9660_fill_drecache(&drecache, dir, mdu->len);
 
     if ((errno = iso9660_fill_inode(rootino, &drecache, 0)) < 0) {
         vfree(isovsb);
 
     if ((errno = iso9660_fill_inode(rootino, &drecache, 0)) < 0) {
         vfree(isovsb);
@@ -81,16 +83,19 @@ iso9660_mount(struct v_superblock* vsb, struct v_dnode* mount_point)
     }
 
     vfs_i_addhash(rootino);
     }
 
     vfs_i_addhash(rootino);
+    return 0;
 
 done:
     vfree(vdesc);
 
 done:
     vfree(vdesc);
-    return 0;
+    return errno;
 }
 
 int
 iso9660_unmount(struct v_superblock* vsb)
 {
 }
 
 int
 iso9660_unmount(struct v_superblock* vsb)
 {
-    // TODO clean up
+    vfree(vsb->data);
+
+    return 0;
 }
 
 void
 }
 
 void
@@ -105,4 +110,5 @@ iso9660_init()
     fs->unmount = iso9660_unmount;
 
     fsm_register(fs);
     fs->unmount = iso9660_unmount;
 
     fsm_register(fs);
-}
\ No newline at end of file
+}
+EXPORT_FILE_SYSTEM(iso9660, iso9660_init);
\ No newline at end of file