Add -N, -X opptions
@@ -20,6 +20,8 @@ var opts struct {
Path *string `short:"p" long:"path" value-name:"PATH" description:"Mount point or block device as emitted by the mount(8) command"`
Exclude *string `short:"x" long:"exclude-device" value-name:"EXCLUDE PATH" description:"Ignore device (only works if -p unspecified)"`
All bool `short:"A" long:"all" description:"Explicitly select all paths."`
+ ExcludeType *string `short:"X" long:"exclude-type" value-name:"TYPE" description:"Ignore all filesystems of indicated type"`
+ IncludeType *string `short:"N" long:"include-type" value-name:"TYPE" description:"Check only filesystems of indicated type"`
Units *string `short:"u" long:"units" value-name:"STRING" description:"Choose bytes, kB, MB, GB, TB (default: MB)"`
}
@@ -95,7 +97,7 @@ func run(args []string) *checkers.Checker {
os.Exit(1)
}
- partitions, err := listPartitions()
+ partitions, err := listPartitions(opts.IncludeType, opts.ExcludeType)
if err != nil {
return checkers.Unknown(fmt.Sprintf("Faild to fetch partitions: %s", err))
}
@@ -223,13 +225,26 @@ func run(args []string) *checkers.Checker {
// ref: mountlist.c in gnulib
// https://github.com/coreutils/gnulib/blob/a742bdb3/lib/mountlist.c#L168
-func listPartitions() ([]gpud.PartitionStat, error) {
+func listPartitions(includeType *string, excludeType *string) ([]gpud.PartitionStat, error) {
allPartitions, err := gpud.Partitions(true)
if err != nil {
return nil, err
}
partitions := make([]gpud.PartitionStat, 0, len(allPartitions))
for _, p := range allPartitions {
+ if includeType != nil {
+ if p.Fstype == *includeType {
+ partitions = append(partitions, p)
+ continue
+ }
+ }
+
+ if excludeType != nil {
+ if p.Fstype == *excludeType {
+ continue
+ }
+ }
+
switch p.Fstype {
case "autofs",
"proc",
