File: errors.go

package info (click to toggle)
golang-github-dennwc-btrfs 0.0~git20221026.3097362-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 312 kB
  • sloc: makefile: 4; sh: 4
file content (52 lines) | stat: -rw-r--r-- 1,297 bytes parent folder | download | duplicates (2)
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")
)