Skip to content

Commit efa4cfa

Browse files
authored
Merge pull request #2859 from saschagrunert/partitions-map-err
Add custom error type if device not found in partitions map
2 parents 717582d + 8f4d3e3 commit efa4cfa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/fs.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package fs
1919

2020
import (
2121
"bufio"
22+
"errors"
2223
"fmt"
2324
"io/ioutil"
2425
"os"
@@ -56,6 +57,9 @@ const (
5657
// A pool for restricting the number of consecutive `du` and `find` tasks running.
5758
var pool = make(chan struct{}, maxConcurrentOps)
5859

60+
// ErrDeviceNotInPartitionsMap is the error resulting if a device could not be found in the partitions map.
61+
var ErrDeviceNotInPartitionsMap = errors.New("could not find device in cached partitions map")
62+
5963
func init() {
6064
for i := 0; i < maxConcurrentOps; i++ {
6165
releaseToken()
@@ -595,7 +599,7 @@ func (i *RealFsInfo) GetDirFsDevice(dir string) (*DeviceInfo, error) {
595599
return &DeviceInfo{mnt.Source, uint(major), uint(minor)}, nil
596600
}
597601

598-
return nil, fmt.Errorf("could not find device with major: %d, minor: %d in cached partitions map", major, minor)
602+
return nil, fmt.Errorf("with major: %d, minor: %d: %w", major, minor, ErrDeviceNotInPartitionsMap)
599603
}
600604

601605
func GetDirUsage(dir string) (UsageInfo, error) {

0 commit comments

Comments
 (0)