From 9ab11aa4d775f7c1242e8b044cc2f8957cc2c784 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 1 May 2017 17:49:37 +0200 Subject: 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. --- tests/defaults/main_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/defaults') diff --git a/tests/defaults/main_test.go b/tests/defaults/main_test.go index 52ca727..8c1b7e3 100644 --- a/tests/defaults/main_test.go +++ b/tests/defaults/main_test.go @@ -116,3 +116,18 @@ func TestOpenTruncateRead(t *testing.T) { t.Fatalf("wrong content: %s", string(content)) } } + +// TestWORead tries to read from a write-only file. +func TestWORead(t *testing.T) { + fn := test_helpers.DefaultPlainDir + "/TestWORead" + fd, err := os.OpenFile(fn, os.O_CREATE|os.O_WRONLY, 0600) + if err != nil { + t.Fatal(err) + } + defer fd.Close() + buf := make([]byte, 10) + _, err = fd.Read(buf) + if err == nil { + t.Error("Reading from write-only file should fail, but did not") + } +} -- cgit v1.2.3