Skip to content

Commit

Permalink
Merge pull request #2787 from gjkim42/support-nfs-in-processmounts
Browse files Browse the repository at this point in the history
Support nfs in processMounts
  • Loading branch information
bobbypage authored Jan 23, 2021
2 parents 3acf91c + a228e69 commit 19e51c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
6 changes: 4 additions & 2 deletions fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ func processMounts(mounts []*mount.Info, excludedMountpointPrefixes []string) ma
partitions := make(map[string]partition)

supportedFsType := map[string]bool{
// all ext systems are checked through prefix.
// 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,
Expand All @@ -179,7 +180,8 @@ func processMounts(mounts []*mount.Info, excludedMountpointPrefixes []string) ma
}

for _, mnt := range mounts {
if !strings.HasPrefix(mnt.Fstype, "ext") && !supportedFsType[mnt.Fstype] {
if !strings.HasPrefix(mnt.Fstype, "ext") && !strings.HasPrefix(mnt.Fstype, "nfs") &&
!supportedFsType[mnt.Fstype] {
continue
}
// Avoid bind mounts, exclude tmpfs.
Expand Down
18 changes: 10 additions & 8 deletions fs/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,18 +563,20 @@ 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: "/g", Source: "127.0.0.1:/nfs", Fstype: "nfs4", Major: 253, Minor: 6},
{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},
"/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},
"/test1": {fsType: "tmpfs", mountpoint: "/test1", major: 253, minor: 4},
"/test2": {fsType: "tmpfs", mountpoint: "/test2", 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},
"127.0.0.1:/nfs": {fsType: "nfs4", mountpoint: "/g", major: 253, minor: 6},
"/test1": {fsType: "tmpfs", mountpoint: "/test1", major: 253, minor: 4},
"/test2": {fsType: "tmpfs", mountpoint: "/test2", major: 253, minor: 4},
},
},
}
Expand Down

0 comments on commit 19e51c8

Please sign in to comment.