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.

67 lines
1.5 KiB

7 years ago
  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/filesys"
  9. "github.com/chrislusf/seaweedfs/weed/glog"
  10. "github.com/chrislusf/seaweedfs/weed/util"
  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. if *mountOptions.chunkSizeLimitMB <= 0 {
  19. fmt.Printf("Please specify a reasonable buffer size.")
  20. return false
  21. }
  22. fuse.Unmount(*mountOptions.dir)
  23. c, err := fuse.Mount(
  24. *mountOptions.dir,
  25. fuse.VolumeName("SeaweedFS"),
  26. fuse.FSName("SeaweedFS"),
  27. fuse.NoAppleDouble(),
  28. fuse.NoAppleXattr(),
  29. fuse.ExclCreate(),
  30. fuse.DaemonTimeout("3600"),
  31. fuse.AllowOther(),
  32. fuse.AllowSUID(),
  33. fuse.DefaultPermissions(),
  34. // fuse.MaxReadahead(1024*128), // TODO: not tested yet, possibly improving read performance
  35. fuse.AsyncRead(),
  36. fuse.WritebackCache(),
  37. )
  38. if err != nil {
  39. glog.Fatal(err)
  40. return false
  41. }
  42. util.OnInterrupt(func() {
  43. fuse.Unmount(*mountOptions.dir)
  44. c.Close()
  45. })
  46. err = fs.Serve(c, filesys.NewSeaweedFileSystem(
  47. *mountOptions.filer, *mountOptions.collection, *mountOptions.replication, *mountOptions.chunkSizeLimitMB))
  48. if err != nil {
  49. fuse.Unmount(*mountOptions.dir)
  50. }
  51. // check if the mount process has an error to report
  52. <-c.Ready
  53. if err := c.MountError; err != nil {
  54. glog.Fatal(err)
  55. }
  56. return true
  57. }