github.com/keltia/go-ipfs@v0.3.8-0.20150909044612-210793031c63/fuse/ipns/mount_unix.go (about)

     1  // +build linux darwin freebsd
     2  // +build !nofuse
     3  
     4  package ipns
     5  
     6  import (
     7  	core "github.com/ipfs/go-ipfs/core"
     8  	mount "github.com/ipfs/go-ipfs/fuse/mount"
     9  	ipnsfs "github.com/ipfs/go-ipfs/ipnsfs"
    10  )
    11  
    12  // Mount mounts ipns at a given location, and returns a mount.Mount instance.
    13  func Mount(ipfs *core.IpfsNode, ipnsmp, ipfsmp string) (mount.Mount, error) {
    14  	cfg, err := ipfs.Repo.Config()
    15  	if err != nil {
    16  		return nil, err
    17  	}
    18  
    19  	allow_other := cfg.Mounts.FuseAllowOther
    20  
    21  	if ipfs.IpnsFs == nil {
    22  		fs, err := ipnsfs.NewFilesystem(ipfs.Context(), ipfs.DAG, ipfs.Namesys, ipfs.Pinning, ipfs.PrivateKey)
    23  		if err != nil {
    24  			return nil, err
    25  		}
    26  		ipfs.IpnsFs = fs
    27  	}
    28  
    29  	fsys, err := NewFileSystem(ipfs, ipfs.PrivateKey, ipfsmp, ipnsmp)
    30  	if err != nil {
    31  		return nil, err
    32  	}
    33  
    34  	return mount.NewMount(ipfs.Process(), fsys, ipnsmp, allow_other)
    35  }