|
21 | 21 | hideSpecial = flag.Bool("hide-special", false, "hide special devices") |
22 | 22 | hideLoops = flag.Bool("hide-loops", true, "hide loop devices") |
23 | 23 | hideBinds = flag.Bool("hide-binds", true, "hide bind mounts") |
| 24 | + hideFs = flag.String("hide-fs", "", "hide specific filesystems, separated with commas") |
24 | 25 |
|
25 | 26 | output = flag.String("output", "", "output fields: "+strings.Join(columnIDs(), ", ")) |
26 | 27 | sortBy = flag.String("sort", "mountpoint", "sort output by: "+strings.Join(columnIDs(), ", ")) |
|
33 | 34 | // renderTables renders all tables. |
34 | 35 | func renderTables(m []Mount, columns []int, sortCol int) error { |
35 | 36 | var local, network, fuse, special []Mount |
| 37 | + hideFsMap := parseHideFs(*hideFs) |
36 | 38 |
|
37 | 39 | // sort/filter devices |
38 | 40 | for _, v := range m { |
| 41 | + // skip hideFs |
| 42 | + if _, ok := hideFsMap[v.Fstype]; ok { |
| 43 | + continue |
| 44 | + } |
39 | 45 | // skip autofs |
40 | 46 | if v.Fstype == "autofs" { |
41 | 47 | continue |
@@ -122,6 +128,19 @@ func parseColumns(cols string) ([]int, error) { |
122 | 128 | return i, nil |
123 | 129 | } |
124 | 130 |
|
| 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 | + |
125 | 144 | func main() { |
126 | 145 | flag.Parse() |
127 | 146 |
|
|
0 commit comments