Added chmod/chown
This commit is contained in:
parent
f746d83141
commit
f8b26d31e3
@ -13,6 +13,8 @@ public:
|
||||
virtual ~Node() {}
|
||||
|
||||
virtual void stat(struct ::stat *result) const = 0;
|
||||
virtual void chmod(mode_t mode) = 0;
|
||||
virtual void chown(uid_t uid, gid_t gid) = 0;
|
||||
virtual void access(int mask) const = 0;
|
||||
virtual void rename(const boost::filesystem::path &to) = 0;
|
||||
virtual void utimens(const timespec times[2]) = 0;
|
||||
|
@ -20,6 +20,8 @@ public:
|
||||
virtual void closeFile(int descriptor) = 0;
|
||||
virtual void lstat(const boost::filesystem::path &path, struct ::stat *stbuf) = 0;
|
||||
virtual void fstat(int descriptor, struct ::stat *stbuf) = 0;
|
||||
virtual void chmod(const boost::filesystem::path &path, mode_t mode) = 0;
|
||||
virtual void chown(const boost::filesystem::path &path, uid_t uid, gid_t gid) = 0;
|
||||
virtual void truncate(const boost::filesystem::path &path, off_t size) = 0;
|
||||
virtual void ftruncate(int descriptor, off_t size) = 0;
|
||||
virtual int read(int descriptor, void *buf, size_t count, off_t offset) = 0;
|
||||
|
@ -241,7 +241,7 @@ int Fuse::fgetattr(const bf::path &path, struct stat *stbuf, fuse_file_info *fil
|
||||
}
|
||||
|
||||
try {
|
||||
_fs->fstat(fileinfo->fh, stbuf);
|
||||
_fs->fstat(fileinfo->fh, stbuf);
|
||||
return 0;
|
||||
} catch(fspp::fuse::FuseErrnoException &e) {
|
||||
return -e.getErrno();
|
||||
@ -324,22 +324,22 @@ int Fuse::link(const bf::path &from, const bf::path &to) {
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
//TODO
|
||||
int Fuse::chmod(const bf::path &path, mode_t mode) {
|
||||
printf("NOT IMPLEMENTED: chmod(%s, %d)\n", path.c_str(), mode);
|
||||
//auto real_path = _impl->RootDir() / path;
|
||||
//int retstat = ::chmod(real_path.c_str(), mode);
|
||||
//return errcode_map(retstat);
|
||||
return ENOSYS;
|
||||
try {
|
||||
_fs->chmod(path, mode);
|
||||
return 0;
|
||||
} catch (fspp::fuse::FuseErrnoException &e) {
|
||||
return -e.getErrno();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
int Fuse::chown(const bf::path &path, uid_t uid, gid_t gid) {
|
||||
printf("NOT IMPLEMENTED: chown(%s, %d, %d)\n", path.c_str(), uid, gid);
|
||||
//auto real_path = _impl->RootDir() / path;
|
||||
//int retstat = ::chown(real_path.c_str(), uid, gid);
|
||||
//return errcode_map(retstat);
|
||||
return ENOSYS;
|
||||
try {
|
||||
_fs->chown(path, uid, gid);
|
||||
return 0;
|
||||
} catch (fspp::fuse::FuseErrnoException &e) {
|
||||
return -e.getErrno();
|
||||
}
|
||||
}
|
||||
|
||||
int Fuse::truncate(const bf::path &path, off_t size) {
|
||||
|
@ -71,6 +71,14 @@ void FilesystemImpl::fstat(int descriptor, struct ::stat *stbuf) {
|
||||
_open_files.get(descriptor)->stat(stbuf);
|
||||
}
|
||||
|
||||
void FilesystemImpl::chmod(const boost::filesystem::path &path, mode_t mode) {
|
||||
_device->Load(path)->chmod(mode);
|
||||
}
|
||||
|
||||
void FilesystemImpl::chown(const boost::filesystem::path &path, uid_t uid, gid_t gid) {
|
||||
_device->Load(path)->chown(uid, gid);
|
||||
}
|
||||
|
||||
void FilesystemImpl::truncate(const bf::path &path, off_t size) {
|
||||
LoadFile(path)->truncate(size);
|
||||
}
|
||||
@ -84,7 +92,6 @@ int FilesystemImpl::read(int descriptor, void *buf, size_t count, off_t offset)
|
||||
}
|
||||
|
||||
void FilesystemImpl::write(int descriptor, const void *buf, size_t count, off_t offset) {
|
||||
//printf("Write %d bytes to offset %d\n", count, offset);fflush(stdout);
|
||||
_open_files.get(descriptor)->write(buf, count, offset);
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@ public:
|
||||
void closeFile(int descriptor) override;
|
||||
void lstat(const boost::filesystem::path &path, struct ::stat *stbuf) override;
|
||||
void fstat(int descriptor, struct ::stat *stbuf) override;
|
||||
void chmod(const boost::filesystem::path &path, mode_t mode) override;
|
||||
void chown(const boost::filesystem::path &path, uid_t uid, gid_t gid) override;
|
||||
void truncate(const boost::filesystem::path &path, off_t size) override;
|
||||
void ftruncate(int descriptor, off_t size) override;
|
||||
int read(int descriptor, void *buf, size_t count, off_t offset) override;
|
||||
|
Loading…
Reference in New Issue
Block a user