1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

daemon/graphdriver fix lint errors/warnings

Addresses #14756

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
This commit is contained in:
Srini Brahmaroutu 2015-07-21 22:21:05 +00:00
parent 5aeb48af77
commit 9e1a41aae5
5 changed files with 49 additions and 18 deletions

View file

@ -11,22 +11,29 @@ import (
"github.com/docker/docker/pkg/archive"
)
// FsMagic unsigned id of the filesystem in use.
type FsMagic uint32
const (
// FsMagicUnsupported is a predifined contant value other than a valid filesystem id.
FsMagicUnsupported = FsMagic(0x00000000)
)
var (
// DefaultDriver if a storage driver is not specified.
DefaultDriver string
// All registred drivers
drivers map[string]InitFunc
ErrNotSupported = errors.New("driver not supported")
ErrPrerequisites = errors.New("prerequisites for driver not satisfied (wrong filesystem?)")
// ErrNotSupported returned when driver is not supported.
ErrNotSupported = errors.New("driver not supported")
// ErrPrerequisites retuned when driver does not meet prerequisites.
ErrPrerequisites = errors.New("prerequisites for driver not satisfied (wrong filesystem?)")
// ErrIncompatibleFS returned when file system is not supported.
ErrIncompatibleFS = fmt.Errorf("backing file system is unsupported for this graph driver")
)
// InitFunc initializes the storage driver.
type InitFunc func(root string, options []string) (Driver, error)
// ProtoDriver defines the basic capabilities of a driver.
@ -89,6 +96,7 @@ func init() {
drivers = make(map[string]InitFunc)
}
// Register registers a InitFunc for the driver.
func Register(name string, initFunc InitFunc) error {
if _, exists := drivers[name]; exists {
return fmt.Errorf("Name already registered %s", name)
@ -98,6 +106,7 @@ func Register(name string, initFunc InitFunc) error {
return nil
}
// GetDriver initializes and returns the registered driver
func GetDriver(name, home string, options []string) (Driver, error) {
if initFunc, exists := drivers[name]; exists {
return initFunc(filepath.Join(home, name), options)
@ -106,6 +115,7 @@ func GetDriver(name, home string, options []string) (Driver, error) {
return nil, ErrNotSupported
}
// New creates the driver and initializes it at the specified root.
func New(root string, options []string) (driver Driver, err error) {
for _, name := range []string{os.Getenv("DOCKER_DRIVER"), DefaultDriver} {
if name != "" {
@ -192,7 +202,7 @@ func checkPriorDriver(name, root string) error {
if len(priorDrivers) > 0 {
return errors.New(fmt.Sprintf("%q contains other graphdrivers: %s; Please cleanup or explicitly choose storage driver (-s <DRIVER>)", root, strings.Join(priorDrivers, ",")))
return fmt.Errorf("%q contains other graphdrivers: %s; Please cleanup or explicitly choose storage driver (-s <DRIVER>)", root, strings.Join(priorDrivers, ","))
}
return nil
}

View file

@ -8,22 +8,38 @@ import (
)
const (
FsMagicAufs = FsMagic(0x61756673)
FsMagicBtrfs = FsMagic(0x9123683E)
FsMagicCramfs = FsMagic(0x28cd3d45)
FsMagicExtfs = FsMagic(0x0000EF53)
FsMagicF2fs = FsMagic(0xF2F52010)
FsMagicJffs2Fs = FsMagic(0x000072b6)
FsMagicJfs = FsMagic(0x3153464a)
FsMagicNfsFs = FsMagic(0x00006969)
FsMagicRamFs = FsMagic(0x858458f6)
// FsMagicAufs filesystem id for Aufs
FsMagicAufs = FsMagic(0x61756673)
// FsMagicBtrfs filesystem id for Btrfs
FsMagicBtrfs = FsMagic(0x9123683E)
// FsMagicCramfs filesystem id for Cramfs
FsMagicCramfs = FsMagic(0x28cd3d45)
// FsMagicExtfs filesystem id for Extfs
FsMagicExtfs = FsMagic(0x0000EF53)
// FsMagicF2fs filesystem id for F2fs
FsMagicF2fs = FsMagic(0xF2F52010)
// FsMagicJffs2Fs filesystem if for Jffs2Fs
FsMagicJffs2Fs = FsMagic(0x000072b6)
// FsMagicJfs filesystem id for Jfs
FsMagicJfs = FsMagic(0x3153464a)
// FsMagicNfsFs filesystem id for NfsFs
FsMagicNfsFs = FsMagic(0x00006969)
// FsMagicRAMFs filesystem id for RamFs
FsMagicRAMFs = FsMagic(0x858458f6)
// FsMagicReiserFs filesystem id for ReiserFs
FsMagicReiserFs = FsMagic(0x52654973)
FsMagicSmbFs = FsMagic(0x0000517B)
// FsMagicSmbFs filesystem id for SmbFs
FsMagicSmbFs = FsMagic(0x0000517B)
// FsMagicSquashFs filesystem id for SquashFs
FsMagicSquashFs = FsMagic(0x73717368)
FsMagicTmpFs = FsMagic(0x01021994)
FsMagicVxFS = FsMagic(0xa501fcf5)
FsMagicXfs = FsMagic(0x58465342)
FsMagicZfs = FsMagic(0x2fc12fc1)
// FsMagicTmpFs filesystem id for TmpFs
FsMagicTmpFs = FsMagic(0x01021994)
// FsMagicVxFS filesystem id for VxFs
FsMagicVxFS = FsMagic(0xa501fcf5)
// FsMagicXfs filesystem id for Xfs
FsMagicXfs = FsMagic(0x58465342)
// FsMagicZfs filesystem id for Zfs
FsMagicZfs = FsMagic(0x2fc12fc1)
)
var (
@ -37,6 +53,7 @@ var (
"vfs",
}
// FsNames maps filesystem id to name of the filesystem.
FsNames = map[FsMagic]string{
FsMagicAufs: "aufs",
FsMagicBtrfs: "btrfs",
@ -46,7 +63,7 @@ var (
FsMagicJffs2Fs: "jffs2",
FsMagicJfs: "jfs",
FsMagicNfsFs: "nfs",
FsMagicRamFs: "ramfs",
FsMagicRAMFs: "ramfs",
FsMagicReiserFs: "reiserfs",
FsMagicSmbFs: "smb",
FsMagicSquashFs: "squashfs",
@ -58,6 +75,7 @@ var (
}
)
// GetFSMagic returns the filesystem id given the path.
func GetFSMagic(rootpath string) (FsMagic, error) {
var buf syscall.Statfs_t
if err := syscall.Statfs(filepath.Dir(rootpath), &buf); err != nil {

View file

@ -9,6 +9,7 @@ var (
}
)
// GetFSMagic returns the filesystem id given the path.
func GetFSMagic(rootpath string) (FsMagic, error) {
return FsMagicUnsupported, nil
}

View file

@ -9,6 +9,7 @@ var (
}
)
// GetFSMagic returns the filesystem id given the path.
func GetFSMagic(rootpath string) (FsMagic, error) {
// Note it is OK to return FsMagicUnsupported on Windows.
return FsMagicUnsupported, nil

View file

@ -25,6 +25,7 @@ packages=(
daemon/execdriver/native
daemon/execdriver/native/template
daemon/execdriver/windows
daemon/graphdriver
daemon/graphdriver/aufs
daemon/graphdriver/devmapper
daemon/graphdriver/overlay