mirror of
https://github.com/ksherlock/profuse.git
synced 2024-10-31 17:04:27 +00:00
git-svn-id: https://profuse.googlecode.com/svn/branches/v2@316 aa027e90-d47c-11dd-86d7-074df07e0730
This commit is contained in:
parent
345927d4b2
commit
1894a178d1
@ -25,6 +25,10 @@
|
|||||||
#include <sys/disk.h>
|
#include <sys/disk.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __minix
|
||||||
|
#include <minix/partition.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <Device/RawDevice.h>
|
#include <Device/RawDevice.h>
|
||||||
|
|
||||||
#include <ProFUSE/Exception.h>
|
#include <ProFUSE/Exception.h>
|
||||||
@ -105,7 +109,7 @@ void RawDevice::devSize(int fd)
|
|||||||
#undef __METHOD__
|
#undef __METHOD__
|
||||||
#define __METHOD__ "RawDevice::devSize"
|
#define __METHOD__ "RawDevice::devSize"
|
||||||
|
|
||||||
unisgned blockSize;
|
unsigned blockSize;
|
||||||
off_t mediaSize;
|
off_t mediaSize;
|
||||||
|
|
||||||
if (::ioctl(fd, DIOCGSECTORSIZE, &blockSize)
|
if (::ioctl(fd, DIOCGSECTORSIZE, &blockSize)
|
||||||
@ -116,11 +120,33 @@ void RawDevice::devSize(int fd)
|
|||||||
|
|
||||||
_blockSize = blockSize;
|
_blockSize = blockSize;
|
||||||
_size = mediaSize;
|
_size = mediaSize;
|
||||||
_blocks = mediaSize / blockSize;
|
_blocks = mediaSize / 512;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#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) :
|
RawDevice::RawDevice(const char *name, File::FileFlags flags) :
|
||||||
_file(name, flags)
|
_file(name, flags)
|
||||||
|
@ -46,10 +46,10 @@ private:
|
|||||||
File _file;
|
File _file;
|
||||||
bool _readOnly;
|
bool _readOnly;
|
||||||
|
|
||||||
uint64_t _size;
|
uint64_t _size; // size of device in bytes.
|
||||||
unsigned _blocks;
|
unsigned _blocks; // # of 512k blocks i.e. _size / 512
|
||||||
|
|
||||||
unsigned _blockSize;
|
unsigned _blockSize; // native block size.
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user