Fix file reading
This commit is contained in:
parent
2e06e0a3b0
commit
a8604d7b58
@ -206,8 +206,9 @@ int CryFuse::read(const path &path, char *buf, size_t size, off_t offset, fuse_f
|
||||
//printf("read(%s, _, %zu, %zu, _)\n", path.c_str(), size, offset);
|
||||
UNUSED(path);
|
||||
try {
|
||||
_device->read(fileinfo->fh, buf, size, offset);
|
||||
return 0;
|
||||
//printf("Reading from file %d\n", fileinfo->fh);
|
||||
//fflush(stdout);
|
||||
return _device->read(fileinfo->fh, buf, size, offset);
|
||||
} catch (CryErrnoException &e) {
|
||||
return -e.getErrno();
|
||||
}
|
||||
@ -218,7 +219,7 @@ int CryFuse::write(const path &path, const char *buf, size_t size, off_t offset,
|
||||
UNUSED(path);
|
||||
try {
|
||||
_device->write(fileinfo->fh, buf, size, offset);
|
||||
return 0;
|
||||
return size;
|
||||
} catch (CryErrnoException &e) {
|
||||
return -e.getErrno();
|
||||
}
|
||||
|
@ -74,8 +74,8 @@ void CryDevice::ftruncate(int descriptor, off_t size) {
|
||||
_open_files.get(descriptor)->truncate(size);
|
||||
}
|
||||
|
||||
void CryDevice::read(int descriptor, void *buf, size_t count, off_t offset) {
|
||||
_open_files.get(descriptor)->read(buf, count, offset);
|
||||
int CryDevice::read(int descriptor, void *buf, size_t count, off_t offset) {
|
||||
return _open_files.get(descriptor)->read(buf, count, offset);
|
||||
}
|
||||
|
||||
void CryDevice::write(int descriptor, const void *buf, size_t count, off_t offset) {
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
void fstat(int descriptor, struct ::stat *stbuf);
|
||||
void truncate(const bf::path &path, off_t size);
|
||||
void ftruncate(int descriptor, off_t size);
|
||||
void read(int descriptor, void *buf, size_t count, off_t offset);
|
||||
int read(int descriptor, void *buf, size_t count, off_t offset);
|
||||
void write(int descriptor, const void *buf, size_t count, off_t offset);
|
||||
void fsync(int descriptor);
|
||||
void fdatasync(int descriptor);
|
||||
|
@ -27,14 +27,21 @@ void CryOpenFile::truncate(off_t size) const {
|
||||
CHECK_RETVAL(retval);
|
||||
}
|
||||
|
||||
void CryOpenFile::read(void *buf, size_t count, off_t offset) {
|
||||
int CryOpenFile::read(void *buf, size_t count, off_t offset) {
|
||||
//printf("Reading from real descriptor %d (%d, %d)\n", _descriptor, offset, count);
|
||||
//fflush(stdout);
|
||||
int retval = ::pread(_descriptor, buf, count, offset);
|
||||
CHECK_RETVAL(retval);
|
||||
//printf("retval: %d, count: %d\n", retval, count);
|
||||
//fflush(stdout);
|
||||
assert(retval <= count);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void CryOpenFile::write(const void *buf, size_t count, off_t offset) {
|
||||
int retval = ::pwrite(_descriptor, buf, count, offset);
|
||||
CHECK_RETVAL(retval);
|
||||
assert(retval == count);
|
||||
}
|
||||
|
||||
void CryOpenFile::fsync() {
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
|
||||
void stat(struct ::stat *result) const;
|
||||
void truncate(off_t size) const;
|
||||
void read(void *buf, size_t count, off_t offset);
|
||||
int read(void *buf, size_t count, off_t offset);
|
||||
void write(const void *buf, size_t count, off_t offset);
|
||||
void fsync();
|
||||
void fdatasync();
|
||||
|
Loading…
Reference in New Issue
Block a user