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

This commit is contained in:
ksherlock 2010-05-31 19:51:50 +00:00
parent 345927d4b2
commit 1894a178d1
2 changed files with 31 additions and 5 deletions

View File

@ -25,6 +25,10 @@
#include <sys/disk.h>
#endif
#ifdef __minix
#include <minix/partition.h>
#endif
#include <Device/RawDevice.h>
#include <ProFUSE/Exception.h>
@ -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)

View File

@ -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.
};
}