mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 18:43:34 +00:00
build: replace k8s.io/mount-utils to v0.29.3
Signed-off-by: Praveen M <m.praveen@ibm.com>
This commit is contained in:
73
vendor/k8s.io/mount-utils/mount_linux.go
generated
vendored
73
vendor/k8s.io/mount-utils/mount_linux.go
generated
vendored
@ -33,7 +33,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/moby/sys/mountinfo"
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
utilexec "k8s.io/utils/exec"
|
||||
@ -56,11 +55,6 @@ const (
|
||||
errNotMounted = "not mounted"
|
||||
)
|
||||
|
||||
var (
|
||||
// Error statx support since Linux 4.11, https://man7.org/linux/man-pages/man2/statx.2.html
|
||||
errStatxNotSupport = errors.New("the statx syscall is not supported. At least Linux kernel 4.11 is needed")
|
||||
)
|
||||
|
||||
// Mounter provides the default implementation of mount.Interface
|
||||
// for the linux platform. This implementation assumes that the
|
||||
// kubelet is running in the host's root mount namespace.
|
||||
@ -391,20 +385,14 @@ func (*Mounter) List() ([]MountPoint, error) {
|
||||
return ListProcMounts(procMountsPath)
|
||||
}
|
||||
|
||||
func statx(file string) (unix.Statx_t, error) {
|
||||
var stat unix.Statx_t
|
||||
if err := unix.Statx(0, file, unix.AT_STATX_DONT_SYNC, 0, &stat); err != nil {
|
||||
if err == unix.ENOSYS {
|
||||
return stat, errStatxNotSupport
|
||||
}
|
||||
|
||||
return stat, err
|
||||
}
|
||||
|
||||
return stat, nil
|
||||
}
|
||||
|
||||
func (mounter *Mounter) isLikelyNotMountPointStat(file string) (bool, error) {
|
||||
// IsLikelyNotMountPoint determines if a directory is not a mountpoint.
|
||||
// It is fast but not necessarily ALWAYS correct. If the path is in fact
|
||||
// a bind mount from one part of a mount to another it will not be detected.
|
||||
// It also can not distinguish between mountpoints and symbolic links.
|
||||
// mkdir /tmp/a /tmp/b; mount --bind /tmp/a /tmp/b; IsLikelyNotMountPoint("/tmp/b")
|
||||
// will return true. When in fact /tmp/b is a mount point. If this situation
|
||||
// is of interest to you, don't use this function...
|
||||
func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) {
|
||||
stat, err := os.Stat(file)
|
||||
if err != nil {
|
||||
return true, err
|
||||
@ -421,51 +409,6 @@ func (mounter *Mounter) isLikelyNotMountPointStat(file string) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (mounter *Mounter) isLikelyNotMountPointStatx(file string) (bool, error) {
|
||||
var stat, rootStat unix.Statx_t
|
||||
var err error
|
||||
|
||||
if stat, err = statx(file); err != nil {
|
||||
return true, err
|
||||
}
|
||||
|
||||
if stat.Attributes_mask != 0 {
|
||||
if stat.Attributes_mask&unix.STATX_ATTR_MOUNT_ROOT != 0 {
|
||||
if stat.Attributes&unix.STATX_ATTR_MOUNT_ROOT != 0 {
|
||||
// file is a mountpoint
|
||||
return false, nil
|
||||
} else {
|
||||
// no need to check rootStat if unix.STATX_ATTR_MOUNT_ROOT supported
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
root := filepath.Dir(strings.TrimSuffix(file, "/"))
|
||||
if rootStat, err = statx(root); err != nil {
|
||||
return true, err
|
||||
}
|
||||
|
||||
return (stat.Dev_major == rootStat.Dev_major && stat.Dev_minor == rootStat.Dev_minor), nil
|
||||
}
|
||||
|
||||
// IsLikelyNotMountPoint determines if a directory is not a mountpoint.
|
||||
// It is fast but not necessarily ALWAYS correct. If the path is in fact
|
||||
// a bind mount from one part of a mount to another it will not be detected.
|
||||
// It also can not distinguish between mountpoints and symbolic links.
|
||||
// mkdir /tmp/a /tmp/b; mount --bind /tmp/a /tmp/b; IsLikelyNotMountPoint("/tmp/b")
|
||||
// will return true. When in fact /tmp/b is a mount point. If this situation
|
||||
// is of interest to you, don't use this function...
|
||||
func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) {
|
||||
notMountPoint, err := mounter.isLikelyNotMountPointStatx(file)
|
||||
if errors.Is(err, errStatxNotSupport) {
|
||||
// fall back to isLikelyNotMountPointStat
|
||||
return mounter.isLikelyNotMountPointStat(file)
|
||||
}
|
||||
|
||||
return notMountPoint, err
|
||||
}
|
||||
|
||||
// CanSafelySkipMountPointCheck relies on the detected behavior of umount when given a target that is not a mount point.
|
||||
func (mounter *Mounter) CanSafelySkipMountPointCheck() bool {
|
||||
return mounter.withSafeNotMountedBehavior
|
||||
|
6
vendor/k8s.io/mount-utils/mount_windows.go
generated
vendored
6
vendor/k8s.io/mount-utils/mount_windows.go
generated
vendored
@ -164,7 +164,7 @@ func (mounter *Mounter) MountSensitive(source string, target string, fstype stri
|
||||
// return (output, error)
|
||||
func newSMBMapping(username, password, remotepath string) (string, error) {
|
||||
if username == "" || password == "" || remotepath == "" {
|
||||
return "", fmt.Errorf("invalid parameter(username: %s, password: %s, remotepath: %s)", username, sensitiveOptionsRemoved, remotepath)
|
||||
return "", fmt.Errorf("invalid parameter(username: %s, password: %s, remoteapth: %s)", username, sensitiveOptionsRemoved, remotepath)
|
||||
}
|
||||
|
||||
// use PowerShell Environment Variables to store user input string to prevent command line injection
|
||||
@ -193,8 +193,8 @@ func isSMBMappingExist(remotepath string) bool {
|
||||
// check whether remotepath is valid
|
||||
// return (true, nil) if remotepath is valid
|
||||
func isValidPath(remotepath string) (bool, error) {
|
||||
cmd := exec.Command("powershell", "/c", `Test-Path $Env:remotepath`)
|
||||
cmd.Env = append(os.Environ(), fmt.Sprintf("remotepath=%s", remotepath))
|
||||
cmd := exec.Command("powershell", "/c", `Test-Path $Env:remoteapth`)
|
||||
cmd.Env = append(os.Environ(), fmt.Sprintf("remoteapth=%s", remotepath))
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("returned output: %s, error: %v", string(output), err)
|
||||
|
Reference in New Issue
Block a user