From a6239f89699069d704287152393fde43a46263e5 Mon Sep 17 00:00:00 2001 From: Xing Zheng Date: Thu, 29 Jun 2023 17:14:05 +0000 Subject: [PATCH] Remove windows related functions --- .../daemonimages/csidriver/driver/mount.go | 2 + .../csidriver/util/fs/fs_unsupported.go | 4 +- .../csidriver/util/fs/fs_windows.go | 76 ------------------- 3 files changed, 4 insertions(+), 78 deletions(-) delete mode 100644 ecs-agent/daemonimages/csidriver/util/fs/fs_windows.go diff --git a/ecs-agent/daemonimages/csidriver/driver/mount.go b/ecs-agent/daemonimages/csidriver/driver/mount.go index 6ee70f81d5..3a78d0592a 100644 --- a/ecs-agent/daemonimages/csidriver/driver/mount.go +++ b/ecs-agent/daemonimages/csidriver/driver/mount.go @@ -13,6 +13,8 @@ package driver +// Mounter defines an interface for many volume related options. As of now, only +// 'PathExists' is added to determine if a file path exists on the node. type Mounter interface { PathExists(path string) (bool, error) } diff --git a/ecs-agent/daemonimages/csidriver/util/fs/fs_unsupported.go b/ecs-agent/daemonimages/csidriver/util/fs/fs_unsupported.go index bf9d877842..962b09e546 100644 --- a/ecs-agent/daemonimages/csidriver/util/fs/fs_unsupported.go +++ b/ecs-agent/daemonimages/csidriver/util/fs/fs_unsupported.go @@ -1,5 +1,5 @@ -//go:build !linux && !darwin && !windows -// +build !linux,!darwin,!windows +//go:build !linux && !darwin +// +build !linux,!darwin // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. // diff --git a/ecs-agent/daemonimages/csidriver/util/fs/fs_windows.go b/ecs-agent/daemonimages/csidriver/util/fs/fs_windows.go deleted file mode 100644 index 70c58b67e0..0000000000 --- a/ecs-agent/daemonimages/csidriver/util/fs/fs_windows.go +++ /dev/null @@ -1,76 +0,0 @@ -//go:build windows -// +build windows - -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"). You may -// not use this file except in compliance with the License. A copy of the -// License is located at -// -// http://aws.amazon.com/apache2.0/ -// -// or in the "license" file accompanying this file. This file is distributed -// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either -// express or implied. See the License for the specific language governing -// permissions and limitations under the License. - -package fs - -import ( - "path/filepath" - "syscall" - "unsafe" - - "golang.org/x/sys/windows" -) - -var ( - modkernel32 = windows.NewLazySystemDLL("kernel32.dll") - procGetDiskFreeSpaceEx = modkernel32.NewProc("GetDiskFreeSpaceExW") -) - -type UsageInfo struct { - Bytes int64 - Inodes int64 -} - -// Info returns (available bytes, byte capacity, byte usage, total inodes, inodes free, inode usage, error) -// for the filesystem that path resides upon. -func Info(path string) ( - available int64, capacity int64, used int64, - totalInodes int64, freeInodes int64, usedInodes int64, - err error) { - var totalNumberOfFreeBytes int64 - // The equivalent linux call supports calls against files but the syscall for windows - // fails for files with error code: The directory name is invalid. (#99173) - // https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499- - // By always ensuring the directory path we meet all uses cases of this function - path = filepath.Dir(path) - ret, _, err := syscall.Syscall6( - procGetDiskFreeSpaceEx.Addr(), - 4, - uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(path))), - uintptr(unsafe.Pointer(&available)), - uintptr(unsafe.Pointer(&capacity)), - uintptr(unsafe.Pointer(&totalNumberOfFreeBytes)), - 0, - 0, - ) - if ret == 0 { - available = 0 - capacity = 0 - used = 0 - - totalInodes = 0 - freeInodes = 0 - usedInodes = 0 - - return - } - - used = capacity - available - totalInodes = 0 - freeInodes = 0 - usedInodes = 0 - return -}