BSD raw device support

git-svn-id: https://profuse.googlecode.com/svn/branches/v2@244 aa027e90-d47c-11dd-86d7-074df07e0730
This commit is contained in:
ksherlock 2010-05-20 23:22:30 +00:00
parent da84b5bca2
commit 91e2aaac70

View File

@ -20,6 +20,11 @@
#include <sys/dkio.h>
#endif
#ifdef __FREEBSD__
#include <sys/disk.h>
#endif
#include <Device/RawDevice.h>
#include <ProFUSE/Exception.h>
@ -89,11 +94,34 @@ void RawDevice::devSize(int fd)
}
#endif
// TODO -- FreeBSD/NetBSD/OpenBSD
#ifdef __FREEBSD__
void RawDevice::devSize(int fd)
{
#undef __METHOD__
#define __METHOD__ "RawDevice::devSize"
unisgned blockSize;
off_t mediaSize;
if (::ioctl(fd, DIOCGSECTORSIZE, &blockSize)
throw POSIXException(__METHOD__ ": Unable to determine block size.", errno);
if (::ioctl(fd, DIOCGMEDIASIZE, &mediaSize)
throw POSIXException(__METHOD__ ": Unable to determine media size.", errno);
_blockSize = blockSize;
_size = mediaSize;
_blocks = mediaSize / blockSize;
}
#endif
RawDevice::RawDevice(const char *name, bool readOnly) :
_file(name, readOnly)
{