aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJakob Unterwurzacher2023-03-29 22:16:14 +0200
committerJakob Unterwurzacher2023-03-29 22:16:14 +0200
commit24b3978715186bed3edc2703e81f165a73c0a74a (patch)
tree54d427d9f1e667deafeb7034f6f3001dfe63b827 /tests
parentb370325ccf8a15d3b58418d85fd22e32e2aeb2fc (diff)
fusefrontent: report correct size on hard link creation
And add a test for it. Fixes https://github.com/rfjakob/gocryptfs/issues/724
Diffstat (limited to 'tests')
-rw-r--r--tests/matrix/matrix_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/matrix/matrix_test.go b/tests/matrix/matrix_test.go
index 34c111f..0d9c22c 100644
--- a/tests/matrix/matrix_test.go
+++ b/tests/matrix/matrix_test.go
@@ -915,6 +915,45 @@ func TestSymlinkSize(t *testing.T) {
}
}
+// gocryptfs 2.0+ reported the ciphertext size on hard link creation
+// https://github.com/rfjakob/gocryptfs/issues/724
+func TestLinkSize(t *testing.T) {
+ p := filepath.Join(test_helpers.DefaultPlainDir, t.Name()) + ".regular"
+ f, err := os.Create(p)
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, err = f.WriteString("x")
+ f.Close()
+ if err != nil {
+ t.Fatal(err)
+ }
+ doTestLinkSize(t, p)
+
+ p = filepath.Join(test_helpers.DefaultPlainDir, t.Name()) + ".symlink"
+ err = syscall.Symlink("x", p)
+ if err != nil {
+ t.Fatal(err)
+ }
+ doTestLinkSize(t, p)
+}
+
+func doTestLinkSize(t *testing.T, p string) {
+ p2 := p + ".link"
+ err := syscall.Link(p, p2)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var st syscall.Stat_t
+ err = syscall.Lstat(p2, &st)
+ if err != nil {
+ t.Fatal(filepath.Base(p2), err)
+ }
+ if st.Size != 1 {
+ t.Errorf("wrong %s size: want=1 have=%d", filepath.Base(p), st.Size)
+ }
+}
+
// TestPwd check that /usr/bin/pwd works inside gocryptfs.
//
// This was broken in gocryptfs v2.0 with -sharedstorage: