mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 18:37:45 +08:00
* Add MFS command line options, extend existing mount functions for MFS, set defaults. * Directory listing and file stat. * Add a read-only MFS view. * Add mkdir and interface checks. * Add remove and rename functionality. * Implement all required write interfaces. * Adjust mount functions for other architechtures. * Merge branch 'master' into feat/10710-mfs-fuse-mount * Write a basic read/write test. * Write more basic tests, add a mutex to the file object, fix modtime. * Add a concurrency test, remove mutexes from file and directory structures. * Refactor naming(mfdir -> mfsdir) and add documentation. * Add CID retrieval through ipfs_cid xattr. * Add docs, add xattr listing, fix bugs for mv and stat, refactor. * Add MFS command line options, extend existing mount functions for MFS, set defaults. * docs phrasing * docs: Mounts.MFS * docs: warn about lazy-loaded DAGs * test: TEST_FUSE=1 ./t0030-mount.sh -v --------- Co-authored-by: Guillaume Michel <guillaumemichel@users.noreply.github.com> Co-authored-by: guillaumemichel <guillaume@michel.id> Co-authored-by: Marcin Rataj <lidel@lidel.org>
94 lines
1.9 KiB
Go
94 lines
1.9 KiB
Go
//go:build !openbsd && !nofuse && !netbsd && !plan9
|
|
// +build !openbsd,!nofuse,!netbsd,!plan9
|
|
|
|
package node
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"bazil.org/fuse"
|
|
|
|
core "github.com/ipfs/kubo/core"
|
|
ipns "github.com/ipfs/kubo/fuse/ipns"
|
|
mount "github.com/ipfs/kubo/fuse/mount"
|
|
|
|
ci "github.com/libp2p/go-libp2p-testing/ci"
|
|
)
|
|
|
|
func maybeSkipFuseTests(t *testing.T) {
|
|
if ci.NoFuse() {
|
|
t.Skip("Skipping FUSE tests")
|
|
}
|
|
}
|
|
|
|
func mkdir(t *testing.T, path string) {
|
|
err := os.Mkdir(path, os.ModeDir|os.ModePerm)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
// Test externally unmounting, then trying to unmount in code.
|
|
func TestExternalUnmount(t *testing.T) {
|
|
if testing.Short() {
|
|
t.SkipNow()
|
|
}
|
|
|
|
// TODO: needed?
|
|
maybeSkipFuseTests(t)
|
|
|
|
node, err := core.NewNode(context.Background(), &core.BuildCfg{})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
err = ipns.InitializeKeyspace(node, node.PrivateKey)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// get the test dir paths (/tmp/TestExternalUnmount)
|
|
dir := t.TempDir()
|
|
|
|
ipfsDir := dir + "/ipfs"
|
|
ipnsDir := dir + "/ipns"
|
|
mfsDir := dir + "/mfs"
|
|
mkdir(t, ipfsDir)
|
|
mkdir(t, ipnsDir)
|
|
mkdir(t, mfsDir)
|
|
|
|
err = Mount(node, ipfsDir, ipnsDir, mfsDir)
|
|
if err != nil {
|
|
if strings.Contains(err.Error(), "unable to check fuse version") || err == fuse.ErrOSXFUSENotFound {
|
|
t.Skip(err)
|
|
}
|
|
}
|
|
|
|
if err != nil {
|
|
t.Fatalf("error mounting: %v", err)
|
|
}
|
|
|
|
// Run shell command to externally unmount the directory
|
|
cmd, err := mount.UnmountCmd(ipfsDir)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if err := cmd.Run(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// TODO(noffle): it takes a moment for the goroutine that's running fs.Serve to be notified and do its cleanup.
|
|
time.Sleep(time.Millisecond * 100)
|
|
|
|
// Attempt to unmount IPFS; it should unmount successfully.
|
|
err = node.Mounts.Ipfs.Unmount()
|
|
if err != mount.ErrNotMounted {
|
|
t.Fatal("Unmount should have failed")
|
|
}
|
|
}
|