-
Notifications
You must be signed in to change notification settings - Fork 11
/
errors.go
52 lines (44 loc) · 1.27 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package btrfs
import (
"errors"
"fmt"
)
type ErrNotBtrfs struct {
Path string
}
func (e ErrNotBtrfs) Error() string {
return fmt.Sprintf("not a btrfs filesystem: %s", e.Path)
}
// Error codes as returned by the kernel
type ErrCode int
func (e ErrCode) Error() string {
s, ok := errorString[e]
if ok {
return s
}
return fmt.Sprintf("error %d", int(e))
}
const (
ErrDevRAID1MinNotMet = ErrCode(iota + 1)
ErrDevRAID10MinNotMet
ErrDevRAID5MinNotMet
ErrDevRAID6MinNotMet
ErrDevTargetReplace
ErrDevMissingNotFound
ErrDevOnlyWritable
ErrDevExclRunInProgress
)
var errorString = map[ErrCode]string{
ErrDevRAID1MinNotMet: "unable to go below two devices on raid1",
ErrDevRAID10MinNotMet: "unable to go below four devices on raid10",
ErrDevRAID5MinNotMet: "unable to go below two devices on raid5",
ErrDevRAID6MinNotMet: "unable to go below three devices on raid6",
ErrDevTargetReplace: "unable to remove the dev_replace target dev",
ErrDevMissingNotFound: "no missing devices found to remove",
ErrDevOnlyWritable: "unable to remove the only writeable device",
ErrDevExclRunInProgress: "add/delete/balance/replace/resize operation in progress",
}
var (
ErrNotFound = errors.New("not found")
errNotImplemented = errors.New("not implemented")
)