diff options
author | Jakob Unterwurzacher | 2020-09-09 11:47:02 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2020-09-09 11:47:17 +0200 |
commit | 6577f1b1463137e5c1912d1778b736ed4e64f89f (patch) | |
tree | ee35df8fc746fe9635db0c9cfc48b6d7bbaee5a4 /tests/test_helpers | |
parent | ac687d53593d8215b881db92fe2d1bbbd2d2d774 (diff) |
test_helpers: print warning when not running on ext4
ext4 reuses inode numbers, tmpfs does not.
Diffstat (limited to 'tests/test_helpers')
-rw-r--r-- | tests/test_helpers/helpers.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_helpers/helpers.go b/tests/test_helpers/helpers.go index 6119065..212c44c 100644 --- a/tests/test_helpers/helpers.go +++ b/tests/test_helpers/helpers.go @@ -51,6 +51,9 @@ func doInit() { // Something like /tmp/gocryptfs-test-parent-1234 testParentDir := fmt.Sprintf("%s/gocryptfs-test-parent-%d", os.TempDir(), os.Getuid()) os.MkdirAll(testParentDir, 0755) + if !isExt4(testParentDir) { + fmt.Printf("test_helpers: warning: testParentDir %q does not reside on ext4, we will miss failures caused by ino reuse\n", testParentDir) + } var err error TmpDir, err = ioutil.TempDir(testParentDir, "") if err != nil { @@ -116,6 +119,23 @@ func ResetTmpDir(createDirIV bool) { } } +// isExt4 finds out if `path` resides on an ext4 filesystem, as reported by +// statfs. +func isExt4(path string) bool { + // From man statfs + const EXT4_SUPER_MAGIC = 0xef53 + + var fs syscall.Statfs_t + err := syscall.Statfs(path, &fs) + if err != nil { + return false + } + if fs.Type == EXT4_SUPER_MAGIC { + return true + } + return false +} + // InitFS creates a new empty cipherdir and calls // // gocryptfs -q -init -extpass "echo test" -scryptn=10 $extraArgs $cipherdir |