SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
clean up previously mounted folder
chrislu7a0c35674ca5
diff --git a/go.mod b/go.modindex 62c09d8f2a..31c7666a2d 100644--- a/go.mod+++ b/go.mod@@ -162,14 +162,17 @@ require (modernc.org/token v1.0.0 // indirect)-require github.com/fluent/fluent-logger-golang v1.8.0+require (+ github.com/fluent/fluent-logger-golang v1.8.0+ github.com/hanwen/go-fuse v1.0.0+ github.com/hanwen/go-fuse/v2 v2.1.0+)require (cloud.google.com/go/kms v1.0.0 // indirectgithub.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798 // indirectgithub.com/d4l3k/messagediff v1.2.1 // indirectgithub.com/gogo/protobuf v1.3.2 // indirect- github.com/hanwen/go-fuse/v2 v2.1.0 // indirectgithub.com/jcmturner/aescts/v2 v2.0.0 // indirectgithub.com/jcmturner/dnsutils/v2 v2.0.0 // indirectgithub.com/jcmturner/goidentity/v6 v6.0.1 // indirectdiff --git a/go.sum b/go.sumindex b1db2fdbf4..1054996bf0 100644--- a/go.sum+++ b/go.sum@@ -516,6 +516,7 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=github.com/kurin/blazer v0.5.3 h1:SAgYv0TKU0kN/ETfO5ExjNAPyMt2FocO2s/UlCHfjAk=github.com/kurin/blazer v0.5.3/go.mod h1:4FCXMUWo9DllR2Do4TtBd377ezyAJ51vB5uTBjt0pGU=+github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4=github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=github.com/lib/pq v1.10.0 h1:Zx5DJFEYQXio93kgXnQ09fXNiUKsqv4OUEu2UtGcB1E=diff --git a/weed/command/mount2_std.go b/weed/command/mount2_std.goindex 795a7864c1..60edb71b04 100644--- a/weed/command/mount2_std.go+++ b/weed/command/mount2_std.go@@ -4,6 +4,7 @@ import ("fmt""github.com/chrislusf/seaweedfs/weed/glog""github.com/chrislusf/seaweedfs/weed/mount"+ "github.com/chrislusf/seaweedfs/weed/mount/unmount""github.com/hanwen/go-fuse/v2/fs""net/http""os"@@ -43,6 +44,12 @@ func RunMount2(option *Mount2Options, umask os.FileMode) bool {opts := &fs.Options{}opts.Debug = true++ unmount.Unmount(*option.dir)+ grace.OnInterrupt(func() {+ unmount.Unmount(*option.dir)+ })+server, err := fs.Mount(*option.dir, &mount.WeedFS{}, opts)if err != nil {glog.Fatalf("Mount fail: %v", err)diff --git a/weed/mount/unmount/unmount.go b/weed/mount/unmount/unmount.gonew file mode 100644index 0000000000..c481d8030c--- /dev/null+++ b/weed/mount/unmount/unmount.go@@ -0,0 +1,6 @@+package unmount++// Unmount tries to unmount the filesystem mounted at dir.+func Unmount(dir string) error {+ return unmount(dir)+}diff --git a/weed/mount/unmount/unmount_linux.go b/weed/mount/unmount/unmount_linux.gonew file mode 100644index 0000000000..e55d48f868--- /dev/null+++ b/weed/mount/unmount/unmount_linux.go@@ -0,0 +1,21 @@+package unmount++import (+ "bytes"+ "errors"+ "os/exec"+)++func unmount(dir string) error {+ cmd := exec.Command("fusermount", "-u", dir)+ output, err := cmd.CombinedOutput()+ if err != nil {+ if len(output) > 0 {+ output = bytes.TrimRight(output, "\n")+ msg := err.Error() + ": " + string(output)+ err = errors.New(msg)+ }+ return err+ }+ return nil+}diff --git a/weed/mount/unmount/unmount_std.go b/weed/mount/unmount/unmount_std.gonew file mode 100644index 0000000000..76267fb6ad--- /dev/null+++ b/weed/mount/unmount/unmount_std.go@@ -0,0 +1,18 @@+//go:build !linux+// +build !linux++package unmount++import (+ "os"+ "syscall"+)++func unmount(dir string) error {+ err := syscall.Unmount(dir, 0)+ if err != nil {+ err = &os.PathError{Op: "unmount", Path: dir, Err: err}+ return err+ }+ return nil+}