File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // +build go1.13
2+
13package mount
24
35import (
6+ "fmt"
47 "sort"
58 "strconv"
6-
7- "github.com/sirupsen/logrus"
89)
910
1011// mountError records an error from mount or unmount operation
@@ -95,18 +96,21 @@ func RecursiveUnmount(target string) error {
9596 return len (mounts [i ].Mountpoint ) > len (mounts [j ].Mountpoint )
9697 })
9798
99+ var suberr error
98100 for i , m := range mounts {
99- logrus .Debugf ("Trying to unmount %s" , m .Mountpoint )
100101 err = unmount (m .Mountpoint , mntDetach )
101102 if err != nil {
102103 if i == len (mounts )- 1 { // last mount
103- return err
104+ return fmt .Errorf ("%w (possible cause: %s)" , err , suberr )
105+ }
106+ // This is a submount, we can ignore the error for now,
107+ // the final unmount will fail if this is a real problem.
108+ // With that in mind, the _first_ failed unmount error
109+ // might be the real error cause, so let's keep it.
110+ if suberr == nil {
111+ suberr = err
104112 }
105- // This is some submount, we can ignore this error for now, the final unmount will fail if this is a real problem
106- logrus .WithError (err ).Warnf ("Failed to unmount submount %s" , m .Mountpoint )
107113 }
108-
109- logrus .Debugf ("Unmounted %s" , m .Mountpoint )
110114 }
111115 return nil
112116}
You can’t perform that action at this time.
0 commit comments