summaryrefslogtreecommitdiff
path: root/core/fs/fs.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2010-05-14 15:22:00 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2010-05-14 15:22:00 -0700
commit4f2568ba84172915df94995df4ad358d2f09cc0e (patch)
treec1a52d8f616b99065d9aac4c9e219c34abcf35e5 /core/fs/fs.c
parent4c7ad2f6dfc8da45eaafd6898feb319b478dca53 (diff)
downloadsyslinux-4f2568ba84172915df94995df4ad358d2f09cc0e.tar.gz
core: fix "sector size" confusionsyslinux-4.00-pre45
Fix the case where the "sector size" used by the pm filesystem driver isn't the same thing as the SECTOR_SIZE/SECTOR_SHIFT macros used in the assembly code. This is a per-device property, and in the particular case of isolinux hybrid, they are not even currently the same (for all others, they are the same for now, but not necessarily in the future.) Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'core/fs/fs.c')
-rw-r--r--core/fs/fs.c35
1 files changed, 34 insertions, 1 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;
}