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;
58 vsb->blksize = ISO9660_BLKSZ;
60 struct v_inode* rootino = vfs_i_alloc(vsb);
61 struct iso_var_mdu* mdu = (struct iso_var_mdu*)vprim->root_record;
62 struct iso_drecord* dir = iso9660_get_drecord(mdu);
70 struct iso_drecache drecache;
71 iso9660_fill_drecache(&drecache, dir, mdu->len);
73 if ((errno = iso9660_fill_inode(rootino, &drecache, 0)) < 0) {
79 if ((errno = iso9660_setup_dnode(mount_point, rootino)) < 0) {
85 vfs_i_addhash(rootino);
94 iso9660_unmount(struct v_superblock* vsb)
105 cake_new_pile("iso_drec", sizeof(struct iso_drecache), 1, 0);
107 struct filesystem* fs = fsm_new_fs("iso9660", -1);
108 fs->types |= FSTYPE_ROFS;
109 fs->mount = iso9660_mount;
110 fs->unmount = iso9660_unmount;
114 EXPORT_FILE_SYSTEM(iso9660, iso9660_init);