go.mod: Bump golang.org/x/sys to v0.17.0

Replace internal LOOP_CONFIGURE ioctl implementation with
IoctlLoopConfigure from sys

Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
This commit is contained in:
Alexandru Matei
2024-02-12 15:26:34 +02:00
parent 2c7520d6eb
commit c2dfae8d05
39 changed files with 222 additions and 90 deletions

View File

@@ -21,9 +21,7 @@ import (
"fmt"
"os"
"strings"
"syscall"
"time"
"unsafe"
"github.com/containerd/containerd/v2/internal/randutil"
kernel "github.com/containerd/containerd/v2/pkg/kernelversion"
@@ -35,8 +33,6 @@ const (
loopDevFormat = "/dev/loop%d"
ebusyString = "device or resource busy"
loopConfigureIoctl = 0x4c0a
)
type LoopConfig struct {
@@ -46,15 +42,6 @@ type LoopConfig struct {
Reserved [8]uint64
}
func ioctlConfigure(fd int, value *LoopConfig) error {
_, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(loopConfigureIoctl), uintptr(unsafe.Pointer(value)))
if err == 0 {
return nil
}
return err
}
// LoopParams parameters to control loop device setup
type LoopParams struct {
// Loop device should forbid write
@@ -107,7 +94,7 @@ func setupLoopDev(backingFile, loopDev string, param LoopParams) (_ *os.File, re
fiveDotEight := kernel.KernelVersion{Kernel: 5, Major: 8}
if ok, err := kernel.GreaterEqualThan(fiveDotEight); err == nil && ok {
config := LoopConfig{
config := unix.LoopConfig{
Fd: uint32(back.Fd()),
}
@@ -124,7 +111,7 @@ func setupLoopDev(backingFile, loopDev string, param LoopParams) (_ *os.File, re
config.Info.Flags |= unix.LO_FLAGS_DIRECT_IO
}
if err := ioctlConfigure(int(loop.Fd()), &config); err != nil {
if err := unix.IoctlLoopConfigure(int(loop.Fd()), &config); err != nil {
return nil, fmt.Errorf("failed to configure loop device: %s: %w", loopDev, err)
}