aboutsummaryrefslogtreecommitdiff
path: root/tests/cli/cli_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-03-07 17:22:29 +0100
committerJakob Unterwurzacher2021-03-07 17:22:29 +0100
commite2dc52a9657e530820b2d5b49ad7425b529029ce (patch)
tree75683d1194615dc2774a1b0f99850b798ade2b83 /tests/cli/cli_test.go
parenteaca820e876bfcdc67323eac6dd43ecc420968f2 (diff)
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
Diffstat (limited to 'tests/cli/cli_test.go')
-rw-r--r--tests/cli/cli_test.go47
1 files changed, 47 insertions, 0 deletions
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)
+ }
+}