diff --git a/Device/RawDevice.cpp b/Device/RawDevice.cpp index 11c1494..2056311 100644 --- a/Device/RawDevice.cpp +++ b/Device/RawDevice.cpp @@ -25,6 +25,10 @@ #include #endif +#ifdef __minix +#include +#endif + #include #include @@ -105,7 +109,7 @@ void RawDevice::devSize(int fd) #undef __METHOD__ #define __METHOD__ "RawDevice::devSize" - unisgned blockSize; + unsigned blockSize; off_t mediaSize; if (::ioctl(fd, DIOCGSECTORSIZE, &blockSize) @@ -116,11 +120,33 @@ void RawDevice::devSize(int fd) _blockSize = blockSize; _size = mediaSize; - _blocks = mediaSize / blockSize; + _blocks = mediaSize / 512; } #endif + + +#ifdef __minix + +void RawDevice::devSize(int fd) +{ +#undef __METHOD__ +#define __METHOD__ "RawDevice::devSize" + + struct partition entry; + + + if (::ioctl(fd, DIOCGETP, &entry) < 0) + throw POSIXException(__METHOD__ ": Unable to determine device size.", errno); + + _size = entry.size + _blockSize = 512; // not really but whatever. + _blocks = _size / 512; + +} + +#endif RawDevice::RawDevice(const char *name, File::FileFlags flags) : _file(name, flags) diff --git a/Device/RawDevice.h b/Device/RawDevice.h index 573ab94..2b036cc 100644 --- a/Device/RawDevice.h +++ b/Device/RawDevice.h @@ -46,10 +46,10 @@ private: File _file; bool _readOnly; - uint64_t _size; - unsigned _blocks; + uint64_t _size; // size of device in bytes. + unsigned _blocks; // # of 512k blocks i.e. _size / 512 - unsigned _blockSize; + unsigned _blockSize; // native block size. }; }