diff --git a/fs/fs.go b/fs/fs.go index 4dfa4e80d9..4dad954cde 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -176,9 +176,11 @@ func processMounts(mounts []*mount.Info, excludedMountpointPrefixes []string) ma if !strings.HasPrefix(mount.Fstype, "ext") && !supportedFsType[mount.Fstype] { continue } - // Avoid bind mounts. + // Avoid bind mounts, exclude tmpfs. if _, ok := partitions[mount.Source]; ok { - continue + if mount.Fstype != "tmpfs" { + continue + } } hasPrefix := false @@ -192,6 +194,10 @@ func processMounts(mounts []*mount.Info, excludedMountpointPrefixes []string) ma continue } + // using mountpoint to replace device once fstype it tmpfs + if mount.Fstype == "tmpfs" { + mount.Source = mount.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 mount.Fstype == "btrfs" && mount.Major == 0 && strings.HasPrefix(mount.Source, "/dev/") { diff --git a/fs/fs_test.go b/fs/fs_test.go index b5ca81be02..f27ff3a3a1 100644 --- a/fs/fs_test.go +++ b/fs/fs_test.go @@ -517,6 +517,8 @@ func TestProcessMounts(t *testing.T) { {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}, + {Root: "/", Mountpoint: "/test1", Source: "tmpfs", Fstype: "tmpfs", Major: 253, Minor: 4}, + {Root: "/", Mountpoint: "/test2", Source: "tmpfs", Fstype: "tmpfs", Major: 253, Minor: 4}, }, expected: map[string]partition{ "/dev/sda": {fsType: "ext3", mountpoint: "/a", major: 253, minor: 0}, @@ -525,6 +527,8 @@ func TestProcessMounts(t *testing.T) { "/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}, + "/test1": {fsType: "tmpfs", mountpoint: "/test1", major: 253, minor: 4}, + "/test2": {fsType: "tmpfs", mountpoint: "/test2", major: 253, minor: 4}, }, }, }