Browse code

daemon/graphdriver fix lint errors/warnings Addresses #14756

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>

Srini Brahmaroutu authored on 2015/07/22 07:21:05
Showing 5 changed files
... ...
@@ -11,22 +11,29 @@ import (
11 11
 	"github.com/docker/docker/pkg/archive"
12 12
 )
13 13
 
14
+// FsMagic unsigned id of the filesystem in use.
14 15
 type FsMagic uint32
15 16
 
16 17
 const (
18
+	// FsMagicUnsupported is a predifined contant value other than a valid filesystem id.
17 19
 	FsMagicUnsupported = FsMagic(0x00000000)
18 20
 )
19 21
 
20 22
 var (
23
+	// DefaultDriver if a storage driver is not specified.
21 24
 	DefaultDriver string
22 25
 	// All registred drivers
23 26
 	drivers map[string]InitFunc
24 27
 
25
-	ErrNotSupported   = errors.New("driver not supported")
26
-	ErrPrerequisites  = errors.New("prerequisites for driver not satisfied (wrong filesystem?)")
28
+	// ErrNotSupported returned when driver is not supported.
29
+	ErrNotSupported = errors.New("driver not supported")
30
+	// ErrPrerequisites retuned when driver does not meet prerequisites.
31
+	ErrPrerequisites = errors.New("prerequisites for driver not satisfied (wrong filesystem?)")
32
+	// ErrIncompatibleFS returned when file system is not supported.
27 33
 	ErrIncompatibleFS = fmt.Errorf("backing file system is unsupported for this graph driver")
28 34
 )
29 35
 
36
+// InitFunc initializes the storage driver.
30 37
 type InitFunc func(root string, options []string) (Driver, error)
31 38
 
32 39
 // ProtoDriver defines the basic capabilities of a driver.
... ...
@@ -89,6 +96,7 @@ func init() {
89 89
 	drivers = make(map[string]InitFunc)
90 90
 }
91 91
 
92
+// Register registers a InitFunc for the driver.
92 93
 func Register(name string, initFunc InitFunc) error {
93 94
 	if _, exists := drivers[name]; exists {
94 95
 		return fmt.Errorf("Name already registered %s", name)
... ...
@@ -98,6 +106,7 @@ func Register(name string, initFunc InitFunc) error {
98 98
 	return nil
99 99
 }
100 100
 
101
+// GetDriver initializes and returns the registered driver
101 102
 func GetDriver(name, home string, options []string) (Driver, error) {
102 103
 	if initFunc, exists := drivers[name]; exists {
103 104
 		return initFunc(filepath.Join(home, name), options)
... ...
@@ -106,6 +115,7 @@ func GetDriver(name, home string, options []string) (Driver, error) {
106 106
 	return nil, ErrNotSupported
107 107
 }
108 108
 
109
+// New creates the driver and initializes it at the specified root.
109 110
 func New(root string, options []string) (driver Driver, err error) {
110 111
 	for _, name := range []string{os.Getenv("DOCKER_DRIVER"), DefaultDriver} {
111 112
 		if name != "" {
... ...
@@ -192,7 +202,7 @@ func checkPriorDriver(name, root string) error {
192 192
 
193 193
 	if len(priorDrivers) > 0 {
194 194
 
195
-		return errors.New(fmt.Sprintf("%q contains other graphdrivers: %s; Please cleanup or explicitly choose storage driver (-s <DRIVER>)", root, strings.Join(priorDrivers, ",")))
195
+		return fmt.Errorf("%q contains other graphdrivers: %s; Please cleanup or explicitly choose storage driver (-s <DRIVER>)", root, strings.Join(priorDrivers, ","))
196 196
 	}
197 197
 	return nil
198 198
 }
... ...
@@ -8,22 +8,38 @@ import (
8 8
 )
9 9
 
10 10
 const (
11
-	FsMagicAufs     = FsMagic(0x61756673)
12
-	FsMagicBtrfs    = FsMagic(0x9123683E)
13
-	FsMagicCramfs   = FsMagic(0x28cd3d45)
14
-	FsMagicExtfs    = FsMagic(0x0000EF53)
15
-	FsMagicF2fs     = FsMagic(0xF2F52010)
16
-	FsMagicJffs2Fs  = FsMagic(0x000072b6)
17
-	FsMagicJfs      = FsMagic(0x3153464a)
18
-	FsMagicNfsFs    = FsMagic(0x00006969)
19
-	FsMagicRamFs    = FsMagic(0x858458f6)
11
+	// FsMagicAufs filesystem id for Aufs
12
+	FsMagicAufs = FsMagic(0x61756673)
13
+	// FsMagicBtrfs filesystem id for Btrfs
14
+	FsMagicBtrfs = FsMagic(0x9123683E)
15
+	// FsMagicCramfs filesystem id for Cramfs
16
+	FsMagicCramfs = FsMagic(0x28cd3d45)
17
+	// FsMagicExtfs filesystem id for Extfs
18
+	FsMagicExtfs = FsMagic(0x0000EF53)
19
+	// FsMagicF2fs filesystem id for F2fs
20
+	FsMagicF2fs = FsMagic(0xF2F52010)
21
+	// FsMagicJffs2Fs filesystem if for Jffs2Fs
22
+	FsMagicJffs2Fs = FsMagic(0x000072b6)
23
+	// FsMagicJfs filesystem id for Jfs
24
+	FsMagicJfs = FsMagic(0x3153464a)
25
+	// FsMagicNfsFs filesystem id for NfsFs
26
+	FsMagicNfsFs = FsMagic(0x00006969)
27
+	// FsMagicRAMFs filesystem id for RamFs
28
+	FsMagicRAMFs = FsMagic(0x858458f6)
29
+	// FsMagicReiserFs filesystem id for ReiserFs
20 30
 	FsMagicReiserFs = FsMagic(0x52654973)
21
-	FsMagicSmbFs    = FsMagic(0x0000517B)
31
+	// FsMagicSmbFs filesystem id for SmbFs
32
+	FsMagicSmbFs = FsMagic(0x0000517B)
33
+	// FsMagicSquashFs filesystem id for SquashFs
22 34
 	FsMagicSquashFs = FsMagic(0x73717368)
23
-	FsMagicTmpFs    = FsMagic(0x01021994)
24
-	FsMagicVxFS     = FsMagic(0xa501fcf5)
25
-	FsMagicXfs      = FsMagic(0x58465342)
26
-	FsMagicZfs      = FsMagic(0x2fc12fc1)
35
+	// FsMagicTmpFs filesystem id for TmpFs
36
+	FsMagicTmpFs = FsMagic(0x01021994)
37
+	// FsMagicVxFS filesystem id for VxFs
38
+	FsMagicVxFS = FsMagic(0xa501fcf5)
39
+	// FsMagicXfs filesystem id for Xfs
40
+	FsMagicXfs = FsMagic(0x58465342)
41
+	// FsMagicZfs filesystem id for Zfs
42
+	FsMagicZfs = FsMagic(0x2fc12fc1)
27 43
 )
28 44
 
29 45
 var (
... ...
@@ -37,6 +53,7 @@ var (
37 37
 		"vfs",
38 38
 	}
39 39
 
40
+	// FsNames maps filesystem id to name of the filesystem.
40 41
 	FsNames = map[FsMagic]string{
41 42
 		FsMagicAufs:        "aufs",
42 43
 		FsMagicBtrfs:       "btrfs",
... ...
@@ -46,7 +63,7 @@ var (
46 46
 		FsMagicJffs2Fs:     "jffs2",
47 47
 		FsMagicJfs:         "jfs",
48 48
 		FsMagicNfsFs:       "nfs",
49
-		FsMagicRamFs:       "ramfs",
49
+		FsMagicRAMFs:       "ramfs",
50 50
 		FsMagicReiserFs:    "reiserfs",
51 51
 		FsMagicSmbFs:       "smb",
52 52
 		FsMagicSquashFs:    "squashfs",
... ...
@@ -58,6 +75,7 @@ var (
58 58
 	}
59 59
 )
60 60
 
61
+// GetFSMagic returns the filesystem id given the path.
61 62
 func GetFSMagic(rootpath string) (FsMagic, error) {
62 63
 	var buf syscall.Statfs_t
63 64
 	if err := syscall.Statfs(filepath.Dir(rootpath), &buf); err != nil {
... ...
@@ -9,6 +9,7 @@ var (
9 9
 	}
10 10
 )
11 11
 
12
+// GetFSMagic returns the filesystem id given the path.
12 13
 func GetFSMagic(rootpath string) (FsMagic, error) {
13 14
 	return FsMagicUnsupported, nil
14 15
 }
... ...
@@ -9,6 +9,7 @@ var (
9 9
 	}
10 10
 )
11 11
 
12
+// GetFSMagic returns the filesystem id given the path.
12 13
 func GetFSMagic(rootpath string) (FsMagic, error) {
13 14
 	// Note it is OK to return FsMagicUnsupported on Windows.
14 15
 	return FsMagicUnsupported, nil
... ...
@@ -25,6 +25,7 @@ packages=(
25 25
 	daemon/execdriver/native
26 26
 	daemon/execdriver/native/template
27 27
 	daemon/execdriver/windows
28
+	daemon/graphdriver
28 29
 	daemon/graphdriver/aufs
29 30
 	daemon/graphdriver/devmapper
30 31
 	daemon/graphdriver/overlay