diff --git a/cmd/ipfs/kubo/daemon.go b/cmd/ipfs/kubo/daemon.go index 5cdf3fa1dca14bb0de213e5967dd760b82ae053e..94b633f794186e873c38455749441f43364c255a 100644 --- a/cmd/ipfs/kubo/daemon.go +++ b/cmd/ipfs/kubo/daemon.go @@ -1065,16 +1065,25 @@ func mountFuse(req *cmds.Request, cctx *oldcmds.Context) error { if !found { fsdir = cfg.Mounts.IPFS } + if err := checkFusePath("Mounts.IPFS", fsdir); err != nil { + return err + } nsdir, found := req.Options[ipnsMountKwd].(string) if !found { nsdir = cfg.Mounts.IPNS } + if err := checkFusePath("Mounts.IPNS", nsdir); err != nil { + return err + } mfsdir, found := req.Options[mfsMountKwd].(string) if !found { mfsdir = cfg.Mounts.MFS } + if err := checkFusePath("Mounts.MFS", mfsdir); err != nil { + return err + } node, err := cctx.ConstructNode() if err != nil { @@ -1091,6 +1100,26 @@ func mountFuse(req *cmds.Request, cctx *oldcmds.Context) error { return nil } +func checkFusePath(name, path string) error { + if path == "" { + return fmt.Errorf("%s path cannot be empty", name) + } + + fileInfo, err := os.Stat(path) + if err != nil { + if os.IsNotExist(err) { + return fmt.Errorf("%s path (%q) does not exist: %w", name, path, err) + } + return fmt.Errorf("error while inspecting %s path (%q): %w", name, path, err) + } + + if !fileInfo.IsDir() { + return fmt.Errorf("%s path (%q) is not a directory", name, path) + } + + return nil +} + func maybeRunGC(req *cmds.Request, node *core.IpfsNode) (<-chan error, error) { enableGC, _ := req.Options[enableGCKwd].(bool) if !enableGC { diff --git a/docs/config.md b/docs/config.md index 4b8d66ac02c2080cd4f52bb12117b43b84caffa4..e40ac5887e4cdce2b84657ea4494aaac21afd44d 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1373,7 +1373,10 @@ Default: `cache` ## `Mounts` > [!CAUTION] -> **EXPERIMENTAL:** read about current limitations at [fuse.md](./fuse.md). +> **EXPERIMENTAL:** +> This feature is disabled by default, requires an explicit opt-in with `ipfs mount` or `ipfs daemon --mount`. +> +> Read about current limitations at [fuse.md](./fuse.md). FUSE mount point configuration options. diff --git a/fuse/ipns/ipns_unix.go b/fuse/ipns/ipns_unix.go index 23704cabd521d374b58aa79dc5139e2df311cad8..ea2e753017e62fa02a0486e917d57153aabd0290 100644 --- a/fuse/ipns/ipns_unix.go +++ b/fuse/ipns/ipns_unix.go @@ -16,6 +16,7 @@ import ( dag "github.com/ipfs/boxo/ipld/merkledag" ft "github.com/ipfs/boxo/ipld/unixfs" + "github.com/ipfs/boxo/namesys" "github.com/ipfs/boxo/path" fuse "bazil.org/fuse" @@ -95,7 +96,7 @@ func loadRoot(ctx context.Context, ipfs iface.CoreAPI, key iface.Key) (*mfs.Root node, err := ipfs.ResolveNode(ctx, key.Path()) switch err { case nil: - case iface.ErrResolveFailed: + case namesys.ErrResolveFailed: node = ft.EmptyDirNode() default: log.Errorf("looking up %s: %s", key.Path(), err)