Make mount.Mounted() capable of handling files
The function `fileutils.ReadSymlinkedDirectory` makes `mount.Mounted()` fail if the mount is a file. We now only check that if the mount is a directory to allow handling files in `mount.Mounted()`. Signed-off-by: Sascha Grunert <sgrunert@suse.com>
This commit is contained in:
parent
19256fe26b
commit
90513cbb96
|
|
@ -1,6 +1,7 @@
|
||||||
package mount
|
package mount
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -56,10 +57,17 @@ func Mounted(mountpoint string) (bool, error) {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
mountpoint, err = fileutils.ReadSymlinkedDirectory(mountpoint)
|
info, err := os.Stat(mountpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
if info.IsDir() {
|
||||||
|
mountpoint, err = fileutils.ReadSymlinkedDirectory(mountpoint)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Search the table for the mountpoint
|
// Search the table for the mountpoint
|
||||||
for _, e := range entries {
|
for _, e := range entries {
|
||||||
if e.Mountpoint == mountpoint {
|
if e.Mountpoint == mountpoint {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue