Fix file size handling
This commit is contained in:
parent
75b9a29ae4
commit
28056ed43f
@ -33,12 +33,14 @@ unique_ptr<fspp::OpenFile> CryFile::open(int flags) const {
|
|||||||
|
|
||||||
void CryFile::stat(struct ::stat *result) const {
|
void CryFile::stat(struct ::stat *result) const {
|
||||||
result->st_mode = S_IFREG | S_IRUSR | S_IXUSR | S_IWUSR;
|
result->st_mode = S_IFREG | S_IRUSR | S_IXUSR | S_IWUSR;
|
||||||
|
//TODO Loading the blob for only getting the size is not very performant.
|
||||||
|
result->st_size = FileBlob(_device->LoadBlob(_key)).size();
|
||||||
return;
|
return;
|
||||||
throw FuseErrnoException(ENOTSUP);
|
throw FuseErrnoException(ENOTSUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CryFile::truncate(off_t size) const {
|
void CryFile::truncate(off_t size) const {
|
||||||
throw FuseErrnoException(ENOTSUP);
|
FileBlob(_device->LoadBlob(_key)).resize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CryFile::unlink() {
|
void CryFile::unlink() {
|
||||||
|
@ -27,11 +27,12 @@ CryOpenFile::~CryOpenFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CryOpenFile::flush() {
|
void CryOpenFile::flush() {
|
||||||
throw FuseErrnoException(ENOTSUP);
|
//throw FuseErrnoException(ENOTSUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CryOpenFile::stat(struct ::stat *result) const {
|
void CryOpenFile::stat(struct ::stat *result) const {
|
||||||
result->st_mode = S_IFREG | S_IRUSR | S_IXUSR | S_IWUSR;
|
result->st_mode = S_IFREG | S_IRUSR | S_IXUSR | S_IWUSR;
|
||||||
|
result->st_size = _fileBlob->size();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,11 +51,11 @@ void CryOpenFile::write(const void *buf, size_t count, off_t offset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CryOpenFile::fsync() {
|
void CryOpenFile::fsync() {
|
||||||
throw FuseErrnoException(ENOTSUP);
|
//throw FuseErrnoException(ENOTSUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CryOpenFile::fdatasync() {
|
void CryOpenFile::fdatasync() {
|
||||||
throw FuseErrnoException(ENOTSUP);
|
//throw FuseErrnoException(ENOTSUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,11 @@ blockstore::Key FileBlob::key() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FileBlob::resize(off_t size) {
|
void FileBlob::resize(off_t size) {
|
||||||
_blob->resize(size);
|
_blob->resize(size+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
off_t FileBlob::size() const {
|
||||||
|
return _blob->size()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ public:
|
|||||||
void write(const void *source, uint64_t offset, uint64_t count);
|
void write(const void *source, uint64_t offset, uint64_t count);
|
||||||
|
|
||||||
void resize(off_t size);
|
void resize(off_t size);
|
||||||
|
off_t size() const;
|
||||||
|
|
||||||
blockstore::Key key() const;
|
blockstore::Key key() const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user