summaryrefslogtreecommitdiff
path: root/internal/fusefrontend/file.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-05-01 17:49:37 +0200
committerJakob Unterwurzacher2017-05-01 17:49:37 +0200
commit9ab11aa4d775f7c1242e8b044cc2f8957cc2c784 (patch)
treef4f302b3573dff151b2290d6f1a2d9436cd24e57 /internal/fusefrontend/file.go
parent514f515dd7196e26ca8df6886ac4a34e928e50dd (diff)
fusefrontend: drop writeOnly flag
We do not have to track the writeOnly status because the kernel will not forward read requests on a write-only FD to us anyway. I have verified this behavoir manually on a 4.10.8 kernel and also added a testcase.
Diffstat (limited to 'internal/fusefrontend/file.go')
-rw-r--r--internal/fusefrontend/file.go10
1 files changed, 1 insertions, 9 deletions
diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go
index 92b1496..0a8c8aa 100644
--- a/internal/fusefrontend/file.go
+++ b/internal/fusefrontend/file.go
@@ -35,8 +35,6 @@ type file struct {
// Every FUSE entrypoint should RLock(). The only user of Lock() is
// Release(), which closes the fd and sets "released" to true.
fdLock sync.RWMutex
- // Was the file opened O_WRONLY?
- writeOnly bool
// Content encryption helper
contentEnc *contentenc.ContentEnc
// Device and inode number uniquely identify the backing file
@@ -59,7 +57,7 @@ type file struct {
}
// NewFile returns a new go-fuse File instance.
-func NewFile(fd *os.File, writeOnly bool, fs *FS) (nodefs.File, fuse.Status) {
+func NewFile(fd *os.File, fs *FS) (nodefs.File, fuse.Status) {
var st syscall.Stat_t
err := syscall.Fstat(int(fd.Fd()), &st)
if err != nil {
@@ -71,7 +69,6 @@ func NewFile(fd *os.File, writeOnly bool, fs *FS) (nodefs.File, fuse.Status) {
return &file{
fd: fd,
- writeOnly: writeOnly,
contentEnc: fs.contentEnc,
qIno: qi,
fileTableEntry: e,
@@ -229,11 +226,6 @@ func (f *file) Read(buf []byte, off int64) (resultData fuse.ReadResult, code fus
tlog.Debug.Printf("ino%d: FUSE Read: offset=%d length=%d", f.qIno.Ino, len(buf), off)
- if f.writeOnly {
- tlog.Warn.Printf("ino%d: Tried to read from write-only file", f.qIno.Ino)
- return nil, fuse.EBADF
- }
-
if f.fs.args.SerializeReads {
serialize_reads.Wait(off, len(buf))
}