FUSE compat: fall back to truncate if no ftruncate

* As defined by the FUSE interface: if the FUSE module doesn't
  implement ftruncate(), fall back to using truncate() instead
This commit is contained in:
Julian Harnath 2017-02-11 10:43:08 +00:00
parent 6297d6c73b
commit 1b4f5f9b94

View File

@ -1474,6 +1474,10 @@ FUSEVolume::Open(void* _node, int openMode, void** _cookie)
// truncate the file, if requested
if (truncate) {
fuseError = fuse_fs_ftruncate(fFS, path, 0, cookie);
if (fuseError == ENOSYS) {
// Fallback to truncate if ftruncate is not implemented
fuseError = fuse_fs_truncate(fFS, path, 0);
}
if (fuseError != 0) {
fuse_fs_flush(fFS, path, cookie);
fuse_fs_release(fFS, path, cookie);