This commit is contained in:
Sebastian Messmer 2014-11-12 12:43:49 +01:00
parent a0a30e3c75
commit e561f52dd5
5 changed files with 27 additions and 11 deletions

View File

@ -111,20 +111,22 @@ int CryFuse::rmdir(const path &path) {
//TODO
int CryFuse::symlink(const path &from, const path &to) {
//printf("symlink(%s, %s)\n", from.c_str(), to.c_str());
auto real_from = _device->RootDir() / from;
auto real_to = _device->RootDir() / to;
int retstat = ::symlink(real_from.c_str(), real_to.c_str());
return errcode_map(retstat);
printf("NOT IMPLEMENTED: symlink(%s, %s)\n", from.c_str(), to.c_str());
//auto real_from = _device->RootDir() / from;
//auto real_to = _device->RootDir() / to;
//int retstat = ::symlink(real_from.c_str(), real_to.c_str());
//return errcode_map(retstat);
return EIO; //TODO Correct return value
}
//TODO
int CryFuse::rename(const path &from, const path &to) {
//printf("rename(%s, %s)\n", from.c_str(), to.c_str());
auto real_from = _device->RootDir() / from;
auto real_to = _device->RootDir() / to;
int retstat = ::rename(real_from.c_str(), real_to.c_str());
return errcode_map(retstat);
try {
_device->rename(from, to);
return 0;
} catch(cryfs::CryErrnoException &e) {
return -e.getErrno();
}
}
//TODO

View File

@ -121,3 +121,8 @@ void CryDevice::unlink(const bf::path &path) {
auto file = LoadFile(path);
file->unlink();
}
void CryDevice::rename(const bf::path &from, const bf::path &to) {
auto node = Load(from);
node->rename(to);
}

View File

@ -37,6 +37,7 @@ public:
void mkdir(const bf::path &path, mode_t mode);
void rmdir(const bf::path &path);
void unlink(const bf::path &path);
void rename(const bf::path &from, const bf::path &to);
const bf::path &RootDir() const;
private:

View File

@ -22,4 +22,11 @@ void CryNode::access(int mask) const {
CHECK_RETVAL(retval);
}
void CryNode::rename(const bf::path &to) {
auto new_base_path = device()->RootDir() / to;
int retval = ::rename(base_path().c_str(), new_base_path.c_str());
CHECK_RETVAL(retval);
_path = to;
}
} /* namespace cryfs */

View File

@ -19,6 +19,7 @@ public:
void stat(struct ::stat *result) const;
void access(int mask) const;
void rename(const bf::path &to);
protected:
bf::path base_path() const;
@ -27,7 +28,7 @@ protected:
private:
CryDevice *const _device;
const bf::path _path;
bf::path _path;
DISALLOW_COPY_AND_ASSIGN(CryNode);
};