mirror of https://github.com/restic/restic.git
Cast unix.Statfs_t.Type to int64 when checking for btrfs
Fixes #3687. Uses the cast suggested by @MichaelEischer, except that the contant isn't cast along, because it's untyped and will be converted by the compiler as necessary.
This commit is contained in:
parent
774c2e75ca
commit
c23c0f7c14
|
@ -59,9 +59,13 @@ func supportsNoatime(t *testing.T, f *os.File) bool {
|
|||
err := unix.Fstatfs(int(f.Fd()), &fsinfo)
|
||||
rtest.OK(t, err)
|
||||
|
||||
return fsinfo.Type == unix.BTRFS_SUPER_MAGIC ||
|
||||
fsinfo.Type == unix.EXT2_SUPER_MAGIC ||
|
||||
fsinfo.Type == unix.EXT3_SUPER_MAGIC ||
|
||||
fsinfo.Type == unix.EXT4_SUPER_MAGIC ||
|
||||
fsinfo.Type == unix.TMPFS_MAGIC
|
||||
// The funky cast works around a compiler error on 32-bit archs:
|
||||
// "unix.BTRFS_SUPER_MAGIC (untyped int constant 2435016766) overflows int32".
|
||||
// https://github.com/golang/go/issues/52061
|
||||
typ := int64(uint(fsinfo.Type))
|
||||
return typ == unix.BTRFS_SUPER_MAGIC ||
|
||||
typ == unix.EXT2_SUPER_MAGIC ||
|
||||
typ == unix.EXT3_SUPER_MAGIC ||
|
||||
typ == unix.EXT4_SUPER_MAGIC ||
|
||||
typ == unix.TMPFS_MAGIC
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue