mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
rebase: update k8s.io/mount-utils to current master
kubernetes/kubernetes#111083 has been merged and synced into k8s.io/mount-utils. This should remove any systemd log messages while calling NodeStageVolume and NodeGetVolumeStats. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
3c3cbc8005
commit
533994daff
72
vendor/github.com/moby/sys/mountinfo/mountinfo_bsd.go
generated
vendored
Normal file
72
vendor/github.com/moby/sys/mountinfo/mountinfo_bsd.go
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
//go:build (freebsd && cgo) || (openbsd && cgo) || (darwin && cgo)
|
||||
// +build freebsd,cgo openbsd,cgo darwin,cgo
|
||||
|
||||
package mountinfo
|
||||
|
||||
/*
|
||||
#include <sys/param.h>
|
||||
#include <sys/ucred.h>
|
||||
#include <sys/mount.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// parseMountTable returns information about mounted filesystems
|
||||
func parseMountTable(filter FilterFunc) ([]*Info, error) {
|
||||
var rawEntries *C.struct_statfs
|
||||
|
||||
count := int(C.getmntinfo(&rawEntries, C.MNT_WAIT))
|
||||
if count == 0 {
|
||||
return nil, fmt.Errorf("failed to call getmntinfo")
|
||||
}
|
||||
|
||||
var entries []C.struct_statfs
|
||||
header := (*reflect.SliceHeader)(unsafe.Pointer(&entries))
|
||||
header.Cap = count
|
||||
header.Len = count
|
||||
header.Data = uintptr(unsafe.Pointer(rawEntries))
|
||||
|
||||
var out []*Info
|
||||
for _, entry := range entries {
|
||||
var mountinfo Info
|
||||
var skip, stop bool
|
||||
mountinfo.Mountpoint = C.GoString(&entry.f_mntonname[0])
|
||||
mountinfo.FSType = C.GoString(&entry.f_fstypename[0])
|
||||
mountinfo.Source = C.GoString(&entry.f_mntfromname[0])
|
||||
|
||||
if filter != nil {
|
||||
// filter out entries we're not interested in
|
||||
skip, stop = filter(&mountinfo)
|
||||
if skip {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
out = append(out, &mountinfo)
|
||||
if stop {
|
||||
break
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func mounted(path string) (bool, error) {
|
||||
path, err := normalizePath(path)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
// Fast path: compare st.st_dev fields.
|
||||
// This should always work for FreeBSD and OpenBSD.
|
||||
mounted, err := mountedByStat(path)
|
||||
if err == nil {
|
||||
return mounted, nil
|
||||
}
|
||||
|
||||
// Fallback to parsing mountinfo
|
||||
return mountedByMountinfo(path)
|
||||
}
|
Reference in New Issue
Block a user