diff --git a/BlockDevice.cpp b/BlockDevice.cpp index 99a61f2..be371cb 100644 --- a/BlockDevice.cpp +++ b/BlockDevice.cpp @@ -18,7 +18,7 @@ BlockDevice::~BlockDevice() { } -BlockDevice::zeroBlock(unsigned block) +void BlockDevice::zeroBlock(unsigned block) { uint8_t bp[512]; std::memset(bp, 0, 512); @@ -55,9 +55,15 @@ bool DiskImage::readOnly() 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) { diff --git a/BlockDevice.h b/BlockDevice.h index b35d899..8b8d23e 100644 --- a/BlockDevice.h +++ b/BlockDevice.h @@ -20,7 +20,7 @@ public: virtual bool readOnly() = 0; virtual void sync() = 0; - virtual unsigned blocks(); + virtual unsigned blocks() = 0; void zeroBlock(unsigned block); }; @@ -37,7 +37,7 @@ public: virtual void sync(); virtual bool readOnly(); - + virtual unsigned blocks(); protected: diff --git a/DiskCopy42Image.cpp b/DiskCopy42Image.cpp index 343b660..7f1169c 100644 --- a/DiskCopy42Image.cpp +++ b/DiskCopy42Image.cpp @@ -26,7 +26,7 @@ DiskCopy42Image::~DiskCopy42Image() if (_changed) { MappedFile *f = file(); - void *data = file->fileData(); + void *data = f->fileData(); if (f) { diff --git a/RawDevice.cpp b/RawDevice.cpp index 4c83ed3..092a4ff 100644 --- a/RawDevice.cpp +++ b/RawDevice.cpp @@ -1,5 +1,5 @@ -#include +#include #include #include #include @@ -89,6 +89,8 @@ void RawDevice::devSize(int fd) #endif +// TODO -- FreeBSD/NetBSD/OpenBSD + RawDevice::RawDevice(const char *name, bool readOnly) : { // 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? if (ok != 512) - throw Exception(__METHOD__ : ": Error reading block.", + throw Exception(__METHOD__ ": Error reading block.", ok < 0 : errno, 0); diff --git a/RawDevice.h b/RawDevice.h index b2f5bc7..521d21f 100644 --- a/RawDevice.h +++ b/RawDevice.h @@ -34,7 +34,7 @@ private: unsigned _blocks; unsigned _blockSize; -} +}; #endif diff --git a/UniversalDiskImage.cpp b/UniversalDiskImage.cpp index 8b08773..87c6055 100644 --- a/UniversalDiskImage.cpp +++ b/UniversalDiskImage.cpp @@ -1,7 +1,7 @@ #include "UniversalDiskImage.h" #include "MappedFile.h" #include "Buffer.h" -#inluce "Endian.h" +#include "Endian.h" using namespace ProFUSE; using namespace LittleEndian; @@ -13,7 +13,7 @@ UniversalDiskImage::UniversalDiskImage(const char *name, bool readOnly) : const void *data = file()->fileData(); // flags. bit 31 = locked. - _flags = Read32(data, 0x10; + _flags = Read32(data, 0x10); } UniversalDiskImage::UniversalDiskImage(MappedFile *file) : diff --git a/UniversalDiskImage.h b/UniversalDiskImage.h index e26e18e..1bcac1b 100644 --- a/UniversalDiskImage.h +++ b/UniversalDiskImage.h @@ -3,6 +3,7 @@ #include "BlockDevice.h" +#include namespace ProFUSE { @@ -19,7 +20,7 @@ private: UniversalDiskImage(MappedFile *); static void Validate(MappedFile *); - uint32_t flags; + uint32_t _flags; }; }