mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 11:28:58 +00:00
fix: Check Statfs_t type using unix package only
This commit is contained in:
@@ -31,12 +31,6 @@ import (
|
||||
"k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
// Defined by Linux - the type number for tmpfs mounts.
|
||||
const (
|
||||
linuxTmpfsMagic = 0x01021994
|
||||
linuxHugetlbfsMagic = 0x958458f6
|
||||
)
|
||||
|
||||
// realMountDetector implements mountDetector in terms of syscalls.
|
||||
type realMountDetector struct {
|
||||
mounter mount.Interface
|
||||
@@ -98,9 +92,9 @@ func (m *realMountDetector) GetMountMedium(path string, requestedMedium v1.Stora
|
||||
|
||||
klog.V(3).Infof("Statfs_t of %v: %+v", path, buf)
|
||||
|
||||
if buf.Type == linuxTmpfsMagic {
|
||||
if buf.Type == unix.TMPFS_MAGIC {
|
||||
return v1.StorageMediumMemory, !notMnt, nil, nil
|
||||
} else if int64(buf.Type) == linuxHugetlbfsMagic {
|
||||
} else if int64(buf.Type) == unix.HUGETLBFS_MAGIC {
|
||||
// Skip page size detection if requested medium doesn't have size specified
|
||||
if requestedMedium == v1.StorageMediumHugePages {
|
||||
return v1.StorageMediumHugePages, !notMnt, nil, nil
|
||||
|
||||
@@ -29,9 +29,6 @@ func umask(mask int) int {
|
||||
return syscall.Umask(mask)
|
||||
}
|
||||
|
||||
// Defined by Linux (sys/statfs.h) - the type number for tmpfs mounts.
|
||||
const linuxTmpfsMagic = 0x01021994
|
||||
|
||||
func fsType(path string) error {
|
||||
if path == "" {
|
||||
return nil
|
||||
@@ -43,11 +40,7 @@ func fsType(path string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if buf.Type == linuxTmpfsMagic {
|
||||
fmt.Printf("mount type of %q: tmpfs\n", path)
|
||||
} else {
|
||||
fmt.Printf("mount type of %q: %v\n", path, buf.Type)
|
||||
}
|
||||
fmt.Printf("mount type of %q: %v\n", path, buf.Type)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user