Skip to content

Commit 0a93666

Browse files
authored
Add --hide-fs to hide specific fs types (#38)
1 parent e2c8b42 commit 0a93666

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

main.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var (
2121
hideSpecial = flag.Bool("hide-special", false, "hide special devices")
2222
hideLoops = flag.Bool("hide-loops", true, "hide loop devices")
2323
hideBinds = flag.Bool("hide-binds", true, "hide bind mounts")
24+
hideFs = flag.String("hide-fs", "", "hide specific filesystems, separated with commas")
2425

2526
output = flag.String("output", "", "output fields: "+strings.Join(columnIDs(), ", "))
2627
sortBy = flag.String("sort", "mountpoint", "sort output by: "+strings.Join(columnIDs(), ", "))
@@ -33,9 +34,14 @@ var (
3334
// renderTables renders all tables.
3435
func renderTables(m []Mount, columns []int, sortCol int) error {
3536
var local, network, fuse, special []Mount
37+
hideFsMap := parseHideFs(*hideFs)
3638

3739
// sort/filter devices
3840
for _, v := range m {
41+
// skip hideFs
42+
if _, ok := hideFsMap[v.Fstype]; ok {
43+
continue
44+
}
3945
// skip autofs
4046
if v.Fstype == "autofs" {
4147
continue
@@ -122,6 +128,19 @@ func parseColumns(cols string) ([]int, error) {
122128
return i, nil
123129
}
124130

131+
// parseHideFs parses the supplied hide-fs flag into a map of fs types which should be skipped.
132+
func parseHideFs(hideFs string) map[string]struct{} {
133+
hideMap := make(map[string]struct{})
134+
for _, fs := range strings.Split(hideFs, ",") {
135+
fs = strings.TrimSpace(fs)
136+
if len(fs) == 0 {
137+
continue
138+
}
139+
hideMap[fs] = struct{}{}
140+
}
141+
return hideMap
142+
}
143+
125144
func main() {
126145
flag.Parse()
127146

0 commit comments

Comments
 (0)