mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #6106 from discordianfish/improve-error-btrfs-on-non-btrfs
Add ErrPrerequisites to improve misleading errors
This commit is contained in:
commit
e2935f9c16
3 changed files with 11 additions and 6 deletions
|
@ -18,6 +18,10 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
btrfsSuperMagic = 0x9123683E
|
||||
)
|
||||
|
||||
func init() {
|
||||
graphdriver.Register("btrfs", Init)
|
||||
}
|
||||
|
@ -30,8 +34,8 @@ func Init(home string) (graphdriver.Driver, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if buf.Type != 0x9123683E {
|
||||
return nil, graphdriver.ErrNotSupported
|
||||
if buf.Type != btrfsSuperMagic {
|
||||
return nil, graphdriver.ErrPrerequisites
|
||||
}
|
||||
|
||||
return &Driver{
|
||||
|
|
|
@ -44,7 +44,8 @@ var (
|
|||
"vfs",
|
||||
}
|
||||
|
||||
ErrNotSupported = errors.New("driver not supported")
|
||||
ErrNotSupported = errors.New("driver not supported")
|
||||
ErrPrerequisites = errors.New("Prerequisites for driver not satisfied (wrong filesystem?)")
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -78,7 +79,7 @@ func New(root string) (driver Driver, err error) {
|
|||
for _, name := range priority {
|
||||
driver, err = GetDriver(name, root)
|
||||
if err != nil {
|
||||
if err == ErrNotSupported {
|
||||
if err == ErrNotSupported || err == ErrPrerequisites {
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
|
@ -89,7 +90,7 @@ func New(root string) (driver Driver, err error) {
|
|||
// Check all registered drivers if no priority driver is found
|
||||
for _, initFunc := range drivers {
|
||||
if driver, err = initFunc(root); err != nil {
|
||||
if err == ErrNotSupported {
|
||||
if err == ErrNotSupported || err == ErrPrerequisites {
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
|
|
|
@ -31,7 +31,7 @@ func newDriver(t *testing.T, name string) *Driver {
|
|||
|
||||
d, err := graphdriver.GetDriver(name, root)
|
||||
if err != nil {
|
||||
if err == graphdriver.ErrNotSupported {
|
||||
if err == graphdriver.ErrNotSupported || err == graphdriver.ErrPrerequisites {
|
||||
t.Skip("Driver %s not supported", name)
|
||||
}
|
||||
t.Fatal(err)
|
||||
|
|
Loading…
Add table
Reference in a new issue