diff options
Diffstat (limited to 'core/fs')
-rw-r--r-- | core/fs/fs.c | 35 | ||||
-rw-r--r-- | core/fs/iso9660/iso9660.c | 4 |
2 files changed, 36 insertions, 3 deletions
diff --git a/core/fs/fs.c b/core/fs/fs.c index 792da02f..3ae12ec9 100644 --- a/core/fs/fs.c +++ b/core/fs/fs.c @@ -117,6 +117,35 @@ void getfssec(com32sys_t *regs) regs->ecx.l = bytes_read; } +void getfsbytes(com32sys_t *regs) +{ + int sectors; + bool have_more; + uint32_t bytes_read; + char *buf; + struct file *file; + uint16_t handle; + + handle = regs->esi.w[0]; + file = handle_to_file(handle); + + sectors = regs->ecx.w[0] >> SECTOR_SHIFT(file->fs); + + buf = MK_PTR(regs->es, regs->ebx.w[0]); + bytes_read = file->fs->fs_ops->getfssec(file, buf, sectors, &have_more); + + /* + * If we reach EOF, the filesystem driver will have already closed + * the underlying file... this really should be cleaner. + */ + if (!have_more) { + _close_file(file); + regs->esi.w[0] = 0; + } + + regs->ecx.l = bytes_read; +} + size_t pmapi_read_file(uint16_t *handle, void *buf, size_t sectors) { bool have_more; @@ -353,8 +382,9 @@ void pm_close_file(com32sys_t *regs) * invoke the fs-specific init function; * initialize the cache if we need one; * finally, get the current inode for relative path looking. - * */ +__bss16 uint16_t SectorSize, SectorShift; + void fs_init(com32sys_t *regs) { static struct fs_info fs; /* The actual filesystem buffer */ @@ -411,4 +441,7 @@ void fs_init(com32sys_t *regs) fs.root = fs.fs_ops->iget_root(&fs); fs.cwd = get_inode(fs.root); } + + SectorShift = fs.sector_shift; + SectorSize = fs.sector_size; } diff --git a/core/fs/iso9660/iso9660.c b/core/fs/iso9660/iso9660.c index 4c568bf6..d695e439 100644 --- a/core/fs/iso9660/iso9660.c +++ b/core/fs/iso9660/iso9660.c @@ -206,8 +206,8 @@ static struct inode *iso_get_inode(struct fs_info *fs, inode->blocks = (inode->size + BLOCK_SIZE(fs) - 1) >> BLOCK_SHIFT(fs); /* We have a single extent for all data */ - inode->next_extent.pstart = de->extent_le << blktosec; - inode->next_extent.len = inode->blocks << blktosec; + inode->next_extent.pstart = (sector_t)de->extent_le << blktosec; + inode->next_extent.len = (sector_t)inode->blocks << blktosec; return inode; } |