From e2dc52a9657e530820b2d5b49ad7425b529029ce Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 7 Mar 2021 17:22:29 +0100 Subject: v2api: -sharestorage: disable hard link tracking & add tests Hard link tracking was not correctly disabled since the migration to the go-fuse v2 api. Add a test to ensure it stays off. Fixes https://github.com/rfjakob/gocryptfs/issues/525 --- tests/cli/cli_test.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'tests/cli') diff --git a/tests/cli/cli_test.go b/tests/cli/cli_test.go index 2872592..23cea05 100644 --- a/tests/cli/cli_test.go +++ b/tests/cli/cli_test.go @@ -822,3 +822,50 @@ func TestInitNotEmpty(t *testing.T) { t.Fatalf("wrong exit code: have=%d, want=%d", exitCode, exitcodes.CipherDir) } } + +// TestSharedstorage checks that `-sharedstorage` hands out arbitrary inode +// numbers (no hard link tracking) +func TestSharedstorage(t *testing.T) { + dir := test_helpers.InitFS(t) + mnt := dir + ".mnt" + err := os.Mkdir(mnt, 0700) + if err != nil { + t.Fatal(err) + } + test_helpers.MountOrFatal(t, dir, mnt, "-extpass=echo test", "-sharedstorage") + defer test_helpers.UnmountPanic(mnt) + foo1 := mnt + "/foo1" + foo2 := mnt + "/foo2" + if err := ioutil.WriteFile(foo1, nil, 0755); err != nil { + t.Fatal(err) + } + if err := os.Link(foo1, foo2); err != nil { + t.Fatal(err) + } + var st1, st2, st3 syscall.Stat_t + if err := syscall.Stat(foo1, &st1); err != nil { + t.Fatal(err) + } + // The link show show a new inode number + if err := syscall.Stat(foo2, &st2); err != nil { + t.Fatal(err) + } + // Stat()'ing again should give us again a new inode number + if err := syscall.Stat(foo2, &st3); err != nil { + t.Fatal(err) + } + if st1.Ino == st2.Ino || st2.Ino == st3.Ino || st1.Ino == st3.Ino { + t.Error(st1.Ino, st2.Ino, st3.Ino) + } + // Check that we we don't have stat caching. New length should show up + // on the hard link immediately. + if err := ioutil.WriteFile(foo1, []byte("xxxxxx"), 0755); err != nil { + t.Fatal(err) + } + if err := syscall.Stat(foo2, &st2); err != nil { + t.Fatal(err) + } + if st2.Size != 6 { + t.Fatal(st2.Size) + } +} -- cgit v1.2.3