This fixes issues where the underlying filesystem may be disconnected and
attempting to unmount may cause a hang.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| ... | ... |
@@ -1,9 +1,5 @@ |
| 1 | 1 |
package mount |
| 2 | 2 |
|
| 3 |
-import ( |
|
| 4 |
- "time" |
|
| 5 |
-) |
|
| 6 |
- |
|
| 7 | 3 |
// GetMounts retrieves a list of mounts for the current running process. |
| 8 | 4 |
func GetMounts() ([]*Info, error) {
|
| 9 | 5 |
return parseMountTable() |
| ... | ... |
@@ -49,23 +45,11 @@ func ForceMount(device, target, mType, options string) error {
|
| 49 | 49 |
return mount(device, target, mType, uintptr(flag), data) |
| 50 | 50 |
} |
| 51 | 51 |
|
| 52 |
-// Unmount will unmount the target filesystem, so long as it is mounted. |
|
| 52 |
+// Unmount lazily unmounts a filesystem on supported platforms, otherwise |
|
| 53 |
+// does a normal unmount. |
|
| 53 | 54 |
func Unmount(target string) error {
|
| 54 | 55 |
if mounted, err := Mounted(target); err != nil || !mounted {
|
| 55 | 56 |
return err |
| 56 | 57 |
} |
| 57 |
- return ForceUnmount(target) |
|
| 58 |
-} |
|
| 59 |
- |
|
| 60 |
-// ForceUnmount will force an unmount of the target filesystem, regardless if |
|
| 61 |
-// it is mounted or not. |
|
| 62 |
-func ForceUnmount(target string) (err error) {
|
|
| 63 |
- // Simple retry logic for unmount |
|
| 64 |
- for i := 0; i < 10; i++ {
|
|
| 65 |
- if err = unmount(target, 0); err == nil {
|
|
| 66 |
- return nil |
|
| 67 |
- } |
|
| 68 |
- time.Sleep(100 * time.Millisecond) |
|
| 69 |
- } |
|
| 70 |
- return |
|
| 58 |
+ return unmount(target, mntDetach) |
|
| 71 | 59 |
} |