mirror of
https://github.com/octoleo/restic.git
synced 2024-11-04 12:34:13 +00:00
b63399d606
This moves all restic source files to src/, and all vendored dependencies to vendor/src.
42 lines
851 B
Go
42 lines
851 B
Go
package fuse
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
func mount(dir string, conf *mountConfig, ready chan<- struct{}, errp *error) (*os.File, error) {
|
|
for k, v := range conf.options {
|
|
if strings.Contains(k, ",") || strings.Contains(v, ",") {
|
|
// Silly limitation but the mount helper does not
|
|
// understand any escaping. See TestMountOptionCommaError.
|
|
return nil, fmt.Errorf("mount options cannot contain commas on FreeBSD: %q=%q", k, v)
|
|
}
|
|
}
|
|
|
|
f, err := os.OpenFile("/dev/fuse", os.O_RDWR, 0000)
|
|
if err != nil {
|
|
*errp = err
|
|
return nil, err
|
|
}
|
|
|
|
cmd := exec.Command(
|
|
"/sbin/mount_fusefs",
|
|
"--safe",
|
|
"-o", conf.getOptions(),
|
|
"3",
|
|
dir,
|
|
)
|
|
cmd.ExtraFiles = []*os.File{f}
|
|
|
|
out, err := cmd.CombinedOutput()
|
|
if err != nil {
|
|
return nil, fmt.Errorf("mount_fusefs: %q, %v", out, err)
|
|
}
|
|
|
|
close(ready)
|
|
return f, nil
|
|
}
|