mirror of https://github.com/docker/docs.git
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
|
@ -18,6 +18,10 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
btrfsSuperMagic = 0x9123683E
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
graphdriver.Register("btrfs", Init)
|
graphdriver.Register("btrfs", Init)
|
||||||
}
|
}
|
||||||
|
@ -30,8 +34,8 @@ func Init(home string) (graphdriver.Driver, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if buf.Type != 0x9123683E {
|
if buf.Type != btrfsSuperMagic {
|
||||||
return nil, graphdriver.ErrNotSupported
|
return nil, graphdriver.ErrPrerequisites
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Driver{
|
return &Driver{
|
||||||
|
|
|
@ -45,6 +45,7 @@ var (
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrNotSupported = errors.New("driver not supported")
|
ErrNotSupported = errors.New("driver not supported")
|
||||||
|
ErrPrerequisites = errors.New("Prerequisites for driver not satisfied (wrong filesystem?)")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -78,7 +79,7 @@ func New(root string) (driver Driver, err error) {
|
||||||
for _, name := range priority {
|
for _, name := range priority {
|
||||||
driver, err = GetDriver(name, root)
|
driver, err = GetDriver(name, root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == ErrNotSupported {
|
if err == ErrNotSupported || err == ErrPrerequisites {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return nil, err
|
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
|
// Check all registered drivers if no priority driver is found
|
||||||
for _, initFunc := range drivers {
|
for _, initFunc := range drivers {
|
||||||
if driver, err = initFunc(root); err != nil {
|
if driver, err = initFunc(root); err != nil {
|
||||||
if err == ErrNotSupported {
|
if err == ErrNotSupported || err == ErrPrerequisites {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -31,7 +31,7 @@ func newDriver(t *testing.T, name string) *Driver {
|
||||||
|
|
||||||
d, err := graphdriver.GetDriver(name, root)
|
d, err := graphdriver.GetDriver(name, root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == graphdriver.ErrNotSupported {
|
if err == graphdriver.ErrNotSupported || err == graphdriver.ErrPrerequisites {
|
||||||
t.Skip("Driver %s not supported", name)
|
t.Skip("Driver %s not supported", name)
|
||||||
}
|
}
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
Loading…
Reference in New Issue