mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
graphdriver/zfs: privatize mountPath and zfsPath
These functions are not part of the graphdriver.Driver
interface and should therefore be private.
Also, remove comments added by commit e27c904
as they are
* pretty obvious
* no longer required by golint
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
This commit is contained in:
parent
f5e2c6f14b
commit
f5f7fee2ec
1 changed files with 10 additions and 12 deletions
|
@ -227,13 +227,11 @@ func (d *Driver) cloneFilesystem(name, parentName string) error {
|
||||||
return snapshot.Destroy(zfs.DestroyDeferDeletion)
|
return snapshot.Destroy(zfs.DestroyDeferDeletion)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ZfsPath returns the filesystem path for the id provided.
|
func (d *Driver) zfsPath(id string) string {
|
||||||
func (d *Driver) ZfsPath(id string) string {
|
|
||||||
return d.options.fsName + "/" + id
|
return d.options.fsName + "/" + id
|
||||||
}
|
}
|
||||||
|
|
||||||
// MountPath returns the mounted filesystem path for the id provided.
|
func (d *Driver) mountPath(id string) string {
|
||||||
func (d *Driver) MountPath(id string) string {
|
|
||||||
return path.Join(d.options.mountPath, "graph", getMountpoint(id))
|
return path.Join(d.options.mountPath, "graph", getMountpoint(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +250,7 @@ func (d *Driver) Create(id string, parent string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
dataset := zfs.Dataset{Name: d.ZfsPath(id)}
|
dataset := zfs.Dataset{Name: d.zfsPath(id)}
|
||||||
if err := dataset.Destroy(zfs.DestroyRecursiveClones); err != nil {
|
if err := dataset.Destroy(zfs.DestroyRecursiveClones); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -262,7 +260,7 @@ func (d *Driver) Create(id string, parent string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) create(id, parent string) error {
|
func (d *Driver) create(id, parent string) error {
|
||||||
name := d.ZfsPath(id)
|
name := d.zfsPath(id)
|
||||||
if parent == "" {
|
if parent == "" {
|
||||||
mountoptions := map[string]string{"mountpoint": "legacy"}
|
mountoptions := map[string]string{"mountpoint": "legacy"}
|
||||||
fs, err := zfs.CreateFilesystem(name, mountoptions)
|
fs, err := zfs.CreateFilesystem(name, mountoptions)
|
||||||
|
@ -273,12 +271,12 @@ func (d *Driver) create(id, parent string) error {
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return d.cloneFilesystem(name, d.ZfsPath(parent))
|
return d.cloneFilesystem(name, d.zfsPath(parent))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove deletes the dataset, filesystem and the cache for the given id.
|
// Remove deletes the dataset, filesystem and the cache for the given id.
|
||||||
func (d *Driver) Remove(id string) error {
|
func (d *Driver) Remove(id string) error {
|
||||||
name := d.ZfsPath(id)
|
name := d.zfsPath(id)
|
||||||
dataset := zfs.Dataset{Name: name}
|
dataset := zfs.Dataset{Name: name}
|
||||||
err := dataset.Destroy(zfs.DestroyRecursive)
|
err := dataset.Destroy(zfs.DestroyRecursive)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -291,8 +289,8 @@ func (d *Driver) Remove(id string) error {
|
||||||
|
|
||||||
// Get returns the mountpoint for the given id after creating the target directories if necessary.
|
// Get returns the mountpoint for the given id after creating the target directories if necessary.
|
||||||
func (d *Driver) Get(id, mountLabel string) (string, error) {
|
func (d *Driver) Get(id, mountLabel string) (string, error) {
|
||||||
mountpoint := d.MountPath(id)
|
mountpoint := d.mountPath(id)
|
||||||
filesystem := d.ZfsPath(id)
|
filesystem := d.zfsPath(id)
|
||||||
options := label.FormatMountLabel("", mountLabel)
|
options := label.FormatMountLabel("", mountLabel)
|
||||||
logrus.Debugf(`[zfs] mount("%s", "%s", "%s")`, filesystem, mountpoint, options)
|
logrus.Debugf(`[zfs] mount("%s", "%s", "%s")`, filesystem, mountpoint, options)
|
||||||
|
|
||||||
|
@ -311,7 +309,7 @@ func (d *Driver) Get(id, mountLabel string) (string, error) {
|
||||||
|
|
||||||
// Put removes the existing mountpoint for the given id if it exists.
|
// Put removes the existing mountpoint for the given id if it exists.
|
||||||
func (d *Driver) Put(id string) error {
|
func (d *Driver) Put(id string) error {
|
||||||
mountpoint := d.MountPath(id)
|
mountpoint := d.mountPath(id)
|
||||||
logrus.Debugf(`[zfs] unmount("%s")`, mountpoint)
|
logrus.Debugf(`[zfs] unmount("%s")`, mountpoint)
|
||||||
|
|
||||||
if err := mount.Unmount(mountpoint); err != nil {
|
if err := mount.Unmount(mountpoint); err != nil {
|
||||||
|
@ -322,5 +320,5 @@ func (d *Driver) Put(id string) error {
|
||||||
|
|
||||||
// Exists checks to see if the cache entry exists for the given id.
|
// Exists checks to see if the cache entry exists for the given id.
|
||||||
func (d *Driver) Exists(id string) bool {
|
func (d *Driver) Exists(id string) bool {
|
||||||
return d.filesystemsCache[d.ZfsPath(id)] == true
|
return d.filesystemsCache[d.zfsPath(id)] == true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue