File: mount_freebsd.go

package info (click to toggle)
golang-github-jacobsa-bazilfuse 0.0~git20150622-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 736 kB
  • sloc: sh: 26; makefile: 4
file content (41 lines) | stat: -rw-r--r-- 856 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package bazilfuse

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
}