1 #include <klibc/string.h>
3 #include <lunaix/fs/iso9660.h>
4 #include <lunaix/mm/valloc.h>
5 #include <lunaix/spike.h>
7 static struct v_inode_ops iso_inode_ops = {
8 .dir_lookup = iso9660_dir_lookup,
12 static struct v_file_ops iso_file_ops = { .close = iso9660_close,
14 .read_page = iso9660_read,
15 .write = iso9660_write,
16 .write_page = iso9660_write,
18 .readdir = iso9660_readdir };
21 iso9660_init_inode(struct v_superblock* vsb, struct v_inode* inode)
23 inode->data = vzalloc(sizeof(struct iso_inode));
27 iso9660_fill_inode(struct v_inode* inode, struct iso_drecache* dir, int ino)
30 struct device* dev = inode->sb->dev;
31 struct iso_inode* isoino = (struct iso_inode*)inode->data;
33 // In the spec, there is a differentiation in how file section organized
34 // between interleaving and non-interleaving mode. To simplify this, we
35 // treat the non-interleaving as an interleaving with gap size = 0 and fu
37 isoino->fu_size = dir->fu_size;
38 isoino->gap_size = dir->gap_size;
40 u32_t fu_len = isoino->fu_size * ISO9660_BLKSZ;
43 inode->lb_addr = dir->extent_addr;
44 inode->ops = &iso_inode_ops;
45 inode->default_fops = &iso_file_ops;
47 // xattr_len is in unit of FU. Each FU comprise <fu_sz> block(s).
48 inode->fsize = dir->data_size - dir->xattr_len * fu_len;
50 if ((dir->flags & ISO_FDIR)) {
51 inode->itype = VFS_IFDIR;
53 inode->itype = VFS_IFFILE;
57 struct iso_xattr* xattr = (struct iso_xattr*)valloc(ISO9660_BLKSZ);
58 // Only bring in single FU, as we only care about the attributes.
60 dev->read(dev, xattr, ISO9660_BLKSZ * inode->lb_addr, ISO9660_BLKSZ);
64 isoino->record_fmt = xattr->record_fmt;
65 isoino->ctime = iso9660_dt2unix(&xattr->ctime);
66 isoino->mtime = iso9660_dt2unix(&xattr->mtime);
68 inode->lb_addr += dir->xattr_len * dir->fu_size;