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.

97 lines
4.8 KiB

3 years ago
3 years ago
3 years ago
3 years ago
1 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. package command
  2. import (
  3. "os"
  4. "time"
  5. )
  6. type MountOptions struct {
  7. filer *string
  8. filerMountRootPath *string
  9. dir *string
  10. dirAutoCreate *bool
  11. collection *string
  12. collectionQuota *int
  13. replication *string
  14. diskType *string
  15. ttlSec *int
  16. chunkSizeLimitMB *int
  17. concurrentWriters *int
  18. cacheDirForRead *string
  19. cacheDirForWrite *string
  20. cacheSizeMBForRead *int64
  21. dataCenter *string
  22. allowOthers *bool
  23. umaskString *string
  24. nonempty *bool
  25. volumeServerAccess *string
  26. uidMap *string
  27. gidMap *string
  28. readOnly *bool
  29. debug *bool
  30. debugPort *int
  31. localSocket *string
  32. disableXAttr *bool
  33. extraOptions []string
  34. writeOnceReadMany *bool
  35. }
  36. var (
  37. mountOptions MountOptions
  38. mountCpuProfile *string
  39. mountMemProfile *string
  40. mountReadRetryTime *time.Duration
  41. )
  42. func init() {
  43. cmdMount.Run = runMount // break init cycle
  44. mountOptions.filer = cmdMount.Flag.String("filer", "localhost:8888", "comma-separated weed filer location")
  45. mountOptions.filerMountRootPath = cmdMount.Flag.String("filer.path", "/", "mount this remote path from filer server")
  46. mountOptions.dir = cmdMount.Flag.String("dir", ".", "mount weed filer to this directory")
  47. mountOptions.dirAutoCreate = cmdMount.Flag.Bool("dirAutoCreate", false, "auto create the directory to mount to")
  48. mountOptions.collection = cmdMount.Flag.String("collection", "", "collection to create the files")
  49. mountOptions.collectionQuota = cmdMount.Flag.Int("collectionQuotaMB", 0, "quota for the collection")
  50. mountOptions.replication = cmdMount.Flag.String("replication", "", "replication(e.g. 000, 001) to create to files. If empty, let filer decide.")
  51. mountOptions.diskType = cmdMount.Flag.String("disk", "", "[hdd|ssd|<tag>] hard drive or solid state drive or any tag")
  52. mountOptions.ttlSec = cmdMount.Flag.Int("ttl", 0, "file ttl in seconds")
  53. mountOptions.chunkSizeLimitMB = cmdMount.Flag.Int("chunkSizeLimitMB", 2, "local write buffer size, also chunk large files")
  54. mountOptions.concurrentWriters = cmdMount.Flag.Int("concurrentWriters", 32, "limit concurrent goroutine writers")
  55. mountOptions.cacheDirForRead = cmdMount.Flag.String("cacheDir", os.TempDir(), "local cache directory for file chunks and meta data")
  56. mountOptions.cacheSizeMBForRead = cmdMount.Flag.Int64("cacheCapacityMB", 0, "file chunk read cache capacity in MB")
  57. mountOptions.cacheDirForWrite = cmdMount.Flag.String("cacheDirWrite", "", "buffer writes mostly for large files")
  58. mountOptions.dataCenter = cmdMount.Flag.String("dataCenter", "", "prefer to write to the data center")
  59. mountOptions.allowOthers = cmdMount.Flag.Bool("allowOthers", true, "allows other users to access the file system")
  60. mountOptions.umaskString = cmdMount.Flag.String("umask", "022", "octal umask, e.g., 022, 0111")
  61. mountOptions.nonempty = cmdMount.Flag.Bool("nonempty", false, "allows the mounting over a non-empty directory")
  62. mountOptions.volumeServerAccess = cmdMount.Flag.String("volumeServerAccess", "direct", "access volume servers by [direct|publicUrl|filerProxy]")
  63. mountOptions.uidMap = cmdMount.Flag.String("map.uid", "", "map local uid to uid on filer, comma-separated <local_uid>:<filer_uid>")
  64. mountOptions.gidMap = cmdMount.Flag.String("map.gid", "", "map local gid to gid on filer, comma-separated <local_gid>:<filer_gid>")
  65. mountOptions.readOnly = cmdMount.Flag.Bool("readOnly", false, "read only")
  66. mountOptions.debug = cmdMount.Flag.Bool("debug", false, "serves runtime profiling data, e.g., http://localhost:<debug.port>/debug/pprof/goroutine?debug=2")
  67. mountOptions.debugPort = cmdMount.Flag.Int("debug.port", 6061, "http port for debugging")
  68. mountOptions.localSocket = cmdMount.Flag.String("localSocket", "", "default to /tmp/seaweedfs-mount-<mount_dir_hash>.sock")
  69. mountOptions.disableXAttr = cmdMount.Flag.Bool("disableXAttr", false, "disable xattr")
  70. mountOptions.writeOnceReadMany = cmdMount.Flag.Bool("writeOnceReadMany", false, "write once, read many times")
  71. mountCpuProfile = cmdMount.Flag.String("cpuprofile", "", "cpu profile output file")
  72. mountMemProfile = cmdMount.Flag.String("memprofile", "", "memory profile output file")
  73. mountReadRetryTime = cmdMount.Flag.Duration("readRetryTime", 6*time.Second, "maximum read retry wait time")
  74. }
  75. var cmdMount = &Command{
  76. UsageLine: "mount -filer=localhost:8888 -dir=/some/dir",
  77. Short: "mount weed filer to a directory as file system in userspace(FUSE)",
  78. Long: `mount weed filer to userspace.
  79. Pre-requisites:
  80. 1) have SeaweedFS master and volume servers running
  81. 2) have a "weed filer" running
  82. These 2 requirements can be achieved with one command "weed server -filer=true"
  83. This uses github.com/seaweedfs/fuse, which enables writing FUSE file systems on
  84. Linux, and OS X.
  85. On OS X, it requires OSXFUSE (https://osxfuse.github.io/).
  86. `,
  87. }