forked from GoogleCloudPlatform/gcsfuse
/
flags.go
130 lines (111 loc) · 3.59 KB
/
flags.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"flag"
"time"
mountpkg "github.com/googlecloudplatform/gcsfuse/mount"
)
type flagStorage struct {
MountOptions map[string]string
Uid int64
Gid int64
FileMode uint
DirMode uint
TempDir string
TempDirLimit int64
GCSChunkSize uint64
ImplicitDirs bool
StatCacheTTL time.Duration
TypeCacheTTL time.Duration
OpRateLimitHz float64
EgressBandwidthLimitBytesPerSecond float64
}
// Add the flags accepted by run to the supplied flag set, returning the
// variables into which the flags will parse.
func populateFlagSet(fs *flag.FlagSet) (flags *flagStorage) {
flags = new(flagStorage)
flags.MountOptions = make(map[string]string)
fs.Var(
mountpkg.OptionValue(flags.MountOptions),
"o",
"Additional system-specific mount options. Be careful!")
fs.Int64Var(
&flags.Uid,
"uid",
-1,
"If non-negative, the UID that owns all inodes. The default is the UID of "+
"the gcsfuse process.")
fs.Int64Var(
&flags.Gid,
"gid",
-1,
"If non-negative, the GID that owns all inodes. The default is the GID of "+
"the gcsfuse process.")
fs.UintVar(
&flags.FileMode,
"file-mode",
0644,
"Permissions bits for files. Default is 0644.")
fs.UintVar(
&flags.DirMode,
"dir-mode",
0755,
"Permissions bits for directories. Default is 0755.")
fs.StringVar(
&flags.TempDir,
"temp-dir", "",
"The temporary directory in which to store local copies of GCS objects. "+
"If empty, the system default (probably /tmp) will be used.")
fs.Int64Var(
&flags.TempDirLimit,
"temp-dir-bytes", 1<<31,
"A desired limit on the number of bytes used in --temp-dir. May be "+
"exceeded for dirty files that have not been flushed or closed.")
fs.Uint64Var(
&flags.GCSChunkSize,
"gcs-chunk-size", 1<<24,
"If set to a non-zero value N, split up GCS objects into multiple "+
"chunks of size at most N when reading, and do not read or cache "+
"unnecessary chunks.")
fs.BoolVar(
&flags.ImplicitDirs,
"implicit-dirs",
false,
"Implicitly define directories based on their content. See "+
"docs/semantics.md.")
fs.DurationVar(
&flags.StatCacheTTL,
"stat-cache-ttl",
time.Minute,
"How long to cache StatObject results from GCS.")
fs.DurationVar(
&flags.TypeCacheTTL,
"type-cache-ttl",
time.Minute,
"How long to cache name -> file/dir type mappings in directory inodes.")
fs.Float64Var(
&flags.OpRateLimitHz,
"limit-ops-per-sec",
5.0,
"If positive, a limit on the rate at which we send requests to GCS, "+
"measured over a 30-second window.")
fs.Float64Var(
&flags.EgressBandwidthLimitBytesPerSecond,
"limit-bytes-per-sec",
-1,
"If positive, a limit on the GCS -> gcsfuse bandwidth for reading "+
"objects, measured over a 30-second window.")
return
}