- added own log prefix for the hdimage stuff

- added multiple sector read/write support for 'growing' images
- fixed two warnings
This commit is contained in:
Volker Ruppert 2011-01-14 16:43:55 +00:00
parent 0e008fedb0
commit 9b70c59980
5 changed files with 40 additions and 16 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: hdimage.cc,v 1.28 2011-01-12 22:34:42 vruppert Exp $
// $Id: hdimage.cc,v 1.29 2011-01-14 16:43:55 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002-2011 The Bochs Project
@ -35,7 +35,7 @@
#include <sys/mman.h>
#endif
#define LOG_THIS bx_devices.pluginHardDrive->
#define LOG_THIS theHDImageCtl->
bx_hdimage_ctl_c* theHDImageCtl = NULL;
@ -51,6 +51,11 @@ void libhdimage_LTX_plugin_fini(void)
delete theHDImageCtl;
}
bx_hdimage_ctl_c::bx_hdimage_ctl_c()
{
put("IMG");
}
device_image_t* bx_hdimage_ctl_c::init_image(Bit8u image_mode, Bit64u disk_size, const char *journal)
{
device_image_t *hdimage = NULL;
@ -672,8 +677,9 @@ ssize_t sparse_image_t::read(void* buf, size_t count)
BX_ASSERT (can_read != 0);
#if BX_ASSERT_ENABLE
size_t was_read = read_page_fragment(position_virtual_page, position_page_offset, can_read, buf);
#endif
BX_ASSERT(was_read == can_read);
total_read += can_read;
@ -1217,7 +1223,8 @@ Bit64s redolog_t::lseek(Bit64s offset, int whence)
ssize_t redolog_t::read(void* buf, size_t count)
{
Bit64s block_offset, bitmap_offset, ret;
Bit64s block_offset, bitmap_offset;
ssize_t ret;
if (count != 512) {
BX_PANIC(("redolog : read() with count not 512"));
@ -1382,14 +1389,29 @@ Bit64s growing_image_t::lseek(Bit64s offset, int whence)
ssize_t growing_image_t::read(void* buf, size_t count)
{
size_t n = 0;
ssize_t ret = 0;
memset(buf, 0, count);
redolog->read((char*) buf, count);
return count;
while (n < count) {
ret = redolog->read((char*) buf, 512);
if (ret < 0) break;
n += 512;
}
return (ret < 0) ? ret : count;
}
ssize_t growing_image_t::write(const void* buf, size_t count)
{
return redolog->write((char*) buf, count);
size_t n = 0;
ssize_t ret = 0;
while (n < count) {
ret = redolog->write((char*) buf, 512);
if (ret < 0) break;
n += 512;
}
return (ret < 0) ? ret : count;
}
/*** undoable_image_t function definitions ***/

View File

@ -1,8 +1,8 @@
/////////////////////////////////////////////////////////////////////////
// $Id: hdimage.h,v 1.17 2011-01-12 22:34:42 vruppert Exp $
// $Id: hdimage.h,v 1.18 2011-01-14 16:43:55 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2005-2009 The Bochs Project
// Copyright (C) 2005-2011 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -578,7 +578,7 @@ class z_volatile_image_t : public device_image_t
class bx_hdimage_ctl_c : public bx_hdimage_ctl_stub_c {
public:
bx_hdimage_ctl_c() {}
bx_hdimage_ctl_c();
virtual ~bx_hdimage_ctl_c() {}
virtual device_image_t *init_image(Bit8u image_mode, Bit64u disk_size, const char *journal);
};

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: vmware3.cc,v 1.24 2011-01-02 16:51:08 vruppert Exp $
// $Id: vmware3.cc,v 1.25 2011-01-14 16:43:55 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
/*
@ -37,7 +37,8 @@
#include "vmware3.h"
const off_t vmware3_image_t::INVALID_OFFSET=(off_t)-1;
#define LOG_THIS bx_devices.pluginHardDrive->
#define LOG_THIS bx_devices.pluginHDImageCtl->
#define DTOH32_HEADER(field) (header.field = (dtoh32(header.field)))
#define HTOD32_HEADER(field) (header.field = (htod32(header.field)))

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: vmware4.cc,v 1.7 2011-01-02 16:51:08 vruppert Exp $
// $Id: vmware4.cc,v 1.8 2011-01-14 16:43:55 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
/*
@ -37,7 +37,8 @@
#include "hdimage.h"
#include "vmware4.h"
#define LOG_THIS bx_devices.pluginHardDrive->
#define LOG_THIS bx_devices.pluginHDImageCtl->
const off_t vmware4_image_t::INVALID_OFFSET = (off_t)-1;
const int vmware4_image_t::SECTOR_SIZE = 512;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: vvfat.cc,v 1.19 2011-01-14 15:37:36 vruppert Exp $
// $Id: vvfat.cc,v 1.20 2011-01-14 16:43:55 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2010/2011 The Bochs Project
@ -48,7 +48,7 @@
#include "hdimage.h"
#include "vvfat.h"
#define LOG_THIS bx_devices.pluginHardDrive->
#define LOG_THIS bx_devices.pluginHDImageCtl->
#define VVFAT_MBR "vvfat_mbr.bin"
#define VVFAT_BOOT "vvfat_boot.bin"