2014-11-15 16:33:24 +01:00
|
|
|
#include "CryFile.h"
|
|
|
|
|
|
|
|
#include "CryDevice.h"
|
|
|
|
#include "CryOpenFile.h"
|
2015-02-17 01:02:15 +01:00
|
|
|
#include "messmer/fspp/fuse/FuseErrnoException.h"
|
2014-11-15 16:33:24 +01:00
|
|
|
|
|
|
|
namespace bf = boost::filesystem;
|
|
|
|
|
|
|
|
//TODO Get rid of this in favor of exception hierarchy
|
2014-11-28 14:46:45 +01:00
|
|
|
using fspp::fuse::CHECK_RETVAL;
|
2014-12-07 08:57:23 +01:00
|
|
|
using fspp::fuse::FuseErrnoException;
|
2014-11-15 16:33:24 +01:00
|
|
|
|
|
|
|
using std::unique_ptr;
|
|
|
|
using std::make_unique;
|
|
|
|
|
|
|
|
namespace cryfs {
|
|
|
|
|
2015-03-08 03:51:19 +01:00
|
|
|
CryFile::CryFile(CryDevice *device, unique_ptr<FileBlob> blob)
|
|
|
|
: _device(device),
|
|
|
|
_blob(std::move(blob)) {
|
2014-11-15 16:33:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CryFile::~CryFile() {
|
|
|
|
}
|
|
|
|
|
2014-11-16 00:05:28 +01:00
|
|
|
unique_ptr<fspp::OpenFile> CryFile::open(int flags) const {
|
2015-03-08 03:51:19 +01:00
|
|
|
//TODO This is a performance issue because we open the blob twice on the "open" syscall
|
|
|
|
return make_unique<CryOpenFile>(make_unique<FileBlob>(_device->LoadBlob(_blob->key())));
|
2014-11-15 16:33:24 +01:00
|
|
|
}
|
|
|
|
|
2015-03-08 03:25:20 +01:00
|
|
|
void CryFile::stat(struct ::stat *result) const {
|
|
|
|
result->st_mode = S_IFREG | S_IRUSR | S_IXUSR | S_IWUSR;
|
|
|
|
return;
|
|
|
|
throw FuseErrnoException(ENOTSUP);
|
|
|
|
}
|
|
|
|
|
2014-11-15 16:33:24 +01:00
|
|
|
void CryFile::truncate(off_t size) const {
|
2014-12-07 08:57:23 +01:00
|
|
|
throw FuseErrnoException(ENOTSUP);
|
2014-11-15 16:33:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CryFile::unlink() {
|
2014-12-07 08:57:23 +01:00
|
|
|
throw FuseErrnoException(ENOTSUP);
|
2014-11-15 16:33:24 +01:00
|
|
|
}
|
|
|
|
|
2014-12-07 08:57:23 +01:00
|
|
|
}
|