X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/c6de44b989e9d7286337e4cbf4d82d919f9120e6..HEAD:/lunaix-os/kernel/fs/iso9660/mount.c diff --git a/lunaix-os/kernel/fs/iso9660/mount.c b/lunaix-os/kernel/fs/iso9660/mount.c index f6bb2fc..aeb6e3b 100644 --- a/lunaix-os/kernel/fs/iso9660/mount.c +++ b/lunaix-os/kernel/fs/iso9660/mount.c @@ -1,32 +1,39 @@ #include -#include -#include +#include #include +#include #include -#include +#include "iso9660.h" struct cake_pile* drec_cache_pile; extern void iso9660_init_inode(struct v_superblock* vsb, struct v_inode* inode); -uint32_t -iso9660_rd_capacity(struct v_superblock* vsb) +static size_t +__iso9660_rd_capacity(struct v_superblock* vsb) { struct iso_superblock* isovsb = (struct iso_superblock*)vsb->data; return isovsb->volume_size; } +static void +__vsb_release(struct v_superblock* vsb) +{ + vfree(vsb->data); +} + int 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; + u32_t lba = 16; 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; @@ -39,7 +46,7 @@ iso9660_mount(struct v_superblock* vsb, struct v_dnode* mount_point) vprim = (struct iso_vol_primary*)vdesc; break; } - + lba++; } while (vdesc->type != ISO_VOLTERM); if (!vprim) { @@ -53,11 +60,13 @@ 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->ops.read_capacity = __iso9660_rd_capacity; + vsb->ops.release = __vsb_release; + vsb->blksize = ISO9660_BLKSZ; 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); @@ -66,7 +75,7 @@ iso9660_mount(struct v_superblock* vsb, struct v_dnode* mount_point) } 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); @@ -81,28 +90,31 @@ iso9660_mount(struct v_superblock* vsb, struct v_dnode* mount_point) } vfs_i_addhash(rootino); + return 0; done: vfree(vdesc); - return 0; + return errno; } + + int iso9660_unmount(struct v_superblock* vsb) { - // TODO clean up + return 0; } void iso9660_init() { + struct filesystem* fs; + fs = fsapi_fs_declare("iso9660", FSTYPE_ROFS); + + fsapi_fs_set_mntops(fs, iso9660_mount, iso9660_unmount); + fsapi_fs_finalise(fs); + drec_cache_pile = cake_new_pile("iso_drec", sizeof(struct iso_drecache), 1, 0); - - struct filesystem* fs = fsm_new_fs("iso9660", -1); - fs->types |= FSTYPE_ROFS; - fs->mount = iso9660_mount; - 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