Adding ability to handle OverlayFS mounts

Signed-off-by: Erik Jansson <erikja@axis.com>
This commit is contained in:
Erik Jansson 2019-04-10 08:41:34 +02:00
parent 1276700730
commit 0a8da7895f
2 changed files with 16 additions and 10 deletions

View File

@ -184,10 +184,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 {
@ -222,6 +223,10 @@ func processMounts(mounts []*mount.Info, excludedMountpointPrefixes []string) ma
}
}
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},
},
},
}