in fs/fs.go [170:236]
func processMounts(mounts []*mount.Info, excludedMountpointPrefixes []string) map[string]partition {
partitions := make(map[string]partition)
supportedFsType := map[string]bool{
// all ext and nfs systems are checked through prefix
// because there are a number of families (e.g., ext3, ext4, nfs3, nfs4...)
"btrfs": true,
"overlay": true,
"tmpfs": true,
"xfs": true,
"zfs": true,
}
for _, mnt := range mounts {
if !strings.HasPrefix(mnt.FSType, "ext") && !strings.HasPrefix(mnt.FSType, "nfs") &&
!supportedFsType[mnt.FSType] {
continue
}
// Avoid bind mounts, exclude tmpfs.
if _, ok := partitions[mnt.Source]; ok {
if mnt.FSType != "tmpfs" {
continue
}
}
hasPrefix := false
for _, prefix := range excludedMountpointPrefixes {
if strings.HasPrefix(mnt.Mountpoint, prefix) {
hasPrefix = true
break
}
}
if hasPrefix {
continue
}
// using mountpoint to replace device once fstype it tmpfs
if mnt.FSType == "tmpfs" {
mnt.Source = mnt.Mountpoint
}
// btrfs fix: following workaround fixes wrong btrfs Major and Minor Ids reported in /proc/self/mountinfo.
// instead of using values from /proc/self/mountinfo we use stat to get Ids from btrfs mount point
if mnt.FSType == "btrfs" && mnt.Major == 0 && strings.HasPrefix(mnt.Source, "/dev/") {
major, minor, err := getBtrfsMajorMinorIds(mnt)
if err != nil {
klog.Warningf("%s", err)
} else {
mnt.Major = major
mnt.Minor = minor
}
}
// overlay fix: Making mount source unique for all overlay mounts, using the mount's major and minor ids.
if mnt.FSType == "overlay" {
mnt.Source = fmt.Sprintf("%s_%d-%d", mnt.Source, mnt.Major, mnt.Minor)
}
partitions[mnt.Source] = partition{
fsType: mnt.FSType,
mountpoint: mnt.Mountpoint,
major: uint(mnt.Major),
minor: uint(mnt.Minor),
}
}
return partitions
}