Merge pull request #2219 from jaerik/master

Adding ability to handle OverlayFS mounts
This commit is contained in:
David Ashpole 2019-09-06 09:41:47 -07:00 committed by GitHub
commit be3c91506e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 10 deletions

View File

@ -167,10 +167,11 @@ func processMounts(mounts []*mount.Info, excludedMountpointPrefixes []string) ma
supportedFsType := map[string]bool{
// all ext systems are checked through prefix.
"btrfs": true,
"tmpfs": true,
"xfs": true,
"zfs": true,
"btrfs": true,
"overlay": true,
"tmpfs": true,
"xfs": true,
"zfs": true,
}
for _, mount := range mounts {
@ -205,6 +206,11 @@ func processMounts(mounts []*mount.Info, excludedMountpointPrefixes []string) ma
}
}
// overlay fix: Making mount source unique for all overlay mounts, using the mount's major and minor ids.
if mount.Fstype == "overlay" {
mount.Source = fmt.Sprintf("%s_%d-%d", mount.Source, mount.Major, mount.Minor)
}
partitions[mount.Source] = partition{
fsType: mount.Fstype,
mountpoint: mount.Mountpoint,

View File

@ -482,7 +482,6 @@ func TestProcessMounts(t *testing.T) {
{
name: "unsupported fs types",
mounts: []*mount.Info{
{Fstype: "overlay"},
{Fstype: "somethingelse"},
},
expected: map[string]partition{},
@ -517,13 +516,15 @@ func TestProcessMounts(t *testing.T) {
{Root: "/", Mountpoint: "/c", Source: "/dev/sdc", Fstype: "btrfs", Major: 253, Minor: 2},
{Root: "/", Mountpoint: "/d", Source: "/dev/sdd", Fstype: "xfs", Major: 253, Minor: 3},
{Root: "/", Mountpoint: "/e", Source: "/dev/sde", Fstype: "zfs", Major: 253, Minor: 4},
{Root: "/", Mountpoint: "/f", Source: "overlay", Fstype: "overlay", Major: 253, Minor: 5},
},
expected: map[string]partition{
"/dev/sda": {fsType: "ext3", mountpoint: "/a", major: 253, minor: 0},
"/dev/sdb": {fsType: "ext4", mountpoint: "/b", major: 253, minor: 1},
"/dev/sdc": {fsType: "btrfs", mountpoint: "/c", major: 253, minor: 2},
"/dev/sdd": {fsType: "xfs", mountpoint: "/d", major: 253, minor: 3},
"/dev/sde": {fsType: "zfs", mountpoint: "/e", major: 253, minor: 4},
"/dev/sda": {fsType: "ext3", mountpoint: "/a", major: 253, minor: 0},
"/dev/sdb": {fsType: "ext4", mountpoint: "/b", major: 253, minor: 1},
"/dev/sdc": {fsType: "btrfs", mountpoint: "/c", major: 253, minor: 2},
"/dev/sdd": {fsType: "xfs", mountpoint: "/d", major: 253, minor: 3},
"/dev/sde": {fsType: "zfs", mountpoint: "/e", major: 253, minor: 4},
"overlay_253-5": {fsType: "overlay", mountpoint: "/f", major: 253, minor: 5},
},
},
}