mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
mount: add option to auto create dir to mount
This commit is contained in:
parent
00f96d86a1
commit
0d1d83a5a5
|
@ -8,6 +8,7 @@ type MountOptions struct {
|
||||||
filer *string
|
filer *string
|
||||||
filerMountRootPath *string
|
filerMountRootPath *string
|
||||||
dir *string
|
dir *string
|
||||||
|
dirAutoCreate *bool
|
||||||
dirListCacheLimit *int64
|
dirListCacheLimit *int64
|
||||||
collection *string
|
collection *string
|
||||||
replication *string
|
replication *string
|
||||||
|
@ -33,6 +34,7 @@ func init() {
|
||||||
mountOptions.filer = cmdMount.Flag.String("filer", "localhost:8888", "weed filer location")
|
mountOptions.filer = cmdMount.Flag.String("filer", "localhost:8888", "weed filer location")
|
||||||
mountOptions.filerMountRootPath = cmdMount.Flag.String("filer.path", "/", "mount this remote path from filer server")
|
mountOptions.filerMountRootPath = cmdMount.Flag.String("filer.path", "/", "mount this remote path from filer server")
|
||||||
mountOptions.dir = cmdMount.Flag.String("dir", ".", "mount weed filer to this directory")
|
mountOptions.dir = cmdMount.Flag.String("dir", ".", "mount weed filer to this directory")
|
||||||
|
mountOptions.dirAutoCreate = cmdMount.Flag.Bool("dirAutoCreate", false, "auto create the directory to mount to")
|
||||||
mountOptions.dirListCacheLimit = cmdMount.Flag.Int64("dirListCacheLimit", 1000000, "limit cache size to speed up directory long format listing")
|
mountOptions.dirListCacheLimit = cmdMount.Flag.Int64("dirListCacheLimit", 1000000, "limit cache size to speed up directory long format listing")
|
||||||
mountOptions.collection = cmdMount.Flag.String("collection", "", "collection to create the files")
|
mountOptions.collection = cmdMount.Flag.String("collection", "", "collection to create the files")
|
||||||
mountOptions.replication = cmdMount.Flag.String("replication", "", "replication(e.g. 000, 001) to create to files. If empty, let filer decide.")
|
mountOptions.replication = cmdMount.Flag.String("replication", "", "replication(e.g. 000, 001) to create to files. If empty, let filer decide.")
|
||||||
|
|
|
@ -88,6 +88,9 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
|
||||||
uid, gid := uint32(0), uint32(0)
|
uid, gid := uint32(0), uint32(0)
|
||||||
|
|
||||||
// detect mount folder mode
|
// detect mount folder mode
|
||||||
|
if *option.dirAutoCreate {
|
||||||
|
os.MkdirAll(dir, 0755)
|
||||||
|
}
|
||||||
mountMode := os.ModeDir | 0755
|
mountMode := os.ModeDir | 0755
|
||||||
fileInfo, err := os.Stat(dir)
|
fileInfo, err := os.Stat(dir)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
Loading…
Reference in a new issue