diff options
author | Yang Zhang <yang.z.zhang@intel.com> | 2015-08-28 09:58:54 +0800 |
---|---|---|
committer | Yang Zhang <yang.z.zhang@intel.com> | 2015-09-01 12:44:00 +0800 |
commit | e44e3482bdb4d0ebde2d8b41830ac2cdb07948fb (patch) | |
tree | 66b09f592c55df2878107a468a91d21506104d3f /qemu/roms/openbios/fs/iso9660/iso9660_read.c | |
parent | 9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 (diff) |
Add qemu 2.4.0
Change-Id: Ic99cbad4b61f8b127b7dc74d04576c0bcbaaf4f5
Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Diffstat (limited to 'qemu/roms/openbios/fs/iso9660/iso9660_read.c')
-rw-r--r-- | qemu/roms/openbios/fs/iso9660/iso9660_read.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/qemu/roms/openbios/fs/iso9660/iso9660_read.c b/qemu/roms/openbios/fs/iso9660/iso9660_read.c new file mode 100644 index 000000000..22cc463f0 --- /dev/null +++ b/qemu/roms/openbios/fs/iso9660/iso9660_read.c @@ -0,0 +1,74 @@ +/* + * + * (c) 2005-2009 Laurent Vivier <Laurent@vivier.eu> + * + * This file has been copied from EMILE, http://emile.sf.net + * + */ + +#include "libiso9660.h" +#include "libopenbios/bindings.h" +#include "libc/diskio.h" + +size_t iso9660_read(iso9660_FILE *_file, char *buf, size_t count) +{ + iso9660_FILE *file = (iso9660_FILE*)_file; + size_t read = 0; + + if ( count > (file->size - file->offset) ) + count = file->size - file->offset; + + while (count > 0) + { + size_t part; + int offset_extent; + int offset_index; + + offset_extent = file->base + + (file->offset / ISOFS_BLOCK_SIZE); + offset_index = file->offset % ISOFS_BLOCK_SIZE; + + if (file->current != offset_extent) + { + if ( (offset_index == 0) && + (count >= ISOFS_BLOCK_SIZE) ) + { + /* direct i/o */ + + int extents_nb; + + extents_nb = count / ISOFS_BLOCK_SIZE; + + part = extents_nb * ISOFS_BLOCK_SIZE; + + seek_io(file->volume->fd, + offset_extent * ISOFS_BLOCK_SIZE); + read_io(file->volume->fd, buf + read, part); + + file->offset += part; + count -= part; + read += part; + + continue; + } + + file->current = offset_extent; + seek_io(file->volume->fd, + offset_extent * ISOFS_BLOCK_SIZE); + read_io(file->volume->fd, file->buffer, + ISOFS_BLOCK_SIZE); + } + + part = ISOFS_BLOCK_SIZE - offset_index; + if (count < part) + part = count; + + memcpy(buf + read, file->buffer + offset_index, part); + + file->offset += part; + count -= part; + read += part; + } + + return read; +} |