aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend
diff options
context:
space:
mode:
Diffstat (limited to 'internal/fusefrontend')
-rw-r--r--internal/fusefrontend/file.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go
index d9588e9..ac00b1d 100644
--- a/internal/fusefrontend/file.go
+++ b/internal/fusefrontend/file.go
@@ -278,6 +278,10 @@ func (f *file) doWrite(data []byte, off int64) (uint32, fuse.Status) {
func (f *file) Write(data []byte, off int64) (uint32, fuse.Status) {
f.fdLock.RLock()
defer f.fdLock.RUnlock()
+ if f.fd.Fd() < 0 {
+ // The file descriptor has been closed concurrently.
+ return 0, fuse.EBADF
+ }
wlock.lock(f.ino)
defer wlock.unlock(f.ino)
@@ -337,6 +341,10 @@ func (f *file) Fsync(flags int) (code fuse.Status) {
func (f *file) Truncate(newSize uint64) fuse.Status {
f.fdLock.RLock()
defer f.fdLock.RUnlock()
+ if f.fd.Fd() < 0 {
+ // The file descriptor has been closed concurrently.
+ return fuse.EBADF
+ }
wlock.lock(f.ino)
defer wlock.unlock(f.ino)