devicemapper: Unmount when removing device
Without this the remove will fail due to a busy device.
This commit is contained in:
parent
e42b574579
commit
0ed762f2d2
|
@ -61,6 +61,10 @@ func (d *Driver) Create(id string, parent string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Remove(id string) error {
|
func (d *Driver) Remove(id string) error {
|
||||||
|
mp := path.Join(d.home, "mnt", id)
|
||||||
|
if err := d.unmount(id, mp); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return d.DeviceSet.RemoveDevice(id)
|
return d.DeviceSet.RemoveDevice(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,3 +94,14 @@ func (d *Driver) mount(id, mountPoint string) error {
|
||||||
// Mount the device
|
// Mount the device
|
||||||
return d.DeviceSet.MountDevice(id, mountPoint, false)
|
return d.DeviceSet.MountDevice(id, mountPoint, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Driver) unmount(id, mountPoint string) error {
|
||||||
|
// If mountpoint is not mounted, do nothing
|
||||||
|
if mounted, err := Mounted(mountPoint); err != nil {
|
||||||
|
return fmt.Errorf("Error checking mountpoint: %s", err)
|
||||||
|
} else if !mounted {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// Unmount the device
|
||||||
|
return d.DeviceSet.UnmountDevice(id, mountPoint, true)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue