2021-09-09 20:25:25 +08:00
|
|
|
//go:build cmount && cgo && !windows
|
|
|
|
// +build cmount,cgo,!windows
|
2020-11-06 21:21:38 +08:00
|
|
|
|
|
|
|
package cmount
|
|
|
|
|
|
|
|
import (
|
2021-11-04 18:12:57 +08:00
|
|
|
"errors"
|
|
|
|
"fmt"
|
2020-11-06 21:21:38 +08:00
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/rclone/rclone/cmd/mountlib"
|
2022-06-11 22:18:48 +08:00
|
|
|
"github.com/rclone/rclone/fs"
|
2020-11-06 21:21:38 +08:00
|
|
|
)
|
|
|
|
|
2022-06-11 22:18:48 +08:00
|
|
|
func getMountpoint(f fs.Fs, mountPath string, opt *mountlib.Options) (string, error) {
|
2020-11-06 21:21:38 +08:00
|
|
|
fi, err := os.Stat(mountPath)
|
|
|
|
if err != nil {
|
2021-11-04 18:12:57 +08:00
|
|
|
return "", fmt.Errorf("failed to retrieve mount path information: %w", err)
|
2020-11-06 21:21:38 +08:00
|
|
|
}
|
|
|
|
if !fi.IsDir() {
|
|
|
|
return "", errors.New("mount path is not a directory")
|
|
|
|
}
|
2022-06-11 22:18:48 +08:00
|
|
|
if err = mountlib.CheckOverlap(f, mountPath); err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
if err = mountlib.CheckAllowNonEmpty(mountPath, opt); err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
2020-11-06 21:21:38 +08:00
|
|
|
return mountPath, nil
|
|
|
|
}
|