2014-11-15 16:33:24 +01:00
|
|
|
#include "CryDir.h"
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
|
2015-02-17 01:02:15 +01:00
|
|
|
#include "messmer/fspp/fuse/FuseErrnoException.h"
|
2014-11-15 16:33:24 +01:00
|
|
|
#include "CryDevice.h"
|
|
|
|
#include "CryFile.h"
|
|
|
|
|
|
|
|
//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
|
|
|
|
|
|
|
namespace bf = boost::filesystem;
|
|
|
|
|
|
|
|
using std::unique_ptr;
|
|
|
|
using std::make_unique;
|
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
|
|
|
|
|
|
|
namespace cryfs {
|
|
|
|
|
2015-02-27 00:51:51 +01:00
|
|
|
CryDir::CryDir(CryDevice *device, unique_ptr<DirBlob> blob)
|
|
|
|
: _device(device), _blob(std::move(blob)) {
|
2014-11-15 16:33:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CryDir::~CryDir() {
|
|
|
|
}
|
|
|
|
|
2015-03-08 03:25:20 +01:00
|
|
|
void CryDir::stat(struct ::stat *result) const {
|
|
|
|
result->st_mode = S_IFDIR | S_IRUSR | S_IXUSR | S_IWUSR;
|
|
|
|
return;
|
|
|
|
throw FuseErrnoException(ENOTSUP);
|
|
|
|
}
|
|
|
|
|
2014-11-16 00:05:28 +01:00
|
|
|
unique_ptr<fspp::File> CryDir::createFile(const string &name, mode_t mode) {
|
2015-02-27 00:51:51 +01:00
|
|
|
auto child = _device->CreateBlob();
|
|
|
|
_blob->AddChild(name, child->key());
|
|
|
|
//TODO Do we need a return value in createDir for fspp? If not, change fspp!
|
|
|
|
auto fileblob = make_unique<FileBlob>(std::move(child));
|
|
|
|
fileblob->InitializeEmptyFile();
|
2015-03-08 03:51:19 +01:00
|
|
|
return make_unique<CryFile>(_device, std::move(fileblob));
|
2014-11-15 16:33:24 +01:00
|
|
|
}
|
|
|
|
|
2014-11-16 00:05:28 +01:00
|
|
|
unique_ptr<fspp::Dir> CryDir::createDir(const string &name, mode_t mode) {
|
2015-02-27 00:51:51 +01:00
|
|
|
auto child = _device->CreateBlob();
|
|
|
|
_blob->AddChild(name, child->key());
|
2014-12-07 10:42:16 +01:00
|
|
|
//TODO I don't think we need a return value in createDir for fspp. Change fspp!
|
2015-02-27 00:51:51 +01:00
|
|
|
auto dirblob = make_unique<DirBlob>(std::move(child));
|
|
|
|
dirblob->InitializeEmptyDir();
|
|
|
|
return make_unique<CryDir>(_device, std::move(dirblob));
|
2014-11-15 16:33:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CryDir::rmdir() {
|
2014-12-07 08:57:23 +01:00
|
|
|
throw FuseErrnoException(ENOTSUP);
|
2014-11-15 16:33:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
unique_ptr<vector<string>> CryDir::children() const {
|
2015-02-27 00:51:51 +01:00
|
|
|
return _blob->GetChildren();
|
2014-11-15 16:33:24 +01:00
|
|
|
}
|
|
|
|
|
2014-12-07 08:57:23 +01:00
|
|
|
}
|