瀏覽代碼

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

Srini Brahmaroutu 10 年之前
父節點
當前提交
17c19f395f
共有 3 個文件被更改,包括 25 次插入10 次删除
  1. 21 6
      daemon/graphdriver/btrfs/btrfs.go
  2. 2 2
      daemon/graphdriver/btrfs/version.go
  3. 2 2
      daemon/graphdriver/btrfs/version_none.go

+ 21 - 6
daemon/graphdriver/btrfs/btrfs.go

@@ -24,6 +24,8 @@ func init() {
 	graphdriver.Register("btrfs", Init)
 	graphdriver.Register("btrfs", Init)
 }
 }
 
 
+// Init returns a new BTRFS driver.
+// An error is returned if BTRFS is not supported.
 func Init(home string, options []string) (graphdriver.Driver, error) {
 func Init(home string, options []string) (graphdriver.Driver, error) {
 	rootdir := path.Dir(home)
 	rootdir := path.Dir(home)
 
 
@@ -51,29 +53,37 @@ func Init(home string, options []string) (graphdriver.Driver, error) {
 	return graphdriver.NaiveDiffDriver(driver), nil
 	return graphdriver.NaiveDiffDriver(driver), nil
 }
 }
 
 
+// Driver contains information about the filesystem mounted.
 type Driver struct {
 type Driver struct {
+	//root of the file system
 	home string
 	home string
 }
 }
 
 
+// String prints the name of the driver (btrfs).
 func (d *Driver) String() string {
 func (d *Driver) String() string {
 	return "btrfs"
 	return "btrfs"
 }
 }
 
 
+// Status returns current driver information in a two dimensional string array.
+// Output contains "Build Version" and "Library Version" of the btrfs libraries used.
+// Version information can be used to check compatibility with your kernel.
 func (d *Driver) Status() [][2]string {
 func (d *Driver) Status() [][2]string {
 	status := [][2]string{}
 	status := [][2]string{}
-	if bv := BtrfsBuildVersion(); bv != "-" {
+	if bv := btrfsBuildVersion(); bv != "-" {
 		status = append(status, [2]string{"Build Version", bv})
 		status = append(status, [2]string{"Build Version", bv})
 	}
 	}
-	if lv := BtrfsLibVersion(); lv != -1 {
+	if lv := btrfsLibVersion(); lv != -1 {
 		status = append(status, [2]string{"Library Version", fmt.Sprintf("%d", lv)})
 		status = append(status, [2]string{"Library Version", fmt.Sprintf("%d", lv)})
 	}
 	}
 	return status
 	return status
 }
 }
 
 
+// GetMetadata returns empty metadata for this driver.
 func (d *Driver) GetMetadata(id string) (map[string]string, error) {
 func (d *Driver) GetMetadata(id string) (map[string]string, error) {
 	return nil, nil
 	return nil, nil
 }
 }
 
 
+// Cleanup unmounts the home directory.
 func (d *Driver) Cleanup() error {
 func (d *Driver) Cleanup() error {
 	return mount.Unmount(d.home)
 	return mount.Unmount(d.home)
 }
 }
@@ -174,10 +184,11 @@ func (d *Driver) subvolumesDir() string {
 	return path.Join(d.home, "subvolumes")
 	return path.Join(d.home, "subvolumes")
 }
 }
 
 
-func (d *Driver) subvolumesDirId(id string) string {
+func (d *Driver) subvolumesDirID(id string) string {
 	return path.Join(d.subvolumesDir(), id)
 	return path.Join(d.subvolumesDir(), id)
 }
 }
 
 
+// Create the filesystem with given id.
 func (d *Driver) Create(id string, parent string) error {
 func (d *Driver) Create(id string, parent string) error {
 	subvolumes := path.Join(d.home, "subvolumes")
 	subvolumes := path.Join(d.home, "subvolumes")
 	if err := os.MkdirAll(subvolumes, 0700); err != nil {
 	if err := os.MkdirAll(subvolumes, 0700); err != nil {
@@ -199,8 +210,9 @@ func (d *Driver) Create(id string, parent string) error {
 	return nil
 	return nil
 }
 }
 
 
+// Remove the filesystem with given id.
 func (d *Driver) Remove(id string) error {
 func (d *Driver) Remove(id string) error {
-	dir := d.subvolumesDirId(id)
+	dir := d.subvolumesDirID(id)
 	if _, err := os.Stat(dir); err != nil {
 	if _, err := os.Stat(dir); err != nil {
 		return err
 		return err
 	}
 	}
@@ -210,8 +222,9 @@ func (d *Driver) Remove(id string) error {
 	return os.RemoveAll(dir)
 	return os.RemoveAll(dir)
 }
 }
 
 
+// Get the requested filesystem id.
 func (d *Driver) Get(id, mountLabel string) (string, error) {
 func (d *Driver) Get(id, mountLabel string) (string, error) {
-	dir := d.subvolumesDirId(id)
+	dir := d.subvolumesDirID(id)
 	st, err := os.Stat(dir)
 	st, err := os.Stat(dir)
 	if err != nil {
 	if err != nil {
 		return "", err
 		return "", err
@@ -224,14 +237,16 @@ func (d *Driver) Get(id, mountLabel string) (string, error) {
 	return dir, nil
 	return dir, nil
 }
 }
 
 
+// Put is not implemented for BTRFS as there is no cleanup required for the id.
 func (d *Driver) Put(id string) error {
 func (d *Driver) Put(id string) error {
 	// Get() creates no runtime resources (like e.g. mounts)
 	// Get() creates no runtime resources (like e.g. mounts)
 	// so this doesn't need to do anything.
 	// so this doesn't need to do anything.
 	return nil
 	return nil
 }
 }
 
 
+// Exists checks if the id exists in the filesystem.
 func (d *Driver) Exists(id string) bool {
 func (d *Driver) Exists(id string) bool {
-	dir := d.subvolumesDirId(id)
+	dir := d.subvolumesDirID(id)
 	_, err := os.Stat(dir)
 	_, err := os.Stat(dir)
 	return err == nil
 	return err == nil
 }
 }

+ 2 - 2
daemon/graphdriver/btrfs/version.go

@@ -17,10 +17,10 @@ package btrfs
 */
 */
 import "C"
 import "C"
 
 
-func BtrfsBuildVersion() string {
+func btrfsBuildVersion() string {
 	return string(C.BTRFS_BUILD_VERSION)
 	return string(C.BTRFS_BUILD_VERSION)
 }
 }
 
 
-func BtrfsLibVersion() int {
+func btrfsLibVersion() int {
 	return int(C.BTRFS_LIB_VERSION)
 	return int(C.BTRFS_LIB_VERSION)
 }
 }

+ 2 - 2
daemon/graphdriver/btrfs/version_none.go

@@ -5,10 +5,10 @@ package btrfs
 // TODO(vbatts) remove this work-around once supported linux distros are on
 // TODO(vbatts) remove this work-around once supported linux distros are on
 // btrfs utililties of >= 3.16.1
 // btrfs utililties of >= 3.16.1
 
 
-func BtrfsBuildVersion() string {
+func btrfsBuildVersion() string {
 	return "-"
 	return "-"
 }
 }
 
 
-func BtrfsLibVersion() int {
+func btrfsLibVersion() int {
 	return -1
 	return -1
 }
 }