Merge pull request #14928 from brahmaroutu/lint_daemon_graphdriver

daemon/graphdriver fix lint errors/warnings
This commit is contained in:
Doug Davis 2015-08-20 03:25:00 -07:00
Родитель 8acd006fd9 9e1a41aae5
Коммит 90ebc3b455
5 изменённых файлов: 49 добавлений и 18 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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