mount: fix check for empty mount point on Linux #3562

This commit is contained in:
Nick Craig-Wood
2023-01-19 15:54:10 +00:00
parent 37db2abecd
commit 267a09001d
3 changed files with 34 additions and 24 deletions

View File

@@ -33,12 +33,20 @@ func CheckMountEmpty(mountpoint string) error {
if err != nil {
return fmt.Errorf("cannot read %s: %w", mtabPath, err)
}
foundAutofs := false
for _, entry := range entries {
if entry.Dir == mountpointAbs && entry.Type != "autofs" {
return fmt.Errorf(msg, mountpointAbs)
if entry.Dir == mountpointAbs {
if entry.Type != "autofs" {
return fmt.Errorf(msg, mountpointAbs)
}
foundAutofs = true
}
}
return nil
// It isn't safe to list an autofs in the middle of mounting
if foundAutofs {
return nil
}
return checkMountEmpty(mountpoint)
}
// CheckMountReady checks whether mountpoint is mounted by rclone.