git-svn-id: https://profuse.googlecode.com/svn/branches/v2@101 aa027e90-d47c-11dd-86d7-074df07e0730

This commit is contained in:
ksherlock
2009-11-24 04:36:48 +00:00
parent 2462938c3a
commit 8212b02088
7 changed files with 22 additions and 13 deletions

View File

@@ -18,7 +18,7 @@ BlockDevice::~BlockDevice()
{ {
} }
BlockDevice::zeroBlock(unsigned block) void BlockDevice::zeroBlock(unsigned block)
{ {
uint8_t bp[512]; uint8_t bp[512];
std::memset(bp, 0, 512); std::memset(bp, 0, 512);
@@ -55,9 +55,15 @@ bool DiskImage::readOnly()
throw Exception(__METHOD__ ": File not set."); throw Exception(__METHOD__ ": File not set.");
} }
unsigned DiskImage::blocks()
{
#undef __METHOD__
#define __METHOD__ "DiskImage::blocks"
if (_file) return _file->blocks();
throw Exception(__METHOD__ ": File not set.");
}
void DiskImage::read(unsigned block, void *bp) void DiskImage::read(unsigned block, void *bp)
{ {

View File

@@ -20,7 +20,7 @@ public:
virtual bool readOnly() = 0; virtual bool readOnly() = 0;
virtual void sync() = 0; virtual void sync() = 0;
virtual unsigned blocks(); virtual unsigned blocks() = 0;
void zeroBlock(unsigned block); void zeroBlock(unsigned block);
}; };
@@ -37,7 +37,7 @@ public:
virtual void sync(); virtual void sync();
virtual bool readOnly(); virtual bool readOnly();
virtual unsigned blocks();
protected: protected:

View File

@@ -26,7 +26,7 @@ DiskCopy42Image::~DiskCopy42Image()
if (_changed) if (_changed)
{ {
MappedFile *f = file(); MappedFile *f = file();
void *data = file->fileData(); void *data = f->fileData();
if (f) if (f)
{ {

View File

@@ -1,5 +1,5 @@
#include <ioctl.h> #include <sys/ioctl.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/uio.h> #include <sys/uio.h>
@@ -89,6 +89,8 @@ void RawDevice::devSize(int fd)
#endif #endif
// TODO -- FreeBSD/NetBSD/OpenBSD
RawDevice::RawDevice(const char *name, bool readOnly) : RawDevice::RawDevice(const char *name, bool readOnly) :
{ {
// open read-only, verify if device is readable, and then try to upgrade to read/write? // open read-only, verify if device is readable, and then try to upgrade to read/write?
@@ -133,7 +135,7 @@ void RawDevice::read(unsigned block, void *bp)
// TODO -- EINTR? // TODO -- EINTR?
if (ok != 512) if (ok != 512)
throw Exception(__METHOD__ : ": Error reading block.", throw Exception(__METHOD__ ": Error reading block.",
ok < 0 : errno, 0); ok < 0 : errno, 0);

View File

@@ -34,7 +34,7 @@ private:
unsigned _blocks; unsigned _blocks;
unsigned _blockSize; unsigned _blockSize;
} };
#endif #endif

View File

@@ -1,7 +1,7 @@
#include "UniversalDiskImage.h" #include "UniversalDiskImage.h"
#include "MappedFile.h" #include "MappedFile.h"
#include "Buffer.h" #include "Buffer.h"
#inluce "Endian.h" #include "Endian.h"
using namespace ProFUSE; using namespace ProFUSE;
using namespace LittleEndian; using namespace LittleEndian;
@@ -13,7 +13,7 @@ UniversalDiskImage::UniversalDiskImage(const char *name, bool readOnly) :
const void *data = file()->fileData(); const void *data = file()->fileData();
// flags. bit 31 = locked. // flags. bit 31 = locked.
_flags = Read32(data, 0x10; _flags = Read32(data, 0x10);
} }
UniversalDiskImage::UniversalDiskImage(MappedFile *file) : UniversalDiskImage::UniversalDiskImage(MappedFile *file) :

View File

@@ -3,6 +3,7 @@
#include "BlockDevice.h" #include "BlockDevice.h"
#include <stdint.h>
namespace ProFUSE { namespace ProFUSE {
@@ -19,7 +20,7 @@ private:
UniversalDiskImage(MappedFile *); UniversalDiskImage(MappedFile *);
static void Validate(MappedFile *); static void Validate(MappedFile *);
uint32_t flags; uint32_t _flags;
}; };
} }