You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
997 B

  1. // +build linux darwin
  2. package command
  3. import (
  4. "fmt"
  5. "runtime"
  6. "bazil.org/fuse"
  7. "bazil.org/fuse/fs"
  8. "github.com/chrislusf/seaweedfs/weed/glog"
  9. "github.com/chrislusf/seaweedfs/weed/util"
  10. "github.com/chrislusf/seaweedfs/weed/filesys"
  11. )
  12. func runMount(cmd *Command, args []string) bool {
  13. fmt.Printf("This is SeaweedFS version %s %s %s\n", util.VERSION, runtime.GOOS, runtime.GOARCH)
  14. if *mountOptions.dir == "" {
  15. fmt.Printf("Please specify the mount directory via \"-dir\"")
  16. return false
  17. }
  18. fuse.Unmount(*mountOptions.dir)
  19. c, err := fuse.Mount(*mountOptions.dir, fuse.LocalVolume())
  20. if err != nil {
  21. glog.Fatal(err)
  22. return false
  23. }
  24. util.OnInterrupt(func() {
  25. fuse.Unmount(*mountOptions.dir)
  26. c.Close()
  27. })
  28. err = fs.Serve(c, filesys.NewSeaweedFileSystem(*mountOptions.filer))
  29. if err != nil {
  30. fuse.Unmount(*mountOptions.dir)
  31. }
  32. // check if the mount process has an error to report
  33. <-c.Ready
  34. if err := c.MountError; err != nil {
  35. glog.Fatal(err)
  36. }
  37. return true
  38. }