test_helpers: print warning when not running on ext4

ext4 reuses inode numbers, tmpfs does not.
This commit is contained in:
Jakob Unterwurzacher 2020-09-09 11:47:02 +02:00
parent ac687d5359
commit 6577f1b146

View File

@ -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