From ae4dcabd39938e93afa1fb095ed5421e92c10d7d Mon Sep 17 00:00:00 2001 From: Florian Lohoff Date: Sat, 4 Oct 2008 15:45:55 +0000 Subject: Seperate ARC prom calls from ext2io.c --- ext2load/ext2io.c | 46 +++++++++++++--------------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) (limited to 'ext2load/ext2io.c') diff --git a/ext2load/ext2io.c b/ext2load/ext2io.c index 6f12b60..8776630 100644 --- a/ext2load/ext2io.c +++ b/ext2load/ext2io.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include /* * All About the Cache @@ -99,8 +99,8 @@ static unsigned long virtual_time; struct arc_private_data { int magic; - OPENMODE mode; - ULONG fileID; + int mode; + unsigned long fileID; struct arc_cache cache[CACHE_SIZE]; char *arc_sg_buf; unsigned long total_read; @@ -122,7 +122,6 @@ static errcode_t fill_sg_blocks(io_channel, struct arc_private_data *, int); static errcode_t raw_read_blk(io_channel, struct arc_private_data *, unsigned long, int, char *); -static void mul64(unsigned long, int, LARGEINTEGER *); static errcode_t arc_seek(io_channel, unsigned long); static errcode_t arc_open(const char *name, int flags, io_channel * channel); @@ -273,9 +272,9 @@ raw_read_blk(io_channel channel, struct arc_private_data *priv, priv->seek_pos_valid = 0; if (status == 0) { length = (count < 0) ? -count : count * channel->block_size; - ULONG nread = 0; + unsigned long nread = 0; - status = ArcRead(priv->fileID, buf, length, &nread); + status = prom_read(priv->fileID, buf, length, &nread); if ((nread > 0) && (nread < length)) { status = EXT2_ET_SHORT_READ; memset(((char *) buf) + nread, 0, length - nread); @@ -479,10 +478,10 @@ arc_open(const char *name, int flags, io_channel * pchannel) channel->private_data = priv; priv->magic = EXT2_ET_BAD_MAGIC; priv->mode = - (flags & IO_FLAG_RW) ? OpenReadWrite : - OpenReadOnly; + (flags & IO_FLAG_RW) ? O_RDWR : + O_RDONLY; status = - ArcOpen((char *) name, priv->mode, + prom_open((char *) name, priv->mode, &priv->fileID); if( status ) { status = EXT2_ET_BAD_DEVICE_NAME; @@ -517,7 +516,7 @@ static errcode_t arc_close(io_channel channel) EXT2_CHECK_MAGIC(priv, EXT2_ET_BAD_MAGIC); if (--channel->refcount == 0) { - status = ArcClose(priv->fileID); + status = prom_close(priv->fileID); free_cache(priv); if (channel->name != NULL) ext2fs_free_mem((void **) &channel->name); @@ -548,31 +547,12 @@ static errcode_t arc_set_blksize(io_channel channel, int blksize) return 0; } -static void -mul64(unsigned long block, int blocksize, LARGEINTEGER *result) -{ - ULONG m1l = block & 0x0FFFF, m1h = (block >> 16) & 0x0FFFF; - ULONG m2l = blocksize & 0x0FFFF, m2h = (blocksize >> 16) & 0x0FFFF; - ULONG i1 = m1l * m2h, i2 = m1h * m2l; - - result->HighPart = - (m1h * m2h) + ((i1 >> 16) & 0x0FFFF) + ((i2 >> 16) & 0x0FFFF); - i1 = - (i1 & 0x0FFFF) + (i2 & 0x0FFFF) + - (((m1l * m2l) >> 16) & 0x0FFFF); - result->LowPart = ((i1 & 0x0FFFF) << 16) + ((m1l * m2l) & 0x0FFFF); - result->HighPart += (i1 >> 16) & 0x0FFFF; -} - static errcode_t arc_seek(io_channel channel, unsigned long block) { struct arc_private_data *priv; - LARGEINTEGER position; - priv = (struct arc_private_data *) channel->private_data; - mul64(block, channel->block_size, &position); - return ArcSeek(priv->fileID, &position, SeekAbsolute); + return prom_seek(priv->fileID, block*channel->block_size, SEEK_SET); } /* @@ -686,14 +666,14 @@ arc_write_blk (io_channel channel, unsigned long block, int count, if (status == 0) { size_t length = (count < 0) ? -count : count * channel->block_size; - ULONG nwritten = 0; + unsigned long nwritten = 0; status = - ArcWrite(priv->fileID, (void *) buf, length, + prom_write(priv->fileID, (void *) buf, length, &nwritten); if ((nwritten > 0) && (nwritten < length)) status = EXT2_ET_SHORT_WRITE; - if ((status != ESUCCESS) && (channel->write_error != NULL)) { + if ((status != 0) && (channel->write_error != NULL)) { status = (channel->write_error) (channel, block, count, buf, length, nwritten, status); } -- cgit v1.2.3