mount_unix.go 792 Bytes
Newer Older
Tonis Tiigi's avatar
Tonis Tiigi committed
1 2
// +build linux darwin freebsd
// +build !nofuse
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
3

Jeromy's avatar
Jeromy committed
4 5 6
package ipns

import (
7 8
	core "github.com/ipfs/go-ipfs/core"
	mount "github.com/ipfs/go-ipfs/fuse/mount"
9
	ipnsfs "github.com/ipfs/go-ipfs/ipnsfs"
Jeromy's avatar
Jeromy committed
10 11
)

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
12 13
// Mount mounts ipns at a given location, and returns a mount.Mount instance.
func Mount(ipfs *core.IpfsNode, ipnsmp, ipfsmp string) (mount.Mount, error) {
Ho-Sheng Hsiao's avatar
Ho-Sheng Hsiao committed
14 15 16
	cfg := ipfs.Repo.Config()
	allow_other := cfg.Mounts.FuseAllowOther

17 18 19 20 21 22 23 24
	if ipfs.IpnsFs == nil {
		fs, err := ipnsfs.NewFilesystem(ipfs.Context(), ipfs.DAG, ipfs.Namesys, ipfs.Pinning, ipfs.PrivateKey)
		if err != nil {
			return nil, err
		}
		ipfs.IpnsFs = fs
	}

25
	fsys, err := NewFileSystem(ipfs, ipfs.PrivateKey, ipfsmp, ipnsmp)
26
	if err != nil {
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
27
		return nil, err
28
	}
Jeromy's avatar
Jeromy committed
29

30
	return mount.NewMount(ipfs.Process(), fsys, ipnsmp, allow_other)
Jeromy's avatar
Jeromy committed
31
}