2009-11-21 03:37:02 +00:00
|
|
|
#ifndef __RAWDEVICE_H__
|
|
|
|
#define __RAWDEVICE_H__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2009-12-16 01:33:28 +00:00
|
|
|
#include <Device/BlockDevice.h>
|
2009-11-21 03:37:02 +00:00
|
|
|
|
2010-05-19 23:47:48 +00:00
|
|
|
#include <File/File.h>
|
|
|
|
|
2009-12-16 01:33:28 +00:00
|
|
|
namespace Device {
|
2009-11-21 03:37:02 +00:00
|
|
|
|
|
|
|
// /dev/xxx
|
|
|
|
|
|
|
|
|
2010-05-19 23:47:48 +00:00
|
|
|
class RawDevice : public BlockDevice {
|
2009-11-21 03:37:02 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
RawDevice(const char *name, bool readOnly);
|
|
|
|
|
2010-05-19 23:47:48 +00:00
|
|
|
RawDevice(File& file, bool readOnly);
|
|
|
|
|
|
|
|
static RawDevice *Open(const char *name, bool readOnly);
|
|
|
|
|
|
|
|
|
2009-11-21 03:37:02 +00:00
|
|
|
virtual ~RawDevice();
|
|
|
|
|
|
|
|
virtual void read(unsigned block, void *bp);
|
2009-12-21 13:57:48 +00:00
|
|
|
virtual void read(TrackSector ts, void *bp);
|
|
|
|
|
2009-11-21 03:37:02 +00:00
|
|
|
virtual void write(unsigned block, const void *bp);
|
2009-12-21 13:57:48 +00:00
|
|
|
virtual void write(TrackSector ts, const void *bp);
|
|
|
|
|
2009-11-21 03:37:02 +00:00
|
|
|
virtual bool readOnly();
|
2009-12-21 13:57:48 +00:00
|
|
|
virtual bool mapped();
|
2009-11-21 03:37:02 +00:00
|
|
|
virtual void sync();
|
|
|
|
|
2010-05-19 23:47:48 +00:00
|
|
|
virtual unsigned blocks();
|
|
|
|
|
2009-11-21 03:37:02 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
void devSize(int fd);
|
|
|
|
|
2010-05-19 23:47:48 +00:00
|
|
|
File _file;
|
2009-11-21 03:37:02 +00:00
|
|
|
bool _readOnly;
|
|
|
|
|
|
|
|
uint64_t _size;
|
|
|
|
unsigned _blocks;
|
|
|
|
|
|
|
|
unsigned _blockSize;
|
2009-11-24 04:36:48 +00:00
|
|
|
};
|
2009-11-21 03:37:02 +00:00
|
|
|
|
2009-11-24 04:46:29 +00:00
|
|
|
}
|
2009-11-21 03:37:02 +00:00
|
|
|
|
|
|
|
#endif
|