treewide: compare syscall.Errno directly instead of interface type
Change-Id: I03eba72177113cf40afc38981c5311a8013855f9
Reviewed-on: https://review.monogon.dev/c/monogon/+/3042
Reviewed-by: Leopold Schabel <leo@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/pkg/blockdev/blockdev_linux.go b/metropolis/pkg/blockdev/blockdev_linux.go
index b5ef106..c5fa784 100644
--- a/metropolis/pkg/blockdev/blockdev_linux.go
+++ b/metropolis/pkg/blockdev/blockdev_linux.go
@@ -68,19 +68,22 @@
var err error
args[0] = uint64(startByte)
args[1] = uint64(endByte - startByte)
- if ctrlErr := d.rawConn.Control(func(fd uintptr) {
+ ctrlErr := d.rawConn.Control(func(fd uintptr) {
// Attempts to leverage discard guarantees to provide extremely quick
// metadata-only zeroing.
err = unix.Fallocate(int(fd), unix.FALLOC_FL_PUNCH_HOLE|unix.FALLOC_FL_KEEP_SIZE, startByte, endByte-startByte)
if errors.Is(err, unix.EOPNOTSUPP) {
// Tries Write Same and friends and then just falls back to writing
// zeroes.
- _, _, err = unix.Syscall(unix.SYS_IOCTL, fd, unix.BLKZEROOUT, uintptr(unsafe.Pointer(&args[0])))
- if err == unix.Errno(0) {
+ _, _, errNo := unix.Syscall(unix.SYS_IOCTL, fd, unix.BLKZEROOUT, uintptr(unsafe.Pointer(&args[0])))
+ if errNo == unix.Errno(0) {
err = nil
+ } else {
+ err = errNo
}
}
- }); ctrlErr != nil {
+ })
+ if ctrlErr != nil {
return ctrlErr
}
if err != nil {
@@ -134,7 +137,7 @@
}
var sizeBytes uint64
- var getSizeErr error
+ var getSizeErr syscall.Errno
outFileC.Control(func(fd uintptr) {
_, _, getSizeErr = unix.Syscall(unix.SYS_IOCTL, fd, unix.BLKGETSIZE64, uintptr(unsafe.Pointer(&sizeBytes)))
})