Without this the remove will fail due to a busy device.
| ... | ... |
@@ -61,6 +61,10 @@ func (d *Driver) Create(id string, parent string) error {
|
| 61 | 61 |
} |
| 62 | 62 |
|
| 63 | 63 |
func (d *Driver) Remove(id string) error {
|
| 64 |
+ mp := path.Join(d.home, "mnt", id) |
|
| 65 |
+ if err := d.unmount(id, mp); err != nil {
|
|
| 66 |
+ return err |
|
| 67 |
+ } |
|
| 64 | 68 |
return d.DeviceSet.RemoveDevice(id) |
| 65 | 69 |
} |
| 66 | 70 |
|
| ... | ... |
@@ -90,3 +94,14 @@ func (d *Driver) mount(id, mountPoint string) error {
|
| 90 | 90 |
// Mount the device |
| 91 | 91 |
return d.DeviceSet.MountDevice(id, mountPoint, false) |
| 92 | 92 |
} |
| 93 |
+ |
|
| 94 |
+func (d *Driver) unmount(id, mountPoint string) error {
|
|
| 95 |
+ // If mountpoint is not mounted, do nothing |
|
| 96 |
+ if mounted, err := Mounted(mountPoint); err != nil {
|
|
| 97 |
+ return fmt.Errorf("Error checking mountpoint: %s", err)
|
|
| 98 |
+ } else if !mounted {
|
|
| 99 |
+ return nil |
|
| 100 |
+ } |
|
| 101 |
+ // Unmount the device |
|
| 102 |
+ return d.DeviceSet.UnmountDevice(id, mountPoint, true) |
|
| 103 |
+} |