mount_std.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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(
  20. *mountOptions.dir,
  21. fuse.VolumeName("SeaweedFS"),
  22. fuse.FSName("SeaweedFS"),
  23. fuse.NoAppleDouble(),
  24. fuse.NoAppleXattr(),
  25. fuse.ExclCreate(),
  26. fuse.DaemonTimeout("3600"),
  27. fuse.AllowOther(),
  28. fuse.AllowSUID(),
  29. fuse.DefaultPermissions(),
  30. // fuse.MaxReadahead(1024*128), // TODO: not tested yet, possibly improving read performance
  31. fuse.AsyncRead(),
  32. fuse.WritebackCache(),
  33. )
  34. if err != nil {
  35. glog.Fatal(err)
  36. return false
  37. }
  38. util.OnInterrupt(func() {
  39. fuse.Unmount(*mountOptions.dir)
  40. c.Close()
  41. })
  42. err = fs.Serve(c, filesys.NewSeaweedFileSystem(*mountOptions.filer))
  43. if err != nil {
  44. fuse.Unmount(*mountOptions.dir)
  45. }
  46. // check if the mount process has an error to report
  47. <-c.Ready
  48. if err := c.MountError; err != nil {
  49. glog.Fatal(err)
  50. }
  51. return true
  52. }