From 9d971fc08dc8d712fedb71d0a54ee125fb164d6a Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Tue, 15 Oct 2024 17:37:31 +0900 Subject: [PATCH] osutil: remove Ftruncate `*os.File` has `Truncate()` Signed-off-by: Akihiro Suda --- pkg/nativeimgutil/nativeimgutil.go | 3 +-- pkg/osutil/osutil_unix.go | 4 ---- pkg/osutil/osutil_windows.go | 4 ---- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/pkg/nativeimgutil/nativeimgutil.go b/pkg/nativeimgutil/nativeimgutil.go index 68ad213ff82..1c314e6b1e7 100644 --- a/pkg/nativeimgutil/nativeimgutil.go +++ b/pkg/nativeimgutil/nativeimgutil.go @@ -14,7 +14,6 @@ import ( "github.com/lima-vm/go-qcow2reader" "github.com/lima-vm/go-qcow2reader/image/qcow2" "github.com/lima-vm/go-qcow2reader/image/raw" - "github.com/lima-vm/lima/pkg/osutil" "github.com/lima-vm/lima/pkg/progressbar" "github.com/sirupsen/logrus" ) @@ -169,5 +168,5 @@ func MakeSparse(f *os.File, n int64) error { if _, err := f.Seek(n, io.SeekStart); err != nil { return err } - return osutil.Ftruncate(int(f.Fd()), n) + return f.Truncate(n) } diff --git a/pkg/osutil/osutil_unix.go b/pkg/osutil/osutil_unix.go index 7c83bd5a0d9..2420a8ef55a 100644 --- a/pkg/osutil/osutil_unix.go +++ b/pkg/osutil/osutil_unix.go @@ -13,10 +13,6 @@ func Dup2(oldfd, newfd int) (err error) { return unix.Dup2(oldfd, newfd) } -func Ftruncate(fd int, length int64) (err error) { - return unix.Ftruncate(fd, length) -} - func SignalName(sig os.Signal) string { return unix.SignalName(sig.(syscall.Signal)) } diff --git a/pkg/osutil/osutil_windows.go b/pkg/osutil/osutil_windows.go index 39d1258bd45..c2f18bdd3d7 100644 --- a/pkg/osutil/osutil_windows.go +++ b/pkg/osutil/osutil_windows.go @@ -38,10 +38,6 @@ func Dup2(oldfd int, newfd syscall.Handle) (err error) { return fmt.Errorf("unimplemented") } -func Ftruncate(_ int, _ int64) (err error) { - return fmt.Errorf("unimplemented") -} - func SignalName(sig os.Signal) string { switch sig { case syscall.SIGINT: