Update dependencies
Tobias Schmidt
3 years ago
3 | 3 | |
4 | 4 | require ( |
5 | 5 | 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 | |
7 | 7 | github.com/prometheus/common v0.10.0 |
8 | 8 | gopkg.in/alecthomas/kingpin.v2 v2.2.6 |
9 | 9 | ) |
92 | 92 | github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= |
93 | 93 | github.com/golang/protobuf v1.4.0 h1:oOuy+ugB+P/kBdUnG5QaMXSIyJ1q38wWSojYCb3z5VQ= |
94 | 94 | 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= | |
95 | 97 | github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= |
96 | 98 | github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= |
97 | 99 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= |
140 | 142 | github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= |
141 | 143 | github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= |
142 | 144 | 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= | |
144 | 146 | github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= |
145 | 147 | github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= |
146 | 148 | github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= |
217 | 219 | github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM= |
218 | 220 | github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= |
219 | 221 | 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= | |
222 | 224 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8= |
223 | 225 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= |
224 | 226 | github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= |
232 | 234 | github.com/prometheus/common v0.4.1 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6Kw= |
233 | 235 | github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= |
234 | 236 | 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= | |
236 | 237 | github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc= |
237 | 238 | github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= |
238 | 239 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= |
240 | 241 | github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs= |
241 | 242 | github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= |
242 | 243 | 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= | |
245 | 246 | github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= |
246 | 247 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= |
247 | 248 | github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= |
343 | 344 | golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
344 | 345 | golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
345 | 346 | 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= | |
348 | 349 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
349 | 350 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= |
350 | 351 | golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
390 | 391 | google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= |
391 | 392 | google.golang.org/protobuf v1.21.0 h1:qdOKuR/EIArgaWNjetjgTzgVTAZ+S/WXVrq9HW9zimw= |
392 | 393 | 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= | |
393 | 396 | gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= |
394 | 397 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= |
395 | 398 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
32 | 32 | return protowire.SizeVarint(v) |
33 | 33 | } |
34 | 34 | |
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. | |
37 | 37 | // It returns (0, 0) if there is a parse error. |
38 | 38 | func DecodeVarint(b []byte) (uint64, int) { |
39 | 39 | v, n := protowire.ConsumeVarint(b) |
111 | 111 | return err |
112 | 112 | } |
113 | 113 | |
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. | |
117 | 117 | func (b *Buffer) Unmarshal(m Message) error { |
118 | 118 | err := UnmarshalMerge(b.Unread(), m) |
119 | 119 | b.idx = len(b.buf) |
259 | 259 | } |
260 | 260 | |
261 | 261 | // DecodeMessage consumes a length-prefixed message from the buffer. |
262 | // It does not reset m. | |
262 | // It does not reset m before unmarshaling. | |
263 | 263 | func (b *Buffer) DecodeMessage(m Message) error { |
264 | 264 | v, err := b.DecodeRawBytes(false) |
265 | 265 | if err != nil { |
271 | 271 | // DecodeGroup consumes a message group from the buffer. |
272 | 272 | // It assumes that the start group marker has already been consumed and |
273 | 273 | // consumes all bytes until (and including the end group marker). |
274 | // It does not reset m. | |
274 | // It does not reset m before unmarshaling. | |
275 | 275 | func (b *Buffer) DecodeGroup(m Message) error { |
276 | 276 | v, n, err := consumeGroup(b.buf[b.idx:]) |
277 | 277 | if err != nil { |
8 | 8 | "errors" |
9 | 9 | "fmt" |
10 | 10 | "strconv" |
11 | ||
12 | protoV2 "google.golang.org/protobuf/proto" | |
11 | 13 | ) |
12 | 14 | |
13 | 15 | var ( |
81 | 83 | return val, nil |
82 | 84 | } |
83 | 85 | |
84 | // Deprecated: Do not use. | |
86 | // Deprecated: Do not use; this type existed for intenal-use only. | |
85 | 87 | type InternalMessageInfo struct{} |
86 | 88 | |
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 | } |
67 | 67 | return has |
68 | 68 | } |
69 | 69 | |
70 | // ClearExtension removes the the exntesion field from m | |
70 | // ClearExtension removes the extension field from m | |
71 | 71 | // either as an explicitly populated field or as an unknown field. |
72 | 72 | func ClearExtension(m Message, xt *ExtensionDesc) { |
73 | 73 | mr := MessageReflect(m) |
107 | 107 | clearUnknown(mr, mr.Descriptor().ExtensionRanges()) |
108 | 108 | } |
109 | 109 | |
110 | // GetExtension retrieves a proto2 extended field from pb. | |
110 | // GetExtension retrieves a proto2 extended field from m. | |
111 | 111 | // |
112 | 112 | // If the descriptor is type complete (i.e., ExtensionDesc.ExtensionType is non-nil), |
113 | 113 | // then GetExtension parses the encoded field and returns a Go value of the specified type. |
28 | 28 | // RegisterFile is called from generated code to register the compressed |
29 | 29 | // FileDescriptorProto with the file path for a proto source file. |
30 | 30 | // |
31 | // Deprecated: Use protoregistry.GlobalFiles.Register instead. | |
31 | // Deprecated: Use protoregistry.GlobalFiles.RegisterFile instead. | |
32 | 32 | func RegisterFile(s filePath, d fileDescGZIP) { |
33 | 33 | // Decompress the descriptor. |
34 | 34 | zr, err := gzip.NewReader(bytes.NewReader(d)) |
52 | 52 | // FileDescriptor returns the compressed FileDescriptorProto given the file path |
53 | 53 | // for a proto source file. It returns nil if not found. |
54 | 54 | // |
55 | // Deprecated: Use protoregistry.GlobalFiles.RangeFilesByPath instead. | |
55 | // Deprecated: Use protoregistry.GlobalFiles.FindFileByPath instead. | |
56 | 56 | func FileDescriptor(s filePath) fileDescGZIP { |
57 | 57 | if v, ok := fileCache.Load(s); ok { |
58 | 58 | return v.(fileDescGZIP) |
97 | 97 | // RegisterEnum is called from the generated code to register the mapping of |
98 | 98 | // enum value names to enum numbers for the enum identified by s. |
99 | 99 | // |
100 | // Deprecated: Use protoregistry.GlobalTypes.Register instead. | |
100 | // Deprecated: Use protoregistry.GlobalTypes.RegisterEnum instead. | |
101 | 101 | func RegisterEnum(s enumName, _ enumsByNumber, m enumsByName) { |
102 | 102 | if _, ok := enumCache.Load(s); ok { |
103 | 103 | panic("proto: duplicate enum registered: " + s) |
180 | 180 | // RegisterType is called from generated code to register the message Go type |
181 | 181 | // for a message of the given name. |
182 | 182 | // |
183 | // Deprecated: Use protoregistry.GlobalTypes.Register instead. | |
183 | // Deprecated: Use protoregistry.GlobalTypes.RegisterMessage instead. | |
184 | 184 | func RegisterType(m Message, s messageName) { |
185 | 185 | mt := protoimpl.X.LegacyMessageTypeOf(m, protoreflect.FullName(s)) |
186 | 186 | if err := protoregistry.GlobalTypes.RegisterMessage(mt); err != nil { |
279 | 279 | // RegisterExtension is called from the generated code to register |
280 | 280 | // the extension descriptor. |
281 | 281 | // |
282 | // Deprecated: Use protoregistry.GlobalTypes.Register instead. | |
282 | // Deprecated: Use protoregistry.GlobalTypes.RegisterExtension instead. | |
283 | 283 | func RegisterExtension(d *ExtensionDesc) { |
284 | 284 | if err := protoregistry.GlobalTypes.RegisterExtension(d); err != nil { |
285 | 285 | panic(err) |
93 | 93 | ) |
94 | 94 | |
95 | 95 | // 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) } | |
97 | 97 | |
98 | 98 | // 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) } | |
100 | 100 | |
101 | 101 | // 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) } | |
103 | 103 | |
104 | 104 | // 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) } | |
106 | 106 | |
107 | 107 | var ( |
108 | 108 | newline = []byte("\n") |
19 | 19 | "strings" |
20 | 20 | |
21 | 21 | "github.com/cespare/xxhash/v2" |
22 | //lint:ignore SA1019 Need to keep deprecated package for compatibility. | |
22 | 23 | "github.com/golang/protobuf/proto" |
23 | 24 | "github.com/prometheus/common/model" |
24 | 25 |
21 | 21 | "sync/atomic" |
22 | 22 | "time" |
23 | 23 | |
24 | //lint:ignore SA1019 Need to keep deprecated package for compatibility. | |
24 | 25 | "github.com/golang/protobuf/proto" |
25 | 26 | |
26 | 27 | dto "github.com/prometheus/client_model/go" |
16 | 16 | "strings" |
17 | 17 | "time" |
18 | 18 | |
19 | //lint:ignore SA1019 Need to keep deprecated package for compatibility. | |
19 | 20 | "github.com/golang/protobuf/proto" |
20 | 21 | "github.com/prometheus/common/model" |
21 | 22 |
25 | 25 | "unicode/utf8" |
26 | 26 | |
27 | 27 | "github.com/cespare/xxhash/v2" |
28 | //lint:ignore SA1019 Need to keep deprecated package for compatibility. | |
28 | 29 | "github.com/golang/protobuf/proto" |
29 | 30 | "github.com/prometheus/common/expfmt" |
30 | 31 |
22 | 22 | "time" |
23 | 23 | |
24 | 24 | "github.com/beorn7/perks/quantile" |
25 | //lint:ignore SA1019 Need to keep deprecated package for compatibility. | |
25 | 26 | "github.com/golang/protobuf/proto" |
26 | 27 | |
27 | 28 | dto "github.com/prometheus/client_model/go" |
312 | 312 | // Base units. |
313 | 313 | "amperes": "amperes", |
314 | 314 | "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. | |
316 | 316 | "grams": "grams", |
317 | 317 | "joules": "joules", |
318 | "kelvin": "kelvin", // SI base unit, used in special cases (e.g. color temperature, scientific measurements). | |
318 | 319 | "meters": "meters", // Both American and international spelling permitted. |
319 | 320 | "metres": "metres", |
320 | 321 | "seconds": "seconds", |
327 | 328 | "days": "seconds", |
328 | 329 | "weeks": "seconds", |
329 | 330 | // Temperature. |
330 | "kelvin": "celsius", | |
331 | "kelvins": "celsius", | |
331 | "kelvins": "kelvin", | |
332 | 332 | "fahrenheit": "celsius", |
333 | 333 | "rankine": "celsius", |
334 | 334 | // Length. |
111 | 111 | panic(fmt.Errorf("collected a non-gauge/counter/untyped metric: %s", pb)) |
112 | 112 | } |
113 | 113 | |
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 | |
139 | 151 | } |
140 | 152 | |
141 | 153 | // CollectAndCompare registers the provided Collector with a newly created |
18 | 18 | "time" |
19 | 19 | "unicode/utf8" |
20 | 20 | |
21 | //lint:ignore SA1019 Need to keep deprecated package for compatibility. | |
21 | 22 | "github.com/golang/protobuf/proto" |
22 | 23 | "github.com/golang/protobuf/ptypes" |
23 | 24 |
16 | 16 | "fmt" |
17 | 17 | "sort" |
18 | 18 | |
19 | //lint:ignore SA1019 Need to keep deprecated package for compatibility. | |
19 | 20 | "github.com/golang/protobuf/proto" |
20 | 21 | |
21 | 22 | dto "github.com/prometheus/client_model/go" |
26 | 27 | // registered with the wrapped Registerer in a modified way. The modified |
27 | 28 | // Collector adds the provided Labels to all Metrics it collects (as |
28 | 29 | // 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. | |
30 | 32 | // |
31 | 33 | // WrapRegistererWith provides a way to add fixed labels to a subset of |
32 | 34 | // Collectors. It should not be used to add fixed labels to all metrics exposed. |
49 | 51 | // Registerer. Collectors registered with the returned Registerer will be |
50 | 52 | // registered with the wrapped Registerer in a modified way. The modified |
51 | 53 | // 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. | |
52 | 55 | // |
53 | 56 | // WrapRegistererWithPrefix is useful to have one place to prefix all metrics of |
54 | 57 | // a sub-system. To make this work, register metrics of the sub-system with the |
79 | 82 | } |
80 | 83 | |
81 | 84 | func (r *wrappingRegisterer) Register(c Collector) error { |
85 | if r.wrappedRegisterer == nil { | |
86 | return nil | |
87 | } | |
82 | 88 | return r.wrappedRegisterer.Register(&wrappingCollector{ |
83 | 89 | wrappedCollector: c, |
84 | 90 | prefix: r.prefix, |
87 | 93 | } |
88 | 94 | |
89 | 95 | func (r *wrappingRegisterer) MustRegister(cs ...Collector) { |
96 | if r.wrappedRegisterer == nil { | |
97 | return | |
98 | } | |
90 | 99 | for _, c := range cs { |
91 | 100 | if err := r.Register(c); err != nil { |
92 | 101 | panic(err) |
95 | 104 | } |
96 | 105 | |
97 | 106 | func (r *wrappingRegisterer) Unregister(c Collector) bool { |
107 | if r.wrappedRegisterer == nil { | |
108 | return false | |
109 | } | |
98 | 110 | return r.wrappedRegisterer.Unregister(&wrappingCollector{ |
99 | 111 | wrappedCollector: c, |
100 | 112 | prefix: r.prefix, |
149 | 149 | $(GO) get $(GOOPTS) -t ./... |
150 | 150 | endif |
151 | 151 | |
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 | ||
152 | 163 | .PHONY: common-test-short |
153 | 164 | common-test-short: $(GOTEST_DIR) |
154 | 165 | @echo ">> running short tests" |
10 | 10 | // See the License for the specific language governing permissions and |
11 | 11 | // limitations under the License. |
12 | 12 | |
13 | // +build linux | |
14 | ||
13 | 15 | package procfs |
14 | 16 | |
15 | 17 | import ( |
16 | 18 | "bufio" |
17 | 19 | "bytes" |
20 | "errors" | |
21 | "regexp" | |
18 | 22 | "strconv" |
19 | 23 | "strings" |
20 | 24 | |
51 | 55 | PowerManagement string |
52 | 56 | } |
53 | 57 | |
58 | var ( | |
59 | cpuinfoClockRegexp = regexp.MustCompile(`([\d.]+)`) | |
60 | cpuinfoS390XProcessorRegexp = regexp.MustCompile(`^processor\s+(\d+):.*`) | |
61 | ) | |
62 | ||
54 | 63 | // CPUInfo returns information about current system CPUs. |
55 | 64 | // See https://www.kernel.org/doc/Documentation/filesystems/proc.txt |
56 | 65 | func (fs FS) CPUInfo() ([]CPUInfo, error) { |
61 | 70 | return parseCPUInfo(data) |
62 | 71 | } |
63 | 72 | |
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) { | |
68 | 74 | 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, ":") { | |
72 | 93 | continue |
73 | 94 | } |
74 | 95 | field := strings.SplitN(line, ": ", 2) |
81 | 102 | return nil, err |
82 | 103 | } |
83 | 104 | cpuinfo[i].Processor = uint(v) |
84 | case "vendor_id": | |
105 | case "vendor", "vendor_id": | |
85 | 106 | cpuinfo[i].VendorID = field[1] |
86 | 107 | case "cpu family": |
87 | 108 | cpuinfo[i].CPUFamily = field[1] |
162 | 183 | } |
163 | 184 | } |
164 | 185 | 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 |
170 | 170 | Path: fixtures/proc/26231/schedstat |
171 | 171 | Lines: 1 |
172 | 172 | 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 | |
173 | 450 | Mode: 644 |
174 | 451 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
175 | 452 | Path: fixtures/proc/26231/stat |
234 | 511 | nonvoluntary_ctxt_switches: 1727500 |
235 | 512 | Mode: 644 |
236 | 513 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
514 | Path: fixtures/proc/26231/wchan | |
515 | Lines: 1 | |
516 | poll_schedule_timeoutEOF | |
517 | Mode: 664 | |
518 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
237 | 519 | Directory: fixtures/proc/26232 |
238 | 520 | Mode: 755 |
239 | 521 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
308 | 590 | Lines: 1 |
309 | 591 | 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 |
310 | 592 | Mode: 644 |
593 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
594 | Path: fixtures/proc/26232/wchan | |
595 | Lines: 1 | |
596 | 0EOF | |
597 | Mode: 664 | |
311 | 598 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
312 | 599 | Directory: fixtures/proc/26233 |
313 | 600 | Mode: 755 |
1553 | 1840 | Mode: 444 |
1554 | 1841 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
1555 | 1842 | Path: fixtures/proc/diskstats |
1556 | Lines: 49 | |
1843 | Lines: 52 | |
1557 | 1844 | 1 0 ram0 0 0 0 0 0 0 0 0 0 0 0 |
1558 | 1845 | 1 1 ram1 0 0 0 0 0 0 0 0 0 0 0 |
1559 | 1846 | 1 2 ram2 0 0 0 0 0 0 0 0 0 0 0 |
1603 | 1890 | 8 0 sdb 326552 841 9657779 84 41822 2895 1972905 5007 0 60730 67070 68851 0 1925173784 11130 |
1604 | 1891 | 8 1 sdb1 231 3 34466 4 24 23 106 0 0 64 64 0 0 0 0 |
1605 | 1892 | 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 | |
1606 | 1896 | Mode: 664 |
1607 | 1897 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
1608 | 1898 | Directory: fixtures/proc/fs |
1609 | 1899 | 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 | |
1610 | 1931 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
1611 | 1932 | Directory: fixtures/proc/fs/xfs |
1612 | 1933 | Mode: 755 |
2023 | 2344 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
2024 | 2345 | Directory: fixtures/proc/sys |
2025 | 2346 | 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 | |
2026 | 2373 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
2027 | 2374 | Directory: fixtures/proc/sys/vm |
2028 | 2375 | Mode: 775 |
2525 | 2872 | Directory: fixtures/sys/block/sda |
2526 | 2873 | Mode: 775 |
2527 | 2874 | # 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
2528 | 3106 | Path: fixtures/sys/block/sda/stat |
2529 | 3107 | Lines: 1 |
2530 | 3108 | 9652963 396792 759304206 412943 8422549 6731723 286915323 13947418 0 5658367 19174573 1 2 3 12 |
2533 | 3111 | Directory: fixtures/sys/class |
2534 | 3112 | Mode: 775 |
2535 | 3113 | # 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
2536 | 3248 | Directory: fixtures/sys/class/infiniband |
2537 | 3249 | Mode: 755 |
2538 | 3250 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
2563 | 3275 | Directory: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters |
2564 | 3276 | Mode: 755 |
2565 | 3277 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
3278 | Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/VL15_dropped | |
3279 | Lines: 1 | |
3280 | 0 | |
3281 | Mode: 664 | |
3282 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
2566 | 3283 | Path: fixtures/sys/class/infiniband/mlx4_0/ports/1/counters/excessive_buffer_overrun_errors |
2567 | 3284 | Lines: 1 |
2568 | 3285 | 0 |
2663 | 3380 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
2664 | 3381 | Directory: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters |
2665 | 3382 | 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 | |
2666 | 3388 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
2667 | 3389 | Path: fixtures/sys/class/infiniband/mlx4_0/ports/2/counters/excessive_buffer_overrun_errors |
2668 | 3390 | Lines: 1 |
3108 | 3830 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
3109 | 3831 | Path: fixtures/sys/class/thermal/thermal_zone1/temp |
3110 | 3832 | Lines: 1 |
3111 | 44000 | |
3833 | -44000 | |
3112 | 3834 | Mode: 664 |
3113 | 3835 | # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
3114 | 3836 | Path: fixtures/sys/class/thermal/thermal_zone1/type |
4286 | 5008 | 0 |
4287 | 5009 | Mode: 644 |
4288 | 5010 | # 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
4289 | 5022 | Path: fixtures/sys/fs/bcache/deaddd54-c735-46d5-868e-f331c5fd7c74/btree_cache_size |
4290 | 5023 | Lines: 1 |
4291 | 5024 | 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 | } |
72 | 72 | return strconv.ParseUint(strings.TrimSpace(string(data)), 10, 64) |
73 | 73 | } |
74 | 74 | |
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 | ||
75 | 84 | // ParseBool parses a string into a boolean pointer. |
76 | 85 | func ParseBool(b string) *bool { |
77 | 86 | 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 | } |
51 | 51 | func (fs FS) MDStat() ([]MDStat, error) { |
52 | 52 | data, err := ioutil.ReadFile(fs.proc.Path("mdstat")) |
53 | 53 | if err != nil { |
54 | return nil, fmt.Errorf("error parsing mdstat %s: %s", fs.proc.Path("mdstat"), err) | |
54 | return nil, err | |
55 | 55 | } |
56 | 56 | mdstat, err := parseMDStat(data) |
57 | 57 | if err != nil { |
76 | 76 | |
77 | 77 | mountInfo := strings.Split(mountString, " ") |
78 | 78 | mountInfoLength := len(mountInfo) |
79 | if mountInfoLength < 11 { | |
79 | if mountInfoLength < 10 { | |
80 | 80 | return nil, fmt.Errorf("couldn't find enough fields in mount string: %s", mountString) |
81 | 81 | } |
82 | 82 | |
143 | 143 | return optionalFields, nil |
144 | 144 | } |
145 | 145 | |
146 | // Parses the mount options, superblock options. | |
146 | // mountOptionsParser parses the mount options, superblock options. | |
147 | 147 | func mountOptionsParser(mountOptions string) map[string]string { |
148 | 148 | opts := make(map[string]string) |
149 | 149 | options := strings.Split(mountOptions, ",") |
160 | 160 | return opts |
161 | 161 | } |
162 | 162 | |
163 | // Retrieves mountinfo information from `/proc/self/mountinfo`. | |
163 | // GetMounts retrieves mountinfo information from `/proc/self/mountinfo`. | |
164 | 164 | func GetMounts() ([]*MountInfo, error) { |
165 | 165 | data, err := util.ReadFileNoStat("/proc/self/mountinfo") |
166 | 166 | if err != nil { |
169 | 169 | return parseMountInfo(data) |
170 | 170 | } |
171 | 171 | |
172 | // Retrieves mountinfo information from a processes' `/proc/<pid>/mountinfo`. | |
172 | // GetProcMounts retrieves mountinfo information from a processes' `/proc/<pid>/mountinfo`. | |
173 | 173 | func GetProcMounts(pid int) ([]*MountInfo, error) { |
174 | 174 | data, err := util.ReadFileNoStat(fmt.Sprintf("/proc/%d/mountinfo", pid)) |
175 | 175 | if err != nil { |
185 | 185 | CumulativeTotalResponseMilliseconds uint64 |
186 | 186 | // Duration from when a request was enqueued to when it was completely handled. |
187 | 187 | CumulativeTotalRequestMilliseconds uint64 |
188 | // The count of operations that complete with tk_status < 0. These statuses usually indicate error conditions. | |
189 | Errors uint64 | |
188 | 190 | } |
189 | 191 | |
190 | 192 | // A NFSTransportStats contains statistics for the NFS mount RPC requests and |
493 | 495 | // line is reached. |
494 | 496 | func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) { |
495 | 497 | 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 | |
498 | 500 | ) |
499 | 501 | |
500 | 502 | var ops []NFSOperationStats |
507 | 509 | break |
508 | 510 | } |
509 | 511 | |
510 | if len(ss) != numFields { | |
512 | if len(ss) < minFields { | |
511 | 513 | return nil, fmt.Errorf("invalid NFS per-operations stats: %v", ss) |
512 | 514 | } |
513 | 515 | |
514 | 516 | // Skip string operation name for integers |
515 | ns := make([]uint64, 0, numFields-1) | |
517 | ns := make([]uint64, 0, minFields-1) | |
516 | 518 | for _, st := range ss[1:] { |
517 | 519 | n, err := strconv.ParseUint(st, 10, 64) |
518 | 520 | if err != nil { |
522 | 524 | ns = append(ns, n) |
523 | 525 | } |
524 | 526 | |
525 | ops = append(ops, NFSOperationStats{ | |
527 | opStats := NFSOperationStats{ | |
526 | 528 | Operation: strings.TrimSuffix(ss[0], ":"), |
527 | 529 | Requests: ns[0], |
528 | 530 | Transmissions: ns[1], |
532 | 534 | CumulativeQueueMilliseconds: ns[5], |
533 | 535 | CumulativeTotalResponseMilliseconds: ns[6], |
534 | 536 | CumulativeTotalRequestMilliseconds: ns[7], |
535 | }) | |
537 | } | |
538 | ||
539 | if len(ns) > 8 { | |
540 | opStats.Errors = ns[8] | |
541 | } | |
542 | ||
543 | ops = append(ops, opStats) | |
536 | 544 | } |
537 | 545 | |
538 | 546 | return ops, s.Err() |
37 | 37 | SearchRestart uint64 |
38 | 38 | } |
39 | 39 | |
40 | // Retrieves netfilter's conntrack statistics, split by CPU cores | |
40 | // ConntrackStat retrieves netfilter's conntrack statistics, split by CPU cores | |
41 | 41 | func (fs FS) ConntrackStat() ([]ConntrackStatEntry, error) { |
42 | 42 | return readConntrackStat(fs.proc.Path("net", "stat", "nf_conntrack")) |
43 | 43 | } |
133 | 133 | return strings.Split(string(bytes.TrimRight(data, string("\x00"))), string(byte(0))), nil |
134 | 134 | } |
135 | 135 | |
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 | ||
136 | 157 | // Comm returns the command name of a process. |
137 | 158 | func (p Proc) Comm() (string, error) { |
138 | 159 | 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 | } |
40 | 40 | Flags string |
41 | 41 | // Mount point ID |
42 | 42 | 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) | |
44 | 44 | InotifyInfos []InotifyInfo |
45 | 45 | } |
46 | 46 |
10 | 10 | // See the License for the specific language governing permissions and |
11 | 11 | // limitations under the License. |
12 | 12 | |
13 | // +build !windows | |
13 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris | |
14 | 14 | |
15 | 15 | package procfs |
16 | 16 | |
24 | 24 | "golang.org/x/sys/unix" |
25 | 25 | ) |
26 | 26 | |
27 | // ProcMapPermissions contains permission settings read from /proc/[pid]/maps | |
27 | 28 | type ProcMapPermissions struct { |
28 | 29 | // mapping has the [R]ead flag set |
29 | 30 | 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 | } |
186 | 186 | #include <sys/select.h> |
187 | 187 | #include <sys/signalfd.h> |
188 | 188 | #include <sys/socket.h> |
189 | #include <sys/timerfd.h> | |
189 | 190 | #include <sys/uio.h> |
190 | 191 | #include <sys/xattr.h> |
191 | 192 | #include <linux/bpf.h> |
479 | 480 | $2 ~ /^(MS|MNT|UMOUNT)_/ || |
480 | 481 | $2 ~ /^NS_GET_/ || |
481 | 482 | $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)_/ || | |
483 | 484 | $2 ~ /^KEXEC_/ || |
484 | 485 | $2 ~ /^LINUX_REBOOT_CMD_/ || |
485 | 486 | $2 ~ /^LINUX_REBOOT_MAGIC[12]$/ || |
5 | 5 | |
6 | 6 | package unix |
7 | 7 | |
8 | import "unsafe" | |
8 | import ( | |
9 | "unsafe" | |
10 | ||
11 | "golang.org/x/sys/internal/unsafeheader" | |
12 | ) | |
9 | 13 | |
10 | 14 | //sys closedir(dir uintptr) (err error) |
11 | 15 | //sys readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) |
70 | 74 | cnt++ |
71 | 75 | continue |
72 | 76 | } |
77 | ||
73 | 78 | reclen := int(entry.Reclen) |
74 | 79 | if reclen > len(buf) { |
75 | 80 | // Not enough room. Return for now. |
78 | 83 | // restarting is O(n^2) in the length of the directory. Oh well. |
79 | 84 | break |
80 | 85 | } |
86 | ||
81 | 87 | // 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 | ||
88 | 95 | buf = buf[reclen:] |
89 | 96 | n += reclen |
90 | 97 | cnt++ |
422 | 422 | //sysnb Getrlimit(which int, lim *Rlimit) (err error) |
423 | 423 | //sysnb Getrusage(who int, rusage *Rusage) (err error) |
424 | 424 | //sysnb Getsid(pid int) (sid int, err error) |
425 | //sysnb Gettimeofday(tp *Timeval) (err error) | |
425 | 426 | //sysnb Getuid() (uid int) |
426 | 427 | //sysnb Issetugid() (tainted bool) |
427 | 428 | //sys Kqueue() (fd int, err error) |
17 | 17 | |
18 | 18 | func setTimeval(sec, usec int64) Timeval { |
19 | 19 | 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 | |
31 | 20 | } |
32 | 21 | |
33 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { |
17 | 17 | |
18 | 18 | func setTimeval(sec, usec int64) Timeval { |
19 | 19 | 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 | |
31 | 20 | } |
32 | 21 | |
33 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { |
17 | 17 | |
18 | 18 | func setTimeval(sec, usec int64) Timeval { |
19 | 19 | 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 | |
31 | 20 | } |
32 | 21 | |
33 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { |
19 | 19 | |
20 | 20 | func setTimeval(sec, usec int64) Timeval { |
21 | 21 | 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 | |
33 | 22 | } |
34 | 23 | |
35 | 24 | func SetKevent(k *Kevent_t, fd, mode, flags int) { |
96 | 96 | return err |
97 | 97 | } |
98 | 98 | |
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 | ||
99 | 105 | func IoctlGetUint32(fd int, req uint) (uint32, error) { |
100 | 106 | var value uint32 |
101 | 107 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) |
105 | 111 | func IoctlGetRTCTime(fd int) (*RTCTime, error) { |
106 | 112 | var value RTCTime |
107 | 113 | 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))) | |
108 | 120 | return &value, err |
109 | 121 | } |
110 | 122 | |
1632 | 1644 | //sys CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) |
1633 | 1645 | //sys DeleteModule(name string, flags int) (err error) |
1634 | 1646 | //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 | ||
1635 | 1656 | //sys Dup3(oldfd int, newfd int, flags int) (err error) |
1636 | 1657 | //sysnb EpollCreate1(flag int) (fd int, err error) |
1637 | 1658 | //sysnb EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) |
1756 | 1777 | //sys Syncfs(fd int) (err error) |
1757 | 1778 | //sysnb Sysinfo(info *Sysinfo_t) (err error) |
1758 | 1779 | //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) | |
1759 | 1783 | //sysnb Tgkill(tgid int, tid int, sig syscall.Signal) (err error) |
1760 | 1784 | //sysnb Times(tms *Tms) (ticks uintptr, err error) |
1761 | 1785 | //sysnb Umask(mask int) (oldmask int) |
2177 | 2201 | // TimerGetoverrun |
2178 | 2202 | // TimerGettime |
2179 | 2203 | // TimerSettime |
2180 | // Timerfd | |
2181 | 2204 | // Tkill (obsolete) |
2182 | 2205 | // Tuxcall |
2183 | 2206 | // Umount2 |
48 | 48 | |
49 | 49 | // 64-bit file system and 32-bit uid calls |
50 | 50 | // (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) | |
52 | 52 | //sysnb EpollCreate(size int) (fd int, err error) |
53 | 53 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) |
54 | 54 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64_64 |
5 | 5 | |
6 | 6 | package unix |
7 | 7 | |
8 | //sys Dup2(oldfd int, newfd int) (err error) | |
8 | //sys dup2(oldfd int, newfd int) (err error) | |
9 | 9 | //sysnb EpollCreate(size int) (fd int, err error) |
10 | 10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) |
11 | 11 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 |
79 | 79 | |
80 | 80 | // 64-bit file system and 32-bit uid calls |
81 | 81 | // (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) | |
83 | 83 | //sysnb EpollCreate(size int) (fd int, err error) |
84 | 84 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) |
85 | 85 | //sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32 |
24 | 24 | //sysnb Getegid() (egid int) |
25 | 25 | //sysnb Geteuid() (euid int) |
26 | 26 | //sysnb Getgid() (gid int) |
27 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) | |
27 | //sysnb getrlimit(resource int, rlim *Rlimit) (err error) | |
28 | 28 | //sysnb Getuid() (uid int) |
29 | 29 | //sys Listen(s int, n int) (err error) |
30 | 30 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 |
46 | 46 | //sysnb Setregid(rgid int, egid int) (err error) |
47 | 47 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) |
48 | 48 | //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) | |
50 | 50 | //sysnb Setreuid(ruid int, euid int) (err error) |
51 | 51 | //sys Shutdown(fd int, how int) (err error) |
52 | 52 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) |
167 | 167 | return |
168 | 168 | } |
169 | 169 | |
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 | ||
170 | 188 | func (r *PtraceRegs) PC() uint64 { return r.Pc } |
171 | 189 | |
172 | 190 | func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc } |
191 | 209 | return InotifyInit1(0) |
192 | 210 | } |
193 | 211 | |
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 | |
197 | 215 | |
198 | 216 | func Pause() error { |
199 | 217 | _, err := ppoll(nil, 0, nil, nil) |
6 | 6 | |
7 | 7 | package unix |
8 | 8 | |
9 | //sys Dup2(oldfd int, newfd int) (err error) | |
9 | //sys dup2(oldfd int, newfd int) (err error) | |
10 | 10 | //sysnb EpollCreate(size int) (fd int, err error) |
11 | 11 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) |
12 | 12 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 |
13 | 13 | |
14 | 14 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) |
15 | 15 | |
16 | //sys Dup2(oldfd int, newfd int) (err error) | |
16 | //sys dup2(oldfd int, newfd int) (err error) | |
17 | 17 | //sysnb EpollCreate(size int) (fd int, err error) |
18 | 18 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) |
19 | 19 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 |
6 | 6 | |
7 | 7 | package unix |
8 | 8 | |
9 | //sys Dup2(oldfd int, newfd int) (err error) | |
9 | //sys dup2(oldfd int, newfd int) (err error) | |
10 | 10 | //sysnb EpollCreate(size int) (fd int, err error) |
11 | 11 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) |
12 | 12 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 |
190 | 190 | return InotifyInit1(0) |
191 | 191 | } |
192 | 192 | |
193 | func Dup2(oldfd int, newfd int) (err error) { | |
194 | return Dup3(oldfd, newfd, 0) | |
195 | } | |
196 | ||
197 | 193 | func Pause() error { |
198 | 194 | _, err := ppoll(nil, 0, nil, nil) |
199 | 195 | return err |
227 | 223 | } |
228 | 224 | return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) |
229 | 225 | } |
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 |
9 | 9 | "unsafe" |
10 | 10 | ) |
11 | 11 | |
12 | //sys Dup2(oldfd int, newfd int) (err error) | |
12 | //sys dup2(oldfd int, newfd int) (err error) | |
13 | 13 | //sysnb EpollCreate(size int) (fd int, err error) |
14 | 14 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) |
15 | 15 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 |
7 | 7 | |
8 | 8 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) |
9 | 9 | //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) | |
11 | 11 | //sys Fchown(fd int, uid int, gid int) (err error) |
12 | 12 | //sys Fstat(fd int, stat *Stat_t) (err error) |
13 | 13 | //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 |
11 | 11 | "sync" |
12 | 12 | "syscall" |
13 | 13 | "unsafe" |
14 | ||
15 | "golang.org/x/sys/internal/unsafeheader" | |
14 | 16 | ) |
15 | 17 | |
16 | 18 | var ( |
112 | 114 | return nil, errno |
113 | 115 | } |
114 | 116 | |
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 | |
124 | 123 | |
125 | 124 | // Register mapping in m and return it. |
126 | 125 | p := &b[cap(b)-1] |
159 | 159 | BPF_A = 0x10 |
160 | 160 | BPF_ABS = 0x20 |
161 | 161 | BPF_ADD = 0x0 |
162 | BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff | |
163 | BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 0x38 | |
164 | 162 | BPF_ALU = 0x4 |
165 | 163 | BPF_ALU64 = 0x7 |
166 | 164 | BPF_AND = 0x50 |
167 | BPF_ANY = 0x0 | |
168 | 165 | BPF_ARSH = 0xc0 |
169 | 166 | BPF_B = 0x10 |
170 | 167 | BPF_BUILD_ID_SIZE = 0x14 |
171 | 168 | 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 | |
177 | 169 | BPF_DIV = 0x30 |
178 | 170 | BPF_DW = 0x18 |
179 | 171 | BPF_END = 0xd0 |
180 | BPF_EXIST = 0x2 | |
181 | 172 | 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 | |
185 | 173 | BPF_FROM_BE = 0x8 |
186 | 174 | BPF_FROM_LE = 0x0 |
187 | 175 | 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 | |
193 | 176 | BPF_F_ALLOW_MULTI = 0x2 |
194 | 177 | BPF_F_ALLOW_OVERRIDE = 0x1 |
195 | 178 | 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 | |
214 | 179 | BPF_F_QUERY_EFFECTIVE = 0x1 |
215 | BPF_F_RDONLY = 0x8 | |
216 | BPF_F_RDONLY_PROG = 0x80 | |
217 | BPF_F_RECOMPUTE_CSUM = 0x1 | |
218 | 180 | 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 | |
223 | 181 | BPF_F_STRICT_ALIGNMENT = 0x1 |
224 | BPF_F_SYSCTL_BASE_NAME = 0x1 | |
225 | 182 | BPF_F_TEST_RND_HI32 = 0x4 |
226 | 183 | 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 | |
234 | 184 | BPF_H = 0x8 |
235 | 185 | BPF_IMM = 0x0 |
236 | 186 | BPF_IND = 0x40 |
266 | 216 | BPF_MUL = 0x20 |
267 | 217 | BPF_NEG = 0x80 |
268 | 218 | BPF_NET_OFF = -0x100000 |
269 | BPF_NOEXIST = 0x1 | |
270 | 219 | BPF_OBJ_NAME_LEN = 0x10 |
271 | 220 | BPF_OR = 0x40 |
272 | 221 | BPF_PSEUDO_CALL = 0x1 |
274 | 223 | BPF_PSEUDO_MAP_VALUE = 0x2 |
275 | 224 | BPF_RET = 0x6 |
276 | 225 | 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 | |
283 | 226 | BPF_ST = 0x2 |
284 | 227 | BPF_STX = 0x3 |
285 | 228 | BPF_SUB = 0x10 |
377 | 320 | CLOCK_TXINT = 0x3 |
378 | 321 | CLONE_ARGS_SIZE_VER0 = 0x40 |
379 | 322 | CLONE_ARGS_SIZE_VER1 = 0x50 |
323 | CLONE_ARGS_SIZE_VER2 = 0x58 | |
380 | 324 | CLONE_CHILD_CLEARTID = 0x200000 |
381 | 325 | CLONE_CHILD_SETTID = 0x1000000 |
382 | 326 | CLONE_CLEAR_SIGHAND = 0x100000000 |
383 | 327 | CLONE_DETACHED = 0x400000 |
384 | 328 | CLONE_FILES = 0x400 |
385 | 329 | CLONE_FS = 0x200 |
330 | CLONE_INTO_CGROUP = 0x200000000 | |
386 | 331 | CLONE_IO = 0x80000000 |
387 | 332 | CLONE_NEWCGROUP = 0x2000000 |
388 | 333 | CLONE_NEWIPC = 0x8000000 |
597 | 542 | FAN_DELETE = 0x200 |
598 | 543 | FAN_DELETE_SELF = 0x400 |
599 | 544 | FAN_DENY = 0x2 |
545 | FAN_DIR_MODIFY = 0x80000 | |
600 | 546 | FAN_ENABLE_AUDIT = 0x40 |
547 | FAN_EVENT_INFO_TYPE_DFID_NAME = 0x2 | |
601 | 548 | FAN_EVENT_INFO_TYPE_FID = 0x1 |
602 | 549 | FAN_EVENT_METADATA_LEN = 0x18 |
603 | 550 | FAN_EVENT_ON_CHILD = 0x8000000 |
2107 | 2054 | TCOFLUSH = 0x1 |
2108 | 2055 | TCOOFF = 0x0 |
2109 | 2056 | TCOON = 0x1 |
2110 | TCP_BPF_IW = 0x3e9 | |
2111 | TCP_BPF_SNDCWND_CLAMP = 0x3ea | |
2112 | 2057 | TCP_CC_INFO = 0x1a |
2113 | 2058 | TCP_CM_INQ = 0x24 |
2114 | 2059 | TCP_CONGESTION = 0xd |
2164 | 2109 | TCP_USER_TIMEOUT = 0x12 |
2165 | 2110 | TCP_WINDOW_CLAMP = 0xa |
2166 | 2111 | TCP_ZEROCOPY_RECEIVE = 0x23 |
2112 | TFD_TIMER_ABSTIME = 0x1 | |
2113 | TFD_TIMER_CANCEL_ON_SET = 0x2 | |
2167 | 2114 | TIMER_ABSTIME = 0x1 |
2168 | 2115 | TIOCM_DTR = 0x2 |
2169 | 2116 | TIOCM_LE = 0x1 |
2381 | 2328 | XDP_COPY = 0x2 |
2382 | 2329 | XDP_FLAGS_DRV_MODE = 0x4 |
2383 | 2330 | XDP_FLAGS_HW_MODE = 0x8 |
2384 | XDP_FLAGS_MASK = 0xf | |
2331 | XDP_FLAGS_MASK = 0x1f | |
2385 | 2332 | XDP_FLAGS_MODES = 0xe |
2333 | XDP_FLAGS_REPLACE = 0x10 | |
2386 | 2334 | XDP_FLAGS_SKB_MODE = 0x2 |
2387 | 2335 | XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1 |
2388 | 2336 | XDP_MMAP_OFFSETS = 0x1 |
74 | 74 | FP_XSTATE_MAGIC2 = 0x46505845 |
75 | 75 | FS_IOC_ENABLE_VERITY = 0x40806685 |
76 | 76 | FS_IOC_GETFLAGS = 0x80046601 |
77 | FS_IOC_GET_ENCRYPTION_NONCE = 0x8010661b | |
77 | 78 | FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615 |
78 | 79 | FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614 |
79 | 80 | FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613 |
341 | 342 | TCSETXF = 0x5434 |
342 | 343 | TCSETXW = 0x5435 |
343 | 344 | TCXONC = 0x540a |
345 | TFD_CLOEXEC = 0x80000 | |
346 | TFD_NONBLOCK = 0x800 | |
344 | 347 | TIOCCBRK = 0x5428 |
345 | 348 | TIOCCONS = 0x541d |
346 | 349 | TIOCEXCL = 0x540c |
74 | 74 | FP_XSTATE_MAGIC2 = 0x46505845 |
75 | 75 | FS_IOC_ENABLE_VERITY = 0x40806685 |
76 | 76 | FS_IOC_GETFLAGS = 0x80086601 |
77 | FS_IOC_GET_ENCRYPTION_NONCE = 0x8010661b | |
77 | 78 | FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615 |
78 | 79 | FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614 |
79 | 80 | FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613 |
342 | 343 | TCSETXF = 0x5434 |
343 | 344 | TCSETXW = 0x5435 |
344 | 345 | TCXONC = 0x540a |
346 | TFD_CLOEXEC = 0x80000 | |
347 | TFD_NONBLOCK = 0x800 | |
345 | 348 | TIOCCBRK = 0x5428 |
346 | 349 | TIOCCONS = 0x541d |
347 | 350 | TIOCEXCL = 0x540c |
73 | 73 | FLUSHO = 0x1000 |
74 | 74 | FS_IOC_ENABLE_VERITY = 0x40806685 |
75 | 75 | FS_IOC_GETFLAGS = 0x80046601 |
76 | FS_IOC_GET_ENCRYPTION_NONCE = 0x8010661b | |
76 | 77 | FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615 |
77 | 78 | FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614 |
78 | 79 | FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613 |
348 | 349 | TCSETXF = 0x5434 |
349 | 350 | TCSETXW = 0x5435 |
350 | 351 | TCXONC = 0x540a |
352 | TFD_CLOEXEC = 0x80000 | |
353 | TFD_NONBLOCK = 0x800 | |
351 | 354 | TIOCCBRK = 0x5428 |
352 | 355 | TIOCCONS = 0x541d |
353 | 356 | TIOCEXCL = 0x540c |
76 | 76 | FPSIMD_MAGIC = 0x46508001 |
77 | 77 | FS_IOC_ENABLE_VERITY = 0x40806685 |
78 | 78 | FS_IOC_GETFLAGS = 0x80086601 |
79 | FS_IOC_GET_ENCRYPTION_NONCE = 0x8010661b | |
79 | 80 | FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615 |
80 | 81 | FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614 |
81 | 82 | FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613 |
335 | 336 | TCSETXF = 0x5434 |
336 | 337 | TCSETXW = 0x5435 |
337 | 338 | TCXONC = 0x540a |
339 | TFD_CLOEXEC = 0x80000 | |
340 | TFD_NONBLOCK = 0x800 | |
338 | 341 | TIOCCBRK = 0x5428 |
339 | 342 | TIOCCONS = 0x541d |
340 | 343 | TIOCEXCL = 0x540c |
73 | 73 | FLUSHO = 0x2000 |
74 | 74 | FS_IOC_ENABLE_VERITY = 0x80806685 |
75 | 75 | FS_IOC_GETFLAGS = 0x40046601 |
76 | FS_IOC_GET_ENCRYPTION_NONCE = 0x4010661b | |
76 | 77 | FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615 |
77 | 78 | FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614 |
78 | 79 | FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613 |
338 | 339 | TCSETSW = 0x540f |
339 | 340 | TCSETSW2 = 0x8030542c |
340 | 341 | TCXONC = 0x5406 |
342 | TFD_CLOEXEC = 0x80000 | |
343 | TFD_NONBLOCK = 0x80 | |
341 | 344 | TIOCCBRK = 0x5428 |
342 | 345 | TIOCCONS = 0x80047478 |
343 | 346 | TIOCEXCL = 0x740d |
73 | 73 | FLUSHO = 0x2000 |
74 | 74 | FS_IOC_ENABLE_VERITY = 0x80806685 |
75 | 75 | FS_IOC_GETFLAGS = 0x40086601 |
76 | FS_IOC_GET_ENCRYPTION_NONCE = 0x4010661b | |
76 | 77 | FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615 |
77 | 78 | FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614 |
78 | 79 | FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613 |
338 | 339 | TCSETSW = 0x540f |
339 | 340 | TCSETSW2 = 0x8030542c |
340 | 341 | TCXONC = 0x5406 |
342 | TFD_CLOEXEC = 0x80000 | |
343 | TFD_NONBLOCK = 0x80 | |
341 | 344 | TIOCCBRK = 0x5428 |
342 | 345 | TIOCCONS = 0x80047478 |
343 | 346 | TIOCEXCL = 0x740d |
73 | 73 | FLUSHO = 0x2000 |
74 | 74 | FS_IOC_ENABLE_VERITY = 0x80806685 |
75 | 75 | FS_IOC_GETFLAGS = 0x40086601 |
76 | FS_IOC_GET_ENCRYPTION_NONCE = 0x4010661b | |
76 | 77 | FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615 |
77 | 78 | FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614 |
78 | 79 | FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613 |
338 | 339 | TCSETSW = 0x540f |
339 | 340 | TCSETSW2 = 0x8030542c |
340 | 341 | TCXONC = 0x5406 |
342 | TFD_CLOEXEC = 0x80000 | |
343 | TFD_NONBLOCK = 0x80 | |
341 | 344 | TIOCCBRK = 0x5428 |
342 | 345 | TIOCCONS = 0x80047478 |
343 | 346 | TIOCEXCL = 0x740d |
73 | 73 | FLUSHO = 0x2000 |
74 | 74 | FS_IOC_ENABLE_VERITY = 0x80806685 |
75 | 75 | FS_IOC_GETFLAGS = 0x40046601 |
76 | FS_IOC_GET_ENCRYPTION_NONCE = 0x4010661b | |
76 | 77 | FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615 |
77 | 78 | FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614 |
78 | 79 | FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613 |
338 | 339 | TCSETSW = 0x540f |
339 | 340 | TCSETSW2 = 0x8030542c |
340 | 341 | TCXONC = 0x5406 |
342 | TFD_CLOEXEC = 0x80000 | |
343 | TFD_NONBLOCK = 0x80 | |
341 | 344 | TIOCCBRK = 0x5428 |
342 | 345 | TIOCCONS = 0x80047478 |
343 | 346 | TIOCEXCL = 0x740d |
73 | 73 | FLUSHO = 0x800000 |
74 | 74 | FS_IOC_ENABLE_VERITY = 0x80806685 |
75 | 75 | FS_IOC_GETFLAGS = 0x40086601 |
76 | FS_IOC_GET_ENCRYPTION_NONCE = 0x4010661b | |
76 | 77 | FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615 |
77 | 78 | FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614 |
78 | 79 | FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613 |
392 | 393 | TCSETSF = 0x802c7416 |
393 | 394 | TCSETSW = 0x802c7415 |
394 | 395 | TCXONC = 0x2000741e |
396 | TFD_CLOEXEC = 0x80000 | |
397 | TFD_NONBLOCK = 0x800 | |
395 | 398 | TIOCCBRK = 0x5428 |
396 | 399 | TIOCCONS = 0x541d |
397 | 400 | TIOCEXCL = 0x540c |
73 | 73 | FLUSHO = 0x800000 |
74 | 74 | FS_IOC_ENABLE_VERITY = 0x80806685 |
75 | 75 | FS_IOC_GETFLAGS = 0x40086601 |
76 | FS_IOC_GET_ENCRYPTION_NONCE = 0x4010661b | |
76 | 77 | FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615 |
77 | 78 | FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614 |
78 | 79 | FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613 |
392 | 393 | TCSETSF = 0x802c7416 |
393 | 394 | TCSETSW = 0x802c7415 |
394 | 395 | TCXONC = 0x2000741e |
396 | TFD_CLOEXEC = 0x80000 | |
397 | TFD_NONBLOCK = 0x800 | |
395 | 398 | TIOCCBRK = 0x5428 |
396 | 399 | TIOCCONS = 0x541d |
397 | 400 | TIOCEXCL = 0x540c |
73 | 73 | FLUSHO = 0x1000 |
74 | 74 | FS_IOC_ENABLE_VERITY = 0x40806685 |
75 | 75 | FS_IOC_GETFLAGS = 0x80086601 |
76 | FS_IOC_GET_ENCRYPTION_NONCE = 0x8010661b | |
76 | 77 | FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615 |
77 | 78 | FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614 |
78 | 79 | FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613 |
329 | 330 | TCSETXF = 0x5434 |
330 | 331 | TCSETXW = 0x5435 |
331 | 332 | TCXONC = 0x540a |
333 | TFD_CLOEXEC = 0x80000 | |
334 | TFD_NONBLOCK = 0x800 | |
332 | 335 | TIOCCBRK = 0x5428 |
333 | 336 | TIOCCONS = 0x541d |
334 | 337 | TIOCEXCL = 0x540c |
73 | 73 | FLUSHO = 0x1000 |
74 | 74 | FS_IOC_ENABLE_VERITY = 0x40806685 |
75 | 75 | FS_IOC_GETFLAGS = 0x80086601 |
76 | FS_IOC_GET_ENCRYPTION_NONCE = 0x8010661b | |
76 | 77 | FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615 |
77 | 78 | FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614 |
78 | 79 | FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613 |
402 | 403 | TCSETXF = 0x5434 |
403 | 404 | TCSETXW = 0x5435 |
404 | 405 | TCXONC = 0x540a |
406 | TFD_CLOEXEC = 0x80000 | |
407 | TFD_NONBLOCK = 0x800 | |
405 | 408 | TIOCCBRK = 0x5428 |
406 | 409 | TIOCCONS = 0x541d |
407 | 410 | TIOCEXCL = 0x540c |
77 | 77 | FLUSHO = 0x1000 |
78 | 78 | FS_IOC_ENABLE_VERITY = 0x80806685 |
79 | 79 | FS_IOC_GETFLAGS = 0x40086601 |
80 | FS_IOC_GET_ENCRYPTION_NONCE = 0x4010661b | |
80 | 81 | FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615 |
81 | 82 | FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614 |
82 | 83 | FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613 |
391 | 392 | TCSETSW = 0x8024540a |
392 | 393 | TCSETSW2 = 0x802c540e |
393 | 394 | TCXONC = 0x20005406 |
395 | TFD_CLOEXEC = 0x400000 | |
396 | TFD_NONBLOCK = 0x4000 | |
394 | 397 | TIOCCBRK = 0x2000747a |
395 | 398 | TIOCCONS = 0x20007424 |
396 | 399 | TIOCEXCL = 0x2000740d |
965 | 965 | |
966 | 966 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
967 | 967 | |
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 | ||
968 | 978 | func Getuid() (uid int) { |
969 | 979 | r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) |
970 | 980 | uid = int(r0) |
1708 | 1718 | |
1709 | 1719 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
1710 | 1720 | |
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 | ||
1723 | 1721 | func Fstat(fd int, stat *Stat_t) (err error) { |
1724 | 1722 | _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) |
1725 | 1723 | if e1 != 0 { |
1375 | 1375 | |
1376 | 1376 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
1377 | 1377 | |
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 | ||
1378 | 1393 | func Getuid() (uid int) { |
1379 | 1394 | r0, _, _ := syscall_rawSyscall(funcPC(libc_getuid_trampoline), 0, 0, 0) |
1380 | 1395 | uid = int(r0) |
2356 | 2371 | |
2357 | 2372 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
2358 | 2373 | |
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 | ||
2376 | 2374 | func Fstat(fd int, stat *Stat_t) (err error) { |
2377 | 2375 | _, _, e1 := syscall_syscall(funcPC(libc_fstat64_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) |
2378 | 2376 | if e1 != 0 { |
965 | 965 | |
966 | 966 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
967 | 967 | |
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 | ||
968 | 978 | func Getuid() (uid int) { |
969 | 979 | r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) |
970 | 980 | uid = int(r0) |
1708 | 1718 | |
1709 | 1719 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
1710 | 1720 | |
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 | ||
1723 | 1721 | func Fstat(fd int, stat *Stat_t) (err error) { |
1724 | 1722 | _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) |
1725 | 1723 | if e1 != 0 { |
1375 | 1375 | |
1376 | 1376 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
1377 | 1377 | |
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 | ||
1378 | 1393 | func Getuid() (uid int) { |
1379 | 1394 | r0, _, _ := syscall_rawSyscall(funcPC(libc_getuid_trampoline), 0, 0, 0) |
1380 | 1395 | uid = int(r0) |
2356 | 2371 | |
2357 | 2372 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
2358 | 2373 | |
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 | ||
2376 | 2374 | func Fstat(fd int, stat *Stat_t) (err error) { |
2377 | 2375 | _, _, e1 := syscall_syscall(funcPC(libc_fstat64_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) |
2378 | 2376 | if e1 != 0 { |
965 | 965 | |
966 | 966 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
967 | 967 | |
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 | ||
968 | 978 | func Getuid() (uid int) { |
969 | 979 | r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) |
970 | 980 | uid = int(r0) |
1681 | 1691 | |
1682 | 1692 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
1683 | 1693 | |
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 | ||
1696 | 1694 | func Fstat(fd int, stat *Stat_t) (err error) { |
1697 | 1695 | _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) |
1698 | 1696 | if e1 != 0 { |
1375 | 1375 | |
1376 | 1376 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
1377 | 1377 | |
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 | ||
1378 | 1393 | func Getuid() (uid int) { |
1379 | 1394 | r0, _, _ := syscall_rawSyscall(funcPC(libc_getuid_trampoline), 0, 0, 0) |
1380 | 1395 | uid = int(r0) |
2341 | 2356 | |
2342 | 2357 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
2343 | 2358 | |
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 | ||
2361 | 2359 | func Fstat(fd int, stat *Stat_t) (err error) { |
2362 | 2360 | _, _, e1 := syscall_syscall(funcPC(libc_fstat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) |
2363 | 2361 | if e1 != 0 { |
965 | 965 | |
966 | 966 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
967 | 967 | |
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 | ||
968 | 978 | func Getuid() (uid int) { |
969 | 979 | r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) |
970 | 980 | uid = int(r0) |
1681 | 1691 | |
1682 | 1692 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
1683 | 1693 | |
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 | ||
1696 | 1694 | func Fstat(fd int, stat *Stat_t) (err error) { |
1697 | 1695 | _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) |
1698 | 1696 | if e1 != 0 { |
1375 | 1375 | |
1376 | 1376 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
1377 | 1377 | |
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 | ||
1378 | 1393 | func Getuid() (uid int) { |
1379 | 1394 | r0, _, _ := syscall_rawSyscall(funcPC(libc_getuid_trampoline), 0, 0, 0) |
1380 | 1395 | uid = int(r0) |
2341 | 2356 | |
2342 | 2357 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
2343 | 2358 | |
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 | ||
2361 | 2359 | func Fstat(fd int, stat *Stat_t) (err error) { |
2362 | 2360 | _, _, e1 := syscall_syscall(funcPC(libc_fstat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) |
2363 | 2361 | if e1 != 0 { |
1449 | 1449 | |
1450 | 1450 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
1451 | 1451 | |
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 | ||
1452 | 1483 | func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { |
1453 | 1484 | _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) |
1454 | 1485 | if e1 != 0 { |
54 | 54 | |
55 | 55 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
56 | 56 | |
57 | func Dup2(oldfd int, newfd int) (err error) { | |
57 | func dup2(oldfd int, newfd int) (err error) { | |
58 | 58 | _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) |
59 | 59 | if e1 != 0 { |
60 | 60 | err = errnoErr(e1) |
44 | 44 | |
45 | 45 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
46 | 46 | |
47 | func Dup2(oldfd int, newfd int) (err error) { | |
47 | func dup2(oldfd int, newfd int) (err error) { | |
48 | 48 | _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) |
49 | 49 | if e1 != 0 { |
50 | 50 | err = errnoErr(e1) |
233 | 233 | |
234 | 234 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
235 | 235 | |
236 | func Dup2(oldfd int, newfd int) (err error) { | |
236 | func dup2(oldfd int, newfd int) (err error) { | |
237 | 237 | _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) |
238 | 238 | if e1 != 0 { |
239 | 239 | err = errnoErr(e1) |
150 | 150 | |
151 | 151 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
152 | 152 | |
153 | func Getrlimit(resource int, rlim *Rlimit) (err error) { | |
153 | func getrlimit(resource int, rlim *Rlimit) (err error) { | |
154 | 154 | _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) |
155 | 155 | if e1 != 0 { |
156 | 156 | err = errnoErr(e1) |
306 | 306 | |
307 | 307 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
308 | 308 | |
309 | func Setrlimit(resource int, rlim *Rlimit) (err error) { | |
309 | func setrlimit(resource int, rlim *Rlimit) (err error) { | |
310 | 310 | _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) |
311 | 311 | if e1 != 0 { |
312 | 312 | err = errnoErr(e1) |
44 | 44 | |
45 | 45 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
46 | 46 | |
47 | func Dup2(oldfd int, newfd int) (err error) { | |
47 | func dup2(oldfd int, newfd int) (err error) { | |
48 | 48 | _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) |
49 | 49 | if e1 != 0 { |
50 | 50 | err = errnoErr(e1) |
44 | 44 | |
45 | 45 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
46 | 46 | |
47 | func Dup2(oldfd int, newfd int) (err error) { | |
47 | func dup2(oldfd int, newfd int) (err error) { | |
48 | 48 | _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) |
49 | 49 | if e1 != 0 { |
50 | 50 | err = errnoErr(e1) |
44 | 44 | |
45 | 45 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
46 | 46 | |
47 | func Dup2(oldfd int, newfd int) (err error) { | |
47 | func dup2(oldfd int, newfd int) (err error) { | |
48 | 48 | _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) |
49 | 49 | if e1 != 0 { |
50 | 50 | err = errnoErr(e1) |
44 | 44 | |
45 | 45 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
46 | 46 | |
47 | func Dup2(oldfd int, newfd int) (err error) { | |
47 | func dup2(oldfd int, newfd int) (err error) { | |
48 | 48 | _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) |
49 | 49 | if e1 != 0 { |
50 | 50 | err = errnoErr(e1) |
44 | 44 | |
45 | 45 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
46 | 46 | |
47 | func Dup2(oldfd int, newfd int) (err error) { | |
47 | func dup2(oldfd int, newfd int) (err error) { | |
48 | 48 | _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) |
49 | 49 | if e1 != 0 { |
50 | 50 | err = errnoErr(e1) |
44 | 44 | |
45 | 45 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
46 | 46 | |
47 | func Dup2(oldfd int, newfd int) (err error) { | |
47 | func dup2(oldfd int, newfd int) (err error) { | |
48 | 48 | _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) |
49 | 49 | if e1 != 0 { |
50 | 50 | err = errnoErr(e1) |
44 | 44 | |
45 | 45 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
46 | 46 | |
47 | func Dup2(oldfd int, newfd int) (err error) { | |
47 | func dup2(oldfd int, newfd int) (err error) { | |
48 | 48 | _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) |
49 | 49 | if e1 != 0 { |
50 | 50 | err = errnoErr(e1) |
71 | 71 | |
72 | 72 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
73 | 73 | |
74 | func Dup2(oldfd int, newfd int) (err error) { | |
74 | func dup2(oldfd int, newfd int) (err error) { | |
75 | 75 | _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) |
76 | 76 | if e1 != 0 { |
77 | 77 | err = errnoErr(e1) |
0 | // mksysctl_openbsd.pl | |
0 | // go run mksysctl_openbsd.go | |
1 | 1 | // Code generated by the command above; DO NOT EDIT. |
2 | 2 | |
3 | 3 | // +build 386,openbsd |
29 | 29 | {"hw.model", []_C_int{6, 2}}, |
30 | 30 | {"hw.ncpu", []_C_int{6, 3}}, |
31 | 31 | {"hw.ncpufound", []_C_int{6, 21}}, |
32 | {"hw.ncpuonline", []_C_int{6, 25}}, | |
32 | 33 | {"hw.pagesize", []_C_int{6, 7}}, |
33 | 34 | {"hw.physmem", []_C_int{6, 19}}, |
34 | 35 | {"hw.product", []_C_int{6, 15}}, |
30 | 30 | {"hw.model", []_C_int{6, 2}}, |
31 | 31 | {"hw.ncpu", []_C_int{6, 3}}, |
32 | 32 | {"hw.ncpufound", []_C_int{6, 21}}, |
33 | {"hw.ncpuonline", []_C_int{6, 25}}, | |
33 | 34 | {"hw.pagesize", []_C_int{6, 7}}, |
34 | 35 | {"hw.perfpolicy", []_C_int{6, 23}}, |
35 | 36 | {"hw.physmem", []_C_int{6, 19}}, |
29 | 29 | {"hw.model", []_C_int{6, 2}}, |
30 | 30 | {"hw.ncpu", []_C_int{6, 3}}, |
31 | 31 | {"hw.ncpufound", []_C_int{6, 21}}, |
32 | {"hw.ncpuonline", []_C_int{6, 25}}, | |
32 | 33 | {"hw.pagesize", []_C_int{6, 7}}, |
33 | 34 | {"hw.physmem", []_C_int{6, 19}}, |
34 | 35 | {"hw.product", []_C_int{6, 15}}, |
16 | 16 | |
17 | 17 | _C_long_long int64 |
18 | 18 | ) |
19 | ||
20 | type ItimerSpec struct { | |
21 | Interval Timespec | |
22 | Value Timespec | |
23 | } | |
19 | 24 | |
20 | 25 | const ( |
21 | 26 | TIME_OK = 0x0 |
1865 | 1870 | ) |
1866 | 1871 | |
1867 | 1872 | 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 | |
2037 | 2116 | ) |
2038 | 2117 | |
2039 | 2118 | const ( |
2199 | 2278 | DEVLINK_CMD_DPIPE_ENTRIES_GET = 0x20 |
2200 | 2279 | DEVLINK_CMD_DPIPE_HEADERS_GET = 0x21 |
2201 | 2280 | DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET = 0x22 |
2202 | DEVLINK_CMD_MAX = 0x44 | |
2281 | DEVLINK_CMD_MAX = 0x48 | |
2203 | 2282 | DEVLINK_PORT_TYPE_NOTSET = 0x0 |
2204 | 2283 | DEVLINK_PORT_TYPE_AUTO = 0x1 |
2205 | 2284 | DEVLINK_PORT_TYPE_ETH = 0x2 |
2279 | 2358 | DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE = 0x3c |
2280 | 2359 | DEVLINK_ATTR_PAD = 0x3d |
2281 | 2360 | DEVLINK_ATTR_ESWITCH_ENCAP_MODE = 0x3e |
2282 | DEVLINK_ATTR_MAX = 0x8c | |
2361 | DEVLINK_ATTR_MAX = 0x90 | |
2283 | 2362 | DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE = 0x0 |
2284 | 2363 | DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX = 0x1 |
2285 | 2364 | DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT = 0x0 |
97 | 97 | // MustFindProc is like FindProc but panics if search fails. |
98 | 98 | func (d *DLL) MustFindProc(name string) *Proc { |
99 | 99 | 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) | |
100 | 129 | if e != nil { |
101 | 130 | panic(e) |
102 | 131 | } |
7 | 7 | |
8 | 8 | import ( |
9 | 9 | "syscall" |
10 | "unicode/utf16" | |
11 | 10 | "unsafe" |
12 | 11 | ) |
13 | 12 | |
39 | 38 | defer DestroyEnvironmentBlock(block) |
40 | 39 | blockp := uintptr(unsafe.Pointer(block)) |
41 | 40 | 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))) | |
49 | 42 | if len(entry) == 0 { |
50 | 43 | break |
51 | 44 | } |
52 | env = append(env, string(utf16.Decode(entry))) | |
45 | env = append(env, entry) | |
53 | 46 | blockp += 2 * (uintptr(len(entry)) + 1) |
54 | 47 | } |
55 | 48 | return env, nil |
22 | 22 | PAGE_EXECUTE_READ = 0x20 |
23 | 23 | PAGE_EXECUTE_READWRITE = 0x40 |
24 | 24 | 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 | |
25 | 30 | ) |
6 | 6 | import ( |
7 | 7 | "syscall" |
8 | 8 | "unsafe" |
9 | ||
10 | "golang.org/x/sys/internal/unsafeheader" | |
9 | 11 | ) |
10 | 12 | |
11 | 13 | const ( |
1228 | 1230 | return "" |
1229 | 1231 | } |
1230 | 1232 | defer LocalFree(Handle(unsafe.Pointer(sddl))) |
1231 | return UTF16ToString((*[(1 << 30) - 1]uint16)(unsafe.Pointer(sddl))[:]) | |
1233 | return UTF16PtrToString(sddl) | |
1232 | 1234 | } |
1233 | 1235 | |
1234 | 1236 | // ToAbsolute converts a self-relative security descriptor into an absolute one. |
1306 | 1308 | } |
1307 | 1309 | |
1308 | 1310 | 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])) | |
1312 | 1322 | } |
1313 | 1323 | |
1314 | 1324 | // SecurityDescriptorFromString converts an SDDL string describing a security descriptor into a |
1390 | 1400 | } |
1391 | 1401 | defer LocalFree(Handle(unsafe.Pointer(winHeapACL))) |
1392 | 1402 | 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)]) | |
1394 | 1404 | return (*ACL)(unsafe.Pointer(&aclBytes[0])), nil |
1395 | 1405 | } |
12 | 12 | "time" |
13 | 13 | "unicode/utf16" |
14 | 14 | "unsafe" |
15 | ||
16 | "golang.org/x/sys/internal/unsafeheader" | |
15 | 17 | ) |
16 | 18 | |
17 | 19 | type Handle uintptr |
114 | 116 | return nil, err |
115 | 117 | } |
116 | 118 | 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)) | |
117 | 145 | } |
118 | 146 | |
119 | 147 | func Getpagesize() int { return 4096 } |
279 | 307 | //sys GetProcessId(process Handle) (id uint32, err error) |
280 | 308 | //sys OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (handle Handle, err error) |
281 | 309 | //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) | |
282 | 312 | |
283 | 313 | // Volume Management Functions |
284 | 314 | //sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW |
1180 | 1210 | Interface uint32 |
1181 | 1211 | } |
1182 | 1212 | |
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 | } | |
1184 | 1219 | |
1185 | 1220 | func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) { |
1186 | 1221 | sys := sysLinger{Onoff: uint16(l.Onoff), Linger: uint16(l.Linger)} |
1377 | 1412 | return "", err |
1378 | 1413 | } |
1379 | 1414 | defer CoTaskMemFree(unsafe.Pointer(p)) |
1380 | return UTF16ToString((*[(1 << 30) - 1]uint16)(unsafe.Pointer(p))[:]), nil | |
1415 | return UTF16PtrToString(p), nil | |
1381 | 1416 | } |
1382 | 1417 | |
1383 | 1418 | // RtlGetVersion returns the version of the underlying operating system, ignoring |
216 | 216 | procGetProcessId = modkernel32.NewProc("GetProcessId") |
217 | 217 | procOpenThread = modkernel32.NewProc("OpenThread") |
218 | 218 | procSetProcessPriorityBoost = modkernel32.NewProc("SetProcessPriorityBoost") |
219 | procGetProcessWorkingSetSizeEx = modkernel32.NewProc("GetProcessWorkingSetSizeEx") | |
220 | procSetProcessWorkingSetSizeEx = modkernel32.NewProc("SetProcessWorkingSetSizeEx") | |
219 | 221 | procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW") |
220 | 222 | procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW") |
221 | 223 | procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW") |
2413 | 2415 | return |
2414 | 2416 | } |
2415 | 2417 | |
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 | ||
2416 | 2435 | func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) { |
2417 | 2436 | r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath))) |
2418 | 2437 | if r1 == 0 { |
15 | 15 | "google.golang.org/protobuf/internal/flags" |
16 | 16 | "google.golang.org/protobuf/internal/pragma" |
17 | 17 | "google.golang.org/protobuf/internal/set" |
18 | "google.golang.org/protobuf/internal/strs" | |
18 | 19 | "google.golang.org/protobuf/proto" |
19 | 20 | pref "google.golang.org/protobuf/reflect/protoreflect" |
20 | 21 | "google.golang.org/protobuf/reflect/protoregistry" |
338 | 339 | |
339 | 340 | case pref.StringKind: |
340 | 341 | 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 | |
345 | 346 | } |
346 | 347 | |
347 | 348 | case pref.BytesKind: |
17 | 17 | "google.golang.org/protobuf/internal/flags" |
18 | 18 | "google.golang.org/protobuf/internal/mapsort" |
19 | 19 | "google.golang.org/protobuf/internal/pragma" |
20 | "google.golang.org/protobuf/internal/strs" | |
20 | 21 | "google.golang.org/protobuf/proto" |
21 | 22 | pref "google.golang.org/protobuf/reflect/protoreflect" |
22 | 23 | "google.golang.org/protobuf/reflect/protoregistry" |
53 | 54 | // terminated by a newline. If non-empty, then Multiline is treated as true. |
54 | 55 | // Indent can only be composed of space or tab characters. |
55 | 56 | 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 | |
56 | 66 | |
57 | 67 | // AllowPartial allows messages that have missing required fields to marshal |
58 | 68 | // without returning an error. If AllowPartial is false (the default), |
80 | 90 | if m == nil || !m.ProtoReflect().IsValid() { |
81 | 91 | return "<nil>" // invalid syntax, but okay since this is for debugging |
82 | 92 | } |
93 | o.allowInvalidUTF8 = true | |
83 | 94 | o.AllowPartial = true |
84 | 95 | o.EmitUnknown = true |
85 | 96 | b, _ := o.Marshal(m) |
90 | 101 | // MarshalOptions object. Do not depend on the output being stable. It may |
91 | 102 | // change over time across different versions of the program. |
92 | 103 | func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) { |
93 | const outputASCII = false | |
94 | 104 | var delims = [2]byte{'{', '}'} |
95 | 105 | |
96 | 106 | if o.Multiline && o.Indent == "" { |
100 | 110 | o.Resolver = protoregistry.GlobalTypes |
101 | 111 | } |
102 | 112 | |
103 | internalEnc, err := text.NewEncoder(o.Indent, delims, outputASCII) | |
113 | internalEnc, err := text.NewEncoder(o.Indent, delims, o.EmitASCII) | |
104 | 114 | if err != nil { |
105 | 115 | 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 | |
106 | 122 | } |
107 | 123 | |
108 | 124 | enc := encoder{internalEnc, o} |
208 | 224 | |
209 | 225 | case pref.StringKind: |
210 | 226 | s := val.String() |
211 | if !utf8.ValidString(s) { | |
227 | if !e.opts.allowInvalidUTF8 && strs.EnforceUTF8(fd) && !utf8.ValidString(s) { | |
212 | 228 | return errors.InvalidUTF8(string(fd.FullName())) |
213 | 229 | } |
214 | 230 | e.WriteString(s) |
105 | 105 | var descriptorAccessors = map[reflect.Type][]string{ |
106 | 106 | reflect.TypeOf((*pref.FileDescriptor)(nil)).Elem(): {"Path", "Package", "Imports", "Messages", "Enums", "Extensions", "Services"}, |
107 | 107 | 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"}, | |
109 | 109 | reflect.TypeOf((*pref.OneofDescriptor)(nil)).Elem(): {"Fields"}, // not directly used; must keep in sync with formatDescOpt |
110 | 110 | reflect.TypeOf((*pref.EnumDescriptor)(nil)).Elem(): {"Values", "ReservedNames", "ReservedRanges"}, |
111 | 111 | reflect.TypeOf((*pref.EnumValueDescriptor)(nil)).Elem(): {"Number"}, |
60 | 60 | |
61 | 61 | // Field numbers for google.protobuf.FieldDescriptorProto. |
62 | 62 | 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 | |
73 | 74 | ) |
74 | 75 | |
75 | 76 | // Field numbers for google.protobuf.OneofDescriptorProto. |
29 | 29 | return a.Number() < b.Number() |
30 | 30 | } |
31 | 31 | return oa.Index() < ob.Index() |
32 | case oa != nil: | |
32 | case oa != nil && !oa.IsSynthetic(): | |
33 | 33 | return false |
34 | case ob != nil: | |
34 | case ob != nil && !ob.IsSynthetic(): | |
35 | 35 | return true |
36 | 36 | default: |
37 | 37 | return a.Number() < b.Number() |
76 | 76 | func (fd *File) Messages() pref.MessageDescriptors { return &fd.L1.Messages } |
77 | 77 | func (fd *File) Extensions() pref.ExtensionDescriptors { return &fd.L1.Extensions } |
78 | 78 | 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 } | |
80 | 80 | func (fd *File) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, fd) } |
81 | 81 | func (fd *File) ProtoType(pref.FileDescriptor) {} |
82 | 82 | func (fd *File) ProtoInternal(pragma.DoNotImplement) {} |
201 | 201 | L1 FieldL1 |
202 | 202 | } |
203 | 203 | 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 | |
218 | 219 | } |
219 | 220 | |
220 | 221 | Oneof struct { |
276 | 277 | func (fd *Field) Kind() pref.Kind { return fd.L1.Kind } |
277 | 278 | func (fd *Field) HasJSONName() bool { return fd.L1.JSONName.has } |
278 | 279 | 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 | } | |
279 | 286 | func (fd *Field) IsPacked() bool { |
280 | 287 | if !fd.L1.HasPacked && fd.L0.ParentFile.L1.Syntax != pref.Proto2 && fd.L1.Cardinality == pref.Repeated { |
281 | 288 | switch fd.L1.Kind { |
337 | 344 | return fd.L0.ParentFile.L1.Syntax == pref.Proto3 |
338 | 345 | } |
339 | 346 | |
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 | } | |
340 | 350 | func (od *Oneof) Options() pref.ProtoMessage { |
341 | 351 | if f := od.L1.Options; f != nil { |
342 | 352 | return f() |
360 | 370 | Kind pref.Kind |
361 | 371 | } |
362 | 372 | 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 | |
369 | 380 | } |
370 | 381 | ) |
371 | 382 | |
375 | 386 | } |
376 | 387 | return descopts.Field |
377 | 388 | } |
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 | } | |
383 | 398 | func (xd *Extension) IsPacked() bool { return xd.lazyInit().IsPacked } |
384 | 399 | func (xd *Extension) IsExtension() bool { return true } |
385 | 400 | func (xd *Extension) IsWeak() bool { return false } |
591 | 606 | // TODO: Avoid panic if we're running with the race detector |
592 | 607 | // and instead spawn a goroutine that periodically resets |
593 | 608 | // 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())) | |
595 | 610 | } |
596 | 611 | return dv.val |
597 | 612 | } |
440 | 440 | panic("oneof type already set") |
441 | 441 | } |
442 | 442 | fd.L1.ContainingOneof = od |
443 | case fieldnum.FieldDescriptorProto_Proto3Optional: | |
444 | fd.L1.IsProto3Optional = protowire.DecodeBool(v) | |
443 | 445 | } |
444 | 446 | case protowire.BytesType: |
445 | 447 | v, m := protowire.ConsumeBytes(b) |
536 | 538 | num, typ, n := protowire.ConsumeTag(b) |
537 | 539 | b = b[n:] |
538 | 540 | 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 | } | |
539 | 548 | case protowire.BytesType: |
540 | 549 | v, m := protowire.ConsumeBytes(b) |
541 | 550 | b = b[m:] |
5077 | 5077 | merge: mergeStringPtr, |
5078 | 5078 | } |
5079 | 5079 | |
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 | ||
5080 | 5120 | // sizeStringSlice returns the size of wire encoding a []string pointer as a repeated String. |
5081 | 5121 | func sizeStringSlice(p pointer, f *coderFieldInfo, _ marshalOptions) (size int) { |
5082 | 5122 | s := *p.StringSlice() |
52 | 52 | |
53 | 53 | mi.coderFields = make(map[protowire.Number]*coderFieldInfo) |
54 | 54 | fields := mi.Desc.Fields() |
55 | preallocFields := make([]coderFieldInfo, fields.Len()) | |
55 | 56 | for i := 0; i < fields.Len(); i++ { |
56 | 57 | fd := fields.Get(i) |
57 | 58 | |
58 | 59 | fs := si.fieldsByNumber[fd.Number()] |
59 | if fd.ContainingOneof() != nil { | |
60 | isOneof := fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic() | |
61 | if isOneof { | |
60 | 62 | fs = si.oneofsByName[fd.ContainingOneof().Name()] |
61 | 63 | } |
62 | 64 | ft := fs.Type |
70 | 72 | var funcs pointerCoderFuncs |
71 | 73 | var childMessage *MessageInfo |
72 | 74 | switch { |
73 | case fd.ContainingOneof() != nil: | |
75 | case isOneof: | |
74 | 76 | fieldOffset = offsetOf(fs, mi.Exporter) |
75 | 77 | case fd.IsWeak(): |
76 | 78 | fieldOffset = si.weakOffset |
79 | 81 | fieldOffset = offsetOf(fs, mi.Exporter) |
80 | 82 | childMessage, funcs = fieldCoder(fd, ft) |
81 | 83 | } |
82 | cf := &coderFieldInfo{ | |
84 | cf := &preallocFields[i] | |
85 | *cf = coderFieldInfo{ | |
83 | 86 | num: fd.Number(), |
84 | 87 | offset: fieldOffset, |
85 | 88 | wiretag: wiretag, |
88 | 91 | funcs: funcs, |
89 | 92 | mi: childMessage, |
90 | 93 | 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(), | |
95 | 95 | isRequired: fd.Cardinality() == pref.Required, |
96 | 96 | } |
97 | 97 | mi.orderedCoderFields = append(mi.orderedCoderFields, cf) |
98 | 98 | mi.coderFields[cf.num] = cf |
99 | 99 | } |
100 | 100 | 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 | } | |
102 | 104 | } |
103 | 105 | if messageset.IsMessageSet(mi.Desc) { |
104 | 106 | if !mi.extensionOffset.IsValid() { |
122 | 124 | } |
123 | 125 | mi.denseCoderFields = make([]*coderFieldInfo, maxDense+1) |
124 | 126 | for _, cf := range mi.orderedCoderFields { |
125 | if int(cf.num) > len(mi.denseCoderFields) { | |
127 | if int(cf.num) >= len(mi.denseCoderFields) { | |
126 | 128 | break |
127 | 129 | } |
128 | 130 | mi.denseCoderFields[cf.num] = cf |
337 | 337 | return nil, coderDoublePtr |
338 | 338 | } |
339 | 339 | case pref.StringKind: |
340 | if ft.Kind() == reflect.String && strs.EnforceUTF8(fd) { | |
341 | return nil, coderStringPtrValidateUTF8 | |
342 | } | |
340 | 343 | if ft.Kind() == reflect.String { |
341 | 344 | return nil, coderStringPtr |
342 | 345 | } |
161 | 161 | return ok |
162 | 162 | } |
163 | 163 | func (c *boolConverter) IsValidGo(v reflect.Value) bool { |
164 | return v.Type() == c.goType | |
164 | return v.IsValid() && v.Type() == c.goType | |
165 | 165 | } |
166 | 166 | func (c *boolConverter) New() pref.Value { return c.def } |
167 | 167 | func (c *boolConverter) Zero() pref.Value { return c.def } |
185 | 185 | return ok |
186 | 186 | } |
187 | 187 | func (c *int32Converter) IsValidGo(v reflect.Value) bool { |
188 | return v.Type() == c.goType | |
188 | return v.IsValid() && v.Type() == c.goType | |
189 | 189 | } |
190 | 190 | func (c *int32Converter) New() pref.Value { return c.def } |
191 | 191 | func (c *int32Converter) Zero() pref.Value { return c.def } |
209 | 209 | return ok |
210 | 210 | } |
211 | 211 | func (c *int64Converter) IsValidGo(v reflect.Value) bool { |
212 | return v.Type() == c.goType | |
212 | return v.IsValid() && v.Type() == c.goType | |
213 | 213 | } |
214 | 214 | func (c *int64Converter) New() pref.Value { return c.def } |
215 | 215 | func (c *int64Converter) Zero() pref.Value { return c.def } |
233 | 233 | return ok |
234 | 234 | } |
235 | 235 | func (c *uint32Converter) IsValidGo(v reflect.Value) bool { |
236 | return v.Type() == c.goType | |
236 | return v.IsValid() && v.Type() == c.goType | |
237 | 237 | } |
238 | 238 | func (c *uint32Converter) New() pref.Value { return c.def } |
239 | 239 | func (c *uint32Converter) Zero() pref.Value { return c.def } |
257 | 257 | return ok |
258 | 258 | } |
259 | 259 | func (c *uint64Converter) IsValidGo(v reflect.Value) bool { |
260 | return v.Type() == c.goType | |
260 | return v.IsValid() && v.Type() == c.goType | |
261 | 261 | } |
262 | 262 | func (c *uint64Converter) New() pref.Value { return c.def } |
263 | 263 | func (c *uint64Converter) Zero() pref.Value { return c.def } |
281 | 281 | return ok |
282 | 282 | } |
283 | 283 | func (c *float32Converter) IsValidGo(v reflect.Value) bool { |
284 | return v.Type() == c.goType | |
284 | return v.IsValid() && v.Type() == c.goType | |
285 | 285 | } |
286 | 286 | func (c *float32Converter) New() pref.Value { return c.def } |
287 | 287 | func (c *float32Converter) Zero() pref.Value { return c.def } |
305 | 305 | return ok |
306 | 306 | } |
307 | 307 | func (c *float64Converter) IsValidGo(v reflect.Value) bool { |
308 | return v.Type() == c.goType | |
308 | return v.IsValid() && v.Type() == c.goType | |
309 | 309 | } |
310 | 310 | func (c *float64Converter) New() pref.Value { return c.def } |
311 | 311 | func (c *float64Converter) Zero() pref.Value { return c.def } |
335 | 335 | return ok |
336 | 336 | } |
337 | 337 | func (c *stringConverter) IsValidGo(v reflect.Value) bool { |
338 | return v.Type() == c.goType | |
338 | return v.IsValid() && v.Type() == c.goType | |
339 | 339 | } |
340 | 340 | func (c *stringConverter) New() pref.Value { return c.def } |
341 | 341 | func (c *stringConverter) Zero() pref.Value { return c.def } |
362 | 362 | return ok |
363 | 363 | } |
364 | 364 | func (c *bytesConverter) IsValidGo(v reflect.Value) bool { |
365 | return v.Type() == c.goType | |
365 | return v.IsValid() && v.Type() == c.goType | |
366 | 366 | } |
367 | 367 | func (c *bytesConverter) New() pref.Value { return c.def } |
368 | 368 | func (c *bytesConverter) Zero() pref.Value { return c.def } |
399 | 399 | } |
400 | 400 | |
401 | 401 | func (c *enumConverter) IsValidGo(v reflect.Value) bool { |
402 | return v.Type() == c.goType | |
402 | return v.IsValid() && v.Type() == c.goType | |
403 | 403 | } |
404 | 404 | |
405 | 405 | func (c *enumConverter) New() pref.Value { |
454 | 454 | } |
455 | 455 | |
456 | 456 | func (c *messageConverter) IsValidGo(v reflect.Value) bool { |
457 | return v.Type() == c.goType | |
457 | return v.IsValid() && v.Type() == c.goType | |
458 | 458 | } |
459 | 459 | |
460 | 460 | func (c *messageConverter) New() pref.Value { |
21 | 21 | } |
22 | 22 | |
23 | 23 | type listConverter struct { |
24 | goType reflect.Type | |
24 | goType reflect.Type // []T | |
25 | 25 | c Converter |
26 | 26 | } |
27 | 27 | |
47 | 47 | if !ok { |
48 | 48 | return false |
49 | 49 | } |
50 | return list.v.Type().Elem() == c.goType && list.IsValid() | |
50 | return list.v.Type().Elem() == c.goType | |
51 | 51 | } |
52 | 52 | |
53 | 53 | func (c *listConverter) IsValidGo(v reflect.Value) bool { |
54 | return v.Type() == c.goType | |
54 | return v.IsValid() && v.Type() == c.goType | |
55 | 55 | } |
56 | 56 | |
57 | 57 | func (c *listConverter) New() pref.Value { |
63 | 63 | } |
64 | 64 | |
65 | 65 | type listPtrConverter struct { |
66 | goType reflect.Type | |
66 | goType reflect.Type // *[]T | |
67 | 67 | c Converter |
68 | 68 | } |
69 | 69 | |
87 | 87 | } |
88 | 88 | |
89 | 89 | func (c *listPtrConverter) IsValidGo(v reflect.Value) bool { |
90 | return v.Type() == c.goType | |
90 | return v.IsValid() && v.Type() == c.goType | |
91 | 91 | } |
92 | 92 | |
93 | 93 | func (c *listPtrConverter) New() pref.Value { |
11 | 11 | ) |
12 | 12 | |
13 | 13 | type mapConverter struct { |
14 | goType reflect.Type | |
14 | goType reflect.Type // map[K]V | |
15 | 15 | keyConv, valConv Converter |
16 | 16 | } |
17 | 17 | |
42 | 42 | if !ok { |
43 | 43 | return false |
44 | 44 | } |
45 | return mapv.v.Type() == c.goType && mapv.IsValid() | |
45 | return mapv.v.Type() == c.goType | |
46 | 46 | } |
47 | 47 | |
48 | 48 | func (c *mapConverter) IsValidGo(v reflect.Value) bool { |
49 | return v.Type() == c.goType | |
49 | return v.IsValid() && v.Type() == c.goType | |
50 | 50 | } |
51 | 51 | |
52 | 52 | func (c *mapConverter) New() pref.Value { |
6 | 6 | import ( |
7 | 7 | "encoding/binary" |
8 | 8 | "encoding/json" |
9 | "fmt" | |
10 | 9 | "hash/crc32" |
11 | 10 | "math" |
12 | 11 | "reflect" |
13 | 12 | |
14 | 13 | "google.golang.org/protobuf/internal/errors" |
15 | 14 | pref "google.golang.org/protobuf/reflect/protoreflect" |
16 | "google.golang.org/protobuf/reflect/protoregistry" | |
17 | 15 | piface "google.golang.org/protobuf/runtime/protoiface" |
18 | 16 | ) |
19 | 17 | |
91 | 89 | out = append(out, gzipFooter[:]...) |
92 | 90 | return out |
93 | 91 | } |
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 | } |
154 | 154 | func (x placeholderExtension) Kind() pref.Kind { return 0 } |
155 | 155 | func (x placeholderExtension) HasJSONName() bool { return false } |
156 | 156 | func (x placeholderExtension) JSONName() string { return "" } |
157 | func (x placeholderExtension) HasPresence() bool { return false } | |
158 | func (x placeholderExtension) HasOptionalKeyword() bool { return false } | |
157 | 159 | func (x placeholderExtension) IsExtension() bool { return true } |
158 | 160 | func (x placeholderExtension) IsWeak() bool { return false } |
159 | 161 | func (x placeholderExtension) IsPacked() bool { return false } |
14 | 14 | "google.golang.org/protobuf/internal/genname" |
15 | 15 | "google.golang.org/protobuf/reflect/protoreflect" |
16 | 16 | pref "google.golang.org/protobuf/reflect/protoreflect" |
17 | piface "google.golang.org/protobuf/runtime/protoiface" | |
18 | 17 | ) |
19 | 18 | |
20 | 19 | // MessageInfo provides protobuf related functionality for a given Go type |
108 | 107 | |
109 | 108 | type ( |
110 | 109 | SizeCache = int32 |
111 | WeakFields = map[int32]piface.MessageV1 | |
110 | WeakFields = map[int32]protoreflect.ProtoMessage | |
112 | 111 | UnknownFields = []byte |
113 | 112 | ExtensionFields = map[int32]ExtensionField |
114 | 113 | ) |
52 | 52 | fs := si.fieldsByNumber[fd.Number()] |
53 | 53 | var fi fieldInfo |
54 | 54 | switch { |
55 | case fd.ContainingOneof() != nil: | |
55 | case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic(): | |
56 | 56 | fi = fieldInfoForOneof(fd, si.oneofsByName[fd.ContainingOneof().Name()], mi.Exporter, si.oneofWrappersByNumber[fd.Number()]) |
57 | 57 | case fd.IsMap(): |
58 | 58 | fi = fieldInfoForMap(fd, fs, mi.Exporter) |
71 | 71 | mi.oneofs = map[pref.Name]*oneofInfo{} |
72 | 72 | for i := 0; i < md.Oneofs().Len(); i++ { |
73 | 73 | 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) | |
75 | 75 | } |
76 | 76 | |
77 | 77 | mi.denseFields = make([]*fieldInfo, fds.Len()*2) |
83 | 83 | |
84 | 84 | for i := 0; i < fds.Len(); { |
85 | 85 | fd := fds.Get(i) |
86 | if od := fd.ContainingOneof(); od != nil { | |
86 | if od := fd.ContainingOneof(); od != nil && !od.IsSynthetic() { | |
87 | 87 | mi.rangeInfos = append(mi.rangeInfos, mi.oneofs[od.Name()]) |
88 | 88 | i += od.Fields().Len() |
89 | 89 | } else { |
169 | 169 | return x.Value().List().Len() > 0 |
170 | 170 | case xd.IsMap(): |
171 | 171 | return x.Value().Map().Len() > 0 |
172 | case xd.Message() != nil: | |
173 | return x.Value().Message().IsValid() | |
172 | 174 | } |
173 | 175 | return true |
174 | 176 | } |
185 | 187 | return xt.Zero() |
186 | 188 | } |
187 | 189 | 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 { | |
189 | 203 | panic(fmt.Sprintf("%v: assigning invalid value", xt.TypeDescriptor().FullName())) |
190 | 204 | } |
205 | ||
191 | 206 | if *m == nil { |
192 | 207 | *m = make(map[int32]ExtensionField) |
193 | 208 | } |
194 | 209 | var x ExtensionField |
195 | 210 | x.Set(xt, v) |
196 | (*m)[int32(xt.TypeDescriptor().Number())] = x | |
211 | (*m)[int32(xd.Number())] = x | |
197 | 212 | } |
198 | 213 | func (m *extensionMap) Mutable(xt pref.ExtensionType) pref.Value { |
199 | 214 | xd := xt.TypeDescriptor() |
322 | 337 | } |
323 | 338 | if fi != nil { |
324 | 339 | 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())) | |
326 | 344 | } |
327 | 345 | return fi, nil |
328 | 346 | } |
329 | 347 | |
330 | 348 | if fd.IsExtension() { |
331 | if fd.ContainingMessage().FullName() != mi.Desc.FullName() { | |
349 | if got, want := fd.ContainingMessage().FullName(), mi.Desc.FullName(); got != want { | |
332 | 350 | // 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)) | |
334 | 352 | } |
335 | 353 | 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())) | |
337 | 355 | } |
338 | 356 | xtd, ok := fd.(pref.ExtensionTypeDescriptor) |
339 | 357 | if !ok { |
340 | panic("extension descriptor does not implement ExtensionTypeDescriptor") | |
358 | panic(fmt.Sprintf("extension %v does not implement protoreflect.ExtensionTypeDescriptor", fd.FullName())) | |
341 | 359 | } |
342 | 360 | return nil, xtd.Type() |
343 | 361 | } |
344 | panic("invalid field descriptor") | |
345 | } | |
362 | panic(fmt.Sprintf("field %v is invalid", fd.FullName())) | |
363 | } |
30 | 30 | func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, x exporter, ot reflect.Type) fieldInfo { |
31 | 31 | ft := fs.Type |
32 | 32 | 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)) | |
34 | 34 | } |
35 | 35 | 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)) | |
37 | 37 | } |
38 | 38 | 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)) | |
40 | 40 | } |
41 | 41 | conv := NewConverter(ot.Field(0).Type, fd) |
42 | 42 | isMessage := fd.Message() != nil |
89 | 89 | }, |
90 | 90 | mutable: func(p pointer) pref.Value { |
91 | 91 | 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())) | |
93 | 93 | } |
94 | 94 | rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem() |
95 | 95 | if rv.IsNil() || rv.Elem().Type().Elem() != ot || rv.Elem().IsNil() { |
113 | 113 | func fieldInfoForMap(fd pref.FieldDescriptor, fs reflect.StructField, x exporter) fieldInfo { |
114 | 114 | ft := fs.Type |
115 | 115 | 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)) | |
117 | 117 | } |
118 | 118 | conv := NewConverter(ft, fd) |
119 | 119 | |
146 | 146 | rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem() |
147 | 147 | pv := conv.GoValueOf(v) |
148 | 148 | 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())) | |
150 | 150 | } |
151 | 151 | rv.Set(pv) |
152 | 152 | }, |
166 | 166 | func fieldInfoForList(fd pref.FieldDescriptor, fs reflect.StructField, x exporter) fieldInfo { |
167 | 167 | ft := fs.Type |
168 | 168 | 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)) | |
170 | 170 | } |
171 | 171 | conv := NewConverter(reflect.PtrTo(ft), fd) |
172 | 172 | |
199 | 199 | rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem() |
200 | 200 | pv := conv.GoValueOf(v) |
201 | 201 | 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())) | |
203 | 203 | } |
204 | 204 | rv.Set(pv.Elem()) |
205 | 205 | }, |
220 | 220 | |
221 | 221 | func fieldInfoForScalar(fd pref.FieldDescriptor, fs reflect.StructField, x exporter) fieldInfo { |
222 | 222 | ft := fs.Type |
223 | nullable := fd.Syntax() == pref.Proto2 | |
223 | nullable := fd.HasPresence() | |
224 | 224 | isBytes := ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8 |
225 | 225 | if nullable { |
226 | 226 | 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)) | |
228 | 228 | } |
229 | 229 | if ft.Kind() == reflect.Ptr { |
230 | 230 | ft = ft.Elem() |
256 | 256 | case reflect.String, reflect.Slice: |
257 | 257 | return rv.Len() > 0 |
258 | 258 | 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 | |
260 | 260 | } |
261 | 261 | }, |
262 | 262 | clear: func(p pointer) { |
289 | 289 | rv.Set(conv.GoValueOf(v)) |
290 | 290 | if isBytes && rv.Len() == 0 { |
291 | 291 | if nullable { |
292 | rv.Set(emptyBytes) // preserve presence in proto2 | |
292 | rv.Set(emptyBytes) // preserve presence | |
293 | 293 | } else { |
294 | rv.Set(nilBytes) // do not preserve presence in proto3 | |
294 | rv.Set(nilBytes) // do not preserve presence | |
295 | 295 | } |
296 | 296 | } |
297 | 297 | }, |
313 | 313 | messageName := fd.Message().FullName() |
314 | 314 | messageType, _ = preg.GlobalTypes.FindMessageByName(messageName) |
315 | 315 | 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())) | |
317 | 317 | } |
318 | 318 | }) |
319 | 319 | } |
346 | 346 | lazyInit() |
347 | 347 | m := v.Message() |
348 | 348 | 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())) | |
350 | 353 | } |
351 | 354 | p.Apply(weakOffset).WeakFields().set(num, m.Interface()) |
352 | 355 | }, |
401 | 404 | rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem() |
402 | 405 | rv.Set(conv.GoValueOf(v)) |
403 | 406 | if rv.IsNil() { |
404 | panic("invalid nil pointer") | |
407 | panic(fmt.Sprintf("field %v has invalid nil pointer", fd.FullName())) | |
405 | 408 | } |
406 | 409 | }, |
407 | 410 | mutable: func(p pointer) pref.Value { |
425 | 428 | which func(pointer) pref.FieldNumber |
426 | 429 | } |
427 | 430 | |
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 { | |
433 | 450 | if p.IsNil() { |
434 | 451 | return 0 |
435 | 452 | } |
441 | 458 | if rv.IsNil() { |
442 | 459 | return 0 |
443 | 460 | } |
444 | return wrappersByType[rv.Type().Elem()] | |
445 | }, | |
446 | } | |
447 | } | |
461 | return si.oneofWrappersByType[rv.Type().Elem()] | |
462 | } | |
463 | } | |
464 | return oi | |
465 | } |
113 | 113 | if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od { |
114 | 114 | return od.Fields().ByNumber(oi.which(m.pointer())) |
115 | 115 | } |
116 | panic("invalid oneof descriptor") | |
116 | panic("invalid oneof descriptor " + string(od.FullName()) + " for message " + string(m.Descriptor().FullName())) | |
117 | 117 | } |
118 | 118 | func (m *messageState) GetUnknown() protoreflect.RawFields { |
119 | 119 | m.messageInfo().init() |
233 | 233 | if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od { |
234 | 234 | return od.Fields().ByNumber(oi.which(m.pointer())) |
235 | 235 | } |
236 | panic("invalid oneof descriptor") | |
236 | panic("invalid oneof descriptor " + string(od.FullName()) + " for message " + string(m.Descriptor().FullName())) | |
237 | 237 | } |
238 | 238 | func (m *messageReflectWrapper) GetUnknown() protoreflect.RawFields { |
239 | 239 | m.messageInfo().init() |
147 | 147 | return pointer{p: unsafe.Pointer(ms)} |
148 | 148 | } |
149 | 149 | 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 | |
151 | 155 | } |
152 | 156 | func (ms *messageState) LoadMessageInfo() *MessageInfo { |
153 | 157 | return (*MessageInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&ms.atomicMessageInfo)))) |
107 | 107 | func newFieldValidationInfo(mi *MessageInfo, si structInfo, fd pref.FieldDescriptor, ft reflect.Type) validationInfo { |
108 | 108 | var vi validationInfo |
109 | 109 | switch { |
110 | case fd.ContainingOneof() != nil: | |
110 | case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic(): | |
111 | 111 | switch fd.Kind() { |
112 | 112 | case pref.MessageKind: |
113 | 113 | vi.typ = validationTypeMessage |
4 | 4 | package impl |
5 | 5 | |
6 | 6 | import ( |
7 | "reflect" | |
7 | "fmt" | |
8 | 8 | |
9 | 9 | pref "google.golang.org/protobuf/reflect/protoreflect" |
10 | "google.golang.org/protobuf/reflect/protoregistry" | |
10 | 11 | ) |
11 | 12 | |
12 | 13 | // weakFields adds methods to the exported WeakFields type for internal use. |
15 | 16 | // defined directly on it. |
16 | 17 | type weakFields WeakFields |
17 | 18 | |
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 | |
34 | 22 | } |
35 | 23 | |
36 | 24 | func (w *weakFields) set(num pref.FieldNumber, m pref.ProtoMessage) { |
37 | 25 | if *w == nil { |
38 | 26 | *w = make(weakFields) |
39 | 27 | } |
40 | (*w)[int32(num)] = Export{}.ProtoMessageV1Of(m) | |
28 | (*w)[int32(num)] = m | |
41 | 29 | } |
42 | 30 | |
43 | 31 | func (w *weakFields) clear(num pref.FieldNumber) { |
44 | 32 | delete(*w, int32(num)) |
45 | 33 | } |
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 | } |
51 | 51 | // 10. Send out the CL for review and submit it. |
52 | 52 | const ( |
53 | 53 | Major = 1 |
54 | Minor = 21 | |
54 | Minor = 23 | |
55 | 55 | Patch = 0 |
56 | 56 | PreRelease = "" |
57 | 57 | ) |
11 | 11 | |
12 | 12 | // CheckInitialized returns an error if any required fields in m are not set. |
13 | 13 | 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 | ||
14 | 20 | return checkInitialized(m.ProtoReflect()) |
15 | 21 | } |
16 | 22 |
73 | 73 | |
74 | 74 | // Marshal returns the wire-format encoding of m. |
75 | 75 | 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 | ||
76 | 81 | out, err := MarshalOptions{}.marshal(nil, m.ProtoReflect()) |
82 | if len(out.Buf) == 0 && err == nil { | |
83 | out.Buf = emptyBytesForMessage(m) | |
84 | } | |
77 | 85 | return out.Buf, err |
78 | 86 | } |
79 | 87 | |
80 | 88 | // Marshal returns the wire-format encoding of m. |
81 | 89 | 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 | ||
82 | 95 | out, err := o.marshal(nil, m.ProtoReflect()) |
96 | if len(out.Buf) == 0 && err == nil { | |
97 | out.Buf = emptyBytesForMessage(m) | |
98 | } | |
83 | 99 | 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[:] | |
84 | 114 | } |
85 | 115 | |
86 | 116 | // MarshalAppend appends the wire-format encoding of m to b, |
87 | 117 | // returning the result. |
88 | 118 | 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 | ||
89 | 124 | out, err := o.marshal(b, m.ProtoReflect()) |
90 | 125 | return out.Buf, err |
91 | 126 | } |
8 | 8 | ) |
9 | 9 | |
10 | 10 | // 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()) | |
14 | 25 | } |
15 | 26 | |
16 | 27 | // ClearExtension clears an extension field such that subsequent |
17 | 28 | // 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()) | |
21 | 32 | } |
22 | 33 | |
23 | 34 | // GetExtension retrieves the value for an extension field. |
24 | 35 | // 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())) | |
29 | 45 | } |
30 | 46 | |
31 | 47 | // 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) | |
35 | 70 | } |
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 | } |
4 | 4 | package proto |
5 | 5 | |
6 | 6 | import ( |
7 | "fmt" | |
8 | ||
7 | 9 | "google.golang.org/protobuf/reflect/protoreflect" |
8 | 10 | "google.golang.org/protobuf/runtime/protoiface" |
9 | 11 | ) |
20 | 22 | // It is semantically equivalent to unmarshaling the encoded form of src |
21 | 23 | // into dst with the UnmarshalOptions.Merge option specified. |
22 | 24 | 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 | ||
23 | 28 | dstMsg, srcMsg := dst.ProtoReflect(), src.ProtoReflect() |
24 | 29 | 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 | } | |
25 | 33 | panic("descriptor mismatch") |
26 | 34 | } |
27 | 35 | mergeOptions{}.mergeMessage(dstMsg, srcMsg) |
68 | 76 | } |
69 | 77 | |
70 | 78 | if !dst.IsValid() { |
71 | panic("cannot merge into invalid destination message") | |
79 | panic(fmt.Sprintf("cannot merge into invalid %v message", dst.Descriptor().FullName())) | |
72 | 80 | } |
73 | 81 | |
74 | 82 | src.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool { |
3 | 3 | |
4 | 4 | package proto |
5 | 5 | |
6 | import "google.golang.org/protobuf/reflect/protoreflect" | |
6 | import ( | |
7 | "fmt" | |
8 | ||
9 | "google.golang.org/protobuf/reflect/protoreflect" | |
10 | ) | |
7 | 11 | |
8 | 12 | // Reset clears every field in the message. |
9 | 13 | // The resulting message shares no observable memory with its previous state |
18 | 22 | |
19 | 23 | func resetMessage(m protoreflect.Message) { |
20 | 24 | if !m.IsValid() { |
21 | panic("cannot reset invalid message") | |
25 | panic(fmt.Sprintf("cannot reset invalid %v message", m.Descriptor().FullName())) | |
22 | 26 | } |
23 | 27 | |
24 | 28 | // Clear all known fields. |
17 | 17 | |
18 | 18 | // Size returns the size in bytes of the wire-format encoding of m. |
19 | 19 | 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 | ||
20 | 25 | return sizeMessage(m.ProtoReflect()) |
21 | 26 | } |
22 | 27 |
21 | 21 | // |
22 | 22 | // The protobuf descriptor interfaces are not meant to be implemented by |
23 | 23 | // 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. | |
26 | 27 | // |
27 | 28 | // |
28 | 29 | // Go Type Descriptors |
280 | 280 | // It is usually the camel-cased form of the field name. |
281 | 281 | JSONName() string |
282 | 282 | |
283 | // HasPresence reports whether the field distinguishes between unpopulated | |
284 | // and default values. | |
285 | HasPresence() bool | |
286 | ||
283 | 287 | // IsExtension reports whether this is an extension field. If false, |
284 | 288 | // then Parent and ContainingMessage refer to the same message. |
285 | 289 | // Otherwise, ContainingMessage and Parent likely differ. |
286 | 290 | IsExtension() bool |
291 | ||
292 | // HasOptionalKeyword reports whether the "optional" keyword was explicitly | |
293 | // specified in the source .proto file. | |
294 | HasOptionalKeyword() bool | |
287 | 295 | |
288 | 296 | // IsWeak reports whether this is a weak field, which does not impose a |
289 | 297 | // direct dependency on the target type. |
373 | 381 | // corresponds with the google.protobuf.OneofDescriptorProto message. |
374 | 382 | type OneofDescriptor interface { |
375 | 383 | 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 | |
376 | 389 | |
377 | 390 | // Fields is a list of fields belonging to this oneof. |
378 | 391 | Fields() FieldDescriptors |
113 | 113 | // Mutable is a mutating operation and unsafe for concurrent use. |
114 | 114 | Mutable(FieldDescriptor) Value |
115 | 115 | |
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. | |
118 | 118 | // For lists, maps, and messages, this returns a new, empty, mutable value. |
119 | 119 | NewField(FieldDescriptor) Value |
120 | 120 |
6 | 6 | import ( |
7 | 7 | "fmt" |
8 | 8 | "math" |
9 | "reflect" | |
10 | 9 | ) |
11 | 10 | |
12 | 11 | // Value is a union where only one Go type may be set at a time. |
86 | 85 | case Message, List, Map: |
87 | 86 | return valueOfIface(v) |
88 | 87 | default: |
89 | panic(fmt.Sprintf("invalid type: %v", reflect.TypeOf(v))) | |
88 | panic(fmt.Sprintf("invalid type: %T", v)) | |
90 | 89 | } |
91 | 90 | } |
92 | 91 | |
196 | 195 | } |
197 | 196 | } |
198 | 197 | |
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 | ||
199 | 240 | // Bool returns v as a bool and panics if the type is not a bool. |
200 | 241 | func (v Value) Bool() bool { |
201 | 242 | switch v.typ { |
202 | 243 | case boolType: |
203 | 244 | return v.num > 0 |
204 | 245 | default: |
205 | panic("proto: value type mismatch") | |
246 | panic(v.panicMessage("bool")) | |
206 | 247 | } |
207 | 248 | } |
208 | 249 | |
212 | 253 | case int32Type, int64Type: |
213 | 254 | return int64(v.num) |
214 | 255 | default: |
215 | panic("proto: value type mismatch") | |
256 | panic(v.panicMessage("int")) | |
216 | 257 | } |
217 | 258 | } |
218 | 259 | |
222 | 263 | case uint32Type, uint64Type: |
223 | 264 | return uint64(v.num) |
224 | 265 | default: |
225 | panic("proto: value type mismatch") | |
266 | panic(v.panicMessage("uint")) | |
226 | 267 | } |
227 | 268 | } |
228 | 269 | |
232 | 273 | case float32Type, float64Type: |
233 | 274 | return math.Float64frombits(uint64(v.num)) |
234 | 275 | default: |
235 | panic("proto: value type mismatch") | |
276 | panic(v.panicMessage("float")) | |
236 | 277 | } |
237 | 278 | } |
238 | 279 | |
253 | 294 | case bytesType: |
254 | 295 | return v.getBytes() |
255 | 296 | default: |
256 | panic("proto: value type mismatch") | |
297 | panic(v.panicMessage("bytes")) | |
257 | 298 | } |
258 | 299 | } |
259 | 300 | |
263 | 304 | case enumType: |
264 | 305 | return EnumNumber(v.num) |
265 | 306 | default: |
266 | panic("proto: value type mismatch") | |
307 | panic(v.panicMessage("enum")) | |
267 | 308 | } |
268 | 309 | } |
269 | 310 | |
270 | 311 | // Message returns v as a Message and panics if the type is not a Message. |
271 | 312 | func (v Value) Message() Message { |
272 | switch v := v.getIface().(type) { | |
313 | switch vi := v.getIface().(type) { | |
273 | 314 | case Message: |
274 | return v | |
275 | default: | |
276 | panic("proto: value type mismatch") | |
315 | return vi | |
316 | default: | |
317 | panic(v.panicMessage("message")) | |
277 | 318 | } |
278 | 319 | } |
279 | 320 | |
280 | 321 | // List returns v as a List and panics if the type is not a List. |
281 | 322 | func (v Value) List() List { |
282 | switch v := v.getIface().(type) { | |
323 | switch vi := v.getIface().(type) { | |
283 | 324 | case List: |
284 | return v | |
285 | default: | |
286 | panic("proto: value type mismatch") | |
325 | return vi | |
326 | default: | |
327 | panic(v.panicMessage("list")) | |
287 | 328 | } |
288 | 329 | } |
289 | 330 | |
290 | 331 | // Map returns v as a Map and panics if the type is not a Map. |
291 | 332 | func (v Value) Map() Map { |
292 | switch v := v.getIface().(type) { | |
333 | switch vi := v.getIface().(type) { | |
293 | 334 | case Map: |
294 | return v | |
295 | default: | |
296 | panic("proto: value type mismatch") | |
335 | return vi | |
336 | default: | |
337 | panic(v.panicMessage("map")) | |
297 | 338 | } |
298 | 339 | } |
299 | 340 | |
302 | 343 | switch v.typ { |
303 | 344 | case boolType, int32Type, int64Type, uint32Type, uint64Type, stringType: |
304 | 345 | return MapKey(v) |
305 | } | |
306 | panic("proto: invalid map key type") | |
346 | default: | |
347 | panic(v.panicMessage("map key")) | |
348 | } | |
307 | 349 | } |
308 | 350 | |
309 | 351 | // MapKey is used to index maps, where the Go type of the MapKey must match |
12 | 12 | github.com/go-kit/kit/log/level |
13 | 13 | # github.com/go-logfmt/logfmt v0.5.0 |
14 | 14 | github.com/go-logfmt/logfmt |
15 | # github.com/golang/protobuf v1.4.0 | |
15 | # github.com/golang/protobuf v1.4.2 | |
16 | 16 | github.com/golang/protobuf/proto |
17 | 17 | github.com/golang/protobuf/ptypes |
18 | 18 | github.com/golang/protobuf/ptypes/any |
22 | 22 | github.com/matttproud/golang_protobuf_extensions/pbutil |
23 | 23 | # github.com/pkg/errors v0.8.1 |
24 | 24 | github.com/pkg/errors |
25 | # github.com/prometheus/client_golang v1.6.0 | |
25 | # github.com/prometheus/client_golang v1.7.0 | |
26 | 26 | ## explicit |
27 | 27 | github.com/prometheus/client_golang/prometheus |
28 | 28 | github.com/prometheus/client_golang/prometheus/internal |
39 | 39 | github.com/prometheus/common/promlog |
40 | 40 | github.com/prometheus/common/promlog/flag |
41 | 41 | github.com/prometheus/common/version |
42 | # github.com/prometheus/procfs v0.0.11 | |
42 | # github.com/prometheus/procfs v0.1.3 | |
43 | 43 | github.com/prometheus/procfs |
44 | 44 | github.com/prometheus/procfs/internal/fs |
45 | 45 | 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 | |
47 | 48 | golang.org/x/sys/unix |
48 | 49 | golang.org/x/sys/windows |
49 | # google.golang.org/protobuf v1.21.0 | |
50 | # google.golang.org/protobuf v1.23.0 | |
50 | 51 | google.golang.org/protobuf/encoding/prototext |
51 | 52 | google.golang.org/protobuf/encoding/protowire |
52 | 53 | google.golang.org/protobuf/internal/descfmt |