Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Unexport MountConfig, it's an implementation detail of MountOption
Browse files Browse the repository at this point in the history
  • Loading branch information
tv42 committed Jun 20, 2015
1 parent 68fc4be commit bfad7b7
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 25 deletions.
4 changes: 2 additions & 2 deletions fuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ type Conn struct {
// possible errors. Incoming requests on Conn must be served to make
// progress.
func Mount(dir string, options ...MountOption) (*Conn, error) {
conf := MountConfig{
conf := mountConfig{
options: make(map[string]string),
}
for _, option := range options {
Expand Down Expand Up @@ -179,7 +179,7 @@ func (e *OldVersionError) Error() string {
return fmt.Sprintf("kernel FUSE version is too old: %v < %v", e.Kernel, e.LibraryMin)
}

func initMount(c *Conn, conf *MountConfig) error {
func initMount(c *Conn, conf *mountConfig) error {
req, err := c.ReadRequest()
if err != nil {
if err == io.EOF {
Expand Down
4 changes: 2 additions & 2 deletions mount_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func openOSXFUSEDev() (*os.File, error) {
}
}

func callMount(dir string, conf *MountConfig, f *os.File, ready chan<- struct{}, errp *error) error {
func callMount(dir string, conf *mountConfig, f *os.File, ready chan<- struct{}, errp *error) error {
bin := "/Library/Filesystems/osxfusefs.fs/Support/mount_osxfusefs"

for k, v := range conf.options {
Expand Down Expand Up @@ -104,7 +104,7 @@ func callMount(dir string, conf *MountConfig, f *os.File, ready chan<- struct{},
return err
}

func mount(dir string, conf *MountConfig, ready chan<- struct{}, errp *error) (*os.File, error) {
func mount(dir string, conf *mountConfig, ready chan<- struct{}, errp *error) (*os.File, error) {
f, err := openOSXFUSEDev()
if err == errNotLoaded {
err = loadOSXFUSE()
Expand Down
2 changes: 1 addition & 1 deletion mount_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
)

func mount(dir string, conf *MountConfig, ready chan<- struct{}, errp *error) (*os.File, error) {
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
Expand Down
2 changes: 1 addition & 1 deletion mount_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func lineLogger(wg *sync.WaitGroup, prefix string, r io.ReadCloser) {
}
}

func mount(dir string, conf *MountConfig, ready chan<- struct{}, errp *error) (fusefd *os.File, err error) {
func mount(dir string, conf *mountConfig, ready chan<- struct{}, errp *error) (fusefd *os.File, err error) {
// linux mount is never delayed
close(ready)

Expand Down
28 changes: 15 additions & 13 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"strings"
)

func dummyOption(conf *MountConfig) error {
func dummyOption(conf *mountConfig) error {
return nil
}

// MountConfig holds the configuration for a mount operation.
// mountConfig holds the configuration for a mount operation.
// Use it by passing MountOption values to Mount.
type MountConfig struct {
type mountConfig struct {
options map[string]string
maxReadahead uint32
initFlags InitFlags
Expand All @@ -26,7 +26,7 @@ func escapeComma(s string) string {
// getOptions makes a string of options suitable for passing to FUSE
// mount flag `-o`. Returns an empty string if no options were set.
// Any platform specific adjustments should happen before the call.
func (m *MountConfig) getOptions() string {
func (m *mountConfig) getOptions() string {
var opts []string
for k, v := range m.options {
k = escapeComma(k)
Expand All @@ -38,15 +38,17 @@ func (m *MountConfig) getOptions() string {
return strings.Join(opts, ",")
}

type mountOption func(*mountConfig) error

// MountOption is passed to Mount to change the behavior of the mount.
type MountOption func(*MountConfig) error
type MountOption mountOption

// FSName sets the file system name (also called source) that is
// visible in the list of mounted file systems.
//
// FreeBSD ignores this option.
func FSName(name string) MountOption {
return func(conf *MountConfig) error {
return func(conf *mountConfig) error {
conf.options["fsname"] = name
return nil
}
Expand All @@ -59,7 +61,7 @@ func FSName(name string) MountOption {
// OS X ignores this option.
// FreeBSD ignores this option.
func Subtype(fstype string) MountOption {
return func(conf *MountConfig) error {
return func(conf *mountConfig) error {
conf.options["subtype"] = fstype
return nil
}
Expand All @@ -86,7 +88,7 @@ var ErrCannotCombineAllowOtherAndAllowRoot = errors.New("cannot combine AllowOth
//
// Only one of AllowOther or AllowRoot can be used.
func AllowOther() MountOption {
return func(conf *MountConfig) error {
return func(conf *mountConfig) error {
if _, ok := conf.options["allow_root"]; ok {
return ErrCannotCombineAllowOtherAndAllowRoot
}
Expand All @@ -101,7 +103,7 @@ func AllowOther() MountOption {
//
// FreeBSD ignores this option.
func AllowRoot() MountOption {
return func(conf *MountConfig) error {
return func(conf *mountConfig) error {
if _, ok := conf.options["allow_other"]; ok {
return ErrCannotCombineAllowOtherAndAllowRoot
}
Expand All @@ -119,15 +121,15 @@ func AllowRoot() MountOption {
//
// FreeBSD ignores this option.
func DefaultPermissions() MountOption {
return func(conf *MountConfig) error {
return func(conf *mountConfig) error {
conf.options["default_permissions"] = ""
return nil
}
}

// ReadOnly makes the mount read-only.
func ReadOnly() MountOption {
return func(conf *MountConfig) error {
return func(conf *mountConfig) error {
conf.options["ro"] = ""
return nil
}
Expand All @@ -141,7 +143,7 @@ func ReadOnly() MountOption {
// originate from any client process. This usually tremendously
// improves read performance.
func MaxReadahead(n uint32) MountOption {
return func(conf *MountConfig) error {
return func(conf *mountConfig) error {
conf.maxReadahead = n
return nil
}
Expand All @@ -151,7 +153,7 @@ func MaxReadahead(n uint32) MountOption {
// handle. Without this, there is at most one request in flight at a
// time.
func AsyncRead() MountOption {
return func(conf *MountConfig) error {
return func(conf *mountConfig) error {
conf.initFlags |= InitAsyncRead
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions options_darwin.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package fuse

func localVolume(conf *MountConfig) error {
func localVolume(conf *mountConfig) error {
conf.options["local"] = ""
return nil
}

func volumeName(name string) MountOption {
return func(conf *MountConfig) error {
return func(conf *mountConfig) error {
conf.options["volname"] = name
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion options_freebsd.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fuse

func localVolume(conf *MountConfig) error {
func localVolume(conf *mountConfig) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion options_helper_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fuse

// for TestMountOptionCommaError
func ForTestSetMountOption(conf *MountConfig, k, v string) {
func ForTestSetMountOption(conf *mountConfig, k, v string) {
conf.options[k] = v
}
2 changes: 1 addition & 1 deletion options_linux.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fuse

func localVolume(conf *MountConfig) error {
func localVolume(conf *mountConfig) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion options_nocomma_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestMountOptionCommaError(t *testing.T) {
// some string content
var evil = "FuseTest,Marker"
mnt, err := fstestutil.MountedT(t, fstestutil.SimpleFS{fstestutil.Dir{}},
func(conf *fuse.MountConfig) error {
func(conf *fuse.mountConfig) error {
fuse.ForTestSetMountOption(conf, "fusetest", evil)
return nil
},
Expand Down

0 comments on commit bfad7b7

Please sign in to comment.