mirror of
https://github.com/ksherlock/profuse.git
synced 2025-04-01 17:30:20 +00:00
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:
parent
da84b5bca2
commit
91e2aaac70
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user