Codebase list prometheus-haproxy-exporter / da73bf8
Update dependencies Tobias Schmidt 3 years ago
140 changed file(s) with 3284 addition(s) and 740 deletion(s). Raw diff Collapse all Expand all
33
44 require (
55 github.com/go-kit/kit v0.10.0
6 github.com/prometheus/client_golang v1.6.0
6 github.com/prometheus/client_golang v1.7.0
77 github.com/prometheus/common v0.10.0
88 gopkg.in/alecthomas/kingpin.v2 v2.2.6
99 )
9292 github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
9393 github.com/golang/protobuf v1.4.0 h1:oOuy+ugB+P/kBdUnG5QaMXSIyJ1q38wWSojYCb3z5VQ=
9494 github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
95 github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
96 github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
9597 github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
9698 github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
9799 github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
140142 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
141143 github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
142144 github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
143 github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
145 github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
144146 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
145147 github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
146148 github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
217219 github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM=
218220 github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
219221 github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
220 github.com/prometheus/client_golang v1.6.0 h1:YVPodQOcK15POxhgARIvnDRVpLcuK8mglnMrWfyrw6A=
221 github.com/prometheus/client_golang v1.6.0/go.mod h1:ZLOG9ck3JLRdB5MgO8f+lLTe83AXG6ro35rLTxvnIl4=
222 github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U=
223 github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
222224 github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8=
223225 github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
224226 github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
232234 github.com/prometheus/common v0.4.1 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6Kw=
233235 github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
234236 github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
235 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
236237 github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc=
237238 github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
238239 github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
240241 github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs=
241242 github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
242243 github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
243 github.com/prometheus/procfs v0.0.11 h1:DhHlBtkHWPYi8O2y31JkK0TF+DGM+51OopZjH/Ia5qI=
244 github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
244 github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
245 github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
245246 github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
246247 github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
247248 github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
343344 golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
344345 golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
345346 golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
346 golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f h1:gWF768j/LaZugp8dyS4UwsslYCYz9XgFxvlgsn0n9H8=
347 golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
347 golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 h1:ogLJMz+qpzav7lGMh10LMvAkM/fAoGlaiiHYiFYdm80=
348 golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
348349 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
349350 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
350351 golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
390391 google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
391392 google.golang.org/protobuf v1.21.0 h1:qdOKuR/EIArgaWNjetjgTzgVTAZ+S/WXVrq9HW9zimw=
392393 google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
394 google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
395 google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
393396 gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
394397 gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
395398 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3232 return protowire.SizeVarint(v)
3333 }
3434
35 // DecodeVarint parses a varint encoded integer from b, returning the
36 // integer value and the length of the varint.
35 // DecodeVarint parses a varint encoded integer from b,
36 // returning the integer value and the length of the varint.
3737 // It returns (0, 0) if there is a parse error.
3838 func DecodeVarint(b []byte) (uint64, int) {
3939 v, n := protowire.ConsumeVarint(b)
111111 return err
112112 }
113113
114 // Unmarshal parses the wire-format message in the buffer and places the decoded results in m.
115 //
116 // Unlike proto.Unmarshal, this does not reset the message before starting to unmarshal.
114 // Unmarshal parses the wire-format message in the buffer and
115 // places the decoded results in m.
116 // It does not reset m before unmarshaling.
117117 func (b *Buffer) Unmarshal(m Message) error {
118118 err := UnmarshalMerge(b.Unread(), m)
119119 b.idx = len(b.buf)
259259 }
260260
261261 // DecodeMessage consumes a length-prefixed message from the buffer.
262 // It does not reset m.
262 // It does not reset m before unmarshaling.
263263 func (b *Buffer) DecodeMessage(m Message) error {
264264 v, err := b.DecodeRawBytes(false)
265265 if err != nil {
271271 // DecodeGroup consumes a message group from the buffer.
272272 // It assumes that the start group marker has already been consumed and
273273 // consumes all bytes until (and including the end group marker).
274 // It does not reset m.
274 // It does not reset m before unmarshaling.
275275 func (b *Buffer) DecodeGroup(m Message) error {
276276 v, n, err := consumeGroup(b.buf[b.idx:])
277277 if err != nil {
88 "errors"
99 "fmt"
1010 "strconv"
11
12 protoV2 "google.golang.org/protobuf/proto"
1113 )
1214
1315 var (
8183 return val, nil
8284 }
8385
84 // Deprecated: Do not use.
86 // Deprecated: Do not use; this type existed for intenal-use only.
8587 type InternalMessageInfo struct{}
8688
87 func (*InternalMessageInfo) DiscardUnknown(Message) { panic("not implemented") }
88 func (*InternalMessageInfo) Marshal([]byte, Message, bool) ([]byte, error) { panic("not implemented") }
89 func (*InternalMessageInfo) Merge(Message, Message) { panic("not implemented") }
90 func (*InternalMessageInfo) Size(Message) int { panic("not implemented") }
91 func (*InternalMessageInfo) Unmarshal(Message, []byte) error { panic("not implemented") }
89 // Deprecated: Do not use; this method existed for intenal-use only.
90 func (*InternalMessageInfo) DiscardUnknown(m Message) {
91 DiscardUnknown(m)
92 }
93
94 // Deprecated: Do not use; this method existed for intenal-use only.
95 func (*InternalMessageInfo) Marshal(b []byte, m Message, deterministic bool) ([]byte, error) {
96 return protoV2.MarshalOptions{Deterministic: deterministic}.MarshalAppend(b, MessageV2(m))
97 }
98
99 // Deprecated: Do not use; this method existed for intenal-use only.
100 func (*InternalMessageInfo) Merge(dst, src Message) {
101 protoV2.Merge(MessageV2(dst), MessageV2(src))
102 }
103
104 // Deprecated: Do not use; this method existed for intenal-use only.
105 func (*InternalMessageInfo) Size(m Message) int {
106 return protoV2.Size(MessageV2(m))
107 }
108
109 // Deprecated: Do not use; this method existed for intenal-use only.
110 func (*InternalMessageInfo) Unmarshal(m Message, b []byte) error {
111 return protoV2.UnmarshalOptions{Merge: true}.Unmarshal(b, MessageV2(m))
112 }
6767 return has
6868 }
6969
70 // ClearExtension removes the the exntesion field from m
70 // ClearExtension removes the extension field from m
7171 // either as an explicitly populated field or as an unknown field.
7272 func ClearExtension(m Message, xt *ExtensionDesc) {
7373 mr := MessageReflect(m)
107107 clearUnknown(mr, mr.Descriptor().ExtensionRanges())
108108 }
109109
110 // GetExtension retrieves a proto2 extended field from pb.
110 // GetExtension retrieves a proto2 extended field from m.
111111 //
112112 // If the descriptor is type complete (i.e., ExtensionDesc.ExtensionType is non-nil),
113113 // then GetExtension parses the encoded field and returns a Go value of the specified type.
2828 // RegisterFile is called from generated code to register the compressed
2929 // FileDescriptorProto with the file path for a proto source file.
3030 //
31 // Deprecated: Use protoregistry.GlobalFiles.Register instead.
31 // Deprecated: Use protoregistry.GlobalFiles.RegisterFile instead.
3232 func RegisterFile(s filePath, d fileDescGZIP) {
3333 // Decompress the descriptor.
3434 zr, err := gzip.NewReader(bytes.NewReader(d))
5252 // FileDescriptor returns the compressed FileDescriptorProto given the file path
5353 // for a proto source file. It returns nil if not found.
5454 //
55 // Deprecated: Use protoregistry.GlobalFiles.RangeFilesByPath instead.
55 // Deprecated: Use protoregistry.GlobalFiles.FindFileByPath instead.
5656 func FileDescriptor(s filePath) fileDescGZIP {
5757 if v, ok := fileCache.Load(s); ok {
5858 return v.(fileDescGZIP)
9797 // RegisterEnum is called from the generated code to register the mapping of
9898 // enum value names to enum numbers for the enum identified by s.
9999 //
100 // Deprecated: Use protoregistry.GlobalTypes.Register instead.
100 // Deprecated: Use protoregistry.GlobalTypes.RegisterEnum instead.
101101 func RegisterEnum(s enumName, _ enumsByNumber, m enumsByName) {
102102 if _, ok := enumCache.Load(s); ok {
103103 panic("proto: duplicate enum registered: " + s)
180180 // RegisterType is called from generated code to register the message Go type
181181 // for a message of the given name.
182182 //
183 // Deprecated: Use protoregistry.GlobalTypes.Register instead.
183 // Deprecated: Use protoregistry.GlobalTypes.RegisterMessage instead.
184184 func RegisterType(m Message, s messageName) {
185185 mt := protoimpl.X.LegacyMessageTypeOf(m, protoreflect.FullName(s))
186186 if err := protoregistry.GlobalTypes.RegisterMessage(mt); err != nil {
279279 // RegisterExtension is called from the generated code to register
280280 // the extension descriptor.
281281 //
282 // Deprecated: Use protoregistry.GlobalTypes.Register instead.
282 // Deprecated: Use protoregistry.GlobalTypes.RegisterExtension instead.
283283 func RegisterExtension(d *ExtensionDesc) {
284284 if err := protoregistry.GlobalTypes.RegisterExtension(d); err != nil {
285285 panic(err)
9393 )
9494
9595 // MarshalText writes the proto text format of m to w.
96 func MarshalText(w io.Writer, pb Message) error { return defaultTextMarshaler.Marshal(w, pb) }
96 func MarshalText(w io.Writer, m Message) error { return defaultTextMarshaler.Marshal(w, m) }
9797
9898 // MarshalTextString returns a proto text formatted string of m.
99 func MarshalTextString(pb Message) string { return defaultTextMarshaler.Text(pb) }
99 func MarshalTextString(m Message) string { return defaultTextMarshaler.Text(m) }
100100
101101 // CompactText writes the compact proto text format of m to w.
102 func CompactText(w io.Writer, pb Message) error { return compactTextMarshaler.Marshal(w, pb) }
102 func CompactText(w io.Writer, m Message) error { return compactTextMarshaler.Marshal(w, m) }
103103
104104 // CompactTextString returns a compact proto text formatted string of m.
105 func CompactTextString(pb Message) string { return compactTextMarshaler.Text(pb) }
105 func CompactTextString(m Message) string { return compactTextMarshaler.Text(m) }
106106
107107 var (
108108 newline = []byte("\n")
1919 "strings"
2020
2121 "github.com/cespare/xxhash/v2"
22 //lint:ignore SA1019 Need to keep deprecated package for compatibility.
2223 "github.com/golang/protobuf/proto"
2324 "github.com/prometheus/common/model"
2425
2121 "sync/atomic"
2222 "time"
2323
24 //lint:ignore SA1019 Need to keep deprecated package for compatibility.
2425 "github.com/golang/protobuf/proto"
2526
2627 dto "github.com/prometheus/client_model/go"
1616 "strings"
1717 "time"
1818
19 //lint:ignore SA1019 Need to keep deprecated package for compatibility.
1920 "github.com/golang/protobuf/proto"
2021 "github.com/prometheus/common/model"
2122
2525 "unicode/utf8"
2626
2727 "github.com/cespare/xxhash/v2"
28 //lint:ignore SA1019 Need to keep deprecated package for compatibility.
2829 "github.com/golang/protobuf/proto"
2930 "github.com/prometheus/common/expfmt"
3031
2222 "time"
2323
2424 "github.com/beorn7/perks/quantile"
25 //lint:ignore SA1019 Need to keep deprecated package for compatibility.
2526 "github.com/golang/protobuf/proto"
2627
2728 dto "github.com/prometheus/client_model/go"
312312 // Base units.
313313 "amperes": "amperes",
314314 "bytes": "bytes",
315 "celsius": "celsius", // Celsius is more common in practice than Kelvin.
315 "celsius": "celsius", // Also allow Celsius because it is common in typical Prometheus use cases.
316316 "grams": "grams",
317317 "joules": "joules",
318 "kelvin": "kelvin", // SI base unit, used in special cases (e.g. color temperature, scientific measurements).
318319 "meters": "meters", // Both American and international spelling permitted.
319320 "metres": "metres",
320321 "seconds": "seconds",
327328 "days": "seconds",
328329 "weeks": "seconds",
329330 // Temperature.
330 "kelvin": "celsius",
331 "kelvins": "celsius",
331 "kelvins": "kelvin",
332332 "fahrenheit": "celsius",
333333 "rankine": "celsius",
334334 // Length.
111111 panic(fmt.Errorf("collected a non-gauge/counter/untyped metric: %s", pb))
112112 }
113113
114 // CollectAndCount collects all Metrics from the provided Collector and returns their number.
115 //
116 // This can be used to assert the number of metrics collected by a given collector after certain operations.
117 //
118 // This function is only for testing purposes, and even for testing, other approaches
119 // are often more appropriate (see this package's documentation).
120 func CollectAndCount(c prometheus.Collector) int {
121 var (
122 mCount int
123 mChan = make(chan prometheus.Metric)
124 done = make(chan struct{})
125 )
126
127 go func() {
128 for range mChan {
129 mCount++
130 }
131 close(done)
132 }()
133
134 c.Collect(mChan)
135 close(mChan)
136 <-done
137
138 return mCount
114 // CollectAndCount registers the provided Collector with a newly created
115 // pedantic Registry. It then calls GatherAndCount with that Registry and with
116 // the provided metricNames. In the unlikely case that the registration or the
117 // gathering fails, this function panics. (This is inconsistent with the other
118 // CollectAnd… functions in this package and has historical reasons. Changing
119 // the function signature would be a breaking change and will therefore only
120 // happen with the next major version bump.)
121 func CollectAndCount(c prometheus.Collector, metricNames ...string) int {
122 reg := prometheus.NewPedanticRegistry()
123 if err := reg.Register(c); err != nil {
124 panic(fmt.Errorf("registering collector failed: %s", err))
125 }
126 result, err := GatherAndCount(reg, metricNames...)
127 if err != nil {
128 panic(err)
129 }
130 return result
131 }
132
133 // GatherAndCount gathers all metrics from the provided Gatherer and counts
134 // them. It returns the number of metric children in all gathered metric
135 // families together. If any metricNames are provided, only metrics with those
136 // names are counted.
137 func GatherAndCount(g prometheus.Gatherer, metricNames ...string) (int, error) {
138 got, err := g.Gather()
139 if err != nil {
140 return 0, fmt.Errorf("gathering metrics failed: %s", err)
141 }
142 if metricNames != nil {
143 got = filterMetrics(got, metricNames)
144 }
145
146 result := 0
147 for _, mf := range got {
148 result += len(mf.GetMetric())
149 }
150 return result, nil
139151 }
140152
141153 // CollectAndCompare registers the provided Collector with a newly created
1818 "time"
1919 "unicode/utf8"
2020
21 //lint:ignore SA1019 Need to keep deprecated package for compatibility.
2122 "github.com/golang/protobuf/proto"
2223 "github.com/golang/protobuf/ptypes"
2324
1616 "fmt"
1717 "sort"
1818
19 //lint:ignore SA1019 Need to keep deprecated package for compatibility.
1920 "github.com/golang/protobuf/proto"
2021
2122 dto "github.com/prometheus/client_model/go"
2627 // registered with the wrapped Registerer in a modified way. The modified
2728 // Collector adds the provided Labels to all Metrics it collects (as
2829 // ConstLabels). The Metrics collected by the unmodified Collector must not
29 // duplicate any of those labels.
30 // duplicate any of those labels. Wrapping a nil value is valid, resulting
31 // in a no-op Registerer.
3032 //
3133 // WrapRegistererWith provides a way to add fixed labels to a subset of
3234 // Collectors. It should not be used to add fixed labels to all metrics exposed.
4951 // Registerer. Collectors registered with the returned Registerer will be
5052 // registered with the wrapped Registerer in a modified way. The modified
5153 // Collector adds the provided prefix to the name of all Metrics it collects.
54 // Wrapping a nil value is valid, resulting in a no-op Registerer.
5255 //
5356 // WrapRegistererWithPrefix is useful to have one place to prefix all metrics of
5457 // a sub-system. To make this work, register metrics of the sub-system with the
7982 }
8083
8184 func (r *wrappingRegisterer) Register(c Collector) error {
85 if r.wrappedRegisterer == nil {
86 return nil
87 }
8288 return r.wrappedRegisterer.Register(&wrappingCollector{
8389 wrappedCollector: c,
8490 prefix: r.prefix,
8793 }
8894
8995 func (r *wrappingRegisterer) MustRegister(cs ...Collector) {
96 if r.wrappedRegisterer == nil {
97 return
98 }
9099 for _, c := range cs {
91100 if err := r.Register(c); err != nil {
92101 panic(err)
95104 }
96105
97106 func (r *wrappingRegisterer) Unregister(c Collector) bool {
107 if r.wrappedRegisterer == nil {
108 return false
109 }
98110 return r.wrappedRegisterer.Unregister(&wrappingCollector{
99111 wrappedCollector: c,
100112 prefix: r.prefix,
149149 $(GO) get $(GOOPTS) -t ./...
150150 endif
151151
152 .PHONY: update-go-deps
153 update-go-deps:
154 @echo ">> updating Go dependencies"
155 @for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
156 $(GO) get $$m; \
157 done
158 GO111MODULE=$(GO111MODULE) $(GO) mod tidy
159 ifneq (,$(wildcard vendor))
160 GO111MODULE=$(GO111MODULE) $(GO) mod vendor
161 endif
162
152163 .PHONY: common-test-short
153164 common-test-short: $(GOTEST_DIR)
154165 @echo ">> running short tests"
1010 // See the License for the specific language governing permissions and
1111 // limitations under the License.
1212
13 // +build linux
14
1315 package procfs
1416
1517 import (
1618 "bufio"
1719 "bytes"
20 "errors"
21 "regexp"
1822 "strconv"
1923 "strings"
2024
5155 PowerManagement string
5256 }
5357
58 var (
59 cpuinfoClockRegexp = regexp.MustCompile(`([\d.]+)`)
60 cpuinfoS390XProcessorRegexp = regexp.MustCompile(`^processor\s+(\d+):.*`)
61 )
62
5463 // CPUInfo returns information about current system CPUs.
5564 // See https://www.kernel.org/doc/Documentation/filesystems/proc.txt
5665 func (fs FS) CPUInfo() ([]CPUInfo, error) {
6170 return parseCPUInfo(data)
6271 }
6372
64 // parseCPUInfo parses data from /proc/cpuinfo
65 func parseCPUInfo(info []byte) ([]CPUInfo, error) {
66 cpuinfo := []CPUInfo{}
67 i := -1
73 func parseCPUInfoX86(info []byte) ([]CPUInfo, error) {
6874 scanner := bufio.NewScanner(bytes.NewReader(info))
69 for scanner.Scan() {
70 line := scanner.Text()
71 if strings.TrimSpace(line) == "" {
75
76 // find the first "processor" line
77 firstLine := firstNonEmptyLine(scanner)
78 if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") {
79 return nil, errors.New("invalid cpuinfo file: " + firstLine)
80 }
81 field := strings.SplitN(firstLine, ": ", 2)
82 v, err := strconv.ParseUint(field[1], 0, 32)
83 if err != nil {
84 return nil, err
85 }
86 firstcpu := CPUInfo{Processor: uint(v)}
87 cpuinfo := []CPUInfo{firstcpu}
88 i := 0
89
90 for scanner.Scan() {
91 line := scanner.Text()
92 if !strings.Contains(line, ":") {
7293 continue
7394 }
7495 field := strings.SplitN(line, ": ", 2)
81102 return nil, err
82103 }
83104 cpuinfo[i].Processor = uint(v)
84 case "vendor_id":
105 case "vendor", "vendor_id":
85106 cpuinfo[i].VendorID = field[1]
86107 case "cpu family":
87108 cpuinfo[i].CPUFamily = field[1]
162183 }
163184 }
164185 return cpuinfo, nil
165
166 }
186 }
187
188 func parseCPUInfoARM(info []byte) ([]CPUInfo, error) {
189 scanner := bufio.NewScanner(bytes.NewReader(info))
190
191 firstLine := firstNonEmptyLine(scanner)
192 match, _ := regexp.MatchString("^[Pp]rocessor", firstLine)
193 if !match || !strings.Contains(firstLine, ":") {
194 return nil, errors.New("invalid cpuinfo file: " + firstLine)
195 }
196 field := strings.SplitN(firstLine, ": ", 2)
197 cpuinfo := []CPUInfo{}
198 featuresLine := ""
199 commonCPUInfo := CPUInfo{}
200 i := 0
201 if strings.TrimSpace(field[0]) == "Processor" {
202 commonCPUInfo = CPUInfo{ModelName: field[1]}
203 i = -1
204 } else {
205 v, err := strconv.ParseUint(field[1], 0, 32)
206 if err != nil {
207 return nil, err
208 }
209 firstcpu := CPUInfo{Processor: uint(v)}
210 cpuinfo = []CPUInfo{firstcpu}
211 }
212
213 for scanner.Scan() {
214 line := scanner.Text()
215 if !strings.Contains(line, ":") {
216 continue
217 }
218 field := strings.SplitN(line, ": ", 2)
219 switch strings.TrimSpace(field[0]) {
220 case "processor":
221 cpuinfo = append(cpuinfo, commonCPUInfo) // start of the next processor
222 i++
223 v, err := strconv.ParseUint(field[1], 0, 32)
224 if err != nil {
225 return nil, err
226 }
227 cpuinfo[i].Processor = uint(v)
228 case "BogoMIPS":
229 if i == -1 {
230 cpuinfo = append(cpuinfo, commonCPUInfo) // There is only one processor
231 i++
232 cpuinfo[i].Processor = 0
233 }
234 v, err := strconv.ParseFloat(field[1], 64)
235 if err != nil {
236 return nil, err
237 }
238 cpuinfo[i].BogoMips = v
239 case "Features":
240 featuresLine = line
241 case "model name":
242 cpuinfo[i].ModelName = field[1]
243 }
244 }
245 fields := strings.SplitN(featuresLine, ": ", 2)
246 for i := range cpuinfo {
247 cpuinfo[i].Flags = strings.Fields(fields[1])
248 }
249 return cpuinfo, nil
250
251 }
252
253 func parseCPUInfoS390X(info []byte) ([]CPUInfo, error) {
254 scanner := bufio.NewScanner(bytes.NewReader(info))
255
256 firstLine := firstNonEmptyLine(scanner)
257 if !strings.HasPrefix(firstLine, "vendor_id") || !strings.Contains(firstLine, ":") {
258 return nil, errors.New("invalid cpuinfo file: " + firstLine)
259 }
260 field := strings.SplitN(firstLine, ": ", 2)
261 cpuinfo := []CPUInfo{}
262 commonCPUInfo := CPUInfo{VendorID: field[1]}
263
264 for scanner.Scan() {
265 line := scanner.Text()
266 if !strings.Contains(line, ":") {
267 continue
268 }
269 field := strings.SplitN(line, ": ", 2)
270 switch strings.TrimSpace(field[0]) {
271 case "bogomips per cpu":
272 v, err := strconv.ParseFloat(field[1], 64)
273 if err != nil {
274 return nil, err
275 }
276 commonCPUInfo.BogoMips = v
277 case "features":
278 commonCPUInfo.Flags = strings.Fields(field[1])
279 }
280 if strings.HasPrefix(line, "processor") {
281 match := cpuinfoS390XProcessorRegexp.FindStringSubmatch(line)
282 if len(match) < 2 {
283 return nil, errors.New("Invalid line found in cpuinfo: " + line)
284 }
285 cpu := commonCPUInfo
286 v, err := strconv.ParseUint(match[1], 0, 32)
287 if err != nil {
288 return nil, err
289 }
290 cpu.Processor = uint(v)
291 cpuinfo = append(cpuinfo, cpu)
292 }
293 if strings.HasPrefix(line, "cpu number") {
294 break
295 }
296 }
297
298 i := 0
299 for scanner.Scan() {
300 line := scanner.Text()
301 if !strings.Contains(line, ":") {
302 continue
303 }
304 field := strings.SplitN(line, ": ", 2)
305 switch strings.TrimSpace(field[0]) {
306 case "cpu number":
307 i++
308 case "cpu MHz dynamic":
309 clock := cpuinfoClockRegexp.FindString(strings.TrimSpace(field[1]))
310 v, err := strconv.ParseFloat(clock, 64)
311 if err != nil {
312 return nil, err
313 }
314 cpuinfo[i].CPUMHz = v
315 }
316 }
317
318 return cpuinfo, nil
319 }
320
321 func parseCPUInfoMips(info []byte) ([]CPUInfo, error) {
322 scanner := bufio.NewScanner(bytes.NewReader(info))
323
324 // find the first "processor" line
325 firstLine := firstNonEmptyLine(scanner)
326 if !strings.HasPrefix(firstLine, "system type") || !strings.Contains(firstLine, ":") {
327 return nil, errors.New("invalid cpuinfo file: " + firstLine)
328 }
329 field := strings.SplitN(firstLine, ": ", 2)
330 cpuinfo := []CPUInfo{}
331 systemType := field[1]
332
333 i := 0
334
335 for scanner.Scan() {
336 line := scanner.Text()
337 if !strings.Contains(line, ":") {
338 continue
339 }
340 field := strings.SplitN(line, ": ", 2)
341 switch strings.TrimSpace(field[0]) {
342 case "processor":
343 v, err := strconv.ParseUint(field[1], 0, 32)
344 if err != nil {
345 return nil, err
346 }
347 i = int(v)
348 cpuinfo = append(cpuinfo, CPUInfo{}) // start of the next processor
349 cpuinfo[i].Processor = uint(v)
350 cpuinfo[i].VendorID = systemType
351 case "cpu model":
352 cpuinfo[i].ModelName = field[1]
353 case "BogoMIPS":
354 v, err := strconv.ParseFloat(field[1], 64)
355 if err != nil {
356 return nil, err
357 }
358 cpuinfo[i].BogoMips = v
359 }
360 }
361 return cpuinfo, nil
362 }
363
364 func parseCPUInfoPPC(info []byte) ([]CPUInfo, error) {
365 scanner := bufio.NewScanner(bytes.NewReader(info))
366
367 firstLine := firstNonEmptyLine(scanner)
368 if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") {
369 return nil, errors.New("invalid cpuinfo file: " + firstLine)
370 }
371 field := strings.SplitN(firstLine, ": ", 2)
372 v, err := strconv.ParseUint(field[1], 0, 32)
373 if err != nil {
374 return nil, err
375 }
376 firstcpu := CPUInfo{Processor: uint(v)}
377 cpuinfo := []CPUInfo{firstcpu}
378 i := 0
379
380 for scanner.Scan() {
381 line := scanner.Text()
382 if !strings.Contains(line, ":") {
383 continue
384 }
385 field := strings.SplitN(line, ": ", 2)
386 switch strings.TrimSpace(field[0]) {
387 case "processor":
388 cpuinfo = append(cpuinfo, CPUInfo{}) // start of the next processor
389 i++
390 v, err := strconv.ParseUint(field[1], 0, 32)
391 if err != nil {
392 return nil, err
393 }
394 cpuinfo[i].Processor = uint(v)
395 case "cpu":
396 cpuinfo[i].VendorID = field[1]
397 case "clock":
398 clock := cpuinfoClockRegexp.FindString(strings.TrimSpace(field[1]))
399 v, err := strconv.ParseFloat(clock, 64)
400 if err != nil {
401 return nil, err
402 }
403 cpuinfo[i].CPUMHz = v
404 }
405 }
406 return cpuinfo, nil
407 }
408
409 // firstNonEmptyLine advances the scanner to the first non-empty line
410 // and returns the contents of that line
411 func firstNonEmptyLine(scanner *bufio.Scanner) string {
412 for scanner.Scan() {
413 line := scanner.Text()
414 if strings.TrimSpace(line) != "" {
415 return line
416 }
417 }
418 return ""
419 }
0 // Copyright 2020 The Prometheus Authors
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12
13 // +build linux
14
15 package procfs
16
17 var parseCPUInfo = parseCPUInfoARM
0 // Copyright 2020 The Prometheus Authors
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12
13 // +build linux
14 // +build arm64
15
16 package procfs
17
18 var parseCPUInfo = parseCPUInfoARM
0 // Copyright 2020 The Prometheus Authors
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12
13 // +build linux
14 // +build 386 amd64
15
16 package procfs
17
18 var parseCPUInfo = parseCPUInfoX86
0 // Copyright 2020 The Prometheus Authors
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12
13 // +build linux
14
15 package procfs
16
17 var parseCPUInfo = parseCPUInfoMips
0 // Copyright 2020 The Prometheus Authors
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12
13 // +build linux
14
15 package procfs
16
17 var parseCPUInfo = parseCPUInfoMips
0 // Copyright 2020 The Prometheus Authors
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12
13 // +build linux
14
15 package procfs
16
17 var parseCPUInfo = parseCPUInfoMips
0 // Copyright 2020 The Prometheus Authors
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12
13 // +build linux
14
15 package procfs
16
17 var parseCPUInfo = parseCPUInfoMips
0 // Copyright 2020 The Prometheus Authors
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12
13 // +build linux
14
15 package procfs
16
17 var parseCPUInfo = parseCPUInfoPPC
0 // Copyright 2020 The Prometheus Authors
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12
13 // +build linux
14
15 package procfs
16
17 var parseCPUInfo = parseCPUInfoPPC
0 // Copyright 2020 The Prometheus Authors
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12
13 // +build linux
14
15 package procfs
16
17 var parseCPUInfo = parseCPUInfoS390X
170170 Path: fixtures/proc/26231/schedstat
171171 Lines: 1
172172 411605849 93680043 79
173 Mode: 644
174 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
175 Path: fixtures/proc/26231/smaps
176 Lines: 252
177 00400000-00cb1000 r-xp 00000000 fd:01 952273 /bin/alertmanager
178 Size: 8900 kB
179 KernelPageSize: 4 kB
180 MMUPageSize: 4 kB
181 Rss: 2952 kB
182 Pss: 2952 kB
183 Shared_Clean: 0 kB
184 Shared_Dirty: 0 kB
185 Private_Clean: 2952 kB
186 Private_Dirty: 0 kB
187 Referenced: 2864 kB
188 Anonymous: 0 kB
189 LazyFree: 0 kB
190 AnonHugePages: 0 kB
191 ShmemPmdMapped: 0 kB
192 Shared_Hugetlb: 0 kB
193 Private_Hugetlb: 0 kB
194 Swap: 0 kB
195 SwapPss: 0 kB
196 Locked: 0 kB
197 VmFlags: rd ex mr mw me dw sd
198 00cb1000-016b0000 r--p 008b1000 fd:01 952273 /bin/alertmanager
199 Size: 10236 kB
200 KernelPageSize: 4 kB
201 MMUPageSize: 4 kB
202 Rss: 6152 kB
203 Pss: 6152 kB
204 Shared_Clean: 0 kB
205 Shared_Dirty: 0 kB
206 Private_Clean: 6152 kB
207 Private_Dirty: 0 kB
208 Referenced: 5308 kB
209 Anonymous: 0 kB
210 LazyFree: 0 kB
211 AnonHugePages: 0 kB
212 ShmemPmdMapped: 0 kB
213 Shared_Hugetlb: 0 kB
214 Private_Hugetlb: 0 kB
215 Swap: 0 kB
216 SwapPss: 0 kB
217 Locked: 0 kB
218 VmFlags: rd mr mw me dw sd
219 016b0000-0171a000 rw-p 012b0000 fd:01 952273 /bin/alertmanager
220 Size: 424 kB
221 KernelPageSize: 4 kB
222 MMUPageSize: 4 kB
223 Rss: 176 kB
224 Pss: 176 kB
225 Shared_Clean: 0 kB
226 Shared_Dirty: 0 kB
227 Private_Clean: 84 kB
228 Private_Dirty: 92 kB
229 Referenced: 176 kB
230 Anonymous: 92 kB
231 LazyFree: 0 kB
232 AnonHugePages: 0 kB
233 ShmemPmdMapped: 0 kB
234 Shared_Hugetlb: 0 kB
235 Private_Hugetlb: 0 kB
236 Swap: 12 kB
237 SwapPss: 12 kB
238 Locked: 0 kB
239 VmFlags: rd wr mr mw me dw ac sd
240 0171a000-0173f000 rw-p 00000000 00:00 0
241 Size: 148 kB
242 KernelPageSize: 4 kB
243 MMUPageSize: 4 kB
244 Rss: 76 kB
245 Pss: 76 kB
246 Shared_Clean: 0 kB
247 Shared_Dirty: 0 kB
248 Private_Clean: 0 kB
249 Private_Dirty: 76 kB
250 Referenced: 76 kB
251 Anonymous: 76 kB
252 LazyFree: 0 kB
253 AnonHugePages: 0 kB
254 ShmemPmdMapped: 0 kB
255 Shared_Hugetlb: 0 kB
256 Private_Hugetlb: 0 kB
257 Swap: 0 kB
258 SwapPss: 0 kB
259 Locked: 0 kB
260 VmFlags: rd wr mr mw me ac sd
261 c000000000-c000400000 rw-p 00000000 00:00 0
262 Size: 4096 kB
263 KernelPageSize: 4 kB
264 MMUPageSize: 4 kB
265 Rss: 2564 kB
266 Pss: 2564 kB
267 Shared_Clean: 0 kB
268 Shared_Dirty: 0 kB
269 Private_Clean: 20 kB
270 Private_Dirty: 2544 kB
271 Referenced: 2544 kB
272 Anonymous: 2564 kB
273 LazyFree: 0 kB
274 AnonHugePages: 0 kB
275 ShmemPmdMapped: 0 kB
276 Shared_Hugetlb: 0 kB
277 Private_Hugetlb: 0 kB
278 Swap: 1100 kB
279 SwapPss: 1100 kB
280 Locked: 0 kB
281 VmFlags: rd wr mr mw me ac sd
282 c000400000-c001600000 rw-p 00000000 00:00 0
283 Size: 18432 kB
284 KernelPageSize: 4 kB
285 MMUPageSize: 4 kB
286 Rss: 16024 kB
287 Pss: 16024 kB
288 Shared_Clean: 0 kB
289 Shared_Dirty: 0 kB
290 Private_Clean: 5864 kB
291 Private_Dirty: 10160 kB
292 Referenced: 11944 kB
293 Anonymous: 16024 kB
294 LazyFree: 5848 kB
295 AnonHugePages: 0 kB
296 ShmemPmdMapped: 0 kB
297 Shared_Hugetlb: 0 kB
298 Private_Hugetlb: 0 kB
299 Swap: 440 kB
300 SwapPss: 440 kB
301 Locked: 0 kB
302 VmFlags: rd wr mr mw me ac sd nh
303 c001600000-c004000000 rw-p 00000000 00:00 0
304 Size: 43008 kB
305 KernelPageSize: 4 kB
306 MMUPageSize: 4 kB
307 Rss: 0 kB
308 Pss: 0 kB
309 Shared_Clean: 0 kB
310 Shared_Dirty: 0 kB
311 Private_Clean: 0 kB
312 Private_Dirty: 0 kB
313 Referenced: 0 kB
314 Anonymous: 0 kB
315 LazyFree: 0 kB
316 AnonHugePages: 0 kB
317 ShmemPmdMapped: 0 kB
318 Shared_Hugetlb: 0 kB
319 Private_Hugetlb: 0 kB
320 Swap: 0 kB
321 SwapPss: 0 kB
322 Locked: 0 kB
323 VmFlags: rd wr mr mw me ac sd
324 7f0ab95ca000-7f0abbb7b000 rw-p 00000000 00:00 0
325 Size: 38596 kB
326 KernelPageSize: 4 kB
327 MMUPageSize: 4 kB
328 Rss: 1992 kB
329 Pss: 1992 kB
330 Shared_Clean: 0 kB
331 Shared_Dirty: 0 kB
332 Private_Clean: 476 kB
333 Private_Dirty: 1516 kB
334 Referenced: 1828 kB
335 Anonymous: 1992 kB
336 LazyFree: 0 kB
337 AnonHugePages: 0 kB
338 ShmemPmdMapped: 0 kB
339 Shared_Hugetlb: 0 kB
340 Private_Hugetlb: 0 kB
341 Swap: 384 kB
342 SwapPss: 384 kB
343 Locked: 0 kB
344 VmFlags: rd wr mr mw me ac sd
345 7ffc07ecf000-7ffc07ef0000 rw-p 00000000 00:00 0 [stack]
346 Size: 132 kB
347 KernelPageSize: 4 kB
348 MMUPageSize: 4 kB
349 Rss: 8 kB
350 Pss: 8 kB
351 Shared_Clean: 0 kB
352 Shared_Dirty: 0 kB
353 Private_Clean: 0 kB
354 Private_Dirty: 8 kB
355 Referenced: 8 kB
356 Anonymous: 8 kB
357 LazyFree: 0 kB
358 AnonHugePages: 0 kB
359 ShmemPmdMapped: 0 kB
360 Shared_Hugetlb: 0 kB
361 Private_Hugetlb: 0 kB
362 Swap: 4 kB
363 SwapPss: 4 kB
364 Locked: 0 kB
365 VmFlags: rd wr mr mw me gd ac
366 7ffc07f9e000-7ffc07fa1000 r--p 00000000 00:00 0 [vvar]
367 Size: 12 kB
368 KernelPageSize: 4 kB
369 MMUPageSize: 4 kB
370 Rss: 0 kB
371 Pss: 0 kB
372 Shared_Clean: 0 kB
373 Shared_Dirty: 0 kB
374 Private_Clean: 0 kB
375 Private_Dirty: 0 kB
376 Referenced: 0 kB
377 Anonymous: 0 kB
378 LazyFree: 0 kB
379 AnonHugePages: 0 kB
380 ShmemPmdMapped: 0 kB
381 Shared_Hugetlb: 0 kB
382 Private_Hugetlb: 0 kB
383 Swap: 0 kB
384 SwapPss: 0 kB
385 Locked: 0 kB
386 VmFlags: rd mr pf io de dd sd
387 7ffc07fa1000-7ffc07fa3000 r-xp 00000000 00:00 0 [vdso]
388 Size: 8 kB
389 KernelPageSize: 4 kB
390 MMUPageSize: 4 kB
391 Rss: 4 kB
392 Pss: 0 kB
393 Shared_Clean: 4 kB
394 Shared_Dirty: 0 kB
395 Private_Clean: 0 kB
396 Private_Dirty: 0 kB
397 Referenced: 4 kB
398 Anonymous: 0 kB
399 LazyFree: 0 kB
400 AnonHugePages: 0 kB
401 ShmemPmdMapped: 0 kB
402 Shared_Hugetlb: 0 kB
403 Private_Hugetlb: 0 kB
404 Swap: 0 kB
405 SwapPss: 0 kB
406 Locked: 0 kB
407 VmFlags: rd ex mr mw me de sd
408 ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
409 Size: 4 kB
410 KernelPageSize: 4 kB
411 MMUPageSize: 4 kB
412 Rss: 0 kB
413 Pss: 0 kB
414 Shared_Clean: 0 kB
415 Shared_Dirty: 0 kB
416 Private_Clean: 0 kB
417 Private_Dirty: 0 kB
418 Referenced: 0 kB
419 Anonymous: 0 kB
420 LazyFree: 0 kB
421 AnonHugePages: 0 kB
422 ShmemPmdMapped: 0 kB
423 Shared_Hugetlb: 0 kB
424 Private_Hugetlb: 0 kB
425 Swap: 0 kB
426 SwapPss: 0 kB
427 Locked: 0 kB
428 VmFlags: rd ex
429 Mode: 644
430 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
431 Path: fixtures/proc/26231/smaps_rollup
432 Lines: 17
433 00400000-ffffffffff601000 ---p 00000000 00:00 0 [rollup]
434 Rss: 29948 kB
435 Pss: 29944 kB
436 Shared_Clean: 4 kB
437 Shared_Dirty: 0 kB
438 Private_Clean: 15548 kB
439 Private_Dirty: 14396 kB
440 Referenced: 24752 kB
441 Anonymous: 20756 kB
442 LazyFree: 5848 kB
443 AnonHugePages: 0 kB
444 ShmemPmdMapped: 0 kB
445 Shared_Hugetlb: 0 kB
446 Private_Hugetlb: 0 kB
447 Swap: 1940 kB
448 SwapPss: 1940 kB
449 Locked: 0 kB
173450 Mode: 644
174451 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
175452 Path: fixtures/proc/26231/stat
234511 nonvoluntary_ctxt_switches: 1727500
235512 Mode: 644
236513 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
514 Path: fixtures/proc/26231/wchan
515 Lines: 1
516 poll_schedule_timeoutEOF
517 Mode: 664
518 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
237519 Directory: fixtures/proc/26232
238520 Mode: 755
239521 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
308590 Lines: 1
309591 33 (ata_sff) S 2 0 0 0 -1 69238880 0 0 0 0 0 0 0 0 0 -20 1 0 5 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744073709551615 0 0 17 1 0 0 0 0 0 0 0 0 0 0 0 0 0
310592 Mode: 644
593 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
594 Path: fixtures/proc/26232/wchan
595 Lines: 1
596 0EOF
597 Mode: 664
311598 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
312599 Directory: fixtures/proc/26233
313600 Mode: 755
15531840 Mode: 444
15541841 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15551842 Path: fixtures/proc/diskstats
1556 Lines: 49
1843 Lines: 52
15571844 1 0 ram0 0 0 0 0 0 0 0 0 0 0 0
15581845 1 1 ram1 0 0 0 0 0 0 0 0 0 0 0
15591846 1 2 ram2 0 0 0 0 0 0 0 0 0 0 0
16031890 8 0 sdb 326552 841 9657779 84 41822 2895 1972905 5007 0 60730 67070 68851 0 1925173784 11130
16041891 8 1 sdb1 231 3 34466 4 24 23 106 0 0 64 64 0 0 0 0
16051892 8 2 sdb2 326310 838 9622281 67 40726 2872 1972799 4924 0 58250 64567 68851 0 1925173784 11130
1893 8 0 sdc 14202 71 579164 21861 2995 1589 180500 40875 0 11628 55200 0 0 0 0 127 182
1894 8 1 sdc1 1027 0 13795 5021 2 0 4096 3 0 690 4579 0 0 0 0 0 0
1895 8 2 sdc2 13126 71 561749 16802 2830 1589 176404 40620 0 10931 50449 0 0 0 0 0 0
16061896 Mode: 664
16071897 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
16081898 Directory: fixtures/proc/fs
16091899 Mode: 755
1900 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1901 Directory: fixtures/proc/fs/fscache
1902 Mode: 755
1903 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1904 Path: fixtures/proc/fs/fscache/stats
1905 Lines: 24
1906 FS-Cache statistics
1907 Cookies: idx=3 dat=67877 spc=0
1908 Objects: alc=67473 nal=0 avl=67473 ded=388
1909 ChkAux : non=12 ok=33 upd=44 obs=55
1910 Pages : mrk=547164 unc=364577
1911 Acquire: n=67880 nul=98 noc=25 ok=67780 nbf=39 oom=26
1912 Lookups: n=67473 neg=67470 pos=58 crt=67473 tmo=85
1913 Invals : n=14 run=13
1914 Updates: n=7 nul=3 run=8
1915 Relinqs: n=394 nul=1 wcr=2 rtr=3
1916 AttrChg: n=6 ok=5 nbf=4 oom=3 run=2
1917 Allocs : n=20 ok=19 wt=18 nbf=17 int=16
1918 Allocs : ops=15 owt=14 abt=13
1919 Retrvls: n=151959 ok=82823 wt=23467 nod=69136 nbf=15 int=69 oom=43
1920 Retrvls: ops=151959 owt=42747 abt=44
1921 Stores : n=225565 ok=225565 agn=12 nbf=13 oom=14
1922 Stores : ops=69156 run=294721 pgs=225565 rxd=225565 olm=43
1923 VmScan : nos=364512 gon=2 bsy=43 can=12 wt=66
1924 Ops : pend=42753 run=221129 enq=628798 can=11 rej=88
1925 Ops : ini=377538 dfr=27 rel=377538 gc=37
1926 CacheOp: alo=1 luo=2 luc=3 gro=4
1927 CacheOp: inv=5 upo=6 dro=7 pto=8 atc=9 syn=10
1928 CacheOp: rap=11 ras=12 alp=13 als=14 wrp=15 ucp=16 dsp=17
1929 CacheEv: nsp=18 stl=19 rtr=20 cul=21EOF
1930 Mode: 644
16101931 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
16111932 Directory: fixtures/proc/fs/xfs
16121933 Mode: 755
20232344 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
20242345 Directory: fixtures/proc/sys
20252346 Mode: 775
2347 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2348 Directory: fixtures/proc/sys/kernel
2349 Mode: 775
2350 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2351 Directory: fixtures/proc/sys/kernel/random
2352 Mode: 755
2353 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2354 Path: fixtures/proc/sys/kernel/random/entropy_avail
2355 Lines: 1
2356 3943
2357 Mode: 644
2358 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2359 Path: fixtures/proc/sys/kernel/random/poolsize
2360 Lines: 1
2361 4096
2362 Mode: 644
2363 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2364 Path: fixtures/proc/sys/kernel/random/urandom_min_reseed_secs
2365 Lines: 1
2366 60
2367 Mode: 644
2368 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2369 Path: fixtures/proc/sys/kernel/random/write_wakeup_threshold
2370 Lines: 1
2371 3072
2372 Mode: 644
20262373 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
20272374 Directory: fixtures/proc/sys/vm
20282375 Mode: 775
25252872 Directory: fixtures/sys/block/sda
25262873 Mode: 775
25272874 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2875 Directory: fixtures/sys/block/sda/queue
2876 Mode: 755
2877 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2878 Path: fixtures/sys/block/sda/queue/add_random
2879 Lines: 1
2880 1
2881 Mode: 644
2882 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2883 Path: fixtures/sys/block/sda/queue/chunk_sectors
2884 Lines: 1
2885 0
2886 Mode: 444
2887 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2888 Path: fixtures/sys/block/sda/queue/dax
2889 Lines: 1
2890 0
2891 Mode: 444
2892 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2893 Path: fixtures/sys/block/sda/queue/discard_granularity
2894 Lines: 1
2895 0
2896 Mode: 444
2897 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2898 Path: fixtures/sys/block/sda/queue/discard_max_bytes
2899 Lines: 1
2900 0
2901 Mode: 644
2902 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2903 Path: fixtures/sys/block/sda/queue/discard_max_hw_bytes
2904 Lines: 1
2905 0
2906 Mode: 444
2907 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2908 Path: fixtures/sys/block/sda/queue/discard_zeroes_data
2909 Lines: 1
2910 0
2911 Mode: 444
2912 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2913 Path: fixtures/sys/block/sda/queue/fua
2914 Lines: 1
2915 0
2916 Mode: 444
2917 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2918 Path: fixtures/sys/block/sda/queue/hw_sector_size
2919 Lines: 1
2920 512
2921 Mode: 444
2922 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2923 Path: fixtures/sys/block/sda/queue/io_poll
2924 Lines: 1
2925 0
2926 Mode: 644
2927 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2928 Path: fixtures/sys/block/sda/queue/io_poll_delay
2929 Lines: 1
2930 -1
2931 Mode: 644
2932 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2933 Path: fixtures/sys/block/sda/queue/io_timeout
2934 Lines: 1
2935 30000
2936 Mode: 644
2937 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2938 Directory: fixtures/sys/block/sda/queue/iosched
2939 Mode: 755
2940 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2941 Path: fixtures/sys/block/sda/queue/iosched/back_seek_max
2942 Lines: 1
2943 16384
2944 Mode: 644
2945 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2946 Path: fixtures/sys/block/sda/queue/iosched/back_seek_penalty
2947 Lines: 1
2948 2
2949 Mode: 644
2950 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2951 Path: fixtures/sys/block/sda/queue/iosched/fifo_expire_async
2952 Lines: 1
2953 250
2954 Mode: 644
2955 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2956 Path: fixtures/sys/block/sda/queue/iosched/fifo_expire_sync
2957 Lines: 1
2958 125
2959 Mode: 644
2960 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2961 Path: fixtures/sys/block/sda/queue/iosched/low_latency
2962 Lines: 1
2963 1
2964 Mode: 644
2965 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2966 Path: fixtures/sys/block/sda/queue/iosched/max_budget
2967 Lines: 1
2968 0
2969 Mode: 644
2970 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2971 Path: fixtures/sys/block/sda/queue/iosched/slice_idle
2972 Lines: 1
2973 8
2974 Mode: 644
2975 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2976 Path: fixtures/sys/block/sda/queue/iosched/slice_idle_us
2977 Lines: 1
2978 8000
2979 Mode: 644
2980 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2981 Path: fixtures/sys/block/sda/queue/iosched/strict_guarantees
2982 Lines: 1
2983 0
2984 Mode: 644
2985 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2986 Path: fixtures/sys/block/sda/queue/iosched/timeout_sync
2987 Lines: 1
2988 125
2989 Mode: 644
2990 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2991 Path: fixtures/sys/block/sda/queue/iostats
2992 Lines: 1
2993 1
2994 Mode: 644
2995 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2996 Path: fixtures/sys/block/sda/queue/logical_block_size
2997 Lines: 1
2998 512
2999 Mode: 444
3000 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3001 Path: fixtures/sys/block/sda/queue/max_discard_segments
3002 Lines: 1
3003 1
3004 Mode: 444
3005 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3006 Path: fixtures/sys/block/sda/queue/max_hw_sectors_kb
3007 Lines: 1
3008 32767
3009 Mode: 444
3010 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3011 Path: fixtures/sys/block/sda/queue/max_integrity_segments
3012 Lines: 1
3013 0
3014 Mode: 444
3015 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3016 Path: fixtures/sys/block/sda/queue/max_sectors_kb
3017 Lines: 1
3018 1280
3019 Mode: 644
3020 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3021 Path: fixtures/sys/block/sda/queue/max_segment_size
3022 Lines: 1
3023 65536
3024 Mode: 444
3025 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3026 Path: fixtures/sys/block/sda/queue/max_segments
3027 Lines: 1
3028 168
3029 Mode: 444
3030 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3031 Path: fixtures/sys/block/sda/queue/minimum_io_size
3032 Lines: 1
3033 512
3034 Mode: 444
3035 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3036 Path: fixtures/sys/block/sda/queue/nomerges
3037 Lines: 1
3038 0
3039 Mode: 644
3040 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3041 Path: fixtures/sys/block/sda/queue/nr_requests
3042 Lines: 1
3043 64
3044 Mode: 644
3045 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3046 Path: fixtures/sys/block/sda/queue/nr_zones
3047 Lines: 1
3048 0
3049 Mode: 444
3050 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3051 Path: fixtures/sys/block/sda/queue/optimal_io_size
3052 Lines: 1
3053 0
3054 Mode: 444
3055 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3056 Path: fixtures/sys/block/sda/queue/physical_block_size
3057 Lines: 1
3058 512
3059 Mode: 444
3060 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3061 Path: fixtures/sys/block/sda/queue/read_ahead_kb
3062 Lines: 1
3063 128
3064 Mode: 644
3065 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3066 Path: fixtures/sys/block/sda/queue/rotational
3067 Lines: 1
3068 1
3069 Mode: 644
3070 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3071 Path: fixtures/sys/block/sda/queue/rq_affinity
3072 Lines: 1
3073 1
3074 Mode: 644
3075 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3076 Path: fixtures/sys/block/sda/queue/scheduler
3077 Lines: 1
3078 mq-deadline kyber [bfq] none
3079 Mode: 644
3080 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3081 Path: fixtures/sys/block/sda/queue/wbt_lat_usec
3082 Lines: 1
3083 75000
3084 Mode: 644
3085 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3086 Path: fixtures/sys/block/sda/queue/write_cache
3087 Lines: 1
3088 write back
3089 Mode: 644
3090 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3091 Path: fixtures/sys/block/sda/queue/write_same_max_bytes
3092 Lines: 1
3093 0
3094 Mode: 444
3095 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3096 Path: fixtures/sys/block/sda/queue/write_zeroes_max_bytes
3097 Lines: 1
3098 0
3099 Mode: 444
3100 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3101 Path: fixtures/sys/block/sda/queue/zoned
3102 Lines: 1
3103 none
3104 Mode: 444
3105 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25283106 Path: fixtures/sys/block/sda/stat
25293107 Lines: 1
25303108 9652963 396792 759304206 412943 8422549 6731723 286915323 13947418 0 5658367 19174573 1 2 3 12
25333111 Directory: fixtures/sys/class
25343112 Mode: 775
25353113 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3114 Directory: fixtures/sys/class/fc_host
3115 Mode: 755
3116 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3117 Directory: fixtures/sys/class/fc_host/host0
3118 Mode: 755
3119 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3120 Path: fixtures/sys/class/fc_host/host0/dev_loss_tmo
3121 Lines: 1
3122 30
3123 Mode: 644
3124 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3125 Path: fixtures/sys/class/fc_host/host0/fabric_name
3126 Lines: 1
3127 0x0
3128 Mode: 644
3129 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3130 Path: fixtures/sys/class/fc_host/host0/node_name
3131 Lines: 1
3132 0x2000e0071bce95f2
3133 Mode: 644
3134 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3135 Path: fixtures/sys/class/fc_host/host0/port_id
3136 Lines: 1
3137 0x000002
3138 Mode: 644
3139 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3140 Path: fixtures/sys/class/fc_host/host0/port_name
3141 Lines: 1
3142 0x1000e0071bce95f2
3143 Mode: 644
3144 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3145 Path: fixtures/sys/class/fc_host/host0/port_state
3146 Lines: 1
3147 Online
3148 Mode: 644
3149 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3150 Path: fixtures/sys/class/fc_host/host0/port_type
3151 Lines: 1
3152 Point-To-Point (direct nport connection)
3153 Mode: 644
3154 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3155 Path: fixtures/sys/class/fc_host/host0/speed
3156 Lines: 1
3157 16 Gbit
3158 Mode: 644
3159 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3160 Directory: fixtures/sys/class/fc_host/host0/statistics
3161 Mode: 755
3162 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3163 Path: fixtures/sys/class/fc_host/host0/statistics/dumped_frames
3164 Lines: 1
3165 0xffffffffffffffff
3166 Mode: 644
3167 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3168 Path: fixtures/sys/class/fc_host/host0/statistics/error_frames
3169 Lines: 1
3170 0x0
3171 Mode: 644
3172 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3173 Path: fixtures/sys/class/fc_host/host0/statistics/fcp_packet_aborts
3174 Lines: 1
3175 0x13
3176 Mode: 644
3177 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3178 Path: fixtures/sys/class/fc_host/host0/statistics/invalid_crc_count
3179 Lines: 1
3180 0x2
3181 Mode: 644
3182 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3183 Path: fixtures/sys/class/fc_host/host0/statistics/invalid_tx_word_count
3184 Lines: 1
3185 0x8
3186 Mode: 644
3187 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3188 Path: fixtures/sys/class/fc_host/host0/statistics/link_failure_count
3189 Lines: 1
3190 0x9
3191 Mode: 644
3192 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3193 Path: fixtures/sys/class/fc_host/host0/statistics/loss_of_signal_count
3194 Lines: 1
3195 0x11
3196 Mode: 644
3197 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3198 Path: fixtures/sys/class/fc_host/host0/statistics/loss_of_sync_count
3199 Lines: 1
3200 0x10
3201 Mode: 644
3202 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3203 Path: fixtures/sys/class/fc_host/host0/statistics/nos_count
3204 Lines: 1
3205 0x12
3206 Mode: 644
3207 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3208 Path: fixtures/sys/class/fc_host/host0/statistics/rx_frames
3209 Lines: 1
3210 0x3
3211 Mode: 644
3212 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3213 Path: fixtures/sys/class/fc_host/host0/statistics/rx_words
3214 Lines: 1
3215 0x4
3216 Mode: 644
3217 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3218 Path: fixtures/sys/class/fc_host/host0/statistics/seconds_since_last_reset
3219 Lines: 1
3220 0x7
3221 Mode: 644
3222 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3223 Path: fixtures/sys/class/fc_host/host0/statistics/tx_frames
3224 Lines: 1
3225 0x5
3226 Mode: 644
3227 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3228 Path: fixtures/sys/class/fc_host/host0/statistics/tx_words
3229 Lines: 1
3230 0x6
3231 Mode: 644
3232 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3233 Path: fixtures/sys/class/fc_host/host0/supported_classes
3234 Lines: 1
3235 Class 3
3236 Mode: 644
3237 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3238 Path: fixtures/sys/class/fc_host/host0/supported_speeds
3239 Lines: 1
3240 4 Gbit, 8 Gbit, 16 Gbit
3241 Mode: 644
3242 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3243 Path: fixtures/sys/class/fc_host/host0/symbolic_name
3244 Lines: 1
3245 Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux
3246 Mode: 644
3247 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25363248 Directory: fixtures/sys/class/infiniband
25373249 Mode: 755
25383250 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25633275 Directory: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters
25643276 Mode: 755
25653277 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3278 Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/VL15_dropped
3279 Lines: 1
3280 0
3281 Mode: 664
3282 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25663283 Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/excessive_buffer_overrun_errors
25673284 Lines: 1
25683285 0
26633380 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
26643381 Directory: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters
26653382 Mode: 755
3383 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3384 Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/VL15_dropped
3385 Lines: 1
3386 0
3387 Mode: 664
26663388 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
26673389 Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/excessive_buffer_overrun_errors
26683390 Lines: 1
31083830 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
31093831 Path: fixtures/sys/class/thermal/thermal_zone1/temp
31103832 Lines: 1
3111 44000
3833 -44000
31123834 Mode: 664
31133835 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
31143836 Path: fixtures/sys/class/thermal/thermal_zone1/type
42865008 0
42875009 Mode: 644
42885010 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5011 Path: fixtures/sys/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/bdev0/writeback_rate_debug
5012 Lines: 7
5013 rate: 1.1M/sec
5014 dirty: 20.4G
5015 target: 20.4G
5016 proportional: 427.5k
5017 integral: 790.0k
5018 change: 321.5k/sec
5019 next io: 17ms
5020 Mode: 644
5021 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
42895022 Path: fixtures/sys/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/btree_cache_size
42905023 Lines: 1
42915024 0
0 // Copyright 2019 The Prometheus Authors
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12
13 package procfs
14
15 import (
16 "bufio"
17 "bytes"
18 "fmt"
19 "io"
20 "strconv"
21 "strings"
22
23 "github.com/prometheus/procfs/internal/util"
24 )
25
26 // Fscacheinfo represents fscache statistics.
27 type Fscacheinfo struct {
28 // Number of index cookies allocated
29 IndexCookiesAllocated uint64
30 // data storage cookies allocated
31 DataStorageCookiesAllocated uint64
32 // Number of special cookies allocated
33 SpecialCookiesAllocated uint64
34 // Number of objects allocated
35 ObjectsAllocated uint64
36 // Number of object allocation failures
37 ObjectAllocationsFailure uint64
38 // Number of objects that reached the available state
39 ObjectsAvailable uint64
40 // Number of objects that reached the dead state
41 ObjectsDead uint64
42 // Number of objects that didn't have a coherency check
43 ObjectsWithoutCoherencyCheck uint64
44 // Number of objects that passed a coherency check
45 ObjectsWithCoherencyCheck uint64
46 // Number of objects that needed a coherency data update
47 ObjectsNeedCoherencyCheckUpdate uint64
48 // Number of objects that were declared obsolete
49 ObjectsDeclaredObsolete uint64
50 // Number of pages marked as being cached
51 PagesMarkedAsBeingCached uint64
52 // Number of uncache page requests seen
53 UncachePagesRequestSeen uint64
54 // Number of acquire cookie requests seen
55 AcquireCookiesRequestSeen uint64
56 // Number of acq reqs given a NULL parent
57 AcquireRequestsWithNullParent uint64
58 // Number of acq reqs rejected due to no cache available
59 AcquireRequestsRejectedNoCacheAvailable uint64
60 // Number of acq reqs succeeded
61 AcquireRequestsSucceeded uint64
62 // Number of acq reqs rejected due to error
63 AcquireRequestsRejectedDueToError uint64
64 // Number of acq reqs failed on ENOMEM
65 AcquireRequestsFailedDueToEnomem uint64
66 // Number of lookup calls made on cache backends
67 LookupsNumber uint64
68 // Number of negative lookups made
69 LookupsNegative uint64
70 // Number of positive lookups made
71 LookupsPositive uint64
72 // Number of objects created by lookup
73 ObjectsCreatedByLookup uint64
74 // Number of lookups timed out and requeued
75 LookupsTimedOutAndRequed uint64
76 InvalidationsNumber uint64
77 InvalidationsRunning uint64
78 // Number of update cookie requests seen
79 UpdateCookieRequestSeen uint64
80 // Number of upd reqs given a NULL parent
81 UpdateRequestsWithNullParent uint64
82 // Number of upd reqs granted CPU time
83 UpdateRequestsRunning uint64
84 // Number of relinquish cookie requests seen
85 RelinquishCookiesRequestSeen uint64
86 // Number of rlq reqs given a NULL parent
87 RelinquishCookiesWithNullParent uint64
88 // Number of rlq reqs waited on completion of creation
89 RelinquishRequestsWaitingCompleteCreation uint64
90 // Relinqs rtr
91 RelinquishRetries uint64
92 // Number of attribute changed requests seen
93 AttributeChangedRequestsSeen uint64
94 // Number of attr changed requests queued
95 AttributeChangedRequestsQueued uint64
96 // Number of attr changed rejected -ENOBUFS
97 AttributeChangedRejectDueToEnobufs uint64
98 // Number of attr changed failed -ENOMEM
99 AttributeChangedFailedDueToEnomem uint64
100 // Number of attr changed ops given CPU time
101 AttributeChangedOps uint64
102 // Number of allocation requests seen
103 AllocationRequestsSeen uint64
104 // Number of successful alloc reqs
105 AllocationOkRequests uint64
106 // Number of alloc reqs that waited on lookup completion
107 AllocationWaitingOnLookup uint64
108 // Number of alloc reqs rejected -ENOBUFS
109 AllocationsRejectedDueToEnobufs uint64
110 // Number of alloc reqs aborted -ERESTARTSYS
111 AllocationsAbortedDueToErestartsys uint64
112 // Number of alloc reqs submitted
113 AllocationOperationsSubmitted uint64
114 // Number of alloc reqs waited for CPU time
115 AllocationsWaitedForCPU uint64
116 // Number of alloc reqs aborted due to object death
117 AllocationsAbortedDueToObjectDeath uint64
118 // Number of retrieval (read) requests seen
119 RetrievalsReadRequests uint64
120 // Number of successful retr reqs
121 RetrievalsOk uint64
122 // Number of retr reqs that waited on lookup completion
123 RetrievalsWaitingLookupCompletion uint64
124 // Number of retr reqs returned -ENODATA
125 RetrievalsReturnedEnodata uint64
126 // Number of retr reqs rejected -ENOBUFS
127 RetrievalsRejectedDueToEnobufs uint64
128 // Number of retr reqs aborted -ERESTARTSYS
129 RetrievalsAbortedDueToErestartsys uint64
130 // Number of retr reqs failed -ENOMEM
131 RetrievalsFailedDueToEnomem uint64
132 // Number of retr reqs submitted
133 RetrievalsRequests uint64
134 // Number of retr reqs waited for CPU time
135 RetrievalsWaitingCPU uint64
136 // Number of retr reqs aborted due to object death
137 RetrievalsAbortedDueToObjectDeath uint64
138 // Number of storage (write) requests seen
139 StoreWriteRequests uint64
140 // Number of successful store reqs
141 StoreSuccessfulRequests uint64
142 // Number of store reqs on a page already pending storage
143 StoreRequestsOnPendingStorage uint64
144 // Number of store reqs rejected -ENOBUFS
145 StoreRequestsRejectedDueToEnobufs uint64
146 // Number of store reqs failed -ENOMEM
147 StoreRequestsFailedDueToEnomem uint64
148 // Number of store reqs submitted
149 StoreRequestsSubmitted uint64
150 // Number of store reqs granted CPU time
151 StoreRequestsRunning uint64
152 // Number of pages given store req processing time
153 StorePagesWithRequestsProcessing uint64
154 // Number of store reqs deleted from tracking tree
155 StoreRequestsDeleted uint64
156 // Number of store reqs over store limit
157 StoreRequestsOverStoreLimit uint64
158 // Number of release reqs against pages with no pending store
159 ReleaseRequestsAgainstPagesWithNoPendingStorage uint64
160 // Number of release reqs against pages stored by time lock granted
161 ReleaseRequestsAgainstPagesStoredByTimeLockGranted uint64
162 // Number of release reqs ignored due to in-progress store
163 ReleaseRequestsIgnoredDueToInProgressStore uint64
164 // Number of page stores cancelled due to release req
165 PageStoresCancelledByReleaseRequests uint64
166 VmscanWaiting uint64
167 // Number of times async ops added to pending queues
168 OpsPending uint64
169 // Number of times async ops given CPU time
170 OpsRunning uint64
171 // Number of times async ops queued for processing
172 OpsEnqueued uint64
173 // Number of async ops cancelled
174 OpsCancelled uint64
175 // Number of async ops rejected due to object lookup/create failure
176 OpsRejected uint64
177 // Number of async ops initialised
178 OpsInitialised uint64
179 // Number of async ops queued for deferred release
180 OpsDeferred uint64
181 // Number of async ops released (should equal ini=N when idle)
182 OpsReleased uint64
183 // Number of deferred-release async ops garbage collected
184 OpsGarbageCollected uint64
185 // Number of in-progress alloc_object() cache ops
186 CacheopAllocationsinProgress uint64
187 // Number of in-progress lookup_object() cache ops
188 CacheopLookupObjectInProgress uint64
189 // Number of in-progress lookup_complete() cache ops
190 CacheopLookupCompleteInPorgress uint64
191 // Number of in-progress grab_object() cache ops
192 CacheopGrabObjectInProgress uint64
193 CacheopInvalidations uint64
194 // Number of in-progress update_object() cache ops
195 CacheopUpdateObjectInProgress uint64
196 // Number of in-progress drop_object() cache ops
197 CacheopDropObjectInProgress uint64
198 // Number of in-progress put_object() cache ops
199 CacheopPutObjectInProgress uint64
200 // Number of in-progress attr_changed() cache ops
201 CacheopAttributeChangeInProgress uint64
202 // Number of in-progress sync_cache() cache ops
203 CacheopSyncCacheInProgress uint64
204 // Number of in-progress read_or_alloc_page() cache ops
205 CacheopReadOrAllocPageInProgress uint64
206 // Number of in-progress read_or_alloc_pages() cache ops
207 CacheopReadOrAllocPagesInProgress uint64
208 // Number of in-progress allocate_page() cache ops
209 CacheopAllocatePageInProgress uint64
210 // Number of in-progress allocate_pages() cache ops
211 CacheopAllocatePagesInProgress uint64
212 // Number of in-progress write_page() cache ops
213 CacheopWritePagesInProgress uint64
214 // Number of in-progress uncache_page() cache ops
215 CacheopUncachePagesInProgress uint64
216 // Number of in-progress dissociate_pages() cache ops
217 CacheopDissociatePagesInProgress uint64
218 // Number of object lookups/creations rejected due to lack of space
219 CacheevLookupsAndCreationsRejectedLackSpace uint64
220 // Number of stale objects deleted
221 CacheevStaleObjectsDeleted uint64
222 // Number of objects retired when relinquished
223 CacheevRetiredWhenReliquished uint64
224 // Number of objects culled
225 CacheevObjectsCulled uint64
226 }
227
228 // Fscacheinfo returns information about current fscache statistics.
229 // See https://www.kernel.org/doc/Documentation/filesystems/caching/fscache.txt
230 func (fs FS) Fscacheinfo() (Fscacheinfo, error) {
231 b, err := util.ReadFileNoStat(fs.proc.Path("fs/fscache/stats"))
232 if err != nil {
233 return Fscacheinfo{}, err
234 }
235
236 m, err := parseFscacheinfo(bytes.NewReader(b))
237 if err != nil {
238 return Fscacheinfo{}, fmt.Errorf("failed to parse Fscacheinfo: %v", err)
239 }
240
241 return *m, nil
242 }
243
244 func setFSCacheFields(fields []string, setFields ...*uint64) error {
245 var err error
246 if len(fields) < len(setFields) {
247 return fmt.Errorf("Insufficient number of fields, expected %v, got %v", len(setFields), len(fields))
248 }
249
250 for i := range setFields {
251 *setFields[i], err = strconv.ParseUint(strings.Split(fields[i], "=")[1], 0, 64)
252 if err != nil {
253 return err
254 }
255 }
256 return nil
257 }
258
259 func parseFscacheinfo(r io.Reader) (*Fscacheinfo, error) {
260 var m Fscacheinfo
261 s := bufio.NewScanner(r)
262 for s.Scan() {
263 fields := strings.Fields(s.Text())
264 if len(fields) < 2 {
265 return nil, fmt.Errorf("malformed Fscacheinfo line: %q", s.Text())
266 }
267
268 switch fields[0] {
269 case "Cookies:":
270 err := setFSCacheFields(fields[1:], &m.IndexCookiesAllocated, &m.DataStorageCookiesAllocated,
271 &m.SpecialCookiesAllocated)
272 if err != nil {
273 return &m, err
274 }
275 case "Objects:":
276 err := setFSCacheFields(fields[1:], &m.ObjectsAllocated, &m.ObjectAllocationsFailure,
277 &m.ObjectsAvailable, &m.ObjectsDead)
278 if err != nil {
279 return &m, err
280 }
281 case "ChkAux":
282 err := setFSCacheFields(fields[2:], &m.ObjectsWithoutCoherencyCheck, &m.ObjectsWithCoherencyCheck,
283 &m.ObjectsNeedCoherencyCheckUpdate, &m.ObjectsDeclaredObsolete)
284 if err != nil {
285 return &m, err
286 }
287 case "Pages":
288 err := setFSCacheFields(fields[2:], &m.PagesMarkedAsBeingCached, &m.UncachePagesRequestSeen)
289 if err != nil {
290 return &m, err
291 }
292 case "Acquire:":
293 err := setFSCacheFields(fields[1:], &m.AcquireCookiesRequestSeen, &m.AcquireRequestsWithNullParent,
294 &m.AcquireRequestsRejectedNoCacheAvailable, &m.AcquireRequestsSucceeded, &m.AcquireRequestsRejectedDueToError,
295 &m.AcquireRequestsFailedDueToEnomem)
296 if err != nil {
297 return &m, err
298 }
299 case "Lookups:":
300 err := setFSCacheFields(fields[1:], &m.LookupsNumber, &m.LookupsNegative, &m.LookupsPositive,
301 &m.ObjectsCreatedByLookup, &m.LookupsTimedOutAndRequed)
302 if err != nil {
303 return &m, err
304 }
305 case "Invals":
306 err := setFSCacheFields(fields[2:], &m.InvalidationsNumber, &m.InvalidationsRunning)
307 if err != nil {
308 return &m, err
309 }
310 case "Updates:":
311 err := setFSCacheFields(fields[1:], &m.UpdateCookieRequestSeen, &m.UpdateRequestsWithNullParent,
312 &m.UpdateRequestsRunning)
313 if err != nil {
314 return &m, err
315 }
316 case "Relinqs:":
317 err := setFSCacheFields(fields[1:], &m.RelinquishCookiesRequestSeen, &m.RelinquishCookiesWithNullParent,
318 &m.RelinquishRequestsWaitingCompleteCreation, &m.RelinquishRetries)
319 if err != nil {
320 return &m, err
321 }
322 case "AttrChg:":
323 err := setFSCacheFields(fields[1:], &m.AttributeChangedRequestsSeen, &m.AttributeChangedRequestsQueued,
324 &m.AttributeChangedRejectDueToEnobufs, &m.AttributeChangedFailedDueToEnomem, &m.AttributeChangedOps)
325 if err != nil {
326 return &m, err
327 }
328 case "Allocs":
329 if strings.Split(fields[2], "=")[0] == "n" {
330 err := setFSCacheFields(fields[2:], &m.AllocationRequestsSeen, &m.AllocationOkRequests,
331 &m.AllocationWaitingOnLookup, &m.AllocationsRejectedDueToEnobufs, &m.AllocationsAbortedDueToErestartsys)
332 if err != nil {
333 return &m, err
334 }
335 } else {
336 err := setFSCacheFields(fields[2:], &m.AllocationOperationsSubmitted, &m.AllocationsWaitedForCPU,
337 &m.AllocationsAbortedDueToObjectDeath)
338 if err != nil {
339 return &m, err
340 }
341 }
342 case "Retrvls:":
343 if strings.Split(fields[1], "=")[0] == "n" {
344 err := setFSCacheFields(fields[1:], &m.RetrievalsReadRequests, &m.RetrievalsOk, &m.RetrievalsWaitingLookupCompletion,
345 &m.RetrievalsReturnedEnodata, &m.RetrievalsRejectedDueToEnobufs, &m.RetrievalsAbortedDueToErestartsys,
346 &m.RetrievalsFailedDueToEnomem)
347 if err != nil {
348 return &m, err
349 }
350 } else {
351 err := setFSCacheFields(fields[1:], &m.RetrievalsRequests, &m.RetrievalsWaitingCPU, &m.RetrievalsAbortedDueToObjectDeath)
352 if err != nil {
353 return &m, err
354 }
355 }
356 case "Stores":
357 if strings.Split(fields[2], "=")[0] == "n" {
358 err := setFSCacheFields(fields[2:], &m.StoreWriteRequests, &m.StoreSuccessfulRequests,
359 &m.StoreRequestsOnPendingStorage, &m.StoreRequestsRejectedDueToEnobufs, &m.StoreRequestsFailedDueToEnomem)
360 if err != nil {
361 return &m, err
362 }
363 } else {
364 err := setFSCacheFields(fields[2:], &m.StoreRequestsSubmitted, &m.StoreRequestsRunning,
365 &m.StorePagesWithRequestsProcessing, &m.StoreRequestsDeleted, &m.StoreRequestsOverStoreLimit)
366 if err != nil {
367 return &m, err
368 }
369 }
370 case "VmScan":
371 err := setFSCacheFields(fields[2:], &m.ReleaseRequestsAgainstPagesWithNoPendingStorage,
372 &m.ReleaseRequestsAgainstPagesStoredByTimeLockGranted, &m.ReleaseRequestsIgnoredDueToInProgressStore,
373 &m.PageStoresCancelledByReleaseRequests, &m.VmscanWaiting)
374 if err != nil {
375 return &m, err
376 }
377 case "Ops":
378 if strings.Split(fields[2], "=")[0] == "pend" {
379 err := setFSCacheFields(fields[2:], &m.OpsPending, &m.OpsRunning, &m.OpsEnqueued, &m.OpsCancelled, &m.OpsRejected)
380 if err != nil {
381 return &m, err
382 }
383 } else {
384 err := setFSCacheFields(fields[2:], &m.OpsInitialised, &m.OpsDeferred, &m.OpsReleased, &m.OpsGarbageCollected)
385 if err != nil {
386 return &m, err
387 }
388 }
389 case "CacheOp:":
390 if strings.Split(fields[1], "=")[0] == "alo" {
391 err := setFSCacheFields(fields[1:], &m.CacheopAllocationsinProgress, &m.CacheopLookupObjectInProgress,
392 &m.CacheopLookupCompleteInPorgress, &m.CacheopGrabObjectInProgress)
393 if err != nil {
394 return &m, err
395 }
396 } else if strings.Split(fields[1], "=")[0] == "inv" {
397 err := setFSCacheFields(fields[1:], &m.CacheopInvalidations, &m.CacheopUpdateObjectInProgress,
398 &m.CacheopDropObjectInProgress, &m.CacheopPutObjectInProgress, &m.CacheopAttributeChangeInProgress,
399 &m.CacheopSyncCacheInProgress)
400 if err != nil {
401 return &m, err
402 }
403 } else {
404 err := setFSCacheFields(fields[1:], &m.CacheopReadOrAllocPageInProgress, &m.CacheopReadOrAllocPagesInProgress,
405 &m.CacheopAllocatePageInProgress, &m.CacheopAllocatePagesInProgress, &m.CacheopWritePagesInProgress,
406 &m.CacheopUncachePagesInProgress, &m.CacheopDissociatePagesInProgress)
407 if err != nil {
408 return &m, err
409 }
410 }
411 case "CacheEv:":
412 err := setFSCacheFields(fields[1:], &m.CacheevLookupsAndCreationsRejectedLackSpace, &m.CacheevStaleObjectsDeleted,
413 &m.CacheevRetiredWhenReliquished, &m.CacheevObjectsCulled)
414 if err != nil {
415 return &m, err
416 }
417 }
418 }
419
420 return &m, nil
421 }
7272 return strconv.ParseUint(strings.TrimSpace(string(data)), 10, 64)
7373 }
7474
75 // ReadIntFromFile reads a file and attempts to parse a int64 from it.
76 func ReadIntFromFile(path string) (int64, error) {
77 data, err := ioutil.ReadFile(path)
78 if err != nil {
79 return 0, err
80 }
81 return strconv.ParseInt(strings.TrimSpace(string(data)), 10, 64)
82 }
83
7584 // ParseBool parses a string into a boolean pointer.
7685 func ParseBool(b string) *bool {
7786 var truth bool
0 // Copyright 2020 The Prometheus Authors
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12
13 // +build !windows
14
15 package procfs
16
17 import (
18 "os"
19
20 "github.com/prometheus/procfs/internal/util"
21 )
22
23 // KernelRandom contains information about to the kernel's random number generator.
24 type KernelRandom struct {
25 // EntropyAvaliable gives the available entropy, in bits.
26 EntropyAvaliable *uint64
27 // PoolSize gives the size of the entropy pool, in bytes.
28 PoolSize *uint64
29 // URandomMinReseedSeconds is the number of seconds after which the DRNG will be reseeded.
30 URandomMinReseedSeconds *uint64
31 // WriteWakeupThreshold the number of bits of entropy below which we wake up processes
32 // that do a select(2) or poll(2) for write access to /dev/random.
33 WriteWakeupThreshold *uint64
34 // ReadWakeupThreshold is the number of bits of entropy required for waking up processes that sleep
35 // waiting for entropy from /dev/random.
36 ReadWakeupThreshold *uint64
37 }
38
39 // KernelRandom returns values from /proc/sys/kernel/random.
40 func (fs FS) KernelRandom() (KernelRandom, error) {
41 random := KernelRandom{}
42
43 for file, p := range map[string]**uint64{
44 "entropy_avail": &random.EntropyAvaliable,
45 "poolsize": &random.PoolSize,
46 "urandom_min_reseed_secs": &random.URandomMinReseedSeconds,
47 "write_wakeup_threshold": &random.WriteWakeupThreshold,
48 "read_wakeup_threshold": &random.ReadWakeupThreshold,
49 } {
50 val, err := util.ReadUintFromFile(fs.proc.Path("sys", "kernel", "random", file))
51 if os.IsNotExist(err) {
52 continue
53 }
54 if err != nil {
55 return random, err
56 }
57 *p = &val
58 }
59
60 return random, nil
61 }
5151 func (fs FS) MDStat() ([]MDStat, error) {
5252 data, err := ioutil.ReadFile(fs.proc.Path("mdstat"))
5353 if err != nil {
54 return nil, fmt.Errorf("error parsing mdstat %s: %s", fs.proc.Path("mdstat"), err)
54 return nil, err
5555 }
5656 mdstat, err := parseMDStat(data)
5757 if err != nil {
7676
7777 mountInfo := strings.Split(mountString, " ")
7878 mountInfoLength := len(mountInfo)
79 if mountInfoLength < 11 {
79 if mountInfoLength < 10 {
8080 return nil, fmt.Errorf("couldn't find enough fields in mount string: %s", mountString)
8181 }
8282
143143 return optionalFields, nil
144144 }
145145
146 // Parses the mount options, superblock options.
146 // mountOptionsParser parses the mount options, superblock options.
147147 func mountOptionsParser(mountOptions string) map[string]string {
148148 opts := make(map[string]string)
149149 options := strings.Split(mountOptions, ",")
160160 return opts
161161 }
162162
163 // Retrieves mountinfo information from `/proc/self/mountinfo`.
163 // GetMounts retrieves mountinfo information from `/proc/self/mountinfo`.
164164 func GetMounts() ([]*MountInfo, error) {
165165 data, err := util.ReadFileNoStat("/proc/self/mountinfo")
166166 if err != nil {
169169 return parseMountInfo(data)
170170 }
171171
172 // Retrieves mountinfo information from a processes' `/proc/<pid>/mountinfo`.
172 // GetProcMounts retrieves mountinfo information from a processes' `/proc/<pid>/mountinfo`.
173173 func GetProcMounts(pid int) ([]*MountInfo, error) {
174174 data, err := util.ReadFileNoStat(fmt.Sprintf("/proc/%d/mountinfo", pid))
175175 if err != nil {
185185 CumulativeTotalResponseMilliseconds uint64
186186 // Duration from when a request was enqueued to when it was completely handled.
187187 CumulativeTotalRequestMilliseconds uint64
188 // The count of operations that complete with tk_status < 0. These statuses usually indicate error conditions.
189 Errors uint64
188190 }
189191
190192 // A NFSTransportStats contains statistics for the NFS mount RPC requests and
493495 // line is reached.
494496 func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) {
495497 const (
496 // Number of expected fields in each per-operation statistics set
497 numFields = 9
498 // Minimum number of expected fields in each per-operation statistics set
499 minFields = 9
498500 )
499501
500502 var ops []NFSOperationStats
507509 break
508510 }
509511
510 if len(ss) != numFields {
512 if len(ss) < minFields {
511513 return nil, fmt.Errorf("invalid NFS per-operations stats: %v", ss)
512514 }
513515
514516 // Skip string operation name for integers
515 ns := make([]uint64, 0, numFields-1)
517 ns := make([]uint64, 0, minFields-1)
516518 for _, st := range ss[1:] {
517519 n, err := strconv.ParseUint(st, 10, 64)
518520 if err != nil {
522524 ns = append(ns, n)
523525 }
524526
525 ops = append(ops, NFSOperationStats{
527 opStats := NFSOperationStats{
526528 Operation: strings.TrimSuffix(ss[0], ":"),
527529 Requests: ns[0],
528530 Transmissions: ns[1],
532534 CumulativeQueueMilliseconds: ns[5],
533535 CumulativeTotalResponseMilliseconds: ns[6],
534536 CumulativeTotalRequestMilliseconds: ns[7],
535 })
537 }
538
539 if len(ns) > 8 {
540 opStats.Errors = ns[8]
541 }
542
543 ops = append(ops, opStats)
536544 }
537545
538546 return ops, s.Err()
3737 SearchRestart uint64
3838 }
3939
40 // Retrieves netfilter's conntrack statistics, split by CPU cores
40 // ConntrackStat retrieves netfilter's conntrack statistics, split by CPU cores
4141 func (fs FS) ConntrackStat() ([]ConntrackStatEntry, error) {
4242 return readConntrackStat(fs.proc.Path("net", "stat", "nf_conntrack"))
4343 }
133133 return strings.Split(string(bytes.TrimRight(data, string("\x00"))), string(byte(0))), nil
134134 }
135135
136 // Wchan returns the wchan (wait channel) of a process.
137 func (p Proc) Wchan() (string, error) {
138 f, err := os.Open(p.path("wchan"))
139 if err != nil {
140 return "", err
141 }
142 defer f.Close()
143
144 data, err := ioutil.ReadAll(f)
145 if err != nil {
146 return "", err
147 }
148
149 wchan := string(data)
150 if wchan == "" || wchan == "0" {
151 return "", nil
152 }
153
154 return wchan, nil
155 }
156
136157 // Comm returns the command name of a process.
137158 func (p Proc) Comm() (string, error) {
138159 data, err := util.ReadFileNoStat(p.path("comm"))
0 // Copyright 2020 The Prometheus Authors
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12
13 package procfs
14
15 import (
16 "bufio"
17 "bytes"
18 "fmt"
19 "strconv"
20 "strings"
21
22 "github.com/prometheus/procfs/internal/util"
23 )
24
25 // Cgroup models one line from /proc/[pid]/cgroup. Each Cgroup struct describes the the placement of a PID inside a
26 // specific control hierarchy. The kernel has two cgroup APIs, v1 and v2. v1 has one hierarchy per available resource
27 // controller, while v2 has one unified hierarchy shared by all controllers. Regardless of v1 or v2, all hierarchies
28 // contain all running processes, so the question answerable with a Cgroup struct is 'where is this process in
29 // this hierarchy' (where==what path on the specific cgroupfs). By prefixing this path with the mount point of
30 // *this specific* hierarchy, you can locate the relevant pseudo-files needed to read/set the data for this PID
31 // in this hierarchy
32 //
33 // Also see http://man7.org/linux/man-pages/man7/cgroups.7.html
34 type Cgroup struct {
35 // HierarchyID that can be matched to a named hierarchy using /proc/cgroups. Cgroups V2 only has one
36 // hierarchy, so HierarchyID is always 0. For cgroups v1 this is a unique ID number
37 HierarchyID int
38 // Controllers using this hierarchy of processes. Controllers are also known as subsystems. For
39 // Cgroups V2 this may be empty, as all active controllers use the same hierarchy
40 Controllers []string
41 // Path of this control group, relative to the mount point of the cgroupfs representing this specific
42 // hierarchy
43 Path string
44 }
45
46 // parseCgroupString parses each line of the /proc/[pid]/cgroup file
47 // Line format is hierarchyID:[controller1,controller2]:path
48 func parseCgroupString(cgroupStr string) (*Cgroup, error) {
49 var err error
50
51 fields := strings.Split(cgroupStr, ":")
52 if len(fields) < 3 {
53 return nil, fmt.Errorf("at least 3 fields required, found %d fields in cgroup string: %s", len(fields), cgroupStr)
54 }
55
56 cgroup := &Cgroup{
57 Path: fields[2],
58 Controllers: nil,
59 }
60 cgroup.HierarchyID, err = strconv.Atoi(fields[0])
61 if err != nil {
62 return nil, fmt.Errorf("failed to parse hierarchy ID")
63 }
64 if fields[1] != "" {
65 ssNames := strings.Split(fields[1], ",")
66 cgroup.Controllers = append(cgroup.Controllers, ssNames...)
67 }
68 return cgroup, nil
69 }
70
71 // parseCgroups reads each line of the /proc/[pid]/cgroup file
72 func parseCgroups(data []byte) ([]Cgroup, error) {
73 var cgroups []Cgroup
74 scanner := bufio.NewScanner(bytes.NewReader(data))
75 for scanner.Scan() {
76 mountString := scanner.Text()
77 parsedMounts, err := parseCgroupString(mountString)
78 if err != nil {
79 return nil, err
80 }
81 cgroups = append(cgroups, *parsedMounts)
82 }
83
84 err := scanner.Err()
85 return cgroups, err
86 }
87
88 // Cgroups reads from /proc/<pid>/cgroups and returns a []*Cgroup struct locating this PID in each process
89 // control hierarchy running on this system. On every system (v1 and v2), all hierarchies contain all processes,
90 // so the len of the returned struct is equal to the number of active hierarchies on this system
91 func (p Proc) Cgroups() ([]Cgroup, error) {
92 data, err := util.ReadFileNoStat(fmt.Sprintf("/proc/%d/cgroup", p.PID))
93 if err != nil {
94 return nil, err
95 }
96 return parseCgroups(data)
97 }
4040 Flags string
4141 // Mount point ID
4242 MntID string
43 // List of inotify lines (structed) in the fdinfo file (kernel 3.8+ only)
43 // List of inotify lines (structured) in the fdinfo file (kernel 3.8+ only)
4444 InotifyInfos []InotifyInfo
4545 }
4646
1010 // See the License for the specific language governing permissions and
1111 // limitations under the License.
1212
13 // +build !windows
13 // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
1414
1515 package procfs
1616
2424 "golang.org/x/sys/unix"
2525 )
2626
27 // ProcMapPermissions contains permission settings read from /proc/[pid]/maps
2728 type ProcMapPermissions struct {
2829 // mapping has the [R]ead flag set
2930 Read bool
0 // Copyright 2020 The Prometheus Authors
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12
13 // +build !windows
14
15 package procfs
16
17 import (
18 "bufio"
19 "errors"
20 "fmt"
21 "os"
22 "regexp"
23 "strconv"
24 "strings"
25
26 "github.com/prometheus/procfs/internal/util"
27 )
28
29 var (
30 // match the header line before each mapped zone in /proc/pid/smaps
31 procSMapsHeaderLine = regexp.MustCompile(`^[a-f0-9].*$`)
32 )
33
34 type ProcSMapsRollup struct {
35 // Amount of the mapping that is currently resident in RAM
36 Rss uint64
37 // Process's proportional share of this mapping
38 Pss uint64
39 // Size in bytes of clean shared pages
40 SharedClean uint64
41 // Size in bytes of dirty shared pages
42 SharedDirty uint64
43 // Size in bytes of clean private pages
44 PrivateClean uint64
45 // Size in bytes of dirty private pages
46 PrivateDirty uint64
47 // Amount of memory currently marked as referenced or accessed
48 Referenced uint64
49 // Amount of memory that does not belong to any file
50 Anonymous uint64
51 // Amount would-be-anonymous memory currently on swap
52 Swap uint64
53 // Process's proportional memory on swap
54 SwapPss uint64
55 }
56
57 // ProcSMapsRollup reads from /proc/[pid]/smaps_rollup to get summed memory information of the
58 // process.
59 //
60 // If smaps_rollup does not exists (require kernel >= 4.15), the content of /proc/pid/smaps will
61 // we read and summed.
62 func (p Proc) ProcSMapsRollup() (ProcSMapsRollup, error) {
63 data, err := util.ReadFileNoStat(p.path("smaps_rollup"))
64 if err != nil && os.IsNotExist(err) {
65 return p.procSMapsRollupManual()
66 }
67 if err != nil {
68 return ProcSMapsRollup{}, err
69 }
70
71 lines := strings.Split(string(data), "\n")
72 smaps := ProcSMapsRollup{}
73
74 // skip first line which don't contains information we need
75 lines = lines[1:]
76 for _, line := range lines {
77 if line == "" {
78 continue
79 }
80
81 if err := smaps.parseLine(line); err != nil {
82 return ProcSMapsRollup{}, err
83 }
84 }
85
86 return smaps, nil
87 }
88
89 // Read /proc/pid/smaps and do the roll-up in Go code.
90 func (p Proc) procSMapsRollupManual() (ProcSMapsRollup, error) {
91 file, err := os.Open(p.path("smaps"))
92 if err != nil {
93 return ProcSMapsRollup{}, err
94 }
95 defer file.Close()
96
97 smaps := ProcSMapsRollup{}
98 scan := bufio.NewScanner(file)
99
100 for scan.Scan() {
101 line := scan.Text()
102
103 if procSMapsHeaderLine.MatchString(line) {
104 continue
105 }
106
107 if err := smaps.parseLine(line); err != nil {
108 return ProcSMapsRollup{}, err
109 }
110 }
111
112 return smaps, nil
113 }
114
115 func (s *ProcSMapsRollup) parseLine(line string) error {
116 kv := strings.SplitN(line, ":", 2)
117 if len(kv) != 2 {
118 fmt.Println(line)
119 return errors.New("invalid net/dev line, missing colon")
120 }
121
122 k := kv[0]
123 if k == "VmFlags" {
124 return nil
125 }
126
127 v := strings.TrimSpace(kv[1])
128 v = strings.TrimRight(v, " kB")
129
130 vKBytes, err := strconv.ParseUint(v, 10, 64)
131 if err != nil {
132 return err
133 }
134 vBytes := vKBytes * 1024
135
136 s.addValue(k, v, vKBytes, vBytes)
137
138 return nil
139 }
140
141 func (s *ProcSMapsRollup) addValue(k string, vString string, vUint uint64, vUintBytes uint64) {
142 switch k {
143 case "Rss":
144 s.Rss += vUintBytes
145 case "Pss":
146 s.Pss += vUintBytes
147 case "Shared_Clean":
148 s.SharedClean += vUintBytes
149 case "Shared_Dirty":
150 s.SharedDirty += vUintBytes
151 case "Private_Clean":
152 s.PrivateClean += vUintBytes
153 case "Private_Dirty":
154 s.PrivateDirty += vUintBytes
155 case "Referenced":
156 s.Referenced += vUintBytes
157 case "Anonymous":
158 s.Anonymous += vUintBytes
159 case "Swap":
160 s.Swap += vUintBytes
161 case "SwapPss":
162 s.SwapPss += vUintBytes
163 }
164 }
0 // Copyright 2020 The Go Authors. All rights reserved.
1 // Use of this source code is governed by a BSD-style
2 // license that can be found in the LICENSE file.
3
4 // Package unsafeheader contains header declarations for the Go runtime's
5 // slice and string implementations.
6 //
7 // This package allows x/sys to use types equivalent to
8 // reflect.SliceHeader and reflect.StringHeader without introducing
9 // a dependency on the (relatively heavy) "reflect" package.
10 package unsafeheader
11
12 import (
13 "unsafe"
14 )
15
16 // Slice is the runtime representation of a slice.
17 // It cannot be used safely or portably and its representation may change in a later release.
18 type Slice struct {
19 Data unsafe.Pointer
20 Len int
21 Cap int
22 }
23
24 // String is the runtime representation of a string.
25 // It cannot be used safely or portably and its representation may change in a later release.
26 type String struct {
27 Data unsafe.Pointer
28 Len int
29 }
186186 #include <sys/select.h>
187187 #include <sys/signalfd.h>
188188 #include <sys/socket.h>
189 #include <sys/timerfd.h>
189190 #include <sys/uio.h>
190191 #include <sys/xattr.h>
191192 #include <linux/bpf.h>
479480 $2 ~ /^(MS|MNT|UMOUNT)_/ ||
480481 $2 ~ /^NS_GET_/ ||
481482 $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
482 $2 ~ /^(O|F|[ES]?FD|NAME|S|PTRACE|PT)_/ ||
483 $2 ~ /^(O|F|[ES]?FD|NAME|S|PTRACE|PT|TFD)_/ ||
483484 $2 ~ /^KEXEC_/ ||
484485 $2 ~ /^LINUX_REBOOT_CMD_/ ||
485486 $2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
55
66 package unix
77
8 import "unsafe"
8 import (
9 "unsafe"
10
11 "golang.org/x/sys/internal/unsafeheader"
12 )
913
1014 //sys closedir(dir uintptr) (err error)
1115 //sys readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno)
7074 cnt++
7175 continue
7276 }
77
7378 reclen := int(entry.Reclen)
7479 if reclen > len(buf) {
7580 // Not enough room. Return for now.
7883 // restarting is O(n^2) in the length of the directory. Oh well.
7984 break
8085 }
86
8187 // Copy entry into return buffer.
82 s := struct {
83 ptr unsafe.Pointer
84 siz int
85 cap int
86 }{ptr: unsafe.Pointer(&entry), siz: reclen, cap: reclen}
87 copy(buf, *(*[]byte)(unsafe.Pointer(&s)))
88 var s []byte
89 hdr := (*unsafeheader.Slice)(unsafe.Pointer(&s))
90 hdr.Data = unsafe.Pointer(&entry)
91 hdr.Cap = reclen
92 hdr.Len = reclen
93 copy(buf, s)
94
8895 buf = buf[reclen:]
8996 n += reclen
9097 cnt++
422422 //sysnb Getrlimit(which int, lim *Rlimit) (err error)
423423 //sysnb Getrusage(who int, rusage *Rusage) (err error)
424424 //sysnb Getsid(pid int) (sid int, err error)
425 //sysnb Gettimeofday(tp *Timeval) (err error)
425426 //sysnb Getuid() (uid int)
426427 //sysnb Issetugid() (tainted bool)
427428 //sys Kqueue() (fd int, err error)
1717
1818 func setTimeval(sec, usec int64) Timeval {
1919 return Timeval{Sec: int32(sec), Usec: int32(usec)}
20 }
21
22 //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
23 func Gettimeofday(tv *Timeval) (err error) {
24 // The tv passed to gettimeofday must be non-nil
25 // but is otherwise unused. The answers come back
26 // in the two registers.
27 sec, usec, err := gettimeofday(tv)
28 tv.Sec = int32(sec)
29 tv.Usec = int32(usec)
30 return err
3120 }
3221
3322 func SetKevent(k *Kevent_t, fd, mode, flags int) {
1717
1818 func setTimeval(sec, usec int64) Timeval {
1919 return Timeval{Sec: sec, Usec: int32(usec)}
20 }
21
22 //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
23 func Gettimeofday(tv *Timeval) (err error) {
24 // The tv passed to gettimeofday must be non-nil
25 // but is otherwise unused. The answers come back
26 // in the two registers.
27 sec, usec, err := gettimeofday(tv)
28 tv.Sec = sec
29 tv.Usec = usec
30 return err
3120 }
3221
3322 func SetKevent(k *Kevent_t, fd, mode, flags int) {
1717
1818 func setTimeval(sec, usec int64) Timeval {
1919 return Timeval{Sec: int32(sec), Usec: int32(usec)}
20 }
21
22 //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
23 func Gettimeofday(tv *Timeval) (err error) {
24 // The tv passed to gettimeofday must be non-nil
25 // but is otherwise unused. The answers come back
26 // in the two registers.
27 sec, usec, err := gettimeofday(tv)
28 tv.Sec = int32(sec)
29 tv.Usec = int32(usec)
30 return err
3120 }
3221
3322 func SetKevent(k *Kevent_t, fd, mode, flags int) {
1919
2020 func setTimeval(sec, usec int64) Timeval {
2121 return Timeval{Sec: sec, Usec: int32(usec)}
22 }
23
24 //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
25 func Gettimeofday(tv *Timeval) (err error) {
26 // The tv passed to gettimeofday must be non-nil
27 // but is otherwise unused. The answers come back
28 // in the two registers.
29 sec, usec, err := gettimeofday(tv)
30 tv.Sec = sec
31 tv.Usec = usec
32 return err
3322 }
3423
3524 func SetKevent(k *Kevent_t, fd, mode, flags int) {
9696 return err
9797 }
9898
99 func IoctlSetRTCWkAlrm(fd int, value *RTCWkAlrm) error {
100 err := ioctl(fd, RTC_WKALM_SET, uintptr(unsafe.Pointer(value)))
101 runtime.KeepAlive(value)
102 return err
103 }
104
99105 func IoctlGetUint32(fd int, req uint) (uint32, error) {
100106 var value uint32
101107 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
105111 func IoctlGetRTCTime(fd int) (*RTCTime, error) {
106112 var value RTCTime
107113 err := ioctl(fd, RTC_RD_TIME, uintptr(unsafe.Pointer(&value)))
114 return &value, err
115 }
116
117 func IoctlGetRTCWkAlrm(fd int) (*RTCWkAlrm, error) {
118 var value RTCWkAlrm
119 err := ioctl(fd, RTC_WKALM_RD, uintptr(unsafe.Pointer(&value)))
108120 return &value, err
109121 }
110122
16321644 //sys CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
16331645 //sys DeleteModule(name string, flags int) (err error)
16341646 //sys Dup(oldfd int) (fd int, err error)
1647
1648 func Dup2(oldfd, newfd int) error {
1649 // Android O and newer blocks dup2; riscv and arm64 don't implement dup2.
1650 if runtime.GOOS == "android" || runtime.GOARCH == "riscv64" || runtime.GOARCH == "arm64" {
1651 return Dup3(oldfd, newfd, 0)
1652 }
1653 return dup2(oldfd, newfd)
1654 }
1655
16351656 //sys Dup3(oldfd int, newfd int, flags int) (err error)
16361657 //sysnb EpollCreate1(flag int) (fd int, err error)
16371658 //sysnb EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error)
17561777 //sys Syncfs(fd int) (err error)
17571778 //sysnb Sysinfo(info *Sysinfo_t) (err error)
17581779 //sys Tee(rfd int, wfd int, len int, flags int) (n int64, err error)
1780 //sysnb TimerfdCreate(clockid int, flags int) (fd int, err error)
1781 //sysnb TimerfdGettime(fd int, currValue *ItimerSpec) (err error)
1782 //sysnb TimerfdSettime(fd int, flags int, newValue *ItimerSpec, oldValue *ItimerSpec) (err error)
17591783 //sysnb Tgkill(tgid int, tid int, sig syscall.Signal) (err error)
17601784 //sysnb Times(tms *Tms) (ticks uintptr, err error)
17611785 //sysnb Umask(mask int) (oldmask int)
21772201 // TimerGetoverrun
21782202 // TimerGettime
21792203 // TimerSettime
2180 // Timerfd
21812204 // Tkill (obsolete)
21822205 // Tuxcall
21832206 // Umount2
4848
4949 // 64-bit file system and 32-bit uid calls
5050 // (386 default is 32-bit file system and 16-bit uid).
51 //sys Dup2(oldfd int, newfd int) (err error)
51 //sys dup2(oldfd int, newfd int) (err error)
5252 //sysnb EpollCreate(size int) (fd int, err error)
5353 //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
5454 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64_64
55
66 package unix
77
8 //sys Dup2(oldfd int, newfd int) (err error)
8 //sys dup2(oldfd int, newfd int) (err error)
99 //sysnb EpollCreate(size int) (fd int, err error)
1010 //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
1111 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
7979
8080 // 64-bit file system and 32-bit uid calls
8181 // (16-bit uid calls are not always supported in newer kernels)
82 //sys Dup2(oldfd int, newfd int) (err error)
82 //sys dup2(oldfd int, newfd int) (err error)
8383 //sysnb EpollCreate(size int) (fd int, err error)
8484 //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
8585 //sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32
2424 //sysnb Getegid() (egid int)
2525 //sysnb Geteuid() (euid int)
2626 //sysnb Getgid() (gid int)
27 //sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
27 //sysnb getrlimit(resource int, rlim *Rlimit) (err error)
2828 //sysnb Getuid() (uid int)
2929 //sys Listen(s int, n int) (err error)
3030 //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
4646 //sysnb Setregid(rgid int, egid int) (err error)
4747 //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
4848 //sysnb Setresuid(ruid int, euid int, suid int) (err error)
49 //sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
49 //sysnb setrlimit(resource int, rlim *Rlimit) (err error)
5050 //sysnb Setreuid(ruid int, euid int) (err error)
5151 //sys Shutdown(fd int, how int) (err error)
5252 //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
167167 return
168168 }
169169
170 // Getrlimit prefers the prlimit64 system call. See issue 38604.
171 func Getrlimit(resource int, rlim *Rlimit) error {
172 err := prlimit(0, resource, nil, rlim)
173 if err != ENOSYS {
174 return err
175 }
176 return getrlimit(resource, rlim)
177 }
178
179 // Setrlimit prefers the prlimit64 system call. See issue 38604.
180 func Setrlimit(resource int, rlim *Rlimit) error {
181 err := prlimit(0, resource, rlim, nil)
182 if err != ENOSYS {
183 return err
184 }
185 return setrlimit(resource, rlim)
186 }
187
170188 func (r *PtraceRegs) PC() uint64 { return r.Pc }
171189
172190 func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
191209 return InotifyInit1(0)
192210 }
193211
194 func Dup2(oldfd int, newfd int) (err error) {
195 return Dup3(oldfd, newfd, 0)
196 }
212 // dup2 exists because func Dup3 in syscall_linux.go references
213 // it in an unreachable path. dup2 isn't available on arm64.
214 func dup2(oldfd int, newfd int) error
197215
198216 func Pause() error {
199217 _, err := ppoll(nil, 0, nil, nil)
66
77 package unix
88
9 //sys Dup2(oldfd int, newfd int) (err error)
9 //sys dup2(oldfd int, newfd int) (err error)
1010 //sysnb EpollCreate(size int) (fd int, err error)
1111 //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
1212 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
1313
1414 func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
1515
16 //sys Dup2(oldfd int, newfd int) (err error)
16 //sys dup2(oldfd int, newfd int) (err error)
1717 //sysnb EpollCreate(size int) (fd int, err error)
1818 //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
1919 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
66
77 package unix
88
9 //sys Dup2(oldfd int, newfd int) (err error)
9 //sys dup2(oldfd int, newfd int) (err error)
1010 //sysnb EpollCreate(size int) (fd int, err error)
1111 //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
1212 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
190190 return InotifyInit1(0)
191191 }
192192
193 func Dup2(oldfd int, newfd int) (err error) {
194 return Dup3(oldfd, newfd, 0)
195 }
196
197193 func Pause() error {
198194 _, err := ppoll(nil, 0, nil, nil)
199195 return err
227223 }
228224 return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
229225 }
226
227 // dup2 exists because func Dup3 in syscall_linux.go references
228 // it in an unreachable path. dup2 isn't available on arm64.
229 func dup2(oldfd int, newfd int) error
99 "unsafe"
1010 )
1111
12 //sys Dup2(oldfd int, newfd int) (err error)
12 //sys dup2(oldfd int, newfd int) (err error)
1313 //sysnb EpollCreate(size int) (fd int, err error)
1414 //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
1515 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
77
88 //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
99 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
10 //sys Dup2(oldfd int, newfd int) (err error)
10 //sys dup2(oldfd int, newfd int) (err error)
1111 //sys Fchown(fd int, uid int, gid int) (err error)
1212 //sys Fstat(fd int, stat *Stat_t) (err error)
1313 //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64
1111 "sync"
1212 "syscall"
1313 "unsafe"
14
15 "golang.org/x/sys/internal/unsafeheader"
1416 )
1517
1618 var (
112114 return nil, errno
113115 }
114116
115 // Slice memory layout
116 var sl = struct {
117 addr uintptr
118 len int
119 cap int
120 }{addr, length, length}
121
122 // Use unsafe to turn sl into a []byte.
123 b := *(*[]byte)(unsafe.Pointer(&sl))
117 // Use unsafe to convert addr into a []byte.
118 var b []byte
119 hdr := (*unsafeheader.Slice)(unsafe.Pointer(&b))
120 hdr.Data = unsafe.Pointer(addr)
121 hdr.Cap = length
122 hdr.Len = length
124123
125124 // Register mapping in m and return it.
126125 p := &b[cap(b)-1]
159159 BPF_A = 0x10
160160 BPF_ABS = 0x20
161161 BPF_ADD = 0x0
162 BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff
163 BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 0x38
164162 BPF_ALU = 0x4
165163 BPF_ALU64 = 0x7
166164 BPF_AND = 0x50
167 BPF_ANY = 0x0
168165 BPF_ARSH = 0xc0
169166 BPF_B = 0x10
170167 BPF_BUILD_ID_SIZE = 0x14
171168 BPF_CALL = 0x80
172 BPF_DEVCG_ACC_MKNOD = 0x1
173 BPF_DEVCG_ACC_READ = 0x2
174 BPF_DEVCG_ACC_WRITE = 0x4
175 BPF_DEVCG_DEV_BLOCK = 0x1
176 BPF_DEVCG_DEV_CHAR = 0x2
177169 BPF_DIV = 0x30
178170 BPF_DW = 0x18
179171 BPF_END = 0xd0
180 BPF_EXIST = 0x2
181172 BPF_EXIT = 0x90
182 BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = 0x1
183 BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = 0x4
184 BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = 0x2
185173 BPF_FROM_BE = 0x8
186174 BPF_FROM_LE = 0x0
187175 BPF_FS_MAGIC = 0xcafe4a11
188 BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 = 0x2
189 BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = 0x4
190 BPF_F_ADJ_ROOM_ENCAP_L4_GRE = 0x8
191 BPF_F_ADJ_ROOM_ENCAP_L4_UDP = 0x10
192 BPF_F_ADJ_ROOM_FIXED_GSO = 0x1
193176 BPF_F_ALLOW_MULTI = 0x2
194177 BPF_F_ALLOW_OVERRIDE = 0x1
195178 BPF_F_ANY_ALIGNMENT = 0x2
196 BPF_F_CLONE = 0x200
197 BPF_F_CTXLEN_MASK = 0xfffff00000000
198 BPF_F_CURRENT_CPU = 0xffffffff
199 BPF_F_CURRENT_NETNS = -0x1
200 BPF_F_DONT_FRAGMENT = 0x4
201 BPF_F_FAST_STACK_CMP = 0x200
202 BPF_F_HDR_FIELD_MASK = 0xf
203 BPF_F_INDEX_MASK = 0xffffffff
204 BPF_F_INGRESS = 0x1
205 BPF_F_INVALIDATE_HASH = 0x2
206 BPF_F_LOCK = 0x4
207 BPF_F_MARK_ENFORCE = 0x40
208 BPF_F_MARK_MANGLED_0 = 0x20
209 BPF_F_MMAPABLE = 0x400
210 BPF_F_NO_COMMON_LRU = 0x2
211 BPF_F_NO_PREALLOC = 0x1
212 BPF_F_NUMA_NODE = 0x4
213 BPF_F_PSEUDO_HDR = 0x10
214179 BPF_F_QUERY_EFFECTIVE = 0x1
215 BPF_F_RDONLY = 0x8
216 BPF_F_RDONLY_PROG = 0x80
217 BPF_F_RECOMPUTE_CSUM = 0x1
218180 BPF_F_REPLACE = 0x4
219 BPF_F_REUSE_STACKID = 0x400
220 BPF_F_SEQ_NUMBER = 0x8
221 BPF_F_SKIP_FIELD_MASK = 0xff
222 BPF_F_STACK_BUILD_ID = 0x20
223181 BPF_F_STRICT_ALIGNMENT = 0x1
224 BPF_F_SYSCTL_BASE_NAME = 0x1
225182 BPF_F_TEST_RND_HI32 = 0x4
226183 BPF_F_TEST_STATE_FREQ = 0x8
227 BPF_F_TUNINFO_IPV6 = 0x1
228 BPF_F_USER_BUILD_ID = 0x800
229 BPF_F_USER_STACK = 0x100
230 BPF_F_WRONLY = 0x10
231 BPF_F_WRONLY_PROG = 0x100
232 BPF_F_ZERO_CSUM_TX = 0x2
233 BPF_F_ZERO_SEED = 0x40
234184 BPF_H = 0x8
235185 BPF_IMM = 0x0
236186 BPF_IND = 0x40
266216 BPF_MUL = 0x20
267217 BPF_NEG = 0x80
268218 BPF_NET_OFF = -0x100000
269 BPF_NOEXIST = 0x1
270219 BPF_OBJ_NAME_LEN = 0x10
271220 BPF_OR = 0x40
272221 BPF_PSEUDO_CALL = 0x1
274223 BPF_PSEUDO_MAP_VALUE = 0x2
275224 BPF_RET = 0x6
276225 BPF_RSH = 0x70
277 BPF_SK_STORAGE_GET_F_CREATE = 0x1
278 BPF_SOCK_OPS_ALL_CB_FLAGS = 0xf
279 BPF_SOCK_OPS_RETRANS_CB_FLAG = 0x2
280 BPF_SOCK_OPS_RTO_CB_FLAG = 0x1
281 BPF_SOCK_OPS_RTT_CB_FLAG = 0x8
282 BPF_SOCK_OPS_STATE_CB_FLAG = 0x4
283226 BPF_ST = 0x2
284227 BPF_STX = 0x3
285228 BPF_SUB = 0x10
377320 CLOCK_TXINT = 0x3
378321 CLONE_ARGS_SIZE_VER0 = 0x40
379322 CLONE_ARGS_SIZE_VER1 = 0x50
323 CLONE_ARGS_SIZE_VER2 = 0x58
380324 CLONE_CHILD_CLEARTID = 0x200000
381325 CLONE_CHILD_SETTID = 0x1000000
382326 CLONE_CLEAR_SIGHAND = 0x100000000
383327 CLONE_DETACHED = 0x400000
384328 CLONE_FILES = 0x400
385329 CLONE_FS = 0x200
330 CLONE_INTO_CGROUP = 0x200000000
386331 CLONE_IO = 0x80000000
387332 CLONE_NEWCGROUP = 0x2000000
388333 CLONE_NEWIPC = 0x8000000
597542 FAN_DELETE = 0x200
598543 FAN_DELETE_SELF = 0x400
599544 FAN_DENY = 0x2
545 FAN_DIR_MODIFY = 0x80000
600546 FAN_ENABLE_AUDIT = 0x40
547 FAN_EVENT_INFO_TYPE_DFID_NAME = 0x2
601548 FAN_EVENT_INFO_TYPE_FID = 0x1
602549 FAN_EVENT_METADATA_LEN = 0x18
603550 FAN_EVENT_ON_CHILD = 0x8000000
21072054 TCOFLUSH = 0x1
21082055 TCOOFF = 0x0
21092056 TCOON = 0x1
2110 TCP_BPF_IW = 0x3e9
2111 TCP_BPF_SNDCWND_CLAMP = 0x3ea
21122057 TCP_CC_INFO = 0x1a
21132058 TCP_CM_INQ = 0x24
21142059 TCP_CONGESTION = 0xd
21642109 TCP_USER_TIMEOUT = 0x12
21652110 TCP_WINDOW_CLAMP = 0xa
21662111 TCP_ZEROCOPY_RECEIVE = 0x23
2112 TFD_TIMER_ABSTIME = 0x1
2113 TFD_TIMER_CANCEL_ON_SET = 0x2
21672114 TIMER_ABSTIME = 0x1
21682115 TIOCM_DTR = 0x2
21692116 TIOCM_LE = 0x1
23812328 XDP_COPY = 0x2
23822329 XDP_FLAGS_DRV_MODE = 0x4
23832330 XDP_FLAGS_HW_MODE = 0x8
2384 XDP_FLAGS_MASK = 0xf
2331 XDP_FLAGS_MASK = 0x1f
23852332 XDP_FLAGS_MODES = 0xe
2333 XDP_FLAGS_REPLACE = 0x10
23862334 XDP_FLAGS_SKB_MODE = 0x2
23872335 XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1
23882336 XDP_MMAP_OFFSETS = 0x1
7474 FP_XSTATE_MAGIC2 = 0x46505845
7575 FS_IOC_ENABLE_VERITY = 0x40806685
7676 FS_IOC_GETFLAGS = 0x80046601
77 FS_IOC_GET_ENCRYPTION_NONCE = 0x8010661b
7778 FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615
7879 FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614
7980 FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613
341342 TCSETXF = 0x5434
342343 TCSETXW = 0x5435
343344 TCXONC = 0x540a
345 TFD_CLOEXEC = 0x80000
346 TFD_NONBLOCK = 0x800
344347 TIOCCBRK = 0x5428
345348 TIOCCONS = 0x541d
346349 TIOCEXCL = 0x540c
7474 FP_XSTATE_MAGIC2 = 0x46505845
7575 FS_IOC_ENABLE_VERITY = 0x40806685
7676 FS_IOC_GETFLAGS = 0x80086601
77 FS_IOC_GET_ENCRYPTION_NONCE = 0x8010661b
7778 FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615
7879 FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614
7980 FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613
342343 TCSETXF = 0x5434
343344 TCSETXW = 0x5435
344345 TCXONC = 0x540a
346 TFD_CLOEXEC = 0x80000
347 TFD_NONBLOCK = 0x800
345348 TIOCCBRK = 0x5428
346349 TIOCCONS = 0x541d
347350 TIOCEXCL = 0x540c
7373 FLUSHO = 0x1000
7474 FS_IOC_ENABLE_VERITY = 0x40806685
7575 FS_IOC_GETFLAGS = 0x80046601
76 FS_IOC_GET_ENCRYPTION_NONCE = 0x8010661b
7677 FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615
7778 FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614
7879 FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613
348349 TCSETXF = 0x5434
349350 TCSETXW = 0x5435
350351 TCXONC = 0x540a
352 TFD_CLOEXEC = 0x80000
353 TFD_NONBLOCK = 0x800
351354 TIOCCBRK = 0x5428
352355 TIOCCONS = 0x541d
353356 TIOCEXCL = 0x540c
7676 FPSIMD_MAGIC = 0x46508001
7777 FS_IOC_ENABLE_VERITY = 0x40806685
7878 FS_IOC_GETFLAGS = 0x80086601
79 FS_IOC_GET_ENCRYPTION_NONCE = 0x8010661b
7980 FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615
8081 FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614
8182 FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613
335336 TCSETXF = 0x5434
336337 TCSETXW = 0x5435
337338 TCXONC = 0x540a
339 TFD_CLOEXEC = 0x80000
340 TFD_NONBLOCK = 0x800
338341 TIOCCBRK = 0x5428
339342 TIOCCONS = 0x541d
340343 TIOCEXCL = 0x540c
7373 FLUSHO = 0x2000
7474 FS_IOC_ENABLE_VERITY = 0x80806685
7575 FS_IOC_GETFLAGS = 0x40046601
76 FS_IOC_GET_ENCRYPTION_NONCE = 0x4010661b
7677 FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615
7778 FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614
7879 FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613
338339 TCSETSW = 0x540f
339340 TCSETSW2 = 0x8030542c
340341 TCXONC = 0x5406
342 TFD_CLOEXEC = 0x80000
343 TFD_NONBLOCK = 0x80
341344 TIOCCBRK = 0x5428
342345 TIOCCONS = 0x80047478
343346 TIOCEXCL = 0x740d
7373 FLUSHO = 0x2000
7474 FS_IOC_ENABLE_VERITY = 0x80806685
7575 FS_IOC_GETFLAGS = 0x40086601
76 FS_IOC_GET_ENCRYPTION_NONCE = 0x4010661b
7677 FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615
7778 FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614
7879 FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613
338339 TCSETSW = 0x540f
339340 TCSETSW2 = 0x8030542c
340341 TCXONC = 0x5406
342 TFD_CLOEXEC = 0x80000
343 TFD_NONBLOCK = 0x80
341344 TIOCCBRK = 0x5428
342345 TIOCCONS = 0x80047478
343346 TIOCEXCL = 0x740d
7373 FLUSHO = 0x2000
7474 FS_IOC_ENABLE_VERITY = 0x80806685
7575 FS_IOC_GETFLAGS = 0x40086601
76 FS_IOC_GET_ENCRYPTION_NONCE = 0x4010661b
7677 FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615
7778 FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614
7879 FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613
338339 TCSETSW = 0x540f
339340 TCSETSW2 = 0x8030542c
340341 TCXONC = 0x5406
342 TFD_CLOEXEC = 0x80000
343 TFD_NONBLOCK = 0x80
341344 TIOCCBRK = 0x5428
342345 TIOCCONS = 0x80047478
343346 TIOCEXCL = 0x740d
7373 FLUSHO = 0x2000
7474 FS_IOC_ENABLE_VERITY = 0x80806685
7575 FS_IOC_GETFLAGS = 0x40046601
76 FS_IOC_GET_ENCRYPTION_NONCE = 0x4010661b
7677 FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615
7778 FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614
7879 FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613
338339 TCSETSW = 0x540f
339340 TCSETSW2 = 0x8030542c
340341 TCXONC = 0x5406
342 TFD_CLOEXEC = 0x80000
343 TFD_NONBLOCK = 0x80
341344 TIOCCBRK = 0x5428
342345 TIOCCONS = 0x80047478
343346 TIOCEXCL = 0x740d
7373 FLUSHO = 0x800000
7474 FS_IOC_ENABLE_VERITY = 0x80806685
7575 FS_IOC_GETFLAGS = 0x40086601
76 FS_IOC_GET_ENCRYPTION_NONCE = 0x4010661b
7677 FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615
7778 FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614
7879 FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613
392393 TCSETSF = 0x802c7416
393394 TCSETSW = 0x802c7415
394395 TCXONC = 0x2000741e
396 TFD_CLOEXEC = 0x80000
397 TFD_NONBLOCK = 0x800
395398 TIOCCBRK = 0x5428
396399 TIOCCONS = 0x541d
397400 TIOCEXCL = 0x540c
7373 FLUSHO = 0x800000
7474 FS_IOC_ENABLE_VERITY = 0x80806685
7575 FS_IOC_GETFLAGS = 0x40086601
76 FS_IOC_GET_ENCRYPTION_NONCE = 0x4010661b
7677 FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615
7778 FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614
7879 FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613
392393 TCSETSF = 0x802c7416
393394 TCSETSW = 0x802c7415
394395 TCXONC = 0x2000741e
396 TFD_CLOEXEC = 0x80000
397 TFD_NONBLOCK = 0x800
395398 TIOCCBRK = 0x5428
396399 TIOCCONS = 0x541d
397400 TIOCEXCL = 0x540c
7373 FLUSHO = 0x1000
7474 FS_IOC_ENABLE_VERITY = 0x40806685
7575 FS_IOC_GETFLAGS = 0x80086601
76 FS_IOC_GET_ENCRYPTION_NONCE = 0x8010661b
7677 FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615
7778 FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614
7879 FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613
329330 TCSETXF = 0x5434
330331 TCSETXW = 0x5435
331332 TCXONC = 0x540a
333 TFD_CLOEXEC = 0x80000
334 TFD_NONBLOCK = 0x800
332335 TIOCCBRK = 0x5428
333336 TIOCCONS = 0x541d
334337 TIOCEXCL = 0x540c
7373 FLUSHO = 0x1000
7474 FS_IOC_ENABLE_VERITY = 0x40806685
7575 FS_IOC_GETFLAGS = 0x80086601
76 FS_IOC_GET_ENCRYPTION_NONCE = 0x8010661b
7677 FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615
7778 FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614
7879 FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613
402403 TCSETXF = 0x5434
403404 TCSETXW = 0x5435
404405 TCXONC = 0x540a
406 TFD_CLOEXEC = 0x80000
407 TFD_NONBLOCK = 0x800
405408 TIOCCBRK = 0x5428
406409 TIOCCONS = 0x541d
407410 TIOCEXCL = 0x540c
7777 FLUSHO = 0x1000
7878 FS_IOC_ENABLE_VERITY = 0x80806685
7979 FS_IOC_GETFLAGS = 0x40086601
80 FS_IOC_GET_ENCRYPTION_NONCE = 0x4010661b
8081 FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615
8182 FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614
8283 FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613
391392 TCSETSW = 0x8024540a
392393 TCSETSW2 = 0x802c540e
393394 TCXONC = 0x20005406
395 TFD_CLOEXEC = 0x400000
396 TFD_NONBLOCK = 0x4000
394397 TIOCCBRK = 0x2000747a
395398 TIOCCONS = 0x20007424
396399 TIOCEXCL = 0x2000740d
965965
966966 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
967967
968 func Gettimeofday(tp *Timeval) (err error) {
969 _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
970 if e1 != 0 {
971 err = errnoErr(e1)
972 }
973 return
974 }
975
976 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
977
968978 func Getuid() (uid int) {
969979 r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
970980 uid = int(r0)
17081718
17091719 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
17101720
1711 func gettimeofday(tp *Timeval) (sec int32, usec int32, err error) {
1712 r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
1713 sec = int32(r0)
1714 usec = int32(r1)
1715 if e1 != 0 {
1716 err = errnoErr(e1)
1717 }
1718 return
1719 }
1720
1721 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1722
17231721 func Fstat(fd int, stat *Stat_t) (err error) {
17241722 _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
17251723 if e1 != 0 {
13751375
13761376 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
13771377
1378 func Gettimeofday(tp *Timeval) (err error) {
1379 _, _, e1 := syscall_rawSyscall(funcPC(libc_gettimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
1380 if e1 != 0 {
1381 err = errnoErr(e1)
1382 }
1383 return
1384 }
1385
1386 func libc_gettimeofday_trampoline()
1387
1388 //go:linkname libc_gettimeofday libc_gettimeofday
1389 //go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
1390
1391 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1392
13781393 func Getuid() (uid int) {
13791394 r0, _, _ := syscall_rawSyscall(funcPC(libc_getuid_trampoline), 0, 0, 0)
13801395 uid = int(r0)
23562371
23572372 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
23582373
2359 func gettimeofday(tp *Timeval) (sec int32, usec int32, err error) {
2360 r0, r1, e1 := syscall_rawSyscall(funcPC(libc_gettimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
2361 sec = int32(r0)
2362 usec = int32(r1)
2363 if e1 != 0 {
2364 err = errnoErr(e1)
2365 }
2366 return
2367 }
2368
2369 func libc_gettimeofday_trampoline()
2370
2371 //go:linkname libc_gettimeofday libc_gettimeofday
2372 //go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
2373
2374 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
2375
23762374 func Fstat(fd int, stat *Stat_t) (err error) {
23772375 _, _, e1 := syscall_syscall(funcPC(libc_fstat64_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
23782376 if e1 != 0 {
965965
966966 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
967967
968 func Gettimeofday(tp *Timeval) (err error) {
969 _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
970 if e1 != 0 {
971 err = errnoErr(e1)
972 }
973 return
974 }
975
976 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
977
968978 func Getuid() (uid int) {
969979 r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
970980 uid = int(r0)
17081718
17091719 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
17101720
1711 func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) {
1712 r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
1713 sec = int64(r0)
1714 usec = int32(r1)
1715 if e1 != 0 {
1716 err = errnoErr(e1)
1717 }
1718 return
1719 }
1720
1721 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1722
17231721 func Fstat(fd int, stat *Stat_t) (err error) {
17241722 _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
17251723 if e1 != 0 {
13751375
13761376 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
13771377
1378 func Gettimeofday(tp *Timeval) (err error) {
1379 _, _, e1 := syscall_rawSyscall(funcPC(libc_gettimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
1380 if e1 != 0 {
1381 err = errnoErr(e1)
1382 }
1383 return
1384 }
1385
1386 func libc_gettimeofday_trampoline()
1387
1388 //go:linkname libc_gettimeofday libc_gettimeofday
1389 //go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
1390
1391 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1392
13781393 func Getuid() (uid int) {
13791394 r0, _, _ := syscall_rawSyscall(funcPC(libc_getuid_trampoline), 0, 0, 0)
13801395 uid = int(r0)
23562371
23572372 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
23582373
2359 func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) {
2360 r0, r1, e1 := syscall_rawSyscall(funcPC(libc_gettimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
2361 sec = int64(r0)
2362 usec = int32(r1)
2363 if e1 != 0 {
2364 err = errnoErr(e1)
2365 }
2366 return
2367 }
2368
2369 func libc_gettimeofday_trampoline()
2370
2371 //go:linkname libc_gettimeofday libc_gettimeofday
2372 //go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
2373
2374 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
2375
23762374 func Fstat(fd int, stat *Stat_t) (err error) {
23772375 _, _, e1 := syscall_syscall(funcPC(libc_fstat64_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
23782376 if e1 != 0 {
965965
966966 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
967967
968 func Gettimeofday(tp *Timeval) (err error) {
969 _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
970 if e1 != 0 {
971 err = errnoErr(e1)
972 }
973 return
974 }
975
976 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
977
968978 func Getuid() (uid int) {
969979 r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
970980 uid = int(r0)
16811691
16821692 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
16831693
1684 func gettimeofday(tp *Timeval) (sec int32, usec int32, err error) {
1685 r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
1686 sec = int32(r0)
1687 usec = int32(r1)
1688 if e1 != 0 {
1689 err = errnoErr(e1)
1690 }
1691 return
1692 }
1693
1694 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1695
16961694 func Fstat(fd int, stat *Stat_t) (err error) {
16971695 _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
16981696 if e1 != 0 {
13751375
13761376 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
13771377
1378 func Gettimeofday(tp *Timeval) (err error) {
1379 _, _, e1 := syscall_rawSyscall(funcPC(libc_gettimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
1380 if e1 != 0 {
1381 err = errnoErr(e1)
1382 }
1383 return
1384 }
1385
1386 func libc_gettimeofday_trampoline()
1387
1388 //go:linkname libc_gettimeofday libc_gettimeofday
1389 //go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
1390
1391 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1392
13781393 func Getuid() (uid int) {
13791394 r0, _, _ := syscall_rawSyscall(funcPC(libc_getuid_trampoline), 0, 0, 0)
13801395 uid = int(r0)
23412356
23422357 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
23432358
2344 func gettimeofday(tp *Timeval) (sec int32, usec int32, err error) {
2345 r0, r1, e1 := syscall_rawSyscall(funcPC(libc_gettimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
2346 sec = int32(r0)
2347 usec = int32(r1)
2348 if e1 != 0 {
2349 err = errnoErr(e1)
2350 }
2351 return
2352 }
2353
2354 func libc_gettimeofday_trampoline()
2355
2356 //go:linkname libc_gettimeofday libc_gettimeofday
2357 //go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
2358
2359 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
2360
23612359 func Fstat(fd int, stat *Stat_t) (err error) {
23622360 _, _, e1 := syscall_syscall(funcPC(libc_fstat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
23632361 if e1 != 0 {
965965
966966 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
967967
968 func Gettimeofday(tp *Timeval) (err error) {
969 _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
970 if e1 != 0 {
971 err = errnoErr(e1)
972 }
973 return
974 }
975
976 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
977
968978 func Getuid() (uid int) {
969979 r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
970980 uid = int(r0)
16811691
16821692 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
16831693
1684 func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) {
1685 r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
1686 sec = int64(r0)
1687 usec = int32(r1)
1688 if e1 != 0 {
1689 err = errnoErr(e1)
1690 }
1691 return
1692 }
1693
1694 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1695
16961694 func Fstat(fd int, stat *Stat_t) (err error) {
16971695 _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
16981696 if e1 != 0 {
13751375
13761376 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
13771377
1378 func Gettimeofday(tp *Timeval) (err error) {
1379 _, _, e1 := syscall_rawSyscall(funcPC(libc_gettimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
1380 if e1 != 0 {
1381 err = errnoErr(e1)
1382 }
1383 return
1384 }
1385
1386 func libc_gettimeofday_trampoline()
1387
1388 //go:linkname libc_gettimeofday libc_gettimeofday
1389 //go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
1390
1391 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1392
13781393 func Getuid() (uid int) {
13791394 r0, _, _ := syscall_rawSyscall(funcPC(libc_getuid_trampoline), 0, 0, 0)
13801395 uid = int(r0)
23412356
23422357 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
23432358
2344 func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) {
2345 r0, r1, e1 := syscall_rawSyscall(funcPC(libc_gettimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
2346 sec = int64(r0)
2347 usec = int32(r1)
2348 if e1 != 0 {
2349 err = errnoErr(e1)
2350 }
2351 return
2352 }
2353
2354 func libc_gettimeofday_trampoline()
2355
2356 //go:linkname libc_gettimeofday libc_gettimeofday
2357 //go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
2358
2359 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
2360
23612359 func Fstat(fd int, stat *Stat_t) (err error) {
23622360 _, _, e1 := syscall_syscall(funcPC(libc_fstat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
23632361 if e1 != 0 {
14491449
14501450 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
14511451
1452 func TimerfdCreate(clockid int, flags int) (fd int, err error) {
1453 r0, _, e1 := RawSyscall(SYS_TIMERFD_CREATE, uintptr(clockid), uintptr(flags), 0)
1454 fd = int(r0)
1455 if e1 != 0 {
1456 err = errnoErr(e1)
1457 }
1458 return
1459 }
1460
1461 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1462
1463 func TimerfdGettime(fd int, currValue *ItimerSpec) (err error) {
1464 _, _, e1 := RawSyscall(SYS_TIMERFD_GETTIME, uintptr(fd), uintptr(unsafe.Pointer(currValue)), 0)
1465 if e1 != 0 {
1466 err = errnoErr(e1)
1467 }
1468 return
1469 }
1470
1471 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1472
1473 func TimerfdSettime(fd int, flags int, newValue *ItimerSpec, oldValue *ItimerSpec) (err error) {
1474 _, _, e1 := RawSyscall6(SYS_TIMERFD_SETTIME, uintptr(fd), uintptr(flags), uintptr(unsafe.Pointer(newValue)), uintptr(unsafe.Pointer(oldValue)), 0, 0)
1475 if e1 != 0 {
1476 err = errnoErr(e1)
1477 }
1478 return
1479 }
1480
1481 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1482
14521483 func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
14531484 _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig))
14541485 if e1 != 0 {
5454
5555 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
5656
57 func Dup2(oldfd int, newfd int) (err error) {
57 func dup2(oldfd int, newfd int) (err error) {
5858 _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
5959 if e1 != 0 {
6060 err = errnoErr(e1)
4444
4545 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
4646
47 func Dup2(oldfd int, newfd int) (err error) {
47 func dup2(oldfd int, newfd int) (err error) {
4848 _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
4949 if e1 != 0 {
5050 err = errnoErr(e1)
233233
234234 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
235235
236 func Dup2(oldfd int, newfd int) (err error) {
236 func dup2(oldfd int, newfd int) (err error) {
237237 _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
238238 if e1 != 0 {
239239 err = errnoErr(e1)
150150
151151 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
152152
153 func Getrlimit(resource int, rlim *Rlimit) (err error) {
153 func getrlimit(resource int, rlim *Rlimit) (err error) {
154154 _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
155155 if e1 != 0 {
156156 err = errnoErr(e1)
306306
307307 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
308308
309 func Setrlimit(resource int, rlim *Rlimit) (err error) {
309 func setrlimit(resource int, rlim *Rlimit) (err error) {
310310 _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
311311 if e1 != 0 {
312312 err = errnoErr(e1)
4444
4545 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
4646
47 func Dup2(oldfd int, newfd int) (err error) {
47 func dup2(oldfd int, newfd int) (err error) {
4848 _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
4949 if e1 != 0 {
5050 err = errnoErr(e1)
4444
4545 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
4646
47 func Dup2(oldfd int, newfd int) (err error) {
47 func dup2(oldfd int, newfd int) (err error) {
4848 _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
4949 if e1 != 0 {
5050 err = errnoErr(e1)
4444
4545 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
4646
47 func Dup2(oldfd int, newfd int) (err error) {
47 func dup2(oldfd int, newfd int) (err error) {
4848 _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
4949 if e1 != 0 {
5050 err = errnoErr(e1)
4444
4545 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
4646
47 func Dup2(oldfd int, newfd int) (err error) {
47 func dup2(oldfd int, newfd int) (err error) {
4848 _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
4949 if e1 != 0 {
5050 err = errnoErr(e1)
4444
4545 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
4646
47 func Dup2(oldfd int, newfd int) (err error) {
47 func dup2(oldfd int, newfd int) (err error) {
4848 _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
4949 if e1 != 0 {
5050 err = errnoErr(e1)
4444
4545 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
4646
47 func Dup2(oldfd int, newfd int) (err error) {
47 func dup2(oldfd int, newfd int) (err error) {
4848 _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
4949 if e1 != 0 {
5050 err = errnoErr(e1)
4444
4545 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
4646
47 func Dup2(oldfd int, newfd int) (err error) {
47 func dup2(oldfd int, newfd int) (err error) {
4848 _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
4949 if e1 != 0 {
5050 err = errnoErr(e1)
7171
7272 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
7373
74 func Dup2(oldfd int, newfd int) (err error) {
74 func dup2(oldfd int, newfd int) (err error) {
7575 _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
7676 if e1 != 0 {
7777 err = errnoErr(e1)
0 // mksysctl_openbsd.pl
0 // go run mksysctl_openbsd.go
11 // Code generated by the command above; DO NOT EDIT.
22
33 // +build 386,openbsd
2929 {"hw.model", []_C_int{6, 2}},
3030 {"hw.ncpu", []_C_int{6, 3}},
3131 {"hw.ncpufound", []_C_int{6, 21}},
32 {"hw.ncpuonline", []_C_int{6, 25}},
3233 {"hw.pagesize", []_C_int{6, 7}},
3334 {"hw.physmem", []_C_int{6, 19}},
3435 {"hw.product", []_C_int{6, 15}},
3030 {"hw.model", []_C_int{6, 2}},
3131 {"hw.ncpu", []_C_int{6, 3}},
3232 {"hw.ncpufound", []_C_int{6, 21}},
33 {"hw.ncpuonline", []_C_int{6, 25}},
3334 {"hw.pagesize", []_C_int{6, 7}},
3435 {"hw.perfpolicy", []_C_int{6, 23}},
3536 {"hw.physmem", []_C_int{6, 19}},
2929 {"hw.model", []_C_int{6, 2}},
3030 {"hw.ncpu", []_C_int{6, 3}},
3131 {"hw.ncpufound", []_C_int{6, 21}},
32 {"hw.ncpuonline", []_C_int{6, 25}},
3233 {"hw.pagesize", []_C_int{6, 7}},
3334 {"hw.physmem", []_C_int{6, 19}},
3435 {"hw.product", []_C_int{6, 15}},
1616
1717 _C_long_long int64
1818 )
19
20 type ItimerSpec struct {
21 Interval Timespec
22 Value Timespec
23 }
1924
2025 const (
2126 TIME_OK = 0x0
18651870 )
18661871
18671872 const (
1868 BPF_REG_0 = 0x0
1869 BPF_REG_1 = 0x1
1870 BPF_REG_2 = 0x2
1871 BPF_REG_3 = 0x3
1872 BPF_REG_4 = 0x4
1873 BPF_REG_5 = 0x5
1874 BPF_REG_6 = 0x6
1875 BPF_REG_7 = 0x7
1876 BPF_REG_8 = 0x8
1877 BPF_REG_9 = 0x9
1878 BPF_REG_10 = 0xa
1879 BPF_MAP_CREATE = 0x0
1880 BPF_MAP_LOOKUP_ELEM = 0x1
1881 BPF_MAP_UPDATE_ELEM = 0x2
1882 BPF_MAP_DELETE_ELEM = 0x3
1883 BPF_MAP_GET_NEXT_KEY = 0x4
1884 BPF_PROG_LOAD = 0x5
1885 BPF_OBJ_PIN = 0x6
1886 BPF_OBJ_GET = 0x7
1887 BPF_PROG_ATTACH = 0x8
1888 BPF_PROG_DETACH = 0x9
1889 BPF_PROG_TEST_RUN = 0xa
1890 BPF_PROG_GET_NEXT_ID = 0xb
1891 BPF_MAP_GET_NEXT_ID = 0xc
1892 BPF_PROG_GET_FD_BY_ID = 0xd
1893 BPF_MAP_GET_FD_BY_ID = 0xe
1894 BPF_OBJ_GET_INFO_BY_FD = 0xf
1895 BPF_PROG_QUERY = 0x10
1896 BPF_RAW_TRACEPOINT_OPEN = 0x11
1897 BPF_BTF_LOAD = 0x12
1898 BPF_BTF_GET_FD_BY_ID = 0x13
1899 BPF_TASK_FD_QUERY = 0x14
1900 BPF_MAP_LOOKUP_AND_DELETE_ELEM = 0x15
1901 BPF_MAP_FREEZE = 0x16
1902 BPF_BTF_GET_NEXT_ID = 0x17
1903 BPF_MAP_TYPE_UNSPEC = 0x0
1904 BPF_MAP_TYPE_HASH = 0x1
1905 BPF_MAP_TYPE_ARRAY = 0x2
1906 BPF_MAP_TYPE_PROG_ARRAY = 0x3
1907 BPF_MAP_TYPE_PERF_EVENT_ARRAY = 0x4
1908 BPF_MAP_TYPE_PERCPU_HASH = 0x5
1909 BPF_MAP_TYPE_PERCPU_ARRAY = 0x6
1910 BPF_MAP_TYPE_STACK_TRACE = 0x7
1911 BPF_MAP_TYPE_CGROUP_ARRAY = 0x8
1912 BPF_MAP_TYPE_LRU_HASH = 0x9
1913 BPF_MAP_TYPE_LRU_PERCPU_HASH = 0xa
1914 BPF_MAP_TYPE_LPM_TRIE = 0xb
1915 BPF_MAP_TYPE_ARRAY_OF_MAPS = 0xc
1916 BPF_MAP_TYPE_HASH_OF_MAPS = 0xd
1917 BPF_MAP_TYPE_DEVMAP = 0xe
1918 BPF_MAP_TYPE_SOCKMAP = 0xf
1919 BPF_MAP_TYPE_CPUMAP = 0x10
1920 BPF_MAP_TYPE_XSKMAP = 0x11
1921 BPF_MAP_TYPE_SOCKHASH = 0x12
1922 BPF_MAP_TYPE_CGROUP_STORAGE = 0x13
1923 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY = 0x14
1924 BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = 0x15
1925 BPF_MAP_TYPE_QUEUE = 0x16
1926 BPF_MAP_TYPE_STACK = 0x17
1927 BPF_MAP_TYPE_SK_STORAGE = 0x18
1928 BPF_MAP_TYPE_DEVMAP_HASH = 0x19
1929 BPF_PROG_TYPE_UNSPEC = 0x0
1930 BPF_PROG_TYPE_SOCKET_FILTER = 0x1
1931 BPF_PROG_TYPE_KPROBE = 0x2
1932 BPF_PROG_TYPE_SCHED_CLS = 0x3
1933 BPF_PROG_TYPE_SCHED_ACT = 0x4
1934 BPF_PROG_TYPE_TRACEPOINT = 0x5
1935 BPF_PROG_TYPE_XDP = 0x6
1936 BPF_PROG_TYPE_PERF_EVENT = 0x7
1937 BPF_PROG_TYPE_CGROUP_SKB = 0x8
1938 BPF_PROG_TYPE_CGROUP_SOCK = 0x9
1939 BPF_PROG_TYPE_LWT_IN = 0xa
1940 BPF_PROG_TYPE_LWT_OUT = 0xb
1941 BPF_PROG_TYPE_LWT_XMIT = 0xc
1942 BPF_PROG_TYPE_SOCK_OPS = 0xd
1943 BPF_PROG_TYPE_SK_SKB = 0xe
1944 BPF_PROG_TYPE_CGROUP_DEVICE = 0xf
1945 BPF_PROG_TYPE_SK_MSG = 0x10
1946 BPF_PROG_TYPE_RAW_TRACEPOINT = 0x11
1947 BPF_PROG_TYPE_CGROUP_SOCK_ADDR = 0x12
1948 BPF_PROG_TYPE_LWT_SEG6LOCAL = 0x13
1949 BPF_PROG_TYPE_LIRC_MODE2 = 0x14
1950 BPF_PROG_TYPE_SK_REUSEPORT = 0x15
1951 BPF_PROG_TYPE_FLOW_DISSECTOR = 0x16
1952 BPF_PROG_TYPE_CGROUP_SYSCTL = 0x17
1953 BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE = 0x18
1954 BPF_PROG_TYPE_CGROUP_SOCKOPT = 0x19
1955 BPF_PROG_TYPE_TRACING = 0x1a
1956 BPF_CGROUP_INET_INGRESS = 0x0
1957 BPF_CGROUP_INET_EGRESS = 0x1
1958 BPF_CGROUP_INET_SOCK_CREATE = 0x2
1959 BPF_CGROUP_SOCK_OPS = 0x3
1960 BPF_SK_SKB_STREAM_PARSER = 0x4
1961 BPF_SK_SKB_STREAM_VERDICT = 0x5
1962 BPF_CGROUP_DEVICE = 0x6
1963 BPF_SK_MSG_VERDICT = 0x7
1964 BPF_CGROUP_INET4_BIND = 0x8
1965 BPF_CGROUP_INET6_BIND = 0x9
1966 BPF_CGROUP_INET4_CONNECT = 0xa
1967 BPF_CGROUP_INET6_CONNECT = 0xb
1968 BPF_CGROUP_INET4_POST_BIND = 0xc
1969 BPF_CGROUP_INET6_POST_BIND = 0xd
1970 BPF_CGROUP_UDP4_SENDMSG = 0xe
1971 BPF_CGROUP_UDP6_SENDMSG = 0xf
1972 BPF_LIRC_MODE2 = 0x10
1973 BPF_FLOW_DISSECTOR = 0x11
1974 BPF_CGROUP_SYSCTL = 0x12
1975 BPF_CGROUP_UDP4_RECVMSG = 0x13
1976 BPF_CGROUP_UDP6_RECVMSG = 0x14
1977 BPF_CGROUP_GETSOCKOPT = 0x15
1978 BPF_CGROUP_SETSOCKOPT = 0x16
1979 BPF_TRACE_RAW_TP = 0x17
1980 BPF_TRACE_FENTRY = 0x18
1981 BPF_TRACE_FEXIT = 0x19
1982 BPF_STACK_BUILD_ID_EMPTY = 0x0
1983 BPF_STACK_BUILD_ID_VALID = 0x1
1984 BPF_STACK_BUILD_ID_IP = 0x2
1985 BPF_ADJ_ROOM_NET = 0x0
1986 BPF_ADJ_ROOM_MAC = 0x1
1987 BPF_HDR_START_MAC = 0x0
1988 BPF_HDR_START_NET = 0x1
1989 BPF_LWT_ENCAP_SEG6 = 0x0
1990 BPF_LWT_ENCAP_SEG6_INLINE = 0x1
1991 BPF_LWT_ENCAP_IP = 0x2
1992 BPF_OK = 0x0
1993 BPF_DROP = 0x2
1994 BPF_REDIRECT = 0x7
1995 BPF_LWT_REROUTE = 0x80
1996 BPF_SOCK_OPS_VOID = 0x0
1997 BPF_SOCK_OPS_TIMEOUT_INIT = 0x1
1998 BPF_SOCK_OPS_RWND_INIT = 0x2
1999 BPF_SOCK_OPS_TCP_CONNECT_CB = 0x3
2000 BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB = 0x4
2001 BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB = 0x5
2002 BPF_SOCK_OPS_NEEDS_ECN = 0x6
2003 BPF_SOCK_OPS_BASE_RTT = 0x7
2004 BPF_SOCK_OPS_RTO_CB = 0x8
2005 BPF_SOCK_OPS_RETRANS_CB = 0x9
2006 BPF_SOCK_OPS_STATE_CB = 0xa
2007 BPF_SOCK_OPS_TCP_LISTEN_CB = 0xb
2008 BPF_SOCK_OPS_RTT_CB = 0xc
2009 BPF_TCP_ESTABLISHED = 0x1
2010 BPF_TCP_SYN_SENT = 0x2
2011 BPF_TCP_SYN_RECV = 0x3
2012 BPF_TCP_FIN_WAIT1 = 0x4
2013 BPF_TCP_FIN_WAIT2 = 0x5
2014 BPF_TCP_TIME_WAIT = 0x6
2015 BPF_TCP_CLOSE = 0x7
2016 BPF_TCP_CLOSE_WAIT = 0x8
2017 BPF_TCP_LAST_ACK = 0x9
2018 BPF_TCP_LISTEN = 0xa
2019 BPF_TCP_CLOSING = 0xb
2020 BPF_TCP_NEW_SYN_RECV = 0xc
2021 BPF_TCP_MAX_STATES = 0xd
2022 BPF_FIB_LKUP_RET_SUCCESS = 0x0
2023 BPF_FIB_LKUP_RET_BLACKHOLE = 0x1
2024 BPF_FIB_LKUP_RET_UNREACHABLE = 0x2
2025 BPF_FIB_LKUP_RET_PROHIBIT = 0x3
2026 BPF_FIB_LKUP_RET_NOT_FWDED = 0x4
2027 BPF_FIB_LKUP_RET_FWD_DISABLED = 0x5
2028 BPF_FIB_LKUP_RET_UNSUPP_LWT = 0x6
2029 BPF_FIB_LKUP_RET_NO_NEIGH = 0x7
2030 BPF_FIB_LKUP_RET_FRAG_NEEDED = 0x8
2031 BPF_FD_TYPE_RAW_TRACEPOINT = 0x0
2032 BPF_FD_TYPE_TRACEPOINT = 0x1
2033 BPF_FD_TYPE_KPROBE = 0x2
2034 BPF_FD_TYPE_KRETPROBE = 0x3
2035 BPF_FD_TYPE_UPROBE = 0x4
2036 BPF_FD_TYPE_URETPROBE = 0x5
1873 BPF_REG_0 = 0x0
1874 BPF_REG_1 = 0x1
1875 BPF_REG_2 = 0x2
1876 BPF_REG_3 = 0x3
1877 BPF_REG_4 = 0x4
1878 BPF_REG_5 = 0x5
1879 BPF_REG_6 = 0x6
1880 BPF_REG_7 = 0x7
1881 BPF_REG_8 = 0x8
1882 BPF_REG_9 = 0x9
1883 BPF_REG_10 = 0xa
1884 BPF_MAP_CREATE = 0x0
1885 BPF_MAP_LOOKUP_ELEM = 0x1
1886 BPF_MAP_UPDATE_ELEM = 0x2
1887 BPF_MAP_DELETE_ELEM = 0x3
1888 BPF_MAP_GET_NEXT_KEY = 0x4
1889 BPF_PROG_LOAD = 0x5
1890 BPF_OBJ_PIN = 0x6
1891 BPF_OBJ_GET = 0x7
1892 BPF_PROG_ATTACH = 0x8
1893 BPF_PROG_DETACH = 0x9
1894 BPF_PROG_TEST_RUN = 0xa
1895 BPF_PROG_GET_NEXT_ID = 0xb
1896 BPF_MAP_GET_NEXT_ID = 0xc
1897 BPF_PROG_GET_FD_BY_ID = 0xd
1898 BPF_MAP_GET_FD_BY_ID = 0xe
1899 BPF_OBJ_GET_INFO_BY_FD = 0xf
1900 BPF_PROG_QUERY = 0x10
1901 BPF_RAW_TRACEPOINT_OPEN = 0x11
1902 BPF_BTF_LOAD = 0x12
1903 BPF_BTF_GET_FD_BY_ID = 0x13
1904 BPF_TASK_FD_QUERY = 0x14
1905 BPF_MAP_LOOKUP_AND_DELETE_ELEM = 0x15
1906 BPF_MAP_FREEZE = 0x16
1907 BPF_BTF_GET_NEXT_ID = 0x17
1908 BPF_MAP_LOOKUP_BATCH = 0x18
1909 BPF_MAP_LOOKUP_AND_DELETE_BATCH = 0x19
1910 BPF_MAP_UPDATE_BATCH = 0x1a
1911 BPF_MAP_DELETE_BATCH = 0x1b
1912 BPF_LINK_CREATE = 0x1c
1913 BPF_LINK_UPDATE = 0x1d
1914 BPF_MAP_TYPE_UNSPEC = 0x0
1915 BPF_MAP_TYPE_HASH = 0x1
1916 BPF_MAP_TYPE_ARRAY = 0x2
1917 BPF_MAP_TYPE_PROG_ARRAY = 0x3
1918 BPF_MAP_TYPE_PERF_EVENT_ARRAY = 0x4
1919 BPF_MAP_TYPE_PERCPU_HASH = 0x5
1920 BPF_MAP_TYPE_PERCPU_ARRAY = 0x6
1921 BPF_MAP_TYPE_STACK_TRACE = 0x7
1922 BPF_MAP_TYPE_CGROUP_ARRAY = 0x8
1923 BPF_MAP_TYPE_LRU_HASH = 0x9
1924 BPF_MAP_TYPE_LRU_PERCPU_HASH = 0xa
1925 BPF_MAP_TYPE_LPM_TRIE = 0xb
1926 BPF_MAP_TYPE_ARRAY_OF_MAPS = 0xc
1927 BPF_MAP_TYPE_HASH_OF_MAPS = 0xd
1928 BPF_MAP_TYPE_DEVMAP = 0xe
1929 BPF_MAP_TYPE_SOCKMAP = 0xf
1930 BPF_MAP_TYPE_CPUMAP = 0x10
1931 BPF_MAP_TYPE_XSKMAP = 0x11
1932 BPF_MAP_TYPE_SOCKHASH = 0x12
1933 BPF_MAP_TYPE_CGROUP_STORAGE = 0x13
1934 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY = 0x14
1935 BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = 0x15
1936 BPF_MAP_TYPE_QUEUE = 0x16
1937 BPF_MAP_TYPE_STACK = 0x17
1938 BPF_MAP_TYPE_SK_STORAGE = 0x18
1939 BPF_MAP_TYPE_DEVMAP_HASH = 0x19
1940 BPF_MAP_TYPE_STRUCT_OPS = 0x1a
1941 BPF_PROG_TYPE_UNSPEC = 0x0
1942 BPF_PROG_TYPE_SOCKET_FILTER = 0x1
1943 BPF_PROG_TYPE_KPROBE = 0x2
1944 BPF_PROG_TYPE_SCHED_CLS = 0x3
1945 BPF_PROG_TYPE_SCHED_ACT = 0x4
1946 BPF_PROG_TYPE_TRACEPOINT = 0x5
1947 BPF_PROG_TYPE_XDP = 0x6
1948 BPF_PROG_TYPE_PERF_EVENT = 0x7
1949 BPF_PROG_TYPE_CGROUP_SKB = 0x8
1950 BPF_PROG_TYPE_CGROUP_SOCK = 0x9
1951 BPF_PROG_TYPE_LWT_IN = 0xa
1952 BPF_PROG_TYPE_LWT_OUT = 0xb
1953 BPF_PROG_TYPE_LWT_XMIT = 0xc
1954 BPF_PROG_TYPE_SOCK_OPS = 0xd
1955 BPF_PROG_TYPE_SK_SKB = 0xe
1956 BPF_PROG_TYPE_CGROUP_DEVICE = 0xf
1957 BPF_PROG_TYPE_SK_MSG = 0x10
1958 BPF_PROG_TYPE_RAW_TRACEPOINT = 0x11
1959 BPF_PROG_TYPE_CGROUP_SOCK_ADDR = 0x12
1960 BPF_PROG_TYPE_LWT_SEG6LOCAL = 0x13
1961 BPF_PROG_TYPE_LIRC_MODE2 = 0x14
1962 BPF_PROG_TYPE_SK_REUSEPORT = 0x15
1963 BPF_PROG_TYPE_FLOW_DISSECTOR = 0x16
1964 BPF_PROG_TYPE_CGROUP_SYSCTL = 0x17
1965 BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE = 0x18
1966 BPF_PROG_TYPE_CGROUP_SOCKOPT = 0x19
1967 BPF_PROG_TYPE_TRACING = 0x1a
1968 BPF_PROG_TYPE_STRUCT_OPS = 0x1b
1969 BPF_PROG_TYPE_EXT = 0x1c
1970 BPF_PROG_TYPE_LSM = 0x1d
1971 BPF_CGROUP_INET_INGRESS = 0x0
1972 BPF_CGROUP_INET_EGRESS = 0x1
1973 BPF_CGROUP_INET_SOCK_CREATE = 0x2
1974 BPF_CGROUP_SOCK_OPS = 0x3
1975 BPF_SK_SKB_STREAM_PARSER = 0x4
1976 BPF_SK_SKB_STREAM_VERDICT = 0x5
1977 BPF_CGROUP_DEVICE = 0x6
1978 BPF_SK_MSG_VERDICT = 0x7
1979 BPF_CGROUP_INET4_BIND = 0x8
1980 BPF_CGROUP_INET6_BIND = 0x9
1981 BPF_CGROUP_INET4_CONNECT = 0xa
1982 BPF_CGROUP_INET6_CONNECT = 0xb
1983 BPF_CGROUP_INET4_POST_BIND = 0xc
1984 BPF_CGROUP_INET6_POST_BIND = 0xd
1985 BPF_CGROUP_UDP4_SENDMSG = 0xe
1986 BPF_CGROUP_UDP6_SENDMSG = 0xf
1987 BPF_LIRC_MODE2 = 0x10
1988 BPF_FLOW_DISSECTOR = 0x11
1989 BPF_CGROUP_SYSCTL = 0x12
1990 BPF_CGROUP_UDP4_RECVMSG = 0x13
1991 BPF_CGROUP_UDP6_RECVMSG = 0x14
1992 BPF_CGROUP_GETSOCKOPT = 0x15
1993 BPF_CGROUP_SETSOCKOPT = 0x16
1994 BPF_TRACE_RAW_TP = 0x17
1995 BPF_TRACE_FENTRY = 0x18
1996 BPF_TRACE_FEXIT = 0x19
1997 BPF_MODIFY_RETURN = 0x1a
1998 BPF_LSM_MAC = 0x1b
1999 BPF_ANY = 0x0
2000 BPF_NOEXIST = 0x1
2001 BPF_EXIST = 0x2
2002 BPF_F_LOCK = 0x4
2003 BPF_F_NO_PREALLOC = 0x1
2004 BPF_F_NO_COMMON_LRU = 0x2
2005 BPF_F_NUMA_NODE = 0x4
2006 BPF_F_RDONLY = 0x8
2007 BPF_F_WRONLY = 0x10
2008 BPF_F_STACK_BUILD_ID = 0x20
2009 BPF_F_ZERO_SEED = 0x40
2010 BPF_F_RDONLY_PROG = 0x80
2011 BPF_F_WRONLY_PROG = 0x100
2012 BPF_F_CLONE = 0x200
2013 BPF_F_MMAPABLE = 0x400
2014 BPF_STACK_BUILD_ID_EMPTY = 0x0
2015 BPF_STACK_BUILD_ID_VALID = 0x1
2016 BPF_STACK_BUILD_ID_IP = 0x2
2017 BPF_F_RECOMPUTE_CSUM = 0x1
2018 BPF_F_INVALIDATE_HASH = 0x2
2019 BPF_F_HDR_FIELD_MASK = 0xf
2020 BPF_F_PSEUDO_HDR = 0x10
2021 BPF_F_MARK_MANGLED_0 = 0x20
2022 BPF_F_MARK_ENFORCE = 0x40
2023 BPF_F_INGRESS = 0x1
2024 BPF_F_TUNINFO_IPV6 = 0x1
2025 BPF_F_SKIP_FIELD_MASK = 0xff
2026 BPF_F_USER_STACK = 0x100
2027 BPF_F_FAST_STACK_CMP = 0x200
2028 BPF_F_REUSE_STACKID = 0x400
2029 BPF_F_USER_BUILD_ID = 0x800
2030 BPF_F_ZERO_CSUM_TX = 0x2
2031 BPF_F_DONT_FRAGMENT = 0x4
2032 BPF_F_SEQ_NUMBER = 0x8
2033 BPF_F_INDEX_MASK = 0xffffffff
2034 BPF_F_CURRENT_CPU = 0xffffffff
2035 BPF_F_CTXLEN_MASK = 0xfffff00000000
2036 BPF_F_CURRENT_NETNS = -0x1
2037 BPF_F_ADJ_ROOM_FIXED_GSO = 0x1
2038 BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 = 0x2
2039 BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = 0x4
2040 BPF_F_ADJ_ROOM_ENCAP_L4_GRE = 0x8
2041 BPF_F_ADJ_ROOM_ENCAP_L4_UDP = 0x10
2042 BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff
2043 BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 0x38
2044 BPF_F_SYSCTL_BASE_NAME = 0x1
2045 BPF_SK_STORAGE_GET_F_CREATE = 0x1
2046 BPF_F_GET_BRANCH_RECORDS_SIZE = 0x1
2047 BPF_ADJ_ROOM_NET = 0x0
2048 BPF_ADJ_ROOM_MAC = 0x1
2049 BPF_HDR_START_MAC = 0x0
2050 BPF_HDR_START_NET = 0x1
2051 BPF_LWT_ENCAP_SEG6 = 0x0
2052 BPF_LWT_ENCAP_SEG6_INLINE = 0x1
2053 BPF_LWT_ENCAP_IP = 0x2
2054 BPF_OK = 0x0
2055 BPF_DROP = 0x2
2056 BPF_REDIRECT = 0x7
2057 BPF_LWT_REROUTE = 0x80
2058 BPF_SOCK_OPS_RTO_CB_FLAG = 0x1
2059 BPF_SOCK_OPS_RETRANS_CB_FLAG = 0x2
2060 BPF_SOCK_OPS_STATE_CB_FLAG = 0x4
2061 BPF_SOCK_OPS_RTT_CB_FLAG = 0x8
2062 BPF_SOCK_OPS_ALL_CB_FLAGS = 0xf
2063 BPF_SOCK_OPS_VOID = 0x0
2064 BPF_SOCK_OPS_TIMEOUT_INIT = 0x1
2065 BPF_SOCK_OPS_RWND_INIT = 0x2
2066 BPF_SOCK_OPS_TCP_CONNECT_CB = 0x3
2067 BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB = 0x4
2068 BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB = 0x5
2069 BPF_SOCK_OPS_NEEDS_ECN = 0x6
2070 BPF_SOCK_OPS_BASE_RTT = 0x7
2071 BPF_SOCK_OPS_RTO_CB = 0x8
2072 BPF_SOCK_OPS_RETRANS_CB = 0x9
2073 BPF_SOCK_OPS_STATE_CB = 0xa
2074 BPF_SOCK_OPS_TCP_LISTEN_CB = 0xb
2075 BPF_SOCK_OPS_RTT_CB = 0xc
2076 BPF_TCP_ESTABLISHED = 0x1
2077 BPF_TCP_SYN_SENT = 0x2
2078 BPF_TCP_SYN_RECV = 0x3
2079 BPF_TCP_FIN_WAIT1 = 0x4
2080 BPF_TCP_FIN_WAIT2 = 0x5
2081 BPF_TCP_TIME_WAIT = 0x6
2082 BPF_TCP_CLOSE = 0x7
2083 BPF_TCP_CLOSE_WAIT = 0x8
2084 BPF_TCP_LAST_ACK = 0x9
2085 BPF_TCP_LISTEN = 0xa
2086 BPF_TCP_CLOSING = 0xb
2087 BPF_TCP_NEW_SYN_RECV = 0xc
2088 BPF_TCP_MAX_STATES = 0xd
2089 TCP_BPF_IW = 0x3e9
2090 TCP_BPF_SNDCWND_CLAMP = 0x3ea
2091 BPF_DEVCG_ACC_MKNOD = 0x1
2092 BPF_DEVCG_ACC_READ = 0x2
2093 BPF_DEVCG_ACC_WRITE = 0x4
2094 BPF_DEVCG_DEV_BLOCK = 0x1
2095 BPF_DEVCG_DEV_CHAR = 0x2
2096 BPF_FIB_LOOKUP_DIRECT = 0x1
2097 BPF_FIB_LOOKUP_OUTPUT = 0x2
2098 BPF_FIB_LKUP_RET_SUCCESS = 0x0
2099 BPF_FIB_LKUP_RET_BLACKHOLE = 0x1
2100 BPF_FIB_LKUP_RET_UNREACHABLE = 0x2
2101 BPF_FIB_LKUP_RET_PROHIBIT = 0x3
2102 BPF_FIB_LKUP_RET_NOT_FWDED = 0x4
2103 BPF_FIB_LKUP_RET_FWD_DISABLED = 0x5
2104 BPF_FIB_LKUP_RET_UNSUPP_LWT = 0x6
2105 BPF_FIB_LKUP_RET_NO_NEIGH = 0x7
2106 BPF_FIB_LKUP_RET_FRAG_NEEDED = 0x8
2107 BPF_FD_TYPE_RAW_TRACEPOINT = 0x0
2108 BPF_FD_TYPE_TRACEPOINT = 0x1
2109 BPF_FD_TYPE_KPROBE = 0x2
2110 BPF_FD_TYPE_KRETPROBE = 0x3
2111 BPF_FD_TYPE_UPROBE = 0x4
2112 BPF_FD_TYPE_URETPROBE = 0x5
2113 BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = 0x1
2114 BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = 0x2
2115 BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = 0x4
20372116 )
20382117
20392118 const (
21992278 DEVLINK_CMD_DPIPE_ENTRIES_GET = 0x20
22002279 DEVLINK_CMD_DPIPE_HEADERS_GET = 0x21
22012280 DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET = 0x22
2202 DEVLINK_CMD_MAX = 0x44
2281 DEVLINK_CMD_MAX = 0x48
22032282 DEVLINK_PORT_TYPE_NOTSET = 0x0
22042283 DEVLINK_PORT_TYPE_AUTO = 0x1
22052284 DEVLINK_PORT_TYPE_ETH = 0x2
22792358 DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE = 0x3c
22802359 DEVLINK_ATTR_PAD = 0x3d
22812360 DEVLINK_ATTR_ESWITCH_ENCAP_MODE = 0x3e
2282 DEVLINK_ATTR_MAX = 0x8c
2361 DEVLINK_ATTR_MAX = 0x90
22832362 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE = 0x0
22842363 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX = 0x1
22852364 DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT = 0x0
9797 // MustFindProc is like FindProc but panics if search fails.
9898 func (d *DLL) MustFindProc(name string) *Proc {
9999 p, e := d.FindProc(name)
100 if e != nil {
101 panic(e)
102 }
103 return p
104 }
105
106 // FindProcByOrdinal searches DLL d for procedure by ordinal and returns *Proc
107 // if found. It returns an error if search fails.
108 func (d *DLL) FindProcByOrdinal(ordinal uintptr) (proc *Proc, err error) {
109 a, e := GetProcAddressByOrdinal(d.Handle, ordinal)
110 name := "#" + itoa(int(ordinal))
111 if e != nil {
112 return nil, &DLLError{
113 Err: e,
114 ObjName: name,
115 Msg: "Failed to find " + name + " procedure in " + d.Name + ": " + e.Error(),
116 }
117 }
118 p := &Proc{
119 Dll: d,
120 Name: name,
121 addr: a,
122 }
123 return p, nil
124 }
125
126 // MustFindProcByOrdinal is like FindProcByOrdinal but panics if search fails.
127 func (d *DLL) MustFindProcByOrdinal(ordinal uintptr) *Proc {
128 p, e := d.FindProcByOrdinal(ordinal)
100129 if e != nil {
101130 panic(e)
102131 }
77
88 import (
99 "syscall"
10 "unicode/utf16"
1110 "unsafe"
1211 )
1312
3938 defer DestroyEnvironmentBlock(block)
4039 blockp := uintptr(unsafe.Pointer(block))
4140 for {
42 entry := (*[(1 << 30) - 1]uint16)(unsafe.Pointer(blockp))[:]
43 for i, v := range entry {
44 if v == 0 {
45 entry = entry[:i]
46 break
47 }
48 }
41 entry := UTF16PtrToString((*uint16)(unsafe.Pointer(blockp)))
4942 if len(entry) == 0 {
5043 break
5144 }
52 env = append(env, string(utf16.Decode(entry)))
45 env = append(env, entry)
5346 blockp += 2 * (uintptr(len(entry)) + 1)
5447 }
5548 return env, nil
2222 PAGE_EXECUTE_READ = 0x20
2323 PAGE_EXECUTE_READWRITE = 0x40
2424 PAGE_EXECUTE_WRITECOPY = 0x80
25
26 QUOTA_LIMITS_HARDWS_MIN_DISABLE = 0x00000002
27 QUOTA_LIMITS_HARDWS_MIN_ENABLE = 0x00000001
28 QUOTA_LIMITS_HARDWS_MAX_DISABLE = 0x00000008
29 QUOTA_LIMITS_HARDWS_MAX_ENABLE = 0x00000004
2530 )
66 import (
77 "syscall"
88 "unsafe"
9
10 "golang.org/x/sys/internal/unsafeheader"
911 )
1012
1113 const (
12281230 return ""
12291231 }
12301232 defer LocalFree(Handle(unsafe.Pointer(sddl)))
1231 return UTF16ToString((*[(1 << 30) - 1]uint16)(unsafe.Pointer(sddl))[:])
1233 return UTF16PtrToString(sddl)
12321234 }
12331235
12341236 // ToAbsolute converts a self-relative security descriptor into an absolute one.
13061308 }
13071309
13081310 func (selfRelativeSD *SECURITY_DESCRIPTOR) copySelfRelativeSecurityDescriptor() *SECURITY_DESCRIPTOR {
1309 sdBytes := make([]byte, selfRelativeSD.Length())
1310 copy(sdBytes, (*[(1 << 31) - 1]byte)(unsafe.Pointer(selfRelativeSD))[:len(sdBytes)])
1311 return (*SECURITY_DESCRIPTOR)(unsafe.Pointer(&sdBytes[0]))
1311 sdLen := (int)(selfRelativeSD.Length())
1312
1313 var src []byte
1314 h := (*unsafeheader.Slice)(unsafe.Pointer(&src))
1315 h.Data = unsafe.Pointer(selfRelativeSD)
1316 h.Len = sdLen
1317 h.Cap = sdLen
1318
1319 dst := make([]byte, sdLen)
1320 copy(dst, src)
1321 return (*SECURITY_DESCRIPTOR)(unsafe.Pointer(&dst[0]))
13121322 }
13131323
13141324 // SecurityDescriptorFromString converts an SDDL string describing a security descriptor into a
13901400 }
13911401 defer LocalFree(Handle(unsafe.Pointer(winHeapACL)))
13921402 aclBytes := make([]byte, winHeapACL.aclSize)
1393 copy(aclBytes, (*[(1 << 31) - 1]byte)(unsafe.Pointer(winHeapACL))[:len(aclBytes)])
1403 copy(aclBytes, (*[(1 << 31) - 1]byte)(unsafe.Pointer(winHeapACL))[:len(aclBytes):len(aclBytes)])
13941404 return (*ACL)(unsafe.Pointer(&aclBytes[0])), nil
13951405 }
1212 "time"
1313 "unicode/utf16"
1414 "unsafe"
15
16 "golang.org/x/sys/internal/unsafeheader"
1517 )
1618
1719 type Handle uintptr
114116 return nil, err
115117 }
116118 return &a[0], nil
119 }
120
121 // UTF16PtrToString takes a pointer to a UTF-16 sequence and returns the corresponding UTF-8 encoded string.
122 // If the pointer is nil, this returns the empty string. This assumes that the UTF-16 sequence is terminated
123 // at a zero word; if the zero word is not present, the program may crash.
124 func UTF16PtrToString(p *uint16) string {
125 if p == nil {
126 return ""
127 }
128 if *p == 0 {
129 return ""
130 }
131
132 // Find NUL terminator.
133 n := 0
134 for ptr := unsafe.Pointer(p); *(*uint16)(ptr) != 0; n++ {
135 ptr = unsafe.Pointer(uintptr(ptr) + unsafe.Sizeof(*p))
136 }
137
138 var s []uint16
139 h := (*unsafeheader.Slice)(unsafe.Pointer(&s))
140 h.Data = unsafe.Pointer(p)
141 h.Len = n
142 h.Cap = n
143
144 return string(utf16.Decode(s))
117145 }
118146
119147 func Getpagesize() int { return 4096 }
279307 //sys GetProcessId(process Handle) (id uint32, err error)
280308 //sys OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (handle Handle, err error)
281309 //sys SetProcessPriorityBoost(process Handle, disable bool) (err error) = kernel32.SetProcessPriorityBoost
310 //sys GetProcessWorkingSetSizeEx(hProcess Handle, lpMinimumWorkingSetSize *uintptr, lpMaximumWorkingSetSize *uintptr, flags *uint32)
311 //sys SetProcessWorkingSetSizeEx(hProcess Handle, dwMinimumWorkingSetSize uintptr, dwMaximumWorkingSetSize uintptr, flags uint32) (err error)
282312
283313 // Volume Management Functions
284314 //sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW
11801210 Interface uint32
11811211 }
11821212
1183 func GetsockoptInt(fd Handle, level, opt int) (int, error) { return -1, syscall.EWINDOWS }
1213 func GetsockoptInt(fd Handle, level, opt int) (int, error) {
1214 v := int32(0)
1215 l := int32(unsafe.Sizeof(v))
1216 err := Getsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&v)), &l)
1217 return int(v), err
1218 }
11841219
11851220 func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) {
11861221 sys := sysLinger{Onoff: uint16(l.Onoff), Linger: uint16(l.Linger)}
13771412 return "", err
13781413 }
13791414 defer CoTaskMemFree(unsafe.Pointer(p))
1380 return UTF16ToString((*[(1 << 30) - 1]uint16)(unsafe.Pointer(p))[:]), nil
1415 return UTF16PtrToString(p), nil
13811416 }
13821417
13831418 // RtlGetVersion returns the version of the underlying operating system, ignoring
216216 procGetProcessId = modkernel32.NewProc("GetProcessId")
217217 procOpenThread = modkernel32.NewProc("OpenThread")
218218 procSetProcessPriorityBoost = modkernel32.NewProc("SetProcessPriorityBoost")
219 procGetProcessWorkingSetSizeEx = modkernel32.NewProc("GetProcessWorkingSetSizeEx")
220 procSetProcessWorkingSetSizeEx = modkernel32.NewProc("SetProcessWorkingSetSizeEx")
219221 procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW")
220222 procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW")
221223 procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW")
24132415 return
24142416 }
24152417
2418 func GetProcessWorkingSetSizeEx(hProcess Handle, lpMinimumWorkingSetSize *uintptr, lpMaximumWorkingSetSize *uintptr, flags *uint32) {
2419 syscall.Syscall6(procGetProcessWorkingSetSizeEx.Addr(), 4, uintptr(hProcess), uintptr(unsafe.Pointer(lpMinimumWorkingSetSize)), uintptr(unsafe.Pointer(lpMaximumWorkingSetSize)), uintptr(unsafe.Pointer(flags)), 0, 0)
2420 return
2421 }
2422
2423 func SetProcessWorkingSetSizeEx(hProcess Handle, dwMinimumWorkingSetSize uintptr, dwMaximumWorkingSetSize uintptr, flags uint32) (err error) {
2424 r1, _, e1 := syscall.Syscall6(procSetProcessWorkingSetSizeEx.Addr(), 4, uintptr(hProcess), uintptr(dwMinimumWorkingSetSize), uintptr(dwMaximumWorkingSetSize), uintptr(flags), 0, 0)
2425 if r1 == 0 {
2426 if e1 != 0 {
2427 err = errnoErr(e1)
2428 } else {
2429 err = syscall.EINVAL
2430 }
2431 }
2432 return
2433 }
2434
24162435 func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) {
24172436 r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)))
24182437 if r1 == 0 {
1515 "google.golang.org/protobuf/internal/flags"
1616 "google.golang.org/protobuf/internal/pragma"
1717 "google.golang.org/protobuf/internal/set"
18 "google.golang.org/protobuf/internal/strs"
1819 "google.golang.org/protobuf/proto"
1920 pref "google.golang.org/protobuf/reflect/protoreflect"
2021 "google.golang.org/protobuf/reflect/protoregistry"
338339
339340 case pref.StringKind:
340341 if s, ok := tok.String(); ok {
341 if utf8.ValidString(s) {
342 return pref.ValueOfString(s), nil
343 }
344 return pref.Value{}, d.newError(tok.Pos(), "contains invalid UTF-8")
342 if strs.EnforceUTF8(fd) && !utf8.ValidString(s) {
343 return pref.Value{}, d.newError(tok.Pos(), "contains invalid UTF-8")
344 }
345 return pref.ValueOfString(s), nil
345346 }
346347
347348 case pref.BytesKind:
1717 "google.golang.org/protobuf/internal/flags"
1818 "google.golang.org/protobuf/internal/mapsort"
1919 "google.golang.org/protobuf/internal/pragma"
20 "google.golang.org/protobuf/internal/strs"
2021 "google.golang.org/protobuf/proto"
2122 pref "google.golang.org/protobuf/reflect/protoreflect"
2223 "google.golang.org/protobuf/reflect/protoregistry"
5354 // terminated by a newline. If non-empty, then Multiline is treated as true.
5455 // Indent can only be composed of space or tab characters.
5556 Indent string
57
58 // EmitASCII specifies whether to format strings and bytes as ASCII only
59 // as opposed to using UTF-8 encoding when possible.
60 EmitASCII bool
61
62 // allowInvalidUTF8 specifies whether to permit the encoding of strings
63 // with invalid UTF-8. This is unexported as it is intended to only
64 // be specified by the Format method.
65 allowInvalidUTF8 bool
5666
5767 // AllowPartial allows messages that have missing required fields to marshal
5868 // without returning an error. If AllowPartial is false (the default),
8090 if m == nil || !m.ProtoReflect().IsValid() {
8191 return "<nil>" // invalid syntax, but okay since this is for debugging
8292 }
93 o.allowInvalidUTF8 = true
8394 o.AllowPartial = true
8495 o.EmitUnknown = true
8596 b, _ := o.Marshal(m)
90101 // MarshalOptions object. Do not depend on the output being stable. It may
91102 // change over time across different versions of the program.
92103 func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) {
93 const outputASCII = false
94104 var delims = [2]byte{'{', '}'}
95105
96106 if o.Multiline && o.Indent == "" {
100110 o.Resolver = protoregistry.GlobalTypes
101111 }
102112
103 internalEnc, err := text.NewEncoder(o.Indent, delims, outputASCII)
113 internalEnc, err := text.NewEncoder(o.Indent, delims, o.EmitASCII)
104114 if err != nil {
105115 return nil, err
116 }
117
118 // Treat nil message interface as an empty message,
119 // in which case there is nothing to output.
120 if m == nil {
121 return []byte{}, nil
106122 }
107123
108124 enc := encoder{internalEnc, o}
208224
209225 case pref.StringKind:
210226 s := val.String()
211 if !utf8.ValidString(s) {
227 if !e.opts.allowInvalidUTF8 && strs.EnforceUTF8(fd) && !utf8.ValidString(s) {
212228 return errors.InvalidUTF8(string(fd.FullName()))
213229 }
214230 e.WriteString(s)
105105 var descriptorAccessors = map[reflect.Type][]string{
106106 reflect.TypeOf((*pref.FileDescriptor)(nil)).Elem(): {"Path", "Package", "Imports", "Messages", "Enums", "Extensions", "Services"},
107107 reflect.TypeOf((*pref.MessageDescriptor)(nil)).Elem(): {"IsMapEntry", "Fields", "Oneofs", "ReservedNames", "ReservedRanges", "RequiredNumbers", "ExtensionRanges", "Messages", "Enums", "Extensions"},
108 reflect.TypeOf((*pref.FieldDescriptor)(nil)).Elem(): {"Number", "Cardinality", "Kind", "HasJSONName", "JSONName", "IsPacked", "IsExtension", "IsWeak", "IsList", "IsMap", "MapKey", "MapValue", "HasDefault", "Default", "ContainingOneof", "ContainingMessage", "Message", "Enum"},
108 reflect.TypeOf((*pref.FieldDescriptor)(nil)).Elem(): {"Number", "Cardinality", "Kind", "HasJSONName", "JSONName", "HasPresence", "IsExtension", "IsPacked", "IsWeak", "IsList", "IsMap", "MapKey", "MapValue", "HasDefault", "Default", "ContainingOneof", "ContainingMessage", "Message", "Enum"},
109109 reflect.TypeOf((*pref.OneofDescriptor)(nil)).Elem(): {"Fields"}, // not directly used; must keep in sync with formatDescOpt
110110 reflect.TypeOf((*pref.EnumDescriptor)(nil)).Elem(): {"Values", "ReservedNames", "ReservedRanges"},
111111 reflect.TypeOf((*pref.EnumValueDescriptor)(nil)).Elem(): {"Number"},
6060
6161 // Field numbers for google.protobuf.FieldDescriptorProto.
6262 const (
63 FieldDescriptorProto_Name = 1 // optional string
64 FieldDescriptorProto_Number = 3 // optional int32
65 FieldDescriptorProto_Label = 4 // optional google.protobuf.FieldDescriptorProto.Label
66 FieldDescriptorProto_Type = 5 // optional google.protobuf.FieldDescriptorProto.Type
67 FieldDescriptorProto_TypeName = 6 // optional string
68 FieldDescriptorProto_Extendee = 2 // optional string
69 FieldDescriptorProto_DefaultValue = 7 // optional string
70 FieldDescriptorProto_OneofIndex = 9 // optional int32
71 FieldDescriptorProto_JsonName = 10 // optional string
72 FieldDescriptorProto_Options = 8 // optional google.protobuf.FieldOptions
63 FieldDescriptorProto_Name = 1 // optional string
64 FieldDescriptorProto_Number = 3 // optional int32
65 FieldDescriptorProto_Label = 4 // optional google.protobuf.FieldDescriptorProto.Label
66 FieldDescriptorProto_Type = 5 // optional google.protobuf.FieldDescriptorProto.Type
67 FieldDescriptorProto_TypeName = 6 // optional string
68 FieldDescriptorProto_Extendee = 2 // optional string
69 FieldDescriptorProto_DefaultValue = 7 // optional string
70 FieldDescriptorProto_OneofIndex = 9 // optional int32
71 FieldDescriptorProto_JsonName = 10 // optional string
72 FieldDescriptorProto_Options = 8 // optional google.protobuf.FieldOptions
73 FieldDescriptorProto_Proto3Optional = 17 // optional bool
7374 )
7475
7576 // Field numbers for google.protobuf.OneofDescriptorProto.
2929 return a.Number() < b.Number()
3030 }
3131 return oa.Index() < ob.Index()
32 case oa != nil:
32 case oa != nil && !oa.IsSynthetic():
3333 return false
34 case ob != nil:
34 case ob != nil && !ob.IsSynthetic():
3535 return true
3636 default:
3737 return a.Number() < b.Number()
7676 func (fd *File) Messages() pref.MessageDescriptors { return &fd.L1.Messages }
7777 func (fd *File) Extensions() pref.ExtensionDescriptors { return &fd.L1.Extensions }
7878 func (fd *File) Services() pref.ServiceDescriptors { return &fd.L1.Services }
79 func (fd *File) SourceLocations() pref.SourceLocations { return &fd.L2.Locations }
79 func (fd *File) SourceLocations() pref.SourceLocations { return &fd.lazyInit().Locations }
8080 func (fd *File) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, fd) }
8181 func (fd *File) ProtoType(pref.FileDescriptor) {}
8282 func (fd *File) ProtoInternal(pragma.DoNotImplement) {}
201201 L1 FieldL1
202202 }
203203 FieldL1 struct {
204 Options func() pref.ProtoMessage
205 Number pref.FieldNumber
206 Cardinality pref.Cardinality // must be consistent with Message.RequiredNumbers
207 Kind pref.Kind
208 JSONName jsonName
209 IsWeak bool // promoted from google.protobuf.FieldOptions
210 HasPacked bool // promoted from google.protobuf.FieldOptions
211 IsPacked bool // promoted from google.protobuf.FieldOptions
212 HasEnforceUTF8 bool // promoted from google.protobuf.FieldOptions
213 EnforceUTF8 bool // promoted from google.protobuf.FieldOptions
214 Default defaultValue
215 ContainingOneof pref.OneofDescriptor // must be consistent with Message.Oneofs.Fields
216 Enum pref.EnumDescriptor
217 Message pref.MessageDescriptor
204 Options func() pref.ProtoMessage
205 Number pref.FieldNumber
206 Cardinality pref.Cardinality // must be consistent with Message.RequiredNumbers
207 Kind pref.Kind
208 JSONName jsonName
209 IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
210 IsWeak bool // promoted from google.protobuf.FieldOptions
211 HasPacked bool // promoted from google.protobuf.FieldOptions
212 IsPacked bool // promoted from google.protobuf.FieldOptions
213 HasEnforceUTF8 bool // promoted from google.protobuf.FieldOptions
214 EnforceUTF8 bool // promoted from google.protobuf.FieldOptions
215 Default defaultValue
216 ContainingOneof pref.OneofDescriptor // must be consistent with Message.Oneofs.Fields
217 Enum pref.EnumDescriptor
218 Message pref.MessageDescriptor
218219 }
219220
220221 Oneof struct {
276277 func (fd *Field) Kind() pref.Kind { return fd.L1.Kind }
277278 func (fd *Field) HasJSONName() bool { return fd.L1.JSONName.has }
278279 func (fd *Field) JSONName() string { return fd.L1.JSONName.get(fd) }
280 func (fd *Field) HasPresence() bool {
281 return fd.L1.Cardinality != pref.Repeated && (fd.L0.ParentFile.L1.Syntax == pref.Proto2 || fd.L1.Message != nil || fd.L1.ContainingOneof != nil)
282 }
283 func (fd *Field) HasOptionalKeyword() bool {
284 return (fd.L0.ParentFile.L1.Syntax == pref.Proto2 && fd.L1.Cardinality == pref.Optional && fd.L1.ContainingOneof == nil) || fd.L1.IsProto3Optional
285 }
279286 func (fd *Field) IsPacked() bool {
280287 if !fd.L1.HasPacked && fd.L0.ParentFile.L1.Syntax != pref.Proto2 && fd.L1.Cardinality == pref.Repeated {
281288 switch fd.L1.Kind {
337344 return fd.L0.ParentFile.L1.Syntax == pref.Proto3
338345 }
339346
347 func (od *Oneof) IsSynthetic() bool {
348 return od.L0.ParentFile.L1.Syntax == pref.Proto3 && len(od.L1.Fields.List) == 1 && od.L1.Fields.List[0].HasOptionalKeyword()
349 }
340350 func (od *Oneof) Options() pref.ProtoMessage {
341351 if f := od.L1.Options; f != nil {
342352 return f()
360370 Kind pref.Kind
361371 }
362372 ExtensionL2 struct {
363 Options func() pref.ProtoMessage
364 JSONName jsonName
365 IsPacked bool // promoted from google.protobuf.FieldOptions
366 Default defaultValue
367 Enum pref.EnumDescriptor
368 Message pref.MessageDescriptor
373 Options func() pref.ProtoMessage
374 JSONName jsonName
375 IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
376 IsPacked bool // promoted from google.protobuf.FieldOptions
377 Default defaultValue
378 Enum pref.EnumDescriptor
379 Message pref.MessageDescriptor
369380 }
370381 )
371382
375386 }
376387 return descopts.Field
377388 }
378 func (xd *Extension) Number() pref.FieldNumber { return xd.L1.Number }
379 func (xd *Extension) Cardinality() pref.Cardinality { return xd.L1.Cardinality }
380 func (xd *Extension) Kind() pref.Kind { return xd.L1.Kind }
381 func (xd *Extension) HasJSONName() bool { return xd.lazyInit().JSONName.has }
382 func (xd *Extension) JSONName() string { return xd.lazyInit().JSONName.get(xd) }
389 func (xd *Extension) Number() pref.FieldNumber { return xd.L1.Number }
390 func (xd *Extension) Cardinality() pref.Cardinality { return xd.L1.Cardinality }
391 func (xd *Extension) Kind() pref.Kind { return xd.L1.Kind }
392 func (xd *Extension) HasJSONName() bool { return xd.lazyInit().JSONName.has }
393 func (xd *Extension) JSONName() string { return xd.lazyInit().JSONName.get(xd) }
394 func (xd *Extension) HasPresence() bool { return xd.L1.Cardinality != pref.Repeated }
395 func (xd *Extension) HasOptionalKeyword() bool {
396 return (xd.L0.ParentFile.L1.Syntax == pref.Proto2 && xd.L1.Cardinality == pref.Optional) || xd.lazyInit().IsProto3Optional
397 }
383398 func (xd *Extension) IsPacked() bool { return xd.lazyInit().IsPacked }
384399 func (xd *Extension) IsExtension() bool { return true }
385400 func (xd *Extension) IsWeak() bool { return false }
591606 // TODO: Avoid panic if we're running with the race detector
592607 // and instead spawn a goroutine that periodically resets
593608 // this value back to the original to induce a race.
594 panic("detected mutation on the default bytes")
609 panic(fmt.Sprintf("detected mutation on the default bytes for %v", fd.FullName()))
595610 }
596611 return dv.val
597612 }
440440 panic("oneof type already set")
441441 }
442442 fd.L1.ContainingOneof = od
443 case fieldnum.FieldDescriptorProto_Proto3Optional:
444 fd.L1.IsProto3Optional = protowire.DecodeBool(v)
443445 }
444446 case protowire.BytesType:
445447 v, m := protowire.ConsumeBytes(b)
536538 num, typ, n := protowire.ConsumeTag(b)
537539 b = b[n:]
538540 switch typ {
541 case protowire.VarintType:
542 v, m := protowire.ConsumeVarint(b)
543 b = b[m:]
544 switch num {
545 case fieldnum.FieldDescriptorProto_Proto3Optional:
546 xd.L2.IsProto3Optional = protowire.DecodeBool(v)
547 }
539548 case protowire.BytesType:
540549 v, m := protowire.ConsumeBytes(b)
541550 b = b[m:]
50775077 merge: mergeStringPtr,
50785078 }
50795079
5080 // appendStringPtrValidateUTF8 wire encodes a *string pointer as a String.
5081 // It panics if the pointer is nil.
5082 func appendStringPtrValidateUTF8(b []byte, p pointer, f *coderFieldInfo, _ marshalOptions) ([]byte, error) {
5083 v := **p.StringPtr()
5084 b = protowire.AppendVarint(b, f.wiretag)
5085 b = protowire.AppendString(b, v)
5086 if !utf8.ValidString(v) {
5087 return b, errInvalidUTF8{}
5088 }
5089 return b, nil
5090 }
5091
5092 // consumeStringPtrValidateUTF8 wire decodes a *string pointer as a String.
5093 func consumeStringPtrValidateUTF8(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, _ unmarshalOptions) (out unmarshalOutput, err error) {
5094 if wtyp != protowire.BytesType {
5095 return out, errUnknown
5096 }
5097 v, n := protowire.ConsumeString(b)
5098 if n < 0 {
5099 return out, protowire.ParseError(n)
5100 }
5101 if !utf8.ValidString(v) {
5102 return out, errInvalidUTF8{}
5103 }
5104 vp := p.StringPtr()
5105 if *vp == nil {
5106 *vp = new(string)
5107 }
5108 **vp = v
5109 out.n = n
5110 return out, nil
5111 }
5112
5113 var coderStringPtrValidateUTF8 = pointerCoderFuncs{
5114 size: sizeStringPtr,
5115 marshal: appendStringPtrValidateUTF8,
5116 unmarshal: consumeStringPtrValidateUTF8,
5117 merge: mergeStringPtr,
5118 }
5119
50805120 // sizeStringSlice returns the size of wire encoding a []string pointer as a repeated String.
50815121 func sizeStringSlice(p pointer, f *coderFieldInfo, _ marshalOptions) (size int) {
50825122 s := *p.StringSlice()
5252
5353 mi.coderFields = make(map[protowire.Number]*coderFieldInfo)
5454 fields := mi.Desc.Fields()
55 preallocFields := make([]coderFieldInfo, fields.Len())
5556 for i := 0; i < fields.Len(); i++ {
5657 fd := fields.Get(i)
5758
5859 fs := si.fieldsByNumber[fd.Number()]
59 if fd.ContainingOneof() != nil {
60 isOneof := fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic()
61 if isOneof {
6062 fs = si.oneofsByName[fd.ContainingOneof().Name()]
6163 }
6264 ft := fs.Type
7072 var funcs pointerCoderFuncs
7173 var childMessage *MessageInfo
7274 switch {
73 case fd.ContainingOneof() != nil:
75 case isOneof:
7476 fieldOffset = offsetOf(fs, mi.Exporter)
7577 case fd.IsWeak():
7678 fieldOffset = si.weakOffset
7981 fieldOffset = offsetOf(fs, mi.Exporter)
8082 childMessage, funcs = fieldCoder(fd, ft)
8183 }
82 cf := &coderFieldInfo{
84 cf := &preallocFields[i]
85 *cf = coderFieldInfo{
8386 num: fd.Number(),
8487 offset: fieldOffset,
8588 wiretag: wiretag,
8891 funcs: funcs,
8992 mi: childMessage,
9093 validation: newFieldValidationInfo(mi, si, fd, ft),
91 isPointer: (fd.Cardinality() == pref.Repeated ||
92 fd.Kind() == pref.MessageKind ||
93 fd.Kind() == pref.GroupKind ||
94 fd.Syntax() != pref.Proto3),
94 isPointer: fd.Cardinality() == pref.Repeated || fd.HasPresence(),
9595 isRequired: fd.Cardinality() == pref.Required,
9696 }
9797 mi.orderedCoderFields = append(mi.orderedCoderFields, cf)
9898 mi.coderFields[cf.num] = cf
9999 }
100100 for i, oneofs := 0, mi.Desc.Oneofs(); i < oneofs.Len(); i++ {
101 mi.initOneofFieldCoders(oneofs.Get(i), si)
101 if od := oneofs.Get(i); !od.IsSynthetic() {
102 mi.initOneofFieldCoders(od, si)
103 }
102104 }
103105 if messageset.IsMessageSet(mi.Desc) {
104106 if !mi.extensionOffset.IsValid() {
122124 }
123125 mi.denseCoderFields = make([]*coderFieldInfo, maxDense+1)
124126 for _, cf := range mi.orderedCoderFields {
125 if int(cf.num) > len(mi.denseCoderFields) {
127 if int(cf.num) >= len(mi.denseCoderFields) {
126128 break
127129 }
128130 mi.denseCoderFields[cf.num] = cf
337337 return nil, coderDoublePtr
338338 }
339339 case pref.StringKind:
340 if ft.Kind() == reflect.String && strs.EnforceUTF8(fd) {
341 return nil, coderStringPtrValidateUTF8
342 }
340343 if ft.Kind() == reflect.String {
341344 return nil, coderStringPtr
342345 }
161161 return ok
162162 }
163163 func (c *boolConverter) IsValidGo(v reflect.Value) bool {
164 return v.Type() == c.goType
164 return v.IsValid() && v.Type() == c.goType
165165 }
166166 func (c *boolConverter) New() pref.Value { return c.def }
167167 func (c *boolConverter) Zero() pref.Value { return c.def }
185185 return ok
186186 }
187187 func (c *int32Converter) IsValidGo(v reflect.Value) bool {
188 return v.Type() == c.goType
188 return v.IsValid() && v.Type() == c.goType
189189 }
190190 func (c *int32Converter) New() pref.Value { return c.def }
191191 func (c *int32Converter) Zero() pref.Value { return c.def }
209209 return ok
210210 }
211211 func (c *int64Converter) IsValidGo(v reflect.Value) bool {
212 return v.Type() == c.goType
212 return v.IsValid() && v.Type() == c.goType
213213 }
214214 func (c *int64Converter) New() pref.Value { return c.def }
215215 func (c *int64Converter) Zero() pref.Value { return c.def }
233233 return ok
234234 }
235235 func (c *uint32Converter) IsValidGo(v reflect.Value) bool {
236 return v.Type() == c.goType
236 return v.IsValid() && v.Type() == c.goType
237237 }
238238 func (c *uint32Converter) New() pref.Value { return c.def }
239239 func (c *uint32Converter) Zero() pref.Value { return c.def }
257257 return ok
258258 }
259259 func (c *uint64Converter) IsValidGo(v reflect.Value) bool {
260 return v.Type() == c.goType
260 return v.IsValid() && v.Type() == c.goType
261261 }
262262 func (c *uint64Converter) New() pref.Value { return c.def }
263263 func (c *uint64Converter) Zero() pref.Value { return c.def }
281281 return ok
282282 }
283283 func (c *float32Converter) IsValidGo(v reflect.Value) bool {
284 return v.Type() == c.goType
284 return v.IsValid() && v.Type() == c.goType
285285 }
286286 func (c *float32Converter) New() pref.Value { return c.def }
287287 func (c *float32Converter) Zero() pref.Value { return c.def }
305305 return ok
306306 }
307307 func (c *float64Converter) IsValidGo(v reflect.Value) bool {
308 return v.Type() == c.goType
308 return v.IsValid() && v.Type() == c.goType
309309 }
310310 func (c *float64Converter) New() pref.Value { return c.def }
311311 func (c *float64Converter) Zero() pref.Value { return c.def }
335335 return ok
336336 }
337337 func (c *stringConverter) IsValidGo(v reflect.Value) bool {
338 return v.Type() == c.goType
338 return v.IsValid() && v.Type() == c.goType
339339 }
340340 func (c *stringConverter) New() pref.Value { return c.def }
341341 func (c *stringConverter) Zero() pref.Value { return c.def }
362362 return ok
363363 }
364364 func (c *bytesConverter) IsValidGo(v reflect.Value) bool {
365 return v.Type() == c.goType
365 return v.IsValid() && v.Type() == c.goType
366366 }
367367 func (c *bytesConverter) New() pref.Value { return c.def }
368368 func (c *bytesConverter) Zero() pref.Value { return c.def }
399399 }
400400
401401 func (c *enumConverter) IsValidGo(v reflect.Value) bool {
402 return v.Type() == c.goType
402 return v.IsValid() && v.Type() == c.goType
403403 }
404404
405405 func (c *enumConverter) New() pref.Value {
454454 }
455455
456456 func (c *messageConverter) IsValidGo(v reflect.Value) bool {
457 return v.Type() == c.goType
457 return v.IsValid() && v.Type() == c.goType
458458 }
459459
460460 func (c *messageConverter) New() pref.Value {
2121 }
2222
2323 type listConverter struct {
24 goType reflect.Type
24 goType reflect.Type // []T
2525 c Converter
2626 }
2727
4747 if !ok {
4848 return false
4949 }
50 return list.v.Type().Elem() == c.goType && list.IsValid()
50 return list.v.Type().Elem() == c.goType
5151 }
5252
5353 func (c *listConverter) IsValidGo(v reflect.Value) bool {
54 return v.Type() == c.goType
54 return v.IsValid() && v.Type() == c.goType
5555 }
5656
5757 func (c *listConverter) New() pref.Value {
6363 }
6464
6565 type listPtrConverter struct {
66 goType reflect.Type
66 goType reflect.Type // *[]T
6767 c Converter
6868 }
6969
8787 }
8888
8989 func (c *listPtrConverter) IsValidGo(v reflect.Value) bool {
90 return v.Type() == c.goType
90 return v.IsValid() && v.Type() == c.goType
9191 }
9292
9393 func (c *listPtrConverter) New() pref.Value {
1111 )
1212
1313 type mapConverter struct {
14 goType reflect.Type
14 goType reflect.Type // map[K]V
1515 keyConv, valConv Converter
1616 }
1717
4242 if !ok {
4343 return false
4444 }
45 return mapv.v.Type() == c.goType && mapv.IsValid()
45 return mapv.v.Type() == c.goType
4646 }
4747
4848 func (c *mapConverter) IsValidGo(v reflect.Value) bool {
49 return v.Type() == c.goType
49 return v.IsValid() && v.Type() == c.goType
5050 }
5151
5252 func (c *mapConverter) New() pref.Value {
66 import (
77 "encoding/binary"
88 "encoding/json"
9 "fmt"
109 "hash/crc32"
1110 "math"
1211 "reflect"
1312
1413 "google.golang.org/protobuf/internal/errors"
1514 pref "google.golang.org/protobuf/reflect/protoreflect"
16 "google.golang.org/protobuf/reflect/protoregistry"
1715 piface "google.golang.org/protobuf/runtime/protoiface"
1816 )
1917
9189 out = append(out, gzipFooter[:]...)
9290 return out
9391 }
94
95 // WeakNil returns a typed nil pointer to a concrete message.
96 // It panics if the message is not linked into the binary.
97 func (Export) WeakNil(s pref.FullName) piface.MessageV1 {
98 mt, err := protoregistry.GlobalTypes.FindMessageByName(s)
99 if err != nil {
100 panic(fmt.Sprintf("weak message %v is not linked in", s))
101 }
102 return mt.Zero().Interface().(piface.MessageV1)
103 }
154154 func (x placeholderExtension) Kind() pref.Kind { return 0 }
155155 func (x placeholderExtension) HasJSONName() bool { return false }
156156 func (x placeholderExtension) JSONName() string { return "" }
157 func (x placeholderExtension) HasPresence() bool { return false }
158 func (x placeholderExtension) HasOptionalKeyword() bool { return false }
157159 func (x placeholderExtension) IsExtension() bool { return true }
158160 func (x placeholderExtension) IsWeak() bool { return false }
159161 func (x placeholderExtension) IsPacked() bool { return false }
1414 "google.golang.org/protobuf/internal/genname"
1515 "google.golang.org/protobuf/reflect/protoreflect"
1616 pref "google.golang.org/protobuf/reflect/protoreflect"
17 piface "google.golang.org/protobuf/runtime/protoiface"
1817 )
1918
2019 // MessageInfo provides protobuf related functionality for a given Go type
108107
109108 type (
110109 SizeCache = int32
111 WeakFields = map[int32]piface.MessageV1
110 WeakFields = map[int32]protoreflect.ProtoMessage
112111 UnknownFields = []byte
113112 ExtensionFields = map[int32]ExtensionField
114113 )
5252 fs := si.fieldsByNumber[fd.Number()]
5353 var fi fieldInfo
5454 switch {
55 case fd.ContainingOneof() != nil:
55 case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
5656 fi = fieldInfoForOneof(fd, si.oneofsByName[fd.ContainingOneof().Name()], mi.Exporter, si.oneofWrappersByNumber[fd.Number()])
5757 case fd.IsMap():
5858 fi = fieldInfoForMap(fd, fs, mi.Exporter)
7171 mi.oneofs = map[pref.Name]*oneofInfo{}
7272 for i := 0; i < md.Oneofs().Len(); i++ {
7373 od := md.Oneofs().Get(i)
74 mi.oneofs[od.Name()] = makeOneofInfo(od, si.oneofsByName[od.Name()], mi.Exporter, si.oneofWrappersByType)
74 mi.oneofs[od.Name()] = makeOneofInfo(od, si, mi.Exporter)
7575 }
7676
7777 mi.denseFields = make([]*fieldInfo, fds.Len()*2)
8383
8484 for i := 0; i < fds.Len(); {
8585 fd := fds.Get(i)
86 if od := fd.ContainingOneof(); od != nil {
86 if od := fd.ContainingOneof(); od != nil && !od.IsSynthetic() {
8787 mi.rangeInfos = append(mi.rangeInfos, mi.oneofs[od.Name()])
8888 i += od.Fields().Len()
8989 } else {
169169 return x.Value().List().Len() > 0
170170 case xd.IsMap():
171171 return x.Value().Map().Len() > 0
172 case xd.Message() != nil:
173 return x.Value().Message().IsValid()
172174 }
173175 return true
174176 }
185187 return xt.Zero()
186188 }
187189 func (m *extensionMap) Set(xt pref.ExtensionType, v pref.Value) {
188 if !xt.IsValidValue(v) {
190 xd := xt.TypeDescriptor()
191 isValid := true
192 switch {
193 case !xt.IsValidValue(v):
194 isValid = false
195 case xd.IsList():
196 isValid = v.List().IsValid()
197 case xd.IsMap():
198 isValid = v.Map().IsValid()
199 case xd.Message() != nil:
200 isValid = v.Message().IsValid()
201 }
202 if !isValid {
189203 panic(fmt.Sprintf("%v: assigning invalid value", xt.TypeDescriptor().FullName()))
190204 }
205
191206 if *m == nil {
192207 *m = make(map[int32]ExtensionField)
193208 }
194209 var x ExtensionField
195210 x.Set(xt, v)
196 (*m)[int32(xt.TypeDescriptor().Number())] = x
211 (*m)[int32(xd.Number())] = x
197212 }
198213 func (m *extensionMap) Mutable(xt pref.ExtensionType) pref.Value {
199214 xd := xt.TypeDescriptor()
322337 }
323338 if fi != nil {
324339 if fi.fieldDesc != fd {
325 panic("mismatching field descriptor")
340 if got, want := fd.FullName(), fi.fieldDesc.FullName(); got != want {
341 panic(fmt.Sprintf("mismatching field: got %v, want %v", got, want))
342 }
343 panic(fmt.Sprintf("mismatching field: %v", fd.FullName()))
326344 }
327345 return fi, nil
328346 }
329347
330348 if fd.IsExtension() {
331 if fd.ContainingMessage().FullName() != mi.Desc.FullName() {
349 if got, want := fd.ContainingMessage().FullName(), mi.Desc.FullName(); got != want {
332350 // TODO: Should this be exact containing message descriptor match?
333 panic("mismatching containing message")
351 panic(fmt.Sprintf("extension %v has mismatching containing message: got %v, want %v", fd.FullName(), got, want))
334352 }
335353 if !mi.Desc.ExtensionRanges().Has(fd.Number()) {
336 panic("invalid extension field")
354 panic(fmt.Sprintf("extension %v extends %v outside the extension range", fd.FullName(), mi.Desc.FullName()))
337355 }
338356 xtd, ok := fd.(pref.ExtensionTypeDescriptor)
339357 if !ok {
340 panic("extension descriptor does not implement ExtensionTypeDescriptor")
358 panic(fmt.Sprintf("extension %v does not implement protoreflect.ExtensionTypeDescriptor", fd.FullName()))
341359 }
342360 return nil, xtd.Type()
343361 }
344 panic("invalid field descriptor")
345 }
362 panic(fmt.Sprintf("field %v is invalid", fd.FullName()))
363 }
3030 func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, x exporter, ot reflect.Type) fieldInfo {
3131 ft := fs.Type
3232 if ft.Kind() != reflect.Interface {
33 panic(fmt.Sprintf("invalid type: got %v, want interface kind", ft))
33 panic(fmt.Sprintf("field %v has invalid type: got %v, want interface kind", fd.FullName(), ft))
3434 }
3535 if ot.Kind() != reflect.Struct {
36 panic(fmt.Sprintf("invalid type: got %v, want struct kind", ot))
36 panic(fmt.Sprintf("field %v has invalid type: got %v, want struct kind", fd.FullName(), ot))
3737 }
3838 if !reflect.PtrTo(ot).Implements(ft) {
39 panic(fmt.Sprintf("invalid type: %v does not implement %v", ot, ft))
39 panic(fmt.Sprintf("field %v has invalid type: %v does not implement %v", fd.FullName(), ot, ft))
4040 }
4141 conv := NewConverter(ot.Field(0).Type, fd)
4242 isMessage := fd.Message() != nil
8989 },
9090 mutable: func(p pointer) pref.Value {
9191 if !isMessage {
92 panic("invalid Mutable on field with non-composite type")
92 panic(fmt.Sprintf("field %v with invalid Mutable call on field with non-composite type", fd.FullName()))
9393 }
9494 rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
9595 if rv.IsNil() || rv.Elem().Type().Elem() != ot || rv.Elem().IsNil() {
113113 func fieldInfoForMap(fd pref.FieldDescriptor, fs reflect.StructField, x exporter) fieldInfo {
114114 ft := fs.Type
115115 if ft.Kind() != reflect.Map {
116 panic(fmt.Sprintf("invalid type: got %v, want map kind", ft))
116 panic(fmt.Sprintf("field %v has invalid type: got %v, want map kind", fd.FullName(), ft))
117117 }
118118 conv := NewConverter(ft, fd)
119119
146146 rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
147147 pv := conv.GoValueOf(v)
148148 if pv.IsNil() {
149 panic(fmt.Sprintf("invalid value: setting map field to read-only value"))
149 panic(fmt.Sprintf("map field %v cannot be set with read-only value", fd.FullName()))
150150 }
151151 rv.Set(pv)
152152 },
166166 func fieldInfoForList(fd pref.FieldDescriptor, fs reflect.StructField, x exporter) fieldInfo {
167167 ft := fs.Type
168168 if ft.Kind() != reflect.Slice {
169 panic(fmt.Sprintf("invalid type: got %v, want slice kind", ft))
169 panic(fmt.Sprintf("field %v has invalid type: got %v, want slice kind", fd.FullName(), ft))
170170 }
171171 conv := NewConverter(reflect.PtrTo(ft), fd)
172172
199199 rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
200200 pv := conv.GoValueOf(v)
201201 if pv.IsNil() {
202 panic(fmt.Sprintf("invalid value: setting repeated field to read-only value"))
202 panic(fmt.Sprintf("list field %v cannot be set with read-only value", fd.FullName()))
203203 }
204204 rv.Set(pv.Elem())
205205 },
220220
221221 func fieldInfoForScalar(fd pref.FieldDescriptor, fs reflect.StructField, x exporter) fieldInfo {
222222 ft := fs.Type
223 nullable := fd.Syntax() == pref.Proto2
223 nullable := fd.HasPresence()
224224 isBytes := ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8
225225 if nullable {
226226 if ft.Kind() != reflect.Ptr && ft.Kind() != reflect.Slice {
227 panic(fmt.Sprintf("invalid type: got %v, want pointer", ft))
227 panic(fmt.Sprintf("field %v has invalid type: got %v, want pointer", fd.FullName(), ft))
228228 }
229229 if ft.Kind() == reflect.Ptr {
230230 ft = ft.Elem()
256256 case reflect.String, reflect.Slice:
257257 return rv.Len() > 0
258258 default:
259 panic(fmt.Sprintf("invalid type: %v", rv.Type())) // should never happen
259 panic(fmt.Sprintf("field %v has invalid type: %v", fd.FullName(), rv.Type())) // should never happen
260260 }
261261 },
262262 clear: func(p pointer) {
289289 rv.Set(conv.GoValueOf(v))
290290 if isBytes && rv.Len() == 0 {
291291 if nullable {
292 rv.Set(emptyBytes) // preserve presence in proto2
292 rv.Set(emptyBytes) // preserve presence
293293 } else {
294 rv.Set(nilBytes) // do not preserve presence in proto3
294 rv.Set(nilBytes) // do not preserve presence
295295 }
296296 }
297297 },
313313 messageName := fd.Message().FullName()
314314 messageType, _ = preg.GlobalTypes.FindMessageByName(messageName)
315315 if messageType == nil {
316 panic(fmt.Sprintf("weak message %v is not linked in", messageName))
316 panic(fmt.Sprintf("weak message %v for field %v is not linked in", messageName, fd.FullName()))
317317 }
318318 })
319319 }
346346 lazyInit()
347347 m := v.Message()
348348 if m.Descriptor() != messageType.Descriptor() {
349 panic("mismatching message descriptor")
349 if got, want := m.Descriptor().FullName(), messageType.Descriptor().FullName(); got != want {
350 panic(fmt.Sprintf("field %v has mismatching message descriptor: got %v, want %v", fd.FullName(), got, want))
351 }
352 panic(fmt.Sprintf("field %v has mismatching message descriptor: %v", fd.FullName(), m.Descriptor().FullName()))
350353 }
351354 p.Apply(weakOffset).WeakFields().set(num, m.Interface())
352355 },
401404 rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
402405 rv.Set(conv.GoValueOf(v))
403406 if rv.IsNil() {
404 panic("invalid nil pointer")
407 panic(fmt.Sprintf("field %v has invalid nil pointer", fd.FullName()))
405408 }
406409 },
407410 mutable: func(p pointer) pref.Value {
425428 which func(pointer) pref.FieldNumber
426429 }
427430
428 func makeOneofInfo(od pref.OneofDescriptor, fs reflect.StructField, x exporter, wrappersByType map[reflect.Type]pref.FieldNumber) *oneofInfo {
429 fieldOffset := offsetOf(fs, x)
430 return &oneofInfo{
431 oneofDesc: od,
432 which: func(p pointer) pref.FieldNumber {
431 func makeOneofInfo(od pref.OneofDescriptor, si structInfo, x exporter) *oneofInfo {
432 oi := &oneofInfo{oneofDesc: od}
433 if od.IsSynthetic() {
434 fs := si.fieldsByNumber[od.Fields().Get(0).Number()]
435 fieldOffset := offsetOf(fs, x)
436 oi.which = func(p pointer) pref.FieldNumber {
437 if p.IsNil() {
438 return 0
439 }
440 rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
441 if rv.IsNil() { // valid on either *T or []byte
442 return 0
443 }
444 return od.Fields().Get(0).Number()
445 }
446 } else {
447 fs := si.oneofsByName[od.Name()]
448 fieldOffset := offsetOf(fs, x)
449 oi.which = func(p pointer) pref.FieldNumber {
433450 if p.IsNil() {
434451 return 0
435452 }
441458 if rv.IsNil() {
442459 return 0
443460 }
444 return wrappersByType[rv.Type().Elem()]
445 },
446 }
447 }
461 return si.oneofWrappersByType[rv.Type().Elem()]
462 }
463 }
464 return oi
465 }
113113 if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
114114 return od.Fields().ByNumber(oi.which(m.pointer()))
115115 }
116 panic("invalid oneof descriptor")
116 panic("invalid oneof descriptor " + string(od.FullName()) + " for message " + string(m.Descriptor().FullName()))
117117 }
118118 func (m *messageState) GetUnknown() protoreflect.RawFields {
119119 m.messageInfo().init()
233233 if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
234234 return od.Fields().ByNumber(oi.which(m.pointer()))
235235 }
236 panic("invalid oneof descriptor")
236 panic("invalid oneof descriptor " + string(od.FullName()) + " for message " + string(m.Descriptor().FullName()))
237237 }
238238 func (m *messageReflectWrapper) GetUnknown() protoreflect.RawFields {
239239 m.messageInfo().init()
147147 return pointer{p: unsafe.Pointer(ms)}
148148 }
149149 func (ms *messageState) messageInfo() *MessageInfo {
150 return ms.LoadMessageInfo()
150 mi := ms.LoadMessageInfo()
151 if mi == nil {
152 panic("invalid nil message info; this suggests memory corruption due to a race or shallow copy on the message struct")
153 }
154 return mi
151155 }
152156 func (ms *messageState) LoadMessageInfo() *MessageInfo {
153157 return (*MessageInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&ms.atomicMessageInfo))))
107107 func newFieldValidationInfo(mi *MessageInfo, si structInfo, fd pref.FieldDescriptor, ft reflect.Type) validationInfo {
108108 var vi validationInfo
109109 switch {
110 case fd.ContainingOneof() != nil:
110 case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
111111 switch fd.Kind() {
112112 case pref.MessageKind:
113113 vi.typ = validationTypeMessage
44 package impl
55
66 import (
7 "reflect"
7 "fmt"
88
99 pref "google.golang.org/protobuf/reflect/protoreflect"
10 "google.golang.org/protobuf/reflect/protoregistry"
1011 )
1112
1213 // weakFields adds methods to the exported WeakFields type for internal use.
1516 // defined directly on it.
1617 type weakFields WeakFields
1718
18 func (w *weakFields) get(num pref.FieldNumber) (_ pref.ProtoMessage, ok bool) {
19 if *w == nil {
20 return nil, false
21 }
22 m, ok := (*w)[int32(num)]
23 if !ok {
24 return nil, false
25 }
26 // As a legacy quirk, consider a typed nil to be unset.
27 //
28 // TODO: Consider fixing the generated set methods to clear the field
29 // when provided with a typed nil.
30 if v := reflect.ValueOf(m); v.Kind() == reflect.Ptr && v.IsNil() {
31 return nil, false
32 }
33 return Export{}.ProtoMessageV2Of(m), true
19 func (w weakFields) get(num pref.FieldNumber) (pref.ProtoMessage, bool) {
20 m, ok := w[int32(num)]
21 return m, ok
3422 }
3523
3624 func (w *weakFields) set(num pref.FieldNumber, m pref.ProtoMessage) {
3725 if *w == nil {
3826 *w = make(weakFields)
3927 }
40 (*w)[int32(num)] = Export{}.ProtoMessageV1Of(m)
28 (*w)[int32(num)] = m
4129 }
4230
4331 func (w *weakFields) clear(num pref.FieldNumber) {
4432 delete(*w, int32(num))
4533 }
34
35 func (Export) HasWeak(w WeakFields, num pref.FieldNumber) bool {
36 _, ok := w[int32(num)]
37 return ok
38 }
39
40 func (Export) ClearWeak(w *WeakFields, num pref.FieldNumber) {
41 delete(*w, int32(num))
42 }
43
44 func (Export) GetWeak(w WeakFields, num pref.FieldNumber, name pref.FullName) pref.ProtoMessage {
45 if m, ok := w[int32(num)]; ok {
46 return m
47 }
48 mt, _ := protoregistry.GlobalTypes.FindMessageByName(name)
49 if mt == nil {
50 panic(fmt.Sprintf("message %v for weak field is not linked in", name))
51 }
52 return mt.Zero().Interface()
53 }
54
55 func (Export) SetWeak(w *WeakFields, num pref.FieldNumber, name pref.FullName, m pref.ProtoMessage) {
56 if m != nil {
57 mt, _ := protoregistry.GlobalTypes.FindMessageByName(name)
58 if mt == nil {
59 panic(fmt.Sprintf("message %v for weak field is not linked in", name))
60 }
61 if mt != m.ProtoReflect().Type() {
62 panic(fmt.Sprintf("invalid message type for weak field: got %T, want %T", m, mt.Zero().Interface()))
63 }
64 }
65 if m == nil || !m.ProtoReflect().IsValid() {
66 delete(*w, int32(num))
67 return
68 }
69 if *w == nil {
70 *w = make(weakFields)
71 }
72 (*w)[int32(num)] = m
73 }
5151 // 10. Send out the CL for review and submit it.
5252 const (
5353 Major = 1
54 Minor = 21
54 Minor = 23
5555 Patch = 0
5656 PreRelease = ""
5757 )
1111
1212 // CheckInitialized returns an error if any required fields in m are not set.
1313 func CheckInitialized(m Message) error {
14 // Treat a nil message interface as an "untyped" empty message,
15 // which we assume to have no required fields.
16 if m == nil {
17 return nil
18 }
19
1420 return checkInitialized(m.ProtoReflect())
1521 }
1622
7373
7474 // Marshal returns the wire-format encoding of m.
7575 func Marshal(m Message) ([]byte, error) {
76 // Treat nil message interface as an empty message; nothing to output.
77 if m == nil {
78 return nil, nil
79 }
80
7681 out, err := MarshalOptions{}.marshal(nil, m.ProtoReflect())
82 if len(out.Buf) == 0 && err == nil {
83 out.Buf = emptyBytesForMessage(m)
84 }
7785 return out.Buf, err
7886 }
7987
8088 // Marshal returns the wire-format encoding of m.
8189 func (o MarshalOptions) Marshal(m Message) ([]byte, error) {
90 // Treat nil message interface as an empty message; nothing to output.
91 if m == nil {
92 return nil, nil
93 }
94
8295 out, err := o.marshal(nil, m.ProtoReflect())
96 if len(out.Buf) == 0 && err == nil {
97 out.Buf = emptyBytesForMessage(m)
98 }
8399 return out.Buf, err
100 }
101
102 // emptyBytesForMessage returns a nil buffer if and only if m is invalid,
103 // otherwise it returns a non-nil empty buffer.
104 //
105 // This is to assist the edge-case where user-code does the following:
106 // m1.OptionalBytes, _ = proto.Marshal(m2)
107 // where they expect the proto2 "optional_bytes" field to be populated
108 // if any only if m2 is a valid message.
109 func emptyBytesForMessage(m Message) []byte {
110 if m == nil || !m.ProtoReflect().IsValid() {
111 return nil
112 }
113 return emptyBuf[:]
84114 }
85115
86116 // MarshalAppend appends the wire-format encoding of m to b,
87117 // returning the result.
88118 func (o MarshalOptions) MarshalAppend(b []byte, m Message) ([]byte, error) {
119 // Treat nil message interface as an empty message; nothing to append.
120 if m == nil {
121 return b, nil
122 }
123
89124 out, err := o.marshal(b, m.ProtoReflect())
90125 return out.Buf, err
91126 }
88 )
99
1010 // HasExtension reports whether an extension field is populated.
11 // It panics if ext does not extend m.
12 func HasExtension(m Message, ext protoreflect.ExtensionType) bool {
13 return m.ProtoReflect().Has(ext.TypeDescriptor())
11 // It returns false if m is invalid or if xt does not extend m.
12 func HasExtension(m Message, xt protoreflect.ExtensionType) bool {
13 // Treat nil message interface as an empty message; no populated fields.
14 if m == nil {
15 return false
16 }
17
18 // As a special-case, we reports invalid or mismatching descriptors
19 // as always not being populated (since they aren't).
20 if xt == nil || m.ProtoReflect().Descriptor() != xt.TypeDescriptor().ContainingMessage() {
21 return false
22 }
23
24 return m.ProtoReflect().Has(xt.TypeDescriptor())
1425 }
1526
1627 // ClearExtension clears an extension field such that subsequent
1728 // HasExtension calls return false.
18 // It panics if ext does not extend m.
19 func ClearExtension(m Message, ext protoreflect.ExtensionType) {
20 m.ProtoReflect().Clear(ext.TypeDescriptor())
29 // It panics if m is invalid or if xt does not extend m.
30 func ClearExtension(m Message, xt protoreflect.ExtensionType) {
31 m.ProtoReflect().Clear(xt.TypeDescriptor())
2132 }
2233
2334 // GetExtension retrieves the value for an extension field.
2435 // If the field is unpopulated, it returns the default value for
25 // scalars and an immutable, empty value for lists, maps, or messages.
26 // It panics if ext does not extend m.
27 func GetExtension(m Message, ext protoreflect.ExtensionType) interface{} {
28 return ext.InterfaceOf(m.ProtoReflect().Get(ext.TypeDescriptor()))
36 // scalars and an immutable, empty value for lists or messages.
37 // It panics if xt does not extend m.
38 func GetExtension(m Message, xt protoreflect.ExtensionType) interface{} {
39 // Treat nil message interface as an empty message; return the default.
40 if m == nil {
41 return xt.InterfaceOf(xt.Zero())
42 }
43
44 return xt.InterfaceOf(m.ProtoReflect().Get(xt.TypeDescriptor()))
2945 }
3046
3147 // SetExtension stores the value of an extension field.
32 // It panics if ext does not extend m or if value type is invalid for the field.
33 func SetExtension(m Message, ext protoreflect.ExtensionType, value interface{}) {
34 m.ProtoReflect().Set(ext.TypeDescriptor(), ext.ValueOf(value))
48 // It panics if m is invalid, xt does not extend m, or if type of v
49 // is invalid for the specified extension field.
50 func SetExtension(m Message, xt protoreflect.ExtensionType, v interface{}) {
51 xd := xt.TypeDescriptor()
52 pv := xt.ValueOf(v)
53
54 // Specially treat an invalid list, map, or message as clear.
55 isValid := true
56 switch {
57 case xd.IsList():
58 isValid = pv.List().IsValid()
59 case xd.IsMap():
60 isValid = pv.Map().IsValid()
61 case xd.Message() != nil:
62 isValid = pv.Message().IsValid()
63 }
64 if !isValid {
65 m.ProtoReflect().Clear(xd)
66 return
67 }
68
69 m.ProtoReflect().Set(xd, pv)
3570 }
71
72 // RangeExtensions iterates over every populated extension field in m in an
73 // undefined order, calling f for each extension type and value encountered.
74 // It returns immediately if f returns false.
75 // While iterating, mutating operations may only be performed
76 // on the current extension field.
77 func RangeExtensions(m Message, f func(protoreflect.ExtensionType, interface{}) bool) {
78 // Treat nil message interface as an empty message; nothing to range over.
79 if m == nil {
80 return
81 }
82
83 m.ProtoReflect().Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
84 if fd.IsExtension() {
85 xt := fd.(protoreflect.ExtensionTypeDescriptor).Type()
86 vi := xt.InterfaceOf(v)
87 return f(xt, vi)
88 }
89 return true
90 })
91 }
44 package proto
55
66 import (
7 "fmt"
8
79 "google.golang.org/protobuf/reflect/protoreflect"
810 "google.golang.org/protobuf/runtime/protoiface"
911 )
2022 // It is semantically equivalent to unmarshaling the encoded form of src
2123 // into dst with the UnmarshalOptions.Merge option specified.
2224 func Merge(dst, src Message) {
25 // TODO: Should nil src be treated as semantically equivalent to a
26 // untyped, read-only, empty message? What about a nil dst?
27
2328 dstMsg, srcMsg := dst.ProtoReflect(), src.ProtoReflect()
2429 if dstMsg.Descriptor() != srcMsg.Descriptor() {
30 if got, want := dstMsg.Descriptor().FullName(), srcMsg.Descriptor().FullName(); got != want {
31 panic(fmt.Sprintf("descriptor mismatch: %v != %v", got, want))
32 }
2533 panic("descriptor mismatch")
2634 }
2735 mergeOptions{}.mergeMessage(dstMsg, srcMsg)
6876 }
6977
7078 if !dst.IsValid() {
71 panic("cannot merge into invalid destination message")
79 panic(fmt.Sprintf("cannot merge into invalid %v message", dst.Descriptor().FullName()))
7280 }
7381
7482 src.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
33
44 package proto
55
6 import "google.golang.org/protobuf/reflect/protoreflect"
6 import (
7 "fmt"
8
9 "google.golang.org/protobuf/reflect/protoreflect"
10 )
711
812 // Reset clears every field in the message.
913 // The resulting message shares no observable memory with its previous state
1822
1923 func resetMessage(m protoreflect.Message) {
2024 if !m.IsValid() {
21 panic("cannot reset invalid message")
25 panic(fmt.Sprintf("cannot reset invalid %v message", m.Descriptor().FullName()))
2226 }
2327
2428 // Clear all known fields.
1717
1818 // Size returns the size in bytes of the wire-format encoding of m.
1919 func (o MarshalOptions) Size(m Message) int {
20 // Treat a nil message interface as an empty message; nothing to output.
21 if m == nil {
22 return 0
23 }
24
2025 return sizeMessage(m.ProtoReflect())
2126 }
2227
2121 //
2222 // The protobuf descriptor interfaces are not meant to be implemented by
2323 // user code since they might need to be extended in the future to support
24 // additions to the protobuf language. Protobuf descriptors can be constructed
25 // using the "google.golang.org/protobuf/reflect/protodesc" package.
24 // additions to the protobuf language.
25 // The "google.golang.org/protobuf/reflect/protodesc" package converts between
26 // google.protobuf.DescriptorProto messages and protobuf descriptors.
2627 //
2728 //
2829 // Go Type Descriptors
280280 // It is usually the camel-cased form of the field name.
281281 JSONName() string
282282
283 // HasPresence reports whether the field distinguishes between unpopulated
284 // and default values.
285 HasPresence() bool
286
283287 // IsExtension reports whether this is an extension field. If false,
284288 // then Parent and ContainingMessage refer to the same message.
285289 // Otherwise, ContainingMessage and Parent likely differ.
286290 IsExtension() bool
291
292 // HasOptionalKeyword reports whether the "optional" keyword was explicitly
293 // specified in the source .proto file.
294 HasOptionalKeyword() bool
287295
288296 // IsWeak reports whether this is a weak field, which does not impose a
289297 // direct dependency on the target type.
373381 // corresponds with the google.protobuf.OneofDescriptorProto message.
374382 type OneofDescriptor interface {
375383 Descriptor
384
385 // IsSynthetic reports whether this is a synthetic oneof created to support
386 // proto3 optional semantics. If true, Fields contains exactly one field
387 // with HasOptionalKeyword specified.
388 IsSynthetic() bool
376389
377390 // Fields is a list of fields belonging to this oneof.
378391 Fields() FieldDescriptors
113113 // Mutable is a mutating operation and unsafe for concurrent use.
114114 Mutable(FieldDescriptor) Value
115115
116 // NewField returns a new value for assignable to the field of a given descriptor.
117 // For scalars, this returns the default value.
116 // NewField returns a new value that is assignable to the field
117 // for the given descriptor. For scalars, this returns the default value.
118118 // For lists, maps, and messages, this returns a new, empty, mutable value.
119119 NewField(FieldDescriptor) Value
120120
66 import (
77 "fmt"
88 "math"
9 "reflect"
109 )
1110
1211 // Value is a union where only one Go type may be set at a time.
8685 case Message, List, Map:
8786 return valueOfIface(v)
8887 default:
89 panic(fmt.Sprintf("invalid type: %v", reflect.TypeOf(v)))
88 panic(fmt.Sprintf("invalid type: %T", v))
9089 }
9190 }
9291
196195 }
197196 }
198197
198 func (v Value) typeName() string {
199 switch v.typ {
200 case nilType:
201 return "nil"
202 case boolType:
203 return "bool"
204 case int32Type:
205 return "int32"
206 case int64Type:
207 return "int64"
208 case uint32Type:
209 return "uint32"
210 case uint64Type:
211 return "uint64"
212 case float32Type:
213 return "float32"
214 case float64Type:
215 return "float64"
216 case stringType:
217 return "string"
218 case bytesType:
219 return "bytes"
220 case enumType:
221 return "enum"
222 default:
223 switch v := v.getIface().(type) {
224 case Message:
225 return "message"
226 case List:
227 return "list"
228 case Map:
229 return "map"
230 default:
231 return fmt.Sprintf("<unknown: %T>", v)
232 }
233 }
234 }
235
236 func (v Value) panicMessage(what string) string {
237 return fmt.Sprintf("type mismatch: cannot convert %v to %s", v.typeName(), what)
238 }
239
199240 // Bool returns v as a bool and panics if the type is not a bool.
200241 func (v Value) Bool() bool {
201242 switch v.typ {
202243 case boolType:
203244 return v.num > 0
204245 default:
205 panic("proto: value type mismatch")
246 panic(v.panicMessage("bool"))
206247 }
207248 }
208249
212253 case int32Type, int64Type:
213254 return int64(v.num)
214255 default:
215 panic("proto: value type mismatch")
256 panic(v.panicMessage("int"))
216257 }
217258 }
218259
222263 case uint32Type, uint64Type:
223264 return uint64(v.num)
224265 default:
225 panic("proto: value type mismatch")
266 panic(v.panicMessage("uint"))
226267 }
227268 }
228269
232273 case float32Type, float64Type:
233274 return math.Float64frombits(uint64(v.num))
234275 default:
235 panic("proto: value type mismatch")
276 panic(v.panicMessage("float"))
236277 }
237278 }
238279
253294 case bytesType:
254295 return v.getBytes()
255296 default:
256 panic("proto: value type mismatch")
297 panic(v.panicMessage("bytes"))
257298 }
258299 }
259300
263304 case enumType:
264305 return EnumNumber(v.num)
265306 default:
266 panic("proto: value type mismatch")
307 panic(v.panicMessage("enum"))
267308 }
268309 }
269310
270311 // Message returns v as a Message and panics if the type is not a Message.
271312 func (v Value) Message() Message {
272 switch v := v.getIface().(type) {
313 switch vi := v.getIface().(type) {
273314 case Message:
274 return v
275 default:
276 panic("proto: value type mismatch")
315 return vi
316 default:
317 panic(v.panicMessage("message"))
277318 }
278319 }
279320
280321 // List returns v as a List and panics if the type is not a List.
281322 func (v Value) List() List {
282 switch v := v.getIface().(type) {
323 switch vi := v.getIface().(type) {
283324 case List:
284 return v
285 default:
286 panic("proto: value type mismatch")
325 return vi
326 default:
327 panic(v.panicMessage("list"))
287328 }
288329 }
289330
290331 // Map returns v as a Map and panics if the type is not a Map.
291332 func (v Value) Map() Map {
292 switch v := v.getIface().(type) {
333 switch vi := v.getIface().(type) {
293334 case Map:
294 return v
295 default:
296 panic("proto: value type mismatch")
335 return vi
336 default:
337 panic(v.panicMessage("map"))
297338 }
298339 }
299340
302343 switch v.typ {
303344 case boolType, int32Type, int64Type, uint32Type, uint64Type, stringType:
304345 return MapKey(v)
305 }
306 panic("proto: invalid map key type")
346 default:
347 panic(v.panicMessage("map key"))
348 }
307349 }
308350
309351 // MapKey is used to index maps, where the Go type of the MapKey must match
1212 github.com/go-kit/kit/log/level
1313 # github.com/go-logfmt/logfmt v0.5.0
1414 github.com/go-logfmt/logfmt
15 # github.com/golang/protobuf v1.4.0
15 # github.com/golang/protobuf v1.4.2
1616 github.com/golang/protobuf/proto
1717 github.com/golang/protobuf/ptypes
1818 github.com/golang/protobuf/ptypes/any
2222 github.com/matttproud/golang_protobuf_extensions/pbutil
2323 # github.com/pkg/errors v0.8.1
2424 github.com/pkg/errors
25 # github.com/prometheus/client_golang v1.6.0
25 # github.com/prometheus/client_golang v1.7.0
2626 ## explicit
2727 github.com/prometheus/client_golang/prometheus
2828 github.com/prometheus/client_golang/prometheus/internal
3939 github.com/prometheus/common/promlog
4040 github.com/prometheus/common/promlog/flag
4141 github.com/prometheus/common/version
42 # github.com/prometheus/procfs v0.0.11
42 # github.com/prometheus/procfs v0.1.3
4343 github.com/prometheus/procfs
4444 github.com/prometheus/procfs/internal/fs
4545 github.com/prometheus/procfs/internal/util
46 # golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f
46 # golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1
47 golang.org/x/sys/internal/unsafeheader
4748 golang.org/x/sys/unix
4849 golang.org/x/sys/windows
49 # google.golang.org/protobuf v1.21.0
50 # google.golang.org/protobuf v1.23.0
5051 google.golang.org/protobuf/encoding/prototext
5152 google.golang.org/protobuf/encoding/protowire
5253 google.golang.org/protobuf/internal/descfmt