Bochs/bochs/iodev/hdimage/vmware4.h
Volker Ruppert 698afee9aa undoable / volatile mode: added support for other types of r/o base images.
These hdimage modes are now supported: flat, sparse, growing, vmware3, vmware4
und vpc. The image mode is auto-detected, so no change of configuration syntax
is necessary (TODO: documentation update). Example:

ata0-master: type=disk, mode=volatile, path=vmware4-test.img
2012-10-07 18:36:22 +00:00

102 lines
3.0 KiB
C++

/////////////////////////////////////////////////////////////////////////
// $Id$
/////////////////////////////////////////////////////////////////////////
/*
* This file provides support for VMWare's virtual disk image
* format version 4 and above.
*
* Author: Sharvil Nanavati
* Contact: snrrrub@gmail.com
*
* Copyright (C) 2006 Sharvil Nanavati.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _VMWARE4_H
#define _VMWARE4_H 1
class vmware4_image_t : public device_image_t
{
public:
vmware4_image_t();
virtual ~vmware4_image_t();
int open(const char* pathname, int flags);
void close();
Bit64s lseek(Bit64s offset, int whence);
ssize_t read(void* buf, size_t count);
ssize_t write(const void* buf, size_t count);
Bit32u get_capabilities();
static int check_format(int fd, Bit64u imgsize);
bx_bool save_state(const char *backup_fname);
void restore_state(const char *backup_fname);
private:
static const off_t INVALID_OFFSET;
static const int SECTOR_SIZE;
#if defined(_MSC_VER)
#pragma pack(push, 1)
#elif defined(__MWERKS__) && defined(macintosh)
#pragma options align=packed
#endif
typedef struct _VM4_Header
{
Bit8u id[4];
Bit32u version;
Bit32u flags;
Bit64u total_sectors;
Bit64u tlb_size_sectors;
Bit64u description_offset_sectors;
Bit64u description_size_sectors;
Bit32u slb_count;
Bit64u flb_offset_sectors;
Bit64u flb_copy_offset_sectors;
Bit64u tlb_offset_sectors;
}
#if !defined(_MSC_VER)
GCC_ATTRIBUTE((packed))
#endif
VM4_Header;
#if defined(_MSC_VER)
#pragma pack(pop)
#elif defined(__MWERKS__) && defined(macintosh)
#pragma options align=reset
#endif
bx_bool is_open() const;
bx_bool read_header();
off_t perform_seek();
void flush();
Bit32u read_block_index(Bit64u sector, Bit32u index);
void write_block_index(Bit64u sector, Bit32u index, Bit32u block_sector);
int file_descriptor;
VM4_Header header;
Bit8u* tlb;
off_t tlb_offset;
off_t current_offset;
bx_bool is_dirty;
const char *pathname;
};
#endif