2014-11-04 18:03:59 +01:00
|
|
|
#pragma once
|
2014-11-04 02:54:23 +01:00
|
|
|
#ifndef CRYFS_LIB_CRYDEVICE_H_
|
|
|
|
#define CRYFS_LIB_CRYDEVICE_H_
|
|
|
|
|
2014-11-05 01:35:41 +01:00
|
|
|
#include <boost/filesystem.hpp>
|
2014-11-10 22:42:17 +01:00
|
|
|
#include <cryfs_lib/CryOpenFileList.h>
|
2014-11-05 01:35:41 +01:00
|
|
|
#include <memory>
|
2014-11-10 22:42:17 +01:00
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
#include "utils/macros.h"
|
2014-11-04 17:40:31 +01:00
|
|
|
|
2014-11-04 02:54:23 +01:00
|
|
|
namespace cryfs {
|
2014-11-05 01:35:41 +01:00
|
|
|
class CryNode;
|
2014-11-10 22:42:17 +01:00
|
|
|
class CryFile;
|
2014-11-10 23:47:41 +01:00
|
|
|
class CryOpenFile;
|
|
|
|
class CryDir;
|
2014-11-05 01:35:41 +01:00
|
|
|
|
|
|
|
namespace bf = boost::filesystem;
|
2014-11-04 02:54:23 +01:00
|
|
|
|
|
|
|
class CryDevice {
|
|
|
|
public:
|
2014-11-05 01:35:41 +01:00
|
|
|
CryDevice(const bf::path &rootdir);
|
2014-11-04 02:54:23 +01:00
|
|
|
virtual ~CryDevice();
|
2014-11-04 21:03:04 +01:00
|
|
|
|
2014-11-10 23:47:41 +01:00
|
|
|
int openFile(const bf::path &path, int flags);
|
|
|
|
void closeFile(int descriptor);
|
2014-11-10 22:42:17 +01:00
|
|
|
void lstat(const bf::path &path, struct ::stat *stbuf);
|
|
|
|
void fstat(int descriptor, struct ::stat *stbuf);
|
2014-11-10 23:47:41 +01:00
|
|
|
void truncate(const bf::path &path, off_t size);
|
|
|
|
void ftruncate(int descriptor, off_t size);
|
2014-11-11 00:18:24 +01:00
|
|
|
int read(int descriptor, void *buf, size_t count, off_t offset);
|
2014-11-10 23:47:41 +01:00
|
|
|
void write(int descriptor, const void *buf, size_t count, off_t offset);
|
|
|
|
void fsync(int descriptor);
|
|
|
|
void fdatasync(int descriptor);
|
|
|
|
void access(const bf::path &path, int mask);
|
2014-11-10 23:51:45 +01:00
|
|
|
int createAndOpenFile(const bf::path &path, mode_t mode);
|
2014-11-12 12:27:23 +01:00
|
|
|
void mkdir(const bf::path &path, mode_t mode);
|
2014-11-12 12:34:35 +01:00
|
|
|
void rmdir(const bf::path &path);
|
2014-11-12 12:31:38 +01:00
|
|
|
void unlink(const bf::path &path);
|
2014-11-12 12:43:49 +01:00
|
|
|
void rename(const bf::path &from, const bf::path &to);
|
2014-11-05 01:35:41 +01:00
|
|
|
|
|
|
|
const bf::path &RootDir() const;
|
2014-11-04 21:03:04 +01:00
|
|
|
private:
|
2014-11-10 22:42:17 +01:00
|
|
|
std::unique_ptr<CryNode> Load(const bf::path &path);
|
|
|
|
std::unique_ptr<CryFile> LoadFile(const bf::path &path);
|
2014-11-10 23:47:41 +01:00
|
|
|
std::unique_ptr<CryDir> LoadDir(const bf::path &path);
|
2014-11-12 12:27:23 +01:00
|
|
|
int openFile(const CryFile &file, int flags);
|
2014-11-05 01:35:41 +01:00
|
|
|
const bf::path _rootdir;
|
2014-11-10 22:42:17 +01:00
|
|
|
CryOpenFileList _open_files;
|
2014-11-04 21:03:04 +01:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CryDevice);
|
2014-11-04 02:54:23 +01:00
|
|
|
};
|
|
|
|
|
2014-11-05 01:35:41 +01:00
|
|
|
inline const bf::path &CryDevice::RootDir() const {
|
2014-11-04 21:03:04 +01:00
|
|
|
return _rootdir;
|
|
|
|
}
|
|
|
|
|
2014-11-04 02:54:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CRYFS_LIB_CRYDEVICE_H_ */
|