Browse code

daemon/graphdriver/btrfs fix lint errors/warnings Addresses #14756 Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>

Srini Brahmaroutu authored on 2015/07/23 05:51:35
Showing 3 changed files
... ...
@@ -24,6 +24,8 @@ func init() {
24 24
 	graphdriver.Register("btrfs", Init)
25 25
 }
26 26
 
27
+// Init returns a new BTRFS driver.
28
+// An error is returned if BTRFS is not supported.
27 29
 func Init(home string, options []string) (graphdriver.Driver, error) {
28 30
 	rootdir := path.Dir(home)
29 31
 
... ...
@@ -51,29 +53,37 @@ func Init(home string, options []string) (graphdriver.Driver, error) {
51 51
 	return graphdriver.NaiveDiffDriver(driver), nil
52 52
 }
53 53
 
54
+// Driver contains information about the filesystem mounted.
54 55
 type Driver struct {
56
+	//root of the file system
55 57
 	home string
56 58
 }
57 59
 
60
+// String prints the name of the driver (btrfs).
58 61
 func (d *Driver) String() string {
59 62
 	return "btrfs"
60 63
 }
61 64
 
65
+// Status returns current driver information in a two dimensional string array.
66
+// Output contains "Build Version" and "Library Version" of the btrfs libraries used.
67
+// Version information can be used to check compatibility with your kernel.
62 68
 func (d *Driver) Status() [][2]string {
63 69
 	status := [][2]string{}
64
-	if bv := BtrfsBuildVersion(); bv != "-" {
70
+	if bv := btrfsBuildVersion(); bv != "-" {
65 71
 		status = append(status, [2]string{"Build Version", bv})
66 72
 	}
67
-	if lv := BtrfsLibVersion(); lv != -1 {
73
+	if lv := btrfsLibVersion(); lv != -1 {
68 74
 		status = append(status, [2]string{"Library Version", fmt.Sprintf("%d", lv)})
69 75
 	}
70 76
 	return status
71 77
 }
72 78
 
79
+// GetMetadata returns empty metadata for this driver.
73 80
 func (d *Driver) GetMetadata(id string) (map[string]string, error) {
74 81
 	return nil, nil
75 82
 }
76 83
 
84
+// Cleanup unmounts the home directory.
77 85
 func (d *Driver) Cleanup() error {
78 86
 	return mount.Unmount(d.home)
79 87
 }
... ...
@@ -174,10 +184,11 @@ func (d *Driver) subvolumesDir() string {
174 174
 	return path.Join(d.home, "subvolumes")
175 175
 }
176 176
 
177
-func (d *Driver) subvolumesDirId(id string) string {
177
+func (d *Driver) subvolumesDirID(id string) string {
178 178
 	return path.Join(d.subvolumesDir(), id)
179 179
 }
180 180
 
181
+// Create the filesystem with given id.
181 182
 func (d *Driver) Create(id string, parent string) error {
182 183
 	subvolumes := path.Join(d.home, "subvolumes")
183 184
 	if err := os.MkdirAll(subvolumes, 0700); err != nil {
... ...
@@ -199,8 +210,9 @@ func (d *Driver) Create(id string, parent string) error {
199 199
 	return nil
200 200
 }
201 201
 
202
+// Remove the filesystem with given id.
202 203
 func (d *Driver) Remove(id string) error {
203
-	dir := d.subvolumesDirId(id)
204
+	dir := d.subvolumesDirID(id)
204 205
 	if _, err := os.Stat(dir); err != nil {
205 206
 		return err
206 207
 	}
... ...
@@ -210,8 +222,9 @@ func (d *Driver) Remove(id string) error {
210 210
 	return os.RemoveAll(dir)
211 211
 }
212 212
 
213
+// Get the requested filesystem id.
213 214
 func (d *Driver) Get(id, mountLabel string) (string, error) {
214
-	dir := d.subvolumesDirId(id)
215
+	dir := d.subvolumesDirID(id)
215 216
 	st, err := os.Stat(dir)
216 217
 	if err != nil {
217 218
 		return "", err
... ...
@@ -224,14 +237,16 @@ func (d *Driver) Get(id, mountLabel string) (string, error) {
224 224
 	return dir, nil
225 225
 }
226 226
 
227
+// Put is not implemented for BTRFS as there is no cleanup required for the id.
227 228
 func (d *Driver) Put(id string) error {
228 229
 	// Get() creates no runtime resources (like e.g. mounts)
229 230
 	// so this doesn't need to do anything.
230 231
 	return nil
231 232
 }
232 233
 
234
+// Exists checks if the id exists in the filesystem.
233 235
 func (d *Driver) Exists(id string) bool {
234
-	dir := d.subvolumesDirId(id)
236
+	dir := d.subvolumesDirID(id)
235 237
 	_, err := os.Stat(dir)
236 238
 	return err == nil
237 239
 }
... ...
@@ -17,10 +17,10 @@ package btrfs
17 17
 */
18 18
 import "C"
19 19
 
20
-func BtrfsBuildVersion() string {
20
+func btrfsBuildVersion() string {
21 21
 	return string(C.BTRFS_BUILD_VERSION)
22 22
 }
23 23
 
24
-func BtrfsLibVersion() int {
24
+func btrfsLibVersion() int {
25 25
 	return int(C.BTRFS_LIB_VERSION)
26 26
 }
... ...
@@ -5,10 +5,10 @@ package btrfs
5 5
 // TODO(vbatts) remove this work-around once supported linux distros are on
6 6
 // btrfs utililties of >= 3.16.1
7 7
 
8
-func BtrfsBuildVersion() string {
8
+func btrfsBuildVersion() string {
9 9
 	return "-"
10 10
 }
11 11
 
12
-func BtrfsLibVersion() int {
12
+func btrfsLibVersion() int {
13 13
 	return -1
14 14
 }