-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
backend-file.h
32 lines (24 loc) · 1.03 KB
/
backend-file.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <string>
#include "backend.h"
class backend_file : public backend
{
private:
const std::string filename;
int fd { -1 };
#if defined(__MINGW32__)
// because mingw does not do pread/pwrite and multiple threads can access backend_file
std::mutex io_lock;
#endif
public:
backend_file(const std::string & filename);
virtual ~backend_file();
bool begin() override;
std::string get_serial() const override;
uint64_t get_size_in_blocks() const override;
uint64_t get_block_size() const override;
bool sync() override;
bool write (const uint64_t block_nr, const uint32_t n_blocks, const uint8_t *const data) override;
bool trim (const uint64_t block_nr, const uint32_t n_blocks ) override;
bool read (const uint64_t block_nr, const uint32_t n_blocks, uint8_t *const data) override;
backend::cmpwrite_result_t cmpwrite(const uint64_t block_nr, const uint32_t n_blocks, const uint8_t *const data_write, const uint8_t *const data_compare) override;
};