1 #include <lunaix/block.h>
3 #include <lunaix/fs/iso9660.h>
4 #include <lunaix/mm/valloc.h>
5 #include <lunaix/spike.h>
7 #include <lunaix/mm/cake.h>
9 struct cake_pile* drec_cache_pile;
12 iso9660_init_inode(struct v_superblock* vsb, struct v_inode* inode);
15 iso9660_rd_capacity(struct v_superblock* vsb)
17 struct iso_superblock* isovsb = (struct iso_superblock*)vsb->data;
18 return isovsb->volume_size;
22 iso9660_mount(struct v_superblock* vsb, struct v_dnode* mount_point)
24 struct device* dev = vsb->dev;
25 struct iso_vol* vdesc = (struct iso_vol*)valloc(ISO9660_BLKSZ);
26 struct iso_vol_primary* vprim = NULL;
30 errno = dev->ops.read(dev, vdesc, ISO9660_BLKSZ * lba, ISO9660_BLKSZ);
35 if (*(u32_t*)vdesc->std_id != ISO_SIGNATURE_LO) {
39 if (vdesc->type == ISO_VOLPRIM) {
40 vprim = (struct iso_vol_primary*)vdesc;
44 } while (vdesc->type != ISO_VOLTERM);
51 struct iso_superblock* isovsb = valloc(sizeof(*isovsb));
52 isovsb->lb_size = vprim->lb_size.le;
53 isovsb->volume_size = vprim->vol_size.le * isovsb->lb_size;
56 vsb->ops.init_inode = iso9660_init_inode;
57 vsb->ops.read_capacity = iso9660_rd_capacity;
59 struct v_inode* rootino = vfs_i_alloc(vsb);
60 struct iso_var_mdu* mdu = (struct iso_var_mdu*)vprim->root_record;
61 struct iso_drecord* dir = iso9660_get_drecord(mdu);
69 struct iso_drecache drecache;
70 iso9660_fill_drecache(&drecache, dir, mdu->len);
72 if ((errno = iso9660_fill_inode(rootino, &drecache, 0)) < 0) {
78 if ((errno = iso9660_setup_dnode(mount_point, rootino)) < 0) {
84 vfs_i_addhash(rootino);
93 iso9660_unmount(struct v_superblock* vsb)
104 cake_new_pile("iso_drec", sizeof(struct iso_drecache), 1, 0);
106 struct filesystem* fs = fsm_new_fs("iso9660", -1);
107 fs->types |= FSTYPE_ROFS;
108 fs->mount = iso9660_mount;
109 fs->unmount = iso9660_unmount;
113 EXPORT_FILE_SYSTEM(iso9660, iso9660_init);