github.com/hanwen/go-fuse@v1.0.0/fuse/nodefs/fuse.go (about)

     1  // Copyright 2016 the Go-FUSE Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package nodefs
     6  
     7  import (
     8  	"github.com/hanwen/go-fuse/fuse"
     9  )
    10  
    11  // MountRoot mounts a filesystem with the given root node on the given directory.
    12  // Convenience wrapper around fuse.NewServer
    13  func MountRoot(mountpoint string, root Node, opts *Options) (*fuse.Server, *FileSystemConnector, error) {
    14  	conn := NewFileSystemConnector(root, opts)
    15  
    16  	mountOpts := fuse.MountOptions{}
    17  	if opts != nil && opts.Debug {
    18  		mountOpts.Debug = opts.Debug
    19  	}
    20  	s, err := fuse.NewServer(conn.RawFS(), mountpoint, &mountOpts)
    21  	if err != nil {
    22  		return nil, nil, err
    23  	}
    24  	return s, conn, nil
    25  }