Fix lstat

This commit is contained in:
Sebastian Messmer 2015-03-08 03:25:20 +01:00
parent 49a4486a40
commit e4a0084ea3
6 changed files with 18 additions and 19 deletions

View File

@ -29,6 +29,12 @@ CryDir::CryDir(CryDevice *device, unique_ptr<DirBlob> blob)
CryDir::~CryDir() {
}
void CryDir::stat(struct ::stat *result) const {
result->st_mode = S_IFDIR | S_IRUSR | S_IXUSR | S_IWUSR;
return;
throw FuseErrnoException(ENOTSUP);
}
unique_ptr<fspp::File> CryDir::createFile(const string &name, mode_t mode) {
auto child = _device->CreateBlob();
_blob->AddChild(name, child->key());

View File

@ -13,6 +13,7 @@ public:
CryDir(CryDevice *device, std::unique_ptr<DirBlob> blob);
virtual ~CryDir();
void stat(struct ::stat *result) const override;
//TODO return type variance to CryFile/CryDir?
std::unique_ptr<fspp::File> createFile(const std::string &name, mode_t mode) override;
std::unique_ptr<fspp::Dir> createDir(const std::string &name, mode_t mode) override;

View File

@ -26,6 +26,12 @@ unique_ptr<fspp::OpenFile> CryFile::open(int flags) const {
throw FuseErrnoException(ENOTSUP);
}
void CryFile::stat(struct ::stat *result) const {
result->st_mode = S_IFREG | S_IRUSR | S_IXUSR | S_IWUSR;
return;
throw FuseErrnoException(ENOTSUP);
}
void CryFile::truncate(off_t size) const {
throw FuseErrnoException(ENOTSUP);
}

View File

@ -14,6 +14,7 @@ public:
CryFile(std::unique_ptr<FileBlob> blob);
virtual ~CryFile();
void stat(struct ::stat *result) const override;
std::unique_ptr<fspp::OpenFile> open(int flags) const override;
void truncate(off_t size) const override;
void unlink() override;

View File

@ -21,21 +21,6 @@ CryNode::CryNode() {
CryNode::~CryNode() {
}
void CryNode::stat(struct ::stat *result) const {
if (dynamic_cast<const CryDir*>(this) != nullptr) {
//printf("Stat: dir\n");
result->st_mode = S_IFDIR;
} else if (dynamic_cast<const CryFile*>(this) != nullptr) {
//printf("Stat: file\n");
result->st_mode = S_IFREG;
} else {
throw FuseErrnoException(EIO);
}
result->st_mode |= S_IRUSR | S_IXUSR | S_IWUSR;
return;
throw FuseErrnoException(ENOTSUP);
}
void CryNode::access(int mask) const {
return;
throw FuseErrnoException(ENOTSUP);

View File

@ -11,14 +11,14 @@ namespace cryfs {
class CryNode: public virtual fspp::Node {
public:
CryNode();
virtual ~CryNode();
void stat(struct ::stat *result) const override;
void access(int mask) const override;
void rename(const boost::filesystem::path &to) override;
void utimens(const timespec times[2]) override;
protected:
CryNode();
virtual ~CryNode();
private:
DISALLOW_COPY_AND_ASSIGN(CryNode);