@@ -116,11 +116,12 @@ func run(args []string) *checkers.Checker {
116
116
}
117
117
118
118
partitions , err := listPartitions ()
119
- if err != nil {
120
- return checkers .Unknown (fmt .Sprintf ("Failed to fetch partitions: %s" , err ))
121
- }
122
119
123
- if ! opts .All {
120
+ if opts .All {
121
+ if err != nil {
122
+ return checkers .Unknown (fmt .Sprintf ("Failed to fetch partitions: %s" , err ))
123
+ }
124
+ } else {
124
125
// Filtering partitions by Fstype
125
126
if opts .IncludeType != nil {
126
127
partitions = filterPartitionsByInclusion (partitions , * opts .IncludeType , fstypeOfPartition )
@@ -140,9 +141,13 @@ func run(args []string) *checkers.Checker {
140
141
}
141
142
142
143
partitions = filterPartitionsByInclusion (partitions , * opts .Path , mountpointOfPartition )
143
- if len (partitions ) == 0 {
144
+ if len (partitions ) < len ( * opts . Path ) {
144
145
return checkers .Unknown (fmt .Sprintf ("Failed to fetch partitions: %s" , errors .New ("No device found for the specified *Mountpoint*" )))
145
146
}
147
+ } else {
148
+ if err != nil {
149
+ return checkers .Unknown (fmt .Sprintf ("Failed to fetch partitions: %s" , err ))
150
+ }
146
151
}
147
152
148
153
if opts .Path == nil && opts .Exclude != nil {
@@ -253,9 +258,6 @@ func run(args []string) *checkers.Checker {
253
258
// https://github.com/coreutils/gnulib/blob/df336dc/lib/mountlist.c#L164
254
259
func listPartitions () ([]gpud.PartitionStat , error ) {
255
260
allPartitions , err := gpud .Partitions (true )
256
- if err != nil {
257
- return nil , err
258
- }
259
261
partitions := make ([]gpud.PartitionStat , 0 , len (allPartitions ))
260
262
for _ , p := range allPartitions {
261
263
switch p .Fstype {
@@ -283,7 +285,7 @@ func listPartitions() ([]gpud.PartitionStat, error) {
283
285
}
284
286
}
285
287
286
- return partitions , nil
288
+ return partitions , err
287
289
}
288
290
289
291
func isBindMount (mountOpts []string ) bool {
0 commit comments