Update vendors out of sync

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu 2018-01-04 21:49:38 +00:00
parent 2b2011dafa
commit 141f57065c
49 changed files with 471 additions and 2229 deletions

View File

@ -1,5 +1,5 @@
github.com/blang/semver v3.1.0 github.com/blang/semver v3.1.0
github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895 github.com/BurntSushi/toml v0.2.0-21-g9906417
github.com/containerd/cgroups 29da22c6171a4316169f9205ab6c49f59b5b852f github.com/containerd/cgroups 29da22c6171a4316169f9205ab6c49f59b5b852f
github.com/containerd/containerd 6c7abf7c76c1973d4fb4b0bad51691de84869a51 github.com/containerd/containerd 6c7abf7c76c1973d4fb4b0bad51691de84869a51
github.com/containerd/continuity cf279e6ac893682272b4479d4c67fd3abf878b4e github.com/containerd/continuity cf279e6ac893682272b4479d4c67fd3abf878b4e
@ -13,12 +13,12 @@ github.com/davecgh/go-spew v1.1.0
github.com/docker/distribution b38e5838b7b2f2ad48e06ec4b500011976080621 github.com/docker/distribution b38e5838b7b2f2ad48e06ec4b500011976080621
github.com/docker/docker 86f080cff0914e9694068ed78d503701667c4c00 github.com/docker/docker 86f080cff0914e9694068ed78d503701667c4c00
github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9
github.com/docker/go-units 0dadbb0345b35ec7ef35e228dabb8de89a65bf52 github.com/docker/go-units v0.3.1
github.com/docker/spdystream 449fdfce4d962303d702fec724ef0ad181c92528 github.com/docker/spdystream 449fdfce4d962303d702fec724ef0ad181c92528
github.com/emicklei/go-restful ff4f55a206334ef123e4f79bbf348980da81ca46 github.com/emicklei/go-restful ff4f55a206334ef123e4f79bbf348980da81ca46
github.com/fsnotify/fsnotify 7d7316ed6e1ed2de075aab8dfc76de5d158d66e1 github.com/fsnotify/fsnotify 7d7316ed6e1ed2de075aab8dfc76de5d158d66e1
github.com/ghodss/yaml 73d445a93680fa1a78ae23a5839bad48f32ba1ee github.com/ghodss/yaml 73d445a93680fa1a78ae23a5839bad48f32ba1ee
github.com/godbus/dbus 97646858c46433e4afb3432ad28c12e968efa298 github.com/godbus/dbus c7fdd8b5cd55e87b4e1f4e372cdb1db61dd6c66f
github.com/gogo/protobuf v0.5 github.com/gogo/protobuf v0.5
github.com/golang/glog 44145f04b68cf362d9c4df2182967c2275eaefed github.com/golang/glog 44145f04b68cf362d9c4df2182967c2275eaefed
github.com/golang/protobuf 1643683e1b54a9e88ad26d98f81400c8c9d9f4f9 github.com/golang/protobuf 1643683e1b54a9e88ad26d98f81400c8c9d9f4f9
@ -57,7 +57,7 @@ github.com/syndtr/gocapability e7cb7fa329f456b3855136a2642b197bad7366ba
github.com/tchap/go-patricia 5ad6cdb7538b0097d5598c7e57f0a24072adf7dc github.com/tchap/go-patricia 5ad6cdb7538b0097d5598c7e57f0a24072adf7dc
golang.org/x/net 7dcfb8076726a3fdd9353b6b8a1f1b6be6811bd6 golang.org/x/net 7dcfb8076726a3fdd9353b6b8a1f1b6be6811bd6
golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c
golang.org/x/sys 8dbc5d05d6edcc104950cc299a1ce6641235bc86 golang.org/x/sys 314a259e304ff91bd6985da2a7149bbf91237993 https://github.com/golang/sys
golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4 golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4
google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944 google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944
google.golang.org/grpc v1.7.2 google.golang.org/grpc v1.7.2

View File

@ -1,21 +1,14 @@
The MIT License (MIT) DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (c) 2013 TOML authors Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Permission is hereby granted, free of charge, to any person obtaining a copy Everyone is permitted to copy and distribute verbatim or modified
of this software and associated documentation files (the "Software"), to deal copies of this license document, and changing it is allowed as long
in the Software without restriction, including without limitation the rights as the name is changed.
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
all copies or substantial portions of the Software. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -6,12 +6,12 @@ packages. This package also supports the `encoding.TextUnmarshaler` and
`encoding.TextMarshaler` interfaces so that you can define custom data `encoding.TextMarshaler` interfaces so that you can define custom data
representations. (There is an example of this below.) representations. (There is an example of this below.)
Spec: https://github.com/toml-lang/toml Spec: https://github.com/mojombo/toml
Compatible with TOML version Compatible with TOML version
[v0.4.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md) [v0.2.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.2.0.md)
Documentation: https://godoc.org/github.com/BurntSushi/toml Documentation: http://godoc.org/github.com/BurntSushi/toml
Installation: Installation:
@ -26,7 +26,8 @@ go get github.com/BurntSushi/toml/cmd/tomlv
tomlv some-toml-file.toml tomlv some-toml-file.toml
``` ```
[![Build Status](https://travis-ci.org/BurntSushi/toml.svg?branch=master)](https://travis-ci.org/BurntSushi/toml) [![GoDoc](https://godoc.org/github.com/BurntSushi/toml?status.svg)](https://godoc.org/github.com/BurntSushi/toml) [![Build status](https://api.travis-ci.org/BurntSushi/toml.png)](https://travis-ci.org/BurntSushi/toml)
### Testing ### Testing
@ -216,3 +217,4 @@ Note that a case insensitive match will be tried if an exact match can't be
found. found.
A working example of the above can be found in `_examples/example.{go,toml}`. A working example of the above can be found in `_examples/example.{go,toml}`.

View File

@ -4,7 +4,7 @@ files via reflection. There is also support for delaying decoding with
the Primitive type, and querying the set of keys in a TOML document with the the Primitive type, and querying the set of keys in a TOML document with the
MetaData type. MetaData type.
The specification implemented: https://github.com/toml-lang/toml The specification implemented: https://github.com/mojombo/toml
The sub-command github.com/BurntSushi/toml/cmd/tomlv can be used to verify The sub-command github.com/BurntSushi/toml/cmd/tomlv can be used to verify
whether a file is a valid TOML document. It can also be used to print the whether a file is a valid TOML document. It can also be used to print the

View File

@ -30,13 +30,10 @@ const (
itemArrayTableEnd itemArrayTableEnd
itemKeyStart itemKeyStart
itemCommentStart itemCommentStart
itemInlineTableStart
itemInlineTableEnd
) )
const ( const (
eof = 0 eof = 0
comma = ','
tableStart = '[' tableStart = '['
tableEnd = ']' tableEnd = ']'
arrayTableStart = '[' arrayTableStart = '['
@ -45,13 +42,12 @@ const (
keySep = '=' keySep = '='
arrayStart = '[' arrayStart = '['
arrayEnd = ']' arrayEnd = ']'
arrayValTerm = ','
commentStart = '#' commentStart = '#'
stringStart = '"' stringStart = '"'
stringEnd = '"' stringEnd = '"'
rawStringStart = '\'' rawStringStart = '\''
rawStringEnd = '\'' rawStringEnd = '\''
inlineTableStart = '{'
inlineTableEnd = '}'
) )
type stateFn func(lx *lexer) stateFn type stateFn func(lx *lexer) stateFn
@ -60,18 +56,11 @@ type lexer struct {
input string input string
start int start int
pos int pos int
width int
line int line int
state stateFn state stateFn
items chan item items chan item
// Allow for backing up up to three runes.
// This is necessary because TOML contains 3-rune tokens (""" and ''').
prevWidths [3]int
nprev int // how many of prevWidths are in use
// If we emit an eof, we can still back up, but it is not OK to call
// next again.
atEOF bool
// A stack of state functions used to maintain context. // A stack of state functions used to maintain context.
// The idea is to reuse parts of the state machine in various places. // The idea is to reuse parts of the state machine in various places.
// For example, values can appear at the top level or within arbitrarily // For example, values can appear at the top level or within arbitrarily
@ -99,7 +88,7 @@ func (lx *lexer) nextItem() item {
func lex(input string) *lexer { func lex(input string) *lexer {
lx := &lexer{ lx := &lexer{
input: input, input: input + "\n",
state: lexTop, state: lexTop,
line: 1, line: 1,
items: make(chan item, 10), items: make(chan item, 10),
@ -114,7 +103,7 @@ func (lx *lexer) push(state stateFn) {
func (lx *lexer) pop() stateFn { func (lx *lexer) pop() stateFn {
if len(lx.stack) == 0 { if len(lx.stack) == 0 {
return lx.errorf("BUG in lexer: no states to pop") return lx.errorf("BUG in lexer: no states to pop.")
} }
last := lx.stack[len(lx.stack)-1] last := lx.stack[len(lx.stack)-1]
lx.stack = lx.stack[0 : len(lx.stack)-1] lx.stack = lx.stack[0 : len(lx.stack)-1]
@ -136,25 +125,16 @@ func (lx *lexer) emitTrim(typ itemType) {
} }
func (lx *lexer) next() (r rune) { func (lx *lexer) next() (r rune) {
if lx.atEOF {
panic("next called after EOF")
}
if lx.pos >= len(lx.input) { if lx.pos >= len(lx.input) {
lx.atEOF = true lx.width = 0
return eof return eof
} }
if lx.input[lx.pos] == '\n' { if lx.input[lx.pos] == '\n' {
lx.line++ lx.line++
} }
lx.prevWidths[2] = lx.prevWidths[1] r, lx.width = utf8.DecodeRuneInString(lx.input[lx.pos:])
lx.prevWidths[1] = lx.prevWidths[0] lx.pos += lx.width
if lx.nprev < 3 {
lx.nprev++
}
r, w := utf8.DecodeRuneInString(lx.input[lx.pos:])
lx.prevWidths[0] = w
lx.pos += w
return r return r
} }
@ -163,20 +143,9 @@ func (lx *lexer) ignore() {
lx.start = lx.pos lx.start = lx.pos
} }
// backup steps back one rune. Can be called only twice between calls to next. // backup steps back one rune. Can be called only once per call of next.
func (lx *lexer) backup() { func (lx *lexer) backup() {
if lx.atEOF { lx.pos -= lx.width
lx.atEOF = false
return
}
if lx.nprev < 1 {
panic("backed up too far")
}
w := lx.prevWidths[0]
lx.prevWidths[0] = lx.prevWidths[1]
lx.prevWidths[1] = lx.prevWidths[2]
lx.nprev--
lx.pos -= w
if lx.pos < len(lx.input) && lx.input[lx.pos] == '\n' { if lx.pos < len(lx.input) && lx.input[lx.pos] == '\n' {
lx.line-- lx.line--
} }
@ -229,6 +198,7 @@ func lexTop(lx *lexer) stateFn {
if isWhitespace(r) || isNL(r) { if isWhitespace(r) || isNL(r) {
return lexSkip(lx, lexTop) return lexSkip(lx, lexTop)
} }
switch r { switch r {
case commentStart: case commentStart:
lx.push(lexTop) lx.push(lexTop)
@ -237,7 +207,7 @@ func lexTop(lx *lexer) stateFn {
return lexTableStart return lexTableStart
case eof: case eof:
if lx.pos > lx.start { if lx.pos > lx.start {
return lx.errorf("unexpected EOF") return lx.errorf("Unexpected EOF.")
} }
lx.emit(itemEOF) lx.emit(itemEOF)
return nil return nil
@ -266,11 +236,11 @@ func lexTopEnd(lx *lexer) stateFn {
lx.ignore() lx.ignore()
return lexTop return lexTop
case r == eof: case r == eof:
lx.emit(itemEOF) lx.ignore()
return nil return lexTop
} }
return lx.errorf("expected a top-level item to end with a newline, "+ return lx.errorf("Expected a top-level item to end with a new line, "+
"comment, or EOF, but got %q instead", r) "comment or EOF, but got %q instead.", r)
} }
// lexTable lexes the beginning of a table. Namely, it makes sure that // lexTable lexes the beginning of a table. Namely, it makes sure that
@ -297,8 +267,8 @@ func lexTableEnd(lx *lexer) stateFn {
func lexArrayTableEnd(lx *lexer) stateFn { func lexArrayTableEnd(lx *lexer) stateFn {
if r := lx.next(); r != arrayTableEnd { if r := lx.next(); r != arrayTableEnd {
return lx.errorf("expected end of table array name delimiter %q, "+ return lx.errorf("Expected end of table array name delimiter %q, "+
"but got %q instead", arrayTableEnd, r) "but got %q instead.", arrayTableEnd, r)
} }
lx.emit(itemArrayTableEnd) lx.emit(itemArrayTableEnd)
return lexTopEnd return lexTopEnd
@ -308,11 +278,11 @@ func lexTableNameStart(lx *lexer) stateFn {
lx.skip(isWhitespace) lx.skip(isWhitespace)
switch r := lx.peek(); { switch r := lx.peek(); {
case r == tableEnd || r == eof: case r == tableEnd || r == eof:
return lx.errorf("unexpected end of table name " + return lx.errorf("Unexpected end of table name. (Table names cannot " +
"(table names cannot be empty)") "be empty.)")
case r == tableSep: case r == tableSep:
return lx.errorf("unexpected table separator " + return lx.errorf("Unexpected table separator. (Table names cannot " +
"(table names cannot be empty)") "be empty.)")
case r == stringStart || r == rawStringStart: case r == stringStart || r == rawStringStart:
lx.ignore() lx.ignore()
lx.push(lexTableNameEnd) lx.push(lexTableNameEnd)
@ -347,8 +317,8 @@ func lexTableNameEnd(lx *lexer) stateFn {
case r == tableEnd: case r == tableEnd:
return lx.pop() return lx.pop()
default: default:
return lx.errorf("expected '.' or ']' to end table name, "+ return lx.errorf("Expected '.' or ']' to end table name, but got %q "+
"but got %q instead", r) "instead.", r)
} }
} }
@ -358,7 +328,7 @@ func lexKeyStart(lx *lexer) stateFn {
r := lx.peek() r := lx.peek()
switch { switch {
case r == keySep: case r == keySep:
return lx.errorf("unexpected key separator %q", keySep) return lx.errorf("Unexpected key separator %q.", keySep)
case isWhitespace(r) || isNL(r): case isWhitespace(r) || isNL(r):
lx.next() lx.next()
return lexSkip(lx, lexKeyStart) return lexSkip(lx, lexKeyStart)
@ -389,7 +359,7 @@ func lexBareKey(lx *lexer) stateFn {
lx.emit(itemText) lx.emit(itemText)
return lexKeyEnd return lexKeyEnd
default: default:
return lx.errorf("bare keys cannot contain %q", r) return lx.errorf("Bare keys cannot contain %q.", r)
} }
} }
@ -402,7 +372,7 @@ func lexKeyEnd(lx *lexer) stateFn {
case isWhitespace(r): case isWhitespace(r):
return lexSkip(lx, lexKeyEnd) return lexSkip(lx, lexKeyEnd)
default: default:
return lx.errorf("expected key separator %q, but got %q instead", return lx.errorf("Expected key separator %q, but got %q instead.",
keySep, r) keySep, r)
} }
} }
@ -412,7 +382,8 @@ func lexKeyEnd(lx *lexer) stateFn {
// After a value is lexed, the last state on the next is popped and returned. // After a value is lexed, the last state on the next is popped and returned.
func lexValue(lx *lexer) stateFn { func lexValue(lx *lexer) stateFn {
// We allow whitespace to precede a value, but NOT new lines. // We allow whitespace to precede a value, but NOT new lines.
// In array syntax, the array states are responsible for ignoring newlines. // In array syntax, the array states are responsible for ignoring new
// lines.
r := lx.next() r := lx.next()
switch { switch {
case isWhitespace(r): case isWhitespace(r):
@ -426,10 +397,6 @@ func lexValue(lx *lexer) stateFn {
lx.ignore() lx.ignore()
lx.emit(itemArray) lx.emit(itemArray)
return lexArrayValue return lexArrayValue
case inlineTableStart:
lx.ignore()
lx.emit(itemInlineTableStart)
return lexInlineTableValue
case stringStart: case stringStart:
if lx.accept(stringStart) { if lx.accept(stringStart) {
if lx.accept(stringStart) { if lx.accept(stringStart) {
@ -453,7 +420,7 @@ func lexValue(lx *lexer) stateFn {
case '+', '-': case '+', '-':
return lexNumberStart return lexNumberStart
case '.': // special error case, be kind to users case '.': // special error case, be kind to users
return lx.errorf("floats must start with a digit, not '.'") return lx.errorf("Floats must start with a digit, not '.'.")
} }
if unicode.IsLetter(r) { if unicode.IsLetter(r) {
// Be permissive here; lexBool will give a nice error if the // Be permissive here; lexBool will give a nice error if the
@ -463,7 +430,7 @@ func lexValue(lx *lexer) stateFn {
lx.backup() lx.backup()
return lexBool return lexBool
} }
return lx.errorf("expected value but found %q instead", r) return lx.errorf("Expected value but found %q instead.", r)
} }
// lexArrayValue consumes one value in an array. It assumes that '[' or ',' // lexArrayValue consumes one value in an array. It assumes that '[' or ','
@ -476,11 +443,10 @@ func lexArrayValue(lx *lexer) stateFn {
case r == commentStart: case r == commentStart:
lx.push(lexArrayValue) lx.push(lexArrayValue)
return lexCommentStart return lexCommentStart
case r == comma: case r == arrayValTerm:
return lx.errorf("unexpected comma") return lx.errorf("Unexpected array value terminator %q.",
arrayValTerm)
case r == arrayEnd: case r == arrayEnd:
// NOTE(caleb): The spec isn't clear about whether you can have
// a trailing comma or not, so we'll allow it.
return lexArrayEnd return lexArrayEnd
} }
@ -489,9 +455,8 @@ func lexArrayValue(lx *lexer) stateFn {
return lexValue return lexValue
} }
// lexArrayValueEnd consumes everything between the end of an array value and // lexArrayValueEnd consumes the cruft between values of an array. Namely,
// the next value (or the end of the array): it ignores whitespace and newlines // it ignores whitespace and expects either a ',' or a ']'.
// and expects either a ',' or a ']'.
func lexArrayValueEnd(lx *lexer) stateFn { func lexArrayValueEnd(lx *lexer) stateFn {
r := lx.next() r := lx.next()
switch { switch {
@ -500,88 +465,31 @@ func lexArrayValueEnd(lx *lexer) stateFn {
case r == commentStart: case r == commentStart:
lx.push(lexArrayValueEnd) lx.push(lexArrayValueEnd)
return lexCommentStart return lexCommentStart
case r == comma: case r == arrayValTerm:
lx.ignore() lx.ignore()
return lexArrayValue // move on to the next value return lexArrayValue // move on to the next value
case r == arrayEnd: case r == arrayEnd:
return lexArrayEnd return lexArrayEnd
} }
return lx.errorf( return lx.errorf("Expected an array value terminator %q or an array "+
"expected a comma or array terminator %q, but got %q instead", "terminator %q, but got %q instead.", arrayValTerm, arrayEnd, r)
arrayEnd, r,
)
} }
// lexArrayEnd finishes the lexing of an array. // lexArrayEnd finishes the lexing of an array. It assumes that a ']' has
// It assumes that a ']' has just been consumed. // just been consumed.
func lexArrayEnd(lx *lexer) stateFn { func lexArrayEnd(lx *lexer) stateFn {
lx.ignore() lx.ignore()
lx.emit(itemArrayEnd) lx.emit(itemArrayEnd)
return lx.pop() return lx.pop()
} }
// lexInlineTableValue consumes one key/value pair in an inline table.
// It assumes that '{' or ',' have already been consumed. Whitespace is ignored.
func lexInlineTableValue(lx *lexer) stateFn {
r := lx.next()
switch {
case isWhitespace(r):
return lexSkip(lx, lexInlineTableValue)
case isNL(r):
return lx.errorf("newlines not allowed within inline tables")
case r == commentStart:
lx.push(lexInlineTableValue)
return lexCommentStart
case r == comma:
return lx.errorf("unexpected comma")
case r == inlineTableEnd:
return lexInlineTableEnd
}
lx.backup()
lx.push(lexInlineTableValueEnd)
return lexKeyStart
}
// lexInlineTableValueEnd consumes everything between the end of an inline table
// key/value pair and the next pair (or the end of the table):
// it ignores whitespace and expects either a ',' or a '}'.
func lexInlineTableValueEnd(lx *lexer) stateFn {
r := lx.next()
switch {
case isWhitespace(r):
return lexSkip(lx, lexInlineTableValueEnd)
case isNL(r):
return lx.errorf("newlines not allowed within inline tables")
case r == commentStart:
lx.push(lexInlineTableValueEnd)
return lexCommentStart
case r == comma:
lx.ignore()
return lexInlineTableValue
case r == inlineTableEnd:
return lexInlineTableEnd
}
return lx.errorf("expected a comma or an inline table terminator %q, "+
"but got %q instead", inlineTableEnd, r)
}
// lexInlineTableEnd finishes the lexing of an inline table.
// It assumes that a '}' has just been consumed.
func lexInlineTableEnd(lx *lexer) stateFn {
lx.ignore()
lx.emit(itemInlineTableEnd)
return lx.pop()
}
// lexString consumes the inner contents of a string. It assumes that the // lexString consumes the inner contents of a string. It assumes that the
// beginning '"' has already been consumed and ignored. // beginning '"' has already been consumed and ignored.
func lexString(lx *lexer) stateFn { func lexString(lx *lexer) stateFn {
r := lx.next() r := lx.next()
switch { switch {
case r == eof:
return lx.errorf("unexpected EOF")
case isNL(r): case isNL(r):
return lx.errorf("strings cannot contain newlines") return lx.errorf("Strings cannot contain new lines.")
case r == '\\': case r == '\\':
lx.push(lexString) lx.push(lexString)
return lexStringEscape return lexStringEscape
@ -598,12 +506,11 @@ func lexString(lx *lexer) stateFn {
// lexMultilineString consumes the inner contents of a string. It assumes that // lexMultilineString consumes the inner contents of a string. It assumes that
// the beginning '"""' has already been consumed and ignored. // the beginning '"""' has already been consumed and ignored.
func lexMultilineString(lx *lexer) stateFn { func lexMultilineString(lx *lexer) stateFn {
switch lx.next() { r := lx.next()
case eof: switch {
return lx.errorf("unexpected EOF") case r == '\\':
case '\\':
return lexMultilineStringEscape return lexMultilineStringEscape
case stringEnd: case r == stringEnd:
if lx.accept(stringEnd) { if lx.accept(stringEnd) {
if lx.accept(stringEnd) { if lx.accept(stringEnd) {
lx.backup() lx.backup()
@ -627,10 +534,8 @@ func lexMultilineString(lx *lexer) stateFn {
func lexRawString(lx *lexer) stateFn { func lexRawString(lx *lexer) stateFn {
r := lx.next() r := lx.next()
switch { switch {
case r == eof:
return lx.errorf("unexpected EOF")
case isNL(r): case isNL(r):
return lx.errorf("strings cannot contain newlines") return lx.errorf("Strings cannot contain new lines.")
case r == rawStringEnd: case r == rawStringEnd:
lx.backup() lx.backup()
lx.emit(itemRawString) lx.emit(itemRawString)
@ -642,13 +547,12 @@ func lexRawString(lx *lexer) stateFn {
} }
// lexMultilineRawString consumes a raw string. Nothing can be escaped in such // lexMultilineRawString consumes a raw string. Nothing can be escaped in such
// a string. It assumes that the beginning "'''" has already been consumed and // a string. It assumes that the beginning "'" has already been consumed and
// ignored. // ignored.
func lexMultilineRawString(lx *lexer) stateFn { func lexMultilineRawString(lx *lexer) stateFn {
switch lx.next() { r := lx.next()
case eof: switch {
return lx.errorf("unexpected EOF") case r == rawStringEnd:
case rawStringEnd:
if lx.accept(rawStringEnd) { if lx.accept(rawStringEnd) {
if lx.accept(rawStringEnd) { if lx.accept(rawStringEnd) {
lx.backup() lx.backup()
@ -701,9 +605,10 @@ func lexStringEscape(lx *lexer) stateFn {
case 'U': case 'U':
return lexLongUnicodeEscape return lexLongUnicodeEscape
} }
return lx.errorf("invalid escape character %q; only the following "+ return lx.errorf("Invalid escape character %q. Only the following "+
"escape characters are allowed: "+ "escape characters are allowed: "+
`\b, \t, \n, \f, \r, \", \\, \uXXXX, and \UXXXXXXXX`, r) "\\b, \\t, \\n, \\f, \\r, \\\", \\/, \\\\, "+
"\\uXXXX and \\UXXXXXXXX.", r)
} }
func lexShortUnicodeEscape(lx *lexer) stateFn { func lexShortUnicodeEscape(lx *lexer) stateFn {
@ -711,8 +616,8 @@ func lexShortUnicodeEscape(lx *lexer) stateFn {
for i := 0; i < 4; i++ { for i := 0; i < 4; i++ {
r = lx.next() r = lx.next()
if !isHexadecimal(r) { if !isHexadecimal(r) {
return lx.errorf(`expected four hexadecimal digits after '\u', `+ return lx.errorf("Expected four hexadecimal digits after '\\u', "+
"but got %q instead", lx.current()) "but got '%s' instead.", lx.current())
} }
} }
return lx.pop() return lx.pop()
@ -723,8 +628,8 @@ func lexLongUnicodeEscape(lx *lexer) stateFn {
for i := 0; i < 8; i++ { for i := 0; i < 8; i++ {
r = lx.next() r = lx.next()
if !isHexadecimal(r) { if !isHexadecimal(r) {
return lx.errorf(`expected eight hexadecimal digits after '\U', `+ return lx.errorf("Expected eight hexadecimal digits after '\\U', "+
"but got %q instead", lx.current()) "but got '%s' instead.", lx.current())
} }
} }
return lx.pop() return lx.pop()
@ -742,9 +647,9 @@ func lexNumberOrDateStart(lx *lexer) stateFn {
case 'e', 'E': case 'e', 'E':
return lexFloat return lexFloat
case '.': case '.':
return lx.errorf("floats must start with a digit, not '.'") return lx.errorf("Floats must start with a digit, not '.'.")
} }
return lx.errorf("expected a digit but got %q", r) return lx.errorf("Expected a digit but got %q.", r)
} }
// lexNumberOrDate consumes either an integer, float or datetime. // lexNumberOrDate consumes either an integer, float or datetime.
@ -775,7 +680,7 @@ func lexDatetime(lx *lexer) stateFn {
return lexDatetime return lexDatetime
} }
switch r { switch r {
case '-', 'T', ':', '.', 'Z', '+': case '-', 'T', ':', '.', 'Z':
return lexDatetime return lexDatetime
} }
@ -792,9 +697,9 @@ func lexNumberStart(lx *lexer) stateFn {
r := lx.next() r := lx.next()
if !isDigit(r) { if !isDigit(r) {
if r == '.' { if r == '.' {
return lx.errorf("floats must start with a digit, not '.'") return lx.errorf("Floats must start with a digit, not '.'.")
} }
return lx.errorf("expected a digit but got %q", r) return lx.errorf("Expected a digit but got %q.", r)
} }
return lexNumber return lexNumber
} }
@ -840,7 +745,7 @@ func lexBool(lx *lexer) stateFn {
var rs []rune var rs []rune
for { for {
r := lx.next() r := lx.next()
if !unicode.IsLetter(r) { if r == eof || isWhitespace(r) || isNL(r) {
lx.backup() lx.backup()
break break
} }
@ -852,7 +757,7 @@ func lexBool(lx *lexer) stateFn {
lx.emit(itemBool) lx.emit(itemBool)
return lx.pop() return lx.pop()
} }
return lx.errorf("expected value but found %q instead", s) return lx.errorf("Expected value but found %q instead.", s)
} }
// lexCommentStart begins the lexing of a comment. It will emit // lexCommentStart begins the lexing of a comment. It will emit

View File

@ -269,41 +269,6 @@ func (p *parser) value(it item) (interface{}, tomlType) {
types = append(types, typ) types = append(types, typ)
} }
return array, p.typeOfArray(types) return array, p.typeOfArray(types)
case itemInlineTableStart:
var (
hash = make(map[string]interface{})
outerContext = p.context
outerKey = p.currentKey
)
p.context = append(p.context, p.currentKey)
p.currentKey = ""
for it := p.next(); it.typ != itemInlineTableEnd; it = p.next() {
if it.typ != itemKeyStart {
p.bug("Expected key start but instead found %q, around line %d",
it.val, p.approxLine)
}
if it.typ == itemCommentStart {
p.expect(itemText)
continue
}
// retrieve key
k := p.next()
p.approxLine = k.line
kname := p.keyString(k)
// retrieve value
p.currentKey = kname
val, typ := p.value(p.next())
// make sure we keep metadata up to date
p.setType(kname, typ)
p.ordered = append(p.ordered, p.context.add(p.currentKey))
hash[kname] = val
}
p.context = outerContext
p.currentKey = outerKey
return hash, tomlHash
} }
p.bug("Unexpected value type: %s", it.typ) p.bug("Unexpected value type: %s", it.typ)
panic("unreachable") panic("unreachable")

View File

@ -12,21 +12,19 @@ import (
func HumanDuration(d time.Duration) string { func HumanDuration(d time.Duration) string {
if seconds := int(d.Seconds()); seconds < 1 { if seconds := int(d.Seconds()); seconds < 1 {
return "Less than a second" return "Less than a second"
} else if seconds == 1 {
return "1 second"
} else if seconds < 60 { } else if seconds < 60 {
return fmt.Sprintf("%d seconds", seconds) return fmt.Sprintf("%d seconds", seconds)
} else if minutes := int(d.Minutes()); minutes == 1 { } else if minutes := int(d.Minutes()); minutes == 1 {
return "About a minute" return "About a minute"
} else if minutes < 46 { } else if minutes < 60 {
return fmt.Sprintf("%d minutes", minutes) return fmt.Sprintf("%d minutes", minutes)
} else if hours := int(d.Hours() + 0.5); hours == 1 { } else if hours := int(d.Hours()); hours == 1 {
return "About an hour" return "About an hour"
} else if hours < 48 { } else if hours < 48 {
return fmt.Sprintf("%d hours", hours) return fmt.Sprintf("%d hours", hours)
} else if hours < 24*7*2 { } else if hours < 24*7*2 {
return fmt.Sprintf("%d days", hours/24) return fmt.Sprintf("%d days", hours/24)
} else if hours < 24*30*2 { } else if hours < 24*30*3 {
return fmt.Sprintf("%d weeks", hours/24/7) return fmt.Sprintf("%d weeks", hours/24/7)
} else if hours < 24*365*2 { } else if hours < 24*365*2 {
return fmt.Sprintf("%d months", hours/24/30) return fmt.Sprintf("%d months", hours/24/30)

View File

@ -37,34 +37,22 @@ var (
var decimapAbbrs = []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"} var decimapAbbrs = []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}
var binaryAbbrs = []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"} var binaryAbbrs = []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}
func getSizeAndUnit(size float64, base float64, _map []string) (float64, string) { // CustomSize returns a human-readable approximation of a size
// using custom format.
func CustomSize(format string, size float64, base float64, _map []string) string {
i := 0 i := 0
unitsLimit := len(_map) - 1 unitsLimit := len(_map) - 1
for size >= base && i < unitsLimit { for size >= base && i < unitsLimit {
size = size / base size = size / base
i++ i++
} }
return size, _map[i] return fmt.Sprintf(format, size, _map[i])
}
// CustomSize returns a human-readable approximation of a size
// using custom format.
func CustomSize(format string, size float64, base float64, _map []string) string {
size, unit := getSizeAndUnit(size, base, _map)
return fmt.Sprintf(format, size, unit)
}
// HumanSizeWithPrecision allows the size to be in any precision,
// instead of 4 digit precision used in units.HumanSize.
func HumanSizeWithPrecision(size float64, precision int) string {
size, unit := getSizeAndUnit(size, 1000.0, decimapAbbrs)
return fmt.Sprintf("%.*g%s", precision, size, unit)
} }
// HumanSize returns a human-readable approximation of a size // HumanSize returns a human-readable approximation of a size
// capped at 4 valid numbers (eg. "2.746 MB", "796 KB"). // capped at 4 valid numbers (eg. "2.746 MB", "796 KB").
func HumanSize(size float64) string { func HumanSize(size float64) string {
return HumanSizeWithPrecision(size, 4) return CustomSize("%.4g %s", size, 1000.0, decimapAbbrs)
} }
// BytesSize returns a human-readable size in bytes, kibibytes, // BytesSize returns a human-readable size in bytes, kibibytes,

View File

@ -1,5 +1,3 @@
[![Build Status](https://travis-ci.org/godbus/dbus.svg?branch=master)](https://travis-ci.org/godbus/dbus)
dbus dbus
---- ----
@ -31,7 +29,6 @@ gives a short overview over the basic usage.
#### Projects using godbus #### Projects using godbus
- [notify](https://github.com/esiqveland/notify) provides desktop notifications over dbus into a library. - [notify](https://github.com/esiqveland/notify) provides desktop notifications over dbus into a library.
- [go-bluetooth](https://github.com/muka/go-bluetooth) provides a bluetooth client over bluez dbus API.
Please note that the API is considered unstable for now and may change without Please note that the API is considered unstable for now and may change without
further notice. further notice.

158
vendor/github.com/godbus/dbus/conn.go generated vendored
View File

@ -9,12 +9,13 @@ import (
"sync" "sync"
) )
const defaultSystemBusAddress = "unix:path=/var/run/dbus/system_bus_socket"
var ( var (
systemBus *Conn systemBus *Conn
systemBusLck sync.Mutex systemBusLck sync.Mutex
sessionBus *Conn sessionBus *Conn
sessionBusLck sync.Mutex sessionBusLck sync.Mutex
sessionEnvLck sync.Mutex
) )
// ErrClosed is the error returned by calls on a closed connection. // ErrClosed is the error returned by calls on a closed connection.
@ -45,13 +46,15 @@ type Conn struct {
calls map[uint32]*Call calls map[uint32]*Call
callsLck sync.RWMutex callsLck sync.RWMutex
handler Handler handlers map[ObjectPath]map[string]exportWithMapping
handlersLck sync.RWMutex
out chan *Message out chan *Message
closed bool closed bool
outLck sync.RWMutex outLck sync.RWMutex
signalHandler SignalHandler signals []chan<- *Signal
signalsLck sync.Mutex
eavesdropped chan<- *Message eavesdropped chan<- *Message
eavesdroppedLck sync.Mutex eavesdroppedLck sync.Mutex
@ -86,33 +89,14 @@ func SessionBus() (conn *Conn, err error) {
return return
} }
func getSessionBusAddress() (string, error) {
sessionEnvLck.Lock()
defer sessionEnvLck.Unlock()
address := os.Getenv("DBUS_SESSION_BUS_ADDRESS")
if address != "" && address != "autolaunch:" {
return address, nil
}
return getSessionBusPlatformAddress()
}
// SessionBusPrivate returns a new private connection to the session bus. // SessionBusPrivate returns a new private connection to the session bus.
func SessionBusPrivate() (*Conn, error) { func SessionBusPrivate() (*Conn, error) {
address, err := getSessionBusAddress() address := os.Getenv("DBUS_SESSION_BUS_ADDRESS")
if err != nil { if address != "" && address != "autolaunch:" {
return nil, err
}
return Dial(address) return Dial(address)
} }
// SessionBusPrivate returns a new private connection to the session bus. return sessionBusPlatform()
func SessionBusPrivateHandler(handler Handler, signalHandler SignalHandler) (*Conn, error) {
address, err := getSessionBusAddress()
if err != nil {
return nil, err
}
return DialHandler(address, handler, signalHandler)
} }
// SystemBus returns a shared connection to the system bus, connecting to it if // SystemBus returns a shared connection to the system bus, connecting to it if
@ -146,12 +130,11 @@ func SystemBus() (conn *Conn, err error) {
// SystemBusPrivate returns a new private connection to the system bus. // SystemBusPrivate returns a new private connection to the system bus.
func SystemBusPrivate() (*Conn, error) { func SystemBusPrivate() (*Conn, error) {
return Dial(getSystemBusPlatformAddress()) address := os.Getenv("DBUS_SYSTEM_BUS_ADDRESS")
if address != "" {
return Dial(address)
} }
return Dial(defaultSystemBusAddress)
// SystemBusPrivateHandler returns a new private connection to the system bus, using the provided handlers.
func SystemBusPrivateHandler(handler Handler, signalHandler SignalHandler) (*Conn, error) {
return DialHandler(getSystemBusPlatformAddress(), handler, signalHandler)
} }
// Dial establishes a new private connection to the message bus specified by address. // Dial establishes a new private connection to the message bus specified by address.
@ -160,36 +143,21 @@ func Dial(address string) (*Conn, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return newConn(tr, newDefaultHandler(), newDefaultSignalHandler()) return newConn(tr)
}
// DialHandler establishes a new private connection to the message bus specified by address, using the supplied handlers.
func DialHandler(address string, handler Handler, signalHandler SignalHandler) (*Conn, error) {
tr, err := getTransport(address)
if err != nil {
return nil, err
}
return newConn(tr, handler, signalHandler)
} }
// NewConn creates a new private *Conn from an already established connection. // NewConn creates a new private *Conn from an already established connection.
func NewConn(conn io.ReadWriteCloser) (*Conn, error) { func NewConn(conn io.ReadWriteCloser) (*Conn, error) {
return NewConnHandler(conn, newDefaultHandler(), newDefaultSignalHandler()) return newConn(genericTransport{conn})
}
// NewConnHandler creates a new private *Conn from an already established connection, using the supplied handlers.
func NewConnHandler(conn io.ReadWriteCloser, handler Handler, signalHandler SignalHandler) (*Conn, error) {
return newConn(genericTransport{conn}, handler, signalHandler)
} }
// newConn creates a new *Conn from a transport. // newConn creates a new *Conn from a transport.
func newConn(tr transport, handler Handler, signalHandler SignalHandler) (*Conn, error) { func newConn(tr transport) (*Conn, error) {
conn := new(Conn) conn := new(Conn)
conn.transport = tr conn.transport = tr
conn.calls = make(map[uint32]*Call) conn.calls = make(map[uint32]*Call)
conn.out = make(chan *Message, 10) conn.out = make(chan *Message, 10)
conn.handler = handler conn.handlers = make(map[ObjectPath]map[string]exportWithMapping)
conn.signalHandler = signalHandler
conn.nextSerial = 1 conn.nextSerial = 1
conn.serialUsed = map[uint32]bool{0: true} conn.serialUsed = map[uint32]bool{0: true}
conn.busObj = conn.Object("org.freedesktop.DBus", "/org/freedesktop/DBus") conn.busObj = conn.Object("org.freedesktop.DBus", "/org/freedesktop/DBus")
@ -217,21 +185,16 @@ func (conn *Conn) Close() error {
close(conn.out) close(conn.out)
conn.closed = true conn.closed = true
conn.outLck.Unlock() conn.outLck.Unlock()
conn.signalsLck.Lock()
if term, ok := conn.signalHandler.(Terminator); ok { for _, ch := range conn.signals {
term.Terminate() close(ch)
} }
conn.signalsLck.Unlock()
if term, ok := conn.handler.(Terminator); ok {
term.Terminate()
}
conn.eavesdroppedLck.Lock() conn.eavesdroppedLck.Lock()
if conn.eavesdropped != nil { if conn.eavesdropped != nil {
close(conn.eavesdropped) close(conn.eavesdropped)
} }
conn.eavesdroppedLck.Unlock() conn.eavesdroppedLck.Unlock()
return conn.transport.Close() return conn.transport.Close()
} }
@ -368,7 +331,17 @@ func (conn *Conn) inWorker() {
conn.namesLck.Unlock() conn.namesLck.Unlock()
} }
} }
go conn.handleSignal(msg) signal := &Signal{
Sender: sender,
Path: msg.Headers[FieldPath].value.(ObjectPath),
Name: iface + "." + member,
Body: msg.Body,
}
conn.signalsLck.Lock()
for _, ch := range conn.signals {
ch <- signal
}
conn.signalsLck.Unlock()
case TypeMethodCall: case TypeMethodCall:
go conn.handleCall(msg) go conn.handleCall(msg)
} }
@ -389,21 +362,6 @@ func (conn *Conn) inWorker() {
} }
} }
func (conn *Conn) handleSignal(msg *Message) {
iface := msg.Headers[FieldInterface].value.(string)
member := msg.Headers[FieldMember].value.(string)
// as per http://dbus.freedesktop.org/doc/dbus-specification.html ,
// sender is optional for signals.
sender, _ := msg.Headers[FieldSender].value.(string)
signal := &Signal{
Sender: sender,
Path: msg.Headers[FieldPath].value.(ObjectPath),
Name: iface + "." + member,
Body: msg.Body,
}
conn.signalHandler.DeliverSignal(iface, member, signal)
}
// Names returns the list of all names that are currently owned by this // Names returns the list of all names that are currently owned by this
// connection. The slice is always at least one element long, the first element // connection. The slice is always at least one element long, the first element
// being the unique name of the connection. // being the unique name of the connection.
@ -494,19 +452,7 @@ func (conn *Conn) Send(msg *Message, ch chan *Call) *Call {
// sendError creates an error message corresponding to the parameters and sends // sendError creates an error message corresponding to the parameters and sends
// it to conn.out. // it to conn.out.
func (conn *Conn) sendError(err error, dest string, serial uint32) { func (conn *Conn) sendError(e Error, dest string, serial uint32) {
var e *Error
switch em := err.(type) {
case Error:
e = &em
case *Error:
e = em
case DBusError:
name, body := em.DBusError()
e = NewError(name, body)
default:
e = MakeFailedError(err)
}
msg := new(Message) msg := new(Message)
msg.Type = TypeError msg.Type = TypeError
msg.serial = conn.getSerial() msg.serial = conn.getSerial()
@ -549,30 +495,21 @@ func (conn *Conn) sendReply(dest string, serial uint32, values ...interface{}) {
conn.outLck.RUnlock() conn.outLck.RUnlock()
} }
func (conn *Conn) defaultSignalAction(fn func(h *defaultSignalHandler, ch chan<- *Signal), ch chan<- *Signal) {
if !isDefaultSignalHandler(conn.signalHandler) {
return
}
handler := conn.signalHandler.(*defaultSignalHandler)
fn(handler, ch)
}
// Signal registers the given channel to be passed all received signal messages. // Signal registers the given channel to be passed all received signal messages.
// The caller has to make sure that ch is sufficiently buffered; if a message // The caller has to make sure that ch is sufficiently buffered; if a message
// arrives when a write to c is not possible, it is discarded. // arrives when a write to c is not possible, it is discarded.
// //
// Multiple of these channels can be registered at the same time. // Multiple of these channels can be registered at the same time. Passing a
// channel that already is registered will remove it from the list of the
// registered channels.
// //
// These channels are "overwritten" by Eavesdrop; i.e., if there currently is a // These channels are "overwritten" by Eavesdrop; i.e., if there currently is a
// channel for eavesdropped messages, this channel receives all signals, and // channel for eavesdropped messages, this channel receives all signals, and
// none of the channels passed to Signal will receive any signals. // none of the channels passed to Signal will receive any signals.
func (conn *Conn) Signal(ch chan<- *Signal) { func (conn *Conn) Signal(ch chan<- *Signal) {
conn.defaultSignalAction((*defaultSignalHandler).addSignal, ch) conn.signalsLck.Lock()
} conn.signals = append(conn.signals, ch)
conn.signalsLck.Unlock()
// RemoveSignal removes the given channel from the list of the registered channels.
func (conn *Conn) RemoveSignal(ch chan<- *Signal) {
conn.defaultSignalAction((*defaultSignalHandler).removeSignal, ch)
} }
// SupportsUnixFDs returns whether the underlying transport supports passing of // SupportsUnixFDs returns whether the underlying transport supports passing of
@ -673,11 +610,16 @@ func dereferenceAll(vs []interface{}) []interface{} {
// getKey gets a key from a the list of keys. Returns "" on error / not found... // getKey gets a key from a the list of keys. Returns "" on error / not found...
func getKey(s, key string) string { func getKey(s, key string) string {
for _, keyEqualsValue := range strings.Split(s, ",") { i := strings.Index(s, key)
keyValue := strings.SplitN(keyEqualsValue, "=", 2) if i == -1 {
if len(keyValue) == 2 && keyValue[0] == key {
return keyValue[1]
}
}
return "" return ""
} }
if i+len(key)+1 >= len(s) || s[i+len(key)] != '=' {
return ""
}
j := strings.Index(s, ",")
if j == -1 {
j = len(s)
}
return s[i+len(key)+1 : j]
}

View File

@ -2,32 +2,20 @@ package dbus
import ( import (
"errors" "errors"
"fmt"
"os"
"os/exec" "os/exec"
) )
const defaultSystemBusAddress = "unix:path=/opt/local/var/run/dbus/system_bus_socket" func sessionBusPlatform() (*Conn, error) {
func getSessionBusPlatformAddress() (string, error) {
cmd := exec.Command("launchctl", "getenv", "DBUS_LAUNCHD_SESSION_BUS_SOCKET") cmd := exec.Command("launchctl", "getenv", "DBUS_LAUNCHD_SESSION_BUS_SOCKET")
b, err := cmd.CombinedOutput() b, err := cmd.CombinedOutput()
if err != nil { if err != nil {
return "", err return nil, err
} }
if len(b) == 0 { if len(b) == 0 {
return "", errors.New("dbus: couldn't determine address of session bus") return nil, errors.New("dbus: couldn't determine address of session bus")
} }
return "unix:path=" + string(b[:len(b)-1]), nil return Dial("unix:path=" + string(b[:len(b)-1]))
}
func getSystemBusPlatformAddress() string {
address := os.Getenv("DBUS_LAUNCHD_SESSION_BUS_SOCKET")
if address != "" {
return fmt.Sprintf("unix:path=%s", address)
}
return defaultSystemBusAddress
} }

View File

@ -5,38 +5,23 @@ package dbus
import ( import (
"bytes" "bytes"
"errors" "errors"
"fmt"
"os"
"os/exec" "os/exec"
) )
const defaultSystemBusAddress = "unix:path=/var/run/dbus/system_bus_socket" func sessionBusPlatform() (*Conn, error) {
func getSessionBusPlatformAddress() (string, error) {
cmd := exec.Command("dbus-launch") cmd := exec.Command("dbus-launch")
b, err := cmd.CombinedOutput() b, err := cmd.CombinedOutput()
if err != nil { if err != nil {
return "", err return nil, err
} }
i := bytes.IndexByte(b, '=') i := bytes.IndexByte(b, '=')
j := bytes.IndexByte(b, '\n') j := bytes.IndexByte(b, '\n')
if i == -1 || j == -1 { if i == -1 || j == -1 {
return "", errors.New("dbus: couldn't determine address of session bus") return nil, errors.New("dbus: couldn't determine address of session bus")
} }
env, addr := string(b[0:i]), string(b[i+1:j]) return Dial(string(b[i+1 : j]))
os.Setenv(env, addr)
return addr, nil
}
func getSystemBusPlatformAddress() string {
address := os.Getenv("DBUS_SYSTEM_BUS_ADDRESS")
if address != "" {
return fmt.Sprintf("unix:path=%s", address)
}
return defaultSystemBusAddress
} }

293
vendor/github.com/godbus/dbus/dbus.go generated vendored
View File

@ -2,7 +2,6 @@ package dbus
import ( import (
"errors" "errors"
"fmt"
"reflect" "reflect"
"strings" "strings"
) )
@ -13,8 +12,6 @@ var (
uint8Type = reflect.TypeOf(uint8(0)) uint8Type = reflect.TypeOf(uint8(0))
int16Type = reflect.TypeOf(int16(0)) int16Type = reflect.TypeOf(int16(0))
uint16Type = reflect.TypeOf(uint16(0)) uint16Type = reflect.TypeOf(uint16(0))
intType = reflect.TypeOf(int(0))
uintType = reflect.TypeOf(uint(0))
int32Type = reflect.TypeOf(int32(0)) int32Type = reflect.TypeOf(int32(0))
uint32Type = reflect.TypeOf(uint32(0)) uint32Type = reflect.TypeOf(uint32(0))
int64Type = reflect.TypeOf(int64(0)) int64Type = reflect.TypeOf(int64(0))
@ -25,7 +22,6 @@ var (
objectPathType = reflect.TypeOf(ObjectPath("")) objectPathType = reflect.TypeOf(ObjectPath(""))
variantType = reflect.TypeOf(Variant{Signature{""}, nil}) variantType = reflect.TypeOf(Variant{Signature{""}, nil})
interfacesType = reflect.TypeOf([]interface{}{}) interfacesType = reflect.TypeOf([]interface{}{})
interfaceType = reflect.TypeOf((*interface{})(nil)).Elem()
unixFDType = reflect.TypeOf(UnixFD(0)) unixFDType = reflect.TypeOf(UnixFD(0))
unixFDIndexType = reflect.TypeOf(UnixFDIndex(0)) unixFDIndexType = reflect.TypeOf(UnixFDIndex(0))
) )
@ -50,251 +46,86 @@ func Store(src []interface{}, dest ...interface{}) error {
} }
for i := range src { for i := range src {
if err := storeInterfaces(src[i], dest[i]); err != nil { if err := store(src[i], dest[i]); err != nil {
return err return err
} }
} }
return nil return nil
} }
func storeInterfaces(src, dest interface{}) error { func store(src, dest interface{}) error {
return store(reflect.ValueOf(dest), reflect.ValueOf(src)) if reflect.TypeOf(dest).Elem() == reflect.TypeOf(src) {
reflect.ValueOf(dest).Elem().Set(reflect.ValueOf(src))
return nil
} else if hasStruct(dest) {
rv := reflect.ValueOf(dest).Elem()
switch rv.Kind() {
case reflect.Struct:
vs, ok := src.([]interface{})
if !ok {
return errors.New("dbus.Store: type mismatch")
} }
t := rv.Type()
func store(dest, src reflect.Value) error { ndest := make([]interface{}, 0, rv.NumField())
if dest.Kind() == reflect.Ptr { for i := 0; i < rv.NumField(); i++ {
return store(dest.Elem(), src) field := t.Field(i)
if field.PkgPath == "" && field.Tag.Get("dbus") != "-" {
ndest = append(ndest, rv.Field(i).Addr().Interface())
}
}
if len(vs) != len(ndest) {
return errors.New("dbus.Store: type mismatch")
}
err := Store(vs, ndest...)
if err != nil {
return errors.New("dbus.Store: type mismatch")
} }
switch src.Kind() {
case reflect.Slice: case reflect.Slice:
return storeSlice(dest, src) sv := reflect.ValueOf(src)
if sv.Kind() != reflect.Slice {
return errors.New("dbus.Store: type mismatch")
}
rv.Set(reflect.MakeSlice(rv.Type(), sv.Len(), sv.Len()))
for i := 0; i < sv.Len(); i++ {
if err := store(sv.Index(i).Interface(), rv.Index(i).Addr().Interface()); err != nil {
return err
}
}
case reflect.Map: case reflect.Map:
return storeMap(dest, src) sv := reflect.ValueOf(src)
default: if sv.Kind() != reflect.Map {
return storeBase(dest, src) return errors.New("dbus.Store: type mismatch")
} }
} keys := sv.MapKeys()
rv.Set(reflect.MakeMap(sv.Type()))
func storeBase(dest, src reflect.Value) error {
return setDest(dest, src)
}
func setDest(dest, src reflect.Value) error {
if !isVariant(src.Type()) && isVariant(dest.Type()) {
//special conversion for dbus.Variant
dest.Set(reflect.ValueOf(MakeVariant(src.Interface())))
return nil
}
if isVariant(src.Type()) && !isVariant(dest.Type()) {
src = getVariantValue(src)
}
if !src.Type().ConvertibleTo(dest.Type()) {
return fmt.Errorf(
"dbus.Store: type mismatch: cannot convert %s to %s",
src.Type(), dest.Type())
}
dest.Set(src.Convert(dest.Type()))
return nil
}
func kindsAreCompatible(dest, src reflect.Type) bool {
switch {
case isVariant(dest):
return true
case dest.Kind() == reflect.Interface:
return true
default:
return dest.Kind() == src.Kind()
}
}
func isConvertibleTo(dest, src reflect.Type) bool {
switch {
case isVariant(dest):
return true
case dest.Kind() == reflect.Interface:
return true
case dest.Kind() == reflect.Slice:
return src.Kind() == reflect.Slice &&
isConvertibleTo(dest.Elem(), src.Elem())
case dest.Kind() == reflect.Struct:
return src == interfacesType
default:
return src.ConvertibleTo(dest)
}
}
func storeMap(dest, src reflect.Value) error {
switch {
case !kindsAreCompatible(dest.Type(), src.Type()):
return fmt.Errorf(
"dbus.Store: type mismatch: "+
"map: cannot store a value of %s into %s",
src.Type(), dest.Type())
case isVariant(dest.Type()):
return storeMapIntoVariant(dest, src)
case dest.Kind() == reflect.Interface:
return storeMapIntoInterface(dest, src)
case isConvertibleTo(dest.Type().Key(), src.Type().Key()) &&
isConvertibleTo(dest.Type().Elem(), src.Type().Elem()):
return storeMapIntoMap(dest, src)
default:
return fmt.Errorf(
"dbus.Store: type mismatch: "+
"map: cannot convert a value of %s into %s",
src.Type(), dest.Type())
}
}
func storeMapIntoVariant(dest, src reflect.Value) error {
dv := reflect.MakeMap(src.Type())
err := store(dv, src)
if err != nil {
return err
}
return storeBase(dest, dv)
}
func storeMapIntoInterface(dest, src reflect.Value) error {
var dv reflect.Value
if isVariant(src.Type().Elem()) {
//Convert variants to interface{} recursively when converting
//to interface{}
dv = reflect.MakeMap(
reflect.MapOf(src.Type().Key(), interfaceType))
} else {
dv = reflect.MakeMap(src.Type())
}
err := store(dv, src)
if err != nil {
return err
}
return storeBase(dest, dv)
}
func storeMapIntoMap(dest, src reflect.Value) error {
if dest.IsNil() {
dest.Set(reflect.MakeMap(dest.Type()))
}
keys := src.MapKeys()
for _, key := range keys { for _, key := range keys {
dkey := key.Convert(dest.Type().Key()) v := reflect.New(sv.Type().Elem())
dval := reflect.New(dest.Type().Elem()).Elem() if err := store(v, sv.MapIndex(key).Interface()); err != nil {
err := store(dval, getVariantValue(src.MapIndex(key)))
if err != nil {
return err return err
} }
dest.SetMapIndex(dkey, dval) rv.SetMapIndex(key, v.Elem())
} }
return nil
}
func storeSlice(dest, src reflect.Value) error {
switch {
case src.Type() == interfacesType && dest.Kind() == reflect.Struct:
//The decoder always decodes structs as slices of interface{}
return storeStruct(dest, src)
case !kindsAreCompatible(dest.Type(), src.Type()):
return fmt.Errorf(
"dbus.Store: type mismatch: "+
"slice: cannot store a value of %s into %s",
src.Type(), dest.Type())
case isVariant(dest.Type()):
return storeSliceIntoVariant(dest, src)
case dest.Kind() == reflect.Interface:
return storeSliceIntoInterface(dest, src)
case isConvertibleTo(dest.Type().Elem(), src.Type().Elem()):
return storeSliceIntoSlice(dest, src)
default: default:
return fmt.Errorf( return errors.New("dbus.Store: type mismatch")
"dbus.Store: type mismatch: "+
"slice: cannot convert a value of %s into %s",
src.Type(), dest.Type())
}
}
func storeStruct(dest, src reflect.Value) error {
if isVariant(dest.Type()) {
return storeBase(dest, src)
}
dval := make([]interface{}, 0, dest.NumField())
dtype := dest.Type()
for i := 0; i < dest.NumField(); i++ {
field := dest.Field(i)
ftype := dtype.Field(i)
if ftype.PkgPath != "" {
continue
}
if ftype.Tag.Get("dbus") == "-" {
continue
}
dval = append(dval, field.Addr().Interface())
}
if src.Len() != len(dval) {
return fmt.Errorf(
"dbus.Store: type mismatch: "+
"destination struct does not have "+
"enough fields need: %d have: %d",
src.Len(), len(dval))
}
return Store(src.Interface().([]interface{}), dval...)
}
func storeSliceIntoVariant(dest, src reflect.Value) error {
dv := reflect.MakeSlice(src.Type(), src.Len(), src.Cap())
err := store(dv, src)
if err != nil {
return err
}
return storeBase(dest, dv)
}
func storeSliceIntoInterface(dest, src reflect.Value) error {
var dv reflect.Value
if isVariant(src.Type().Elem()) {
//Convert variants to interface{} recursively when converting
//to interface{}
dv = reflect.MakeSlice(reflect.SliceOf(interfaceType),
src.Len(), src.Cap())
} else {
dv = reflect.MakeSlice(src.Type(), src.Len(), src.Cap())
}
err := store(dv, src)
if err != nil {
return err
}
return storeBase(dest, dv)
}
func storeSliceIntoSlice(dest, src reflect.Value) error {
if dest.IsNil() || dest.Len() < src.Len() {
dest.Set(reflect.MakeSlice(dest.Type(), src.Len(), src.Cap()))
}
if dest.Len() != src.Len() {
return fmt.Errorf(
"dbus.Store: type mismatch: "+
"slices are different lengths "+
"need: %d have: %d",
src.Len(), dest.Len())
}
for i := 0; i < src.Len(); i++ {
err := store(dest.Index(i), getVariantValue(src.Index(i)))
if err != nil {
return err
}
} }
return nil return nil
} else {
return errors.New("dbus.Store: type mismatch")
}
} }
func getVariantValue(in reflect.Value) reflect.Value { func hasStruct(v interface{}) bool {
if isVariant(in.Type()) { t := reflect.TypeOf(v)
return reflect.ValueOf(in.Interface().(Variant).Value()) for {
switch t.Kind() {
case reflect.Struct:
return true
case reflect.Slice, reflect.Ptr, reflect.Map:
t = t.Elem()
default:
return false
} }
return in
} }
func isVariant(t reflect.Type) bool {
return t == variantType
} }
// An ObjectPath is an object path as defined by the D-Bus spec. // An ObjectPath is an object path as defined by the D-Bus spec.
@ -346,15 +177,15 @@ func alignment(t reflect.Type) int {
return 4 return 4
case signatureType: case signatureType:
return 1 return 1
case interfacesType: case interfacesType: // sometimes used for structs
return 4 return 8
} }
switch t.Kind() { switch t.Kind() {
case reflect.Uint8: case reflect.Uint8:
return 1 return 1
case reflect.Uint16, reflect.Int16: case reflect.Uint16, reflect.Int16:
return 2 return 2
case reflect.Uint, reflect.Int, reflect.Uint32, reflect.Int32, reflect.String, reflect.Array, reflect.Slice, reflect.Map: case reflect.Uint32, reflect.Int32, reflect.String, reflect.Array, reflect.Slice, reflect.Map:
return 4 return 4
case reflect.Uint64, reflect.Int64, reflect.Float64, reflect.Struct: case reflect.Uint64, reflect.Int64, reflect.Float64, reflect.Struct:
return 8 return 8
@ -369,7 +200,7 @@ func isKeyType(t reflect.Type) bool {
switch t.Kind() { switch t.Kind() {
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
reflect.Int16, reflect.Int32, reflect.Int64, reflect.Float64, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Float64,
reflect.String, reflect.Uint, reflect.Int: reflect.String:
return true return true
} }

View File

@ -1,283 +0,0 @@
package dbus
import (
"bytes"
"reflect"
"strings"
"sync"
)
func newIntrospectIntf(h *defaultHandler) *exportedIntf {
methods := make(map[string]Method)
methods["Introspect"] = exportedMethod{
reflect.ValueOf(func(msg Message) (string, *Error) {
path := msg.Headers[FieldPath].value.(ObjectPath)
return h.introspectPath(path), nil
}),
}
return newExportedIntf(methods, true)
}
func newDefaultHandler() *defaultHandler {
h := &defaultHandler{
objects: make(map[ObjectPath]*exportedObj),
defaultIntf: make(map[string]*exportedIntf),
}
h.defaultIntf["org.freedesktop.DBus.Introspectable"] = newIntrospectIntf(h)
return h
}
type defaultHandler struct {
sync.RWMutex
objects map[ObjectPath]*exportedObj
defaultIntf map[string]*exportedIntf
}
func (h *defaultHandler) PathExists(path ObjectPath) bool {
_, ok := h.objects[path]
return ok
}
func (h *defaultHandler) introspectPath(path ObjectPath) string {
subpath := make(map[string]struct{})
var xml bytes.Buffer
xml.WriteString("<node>")
for obj, _ := range h.objects {
p := string(path)
if p != "/" {
p += "/"
}
if strings.HasPrefix(string(obj), p) {
node_name := strings.Split(string(obj[len(p):]), "/")[0]
subpath[node_name] = struct{}{}
}
}
for s, _ := range subpath {
xml.WriteString("\n\t<node name=\"" + s + "\"/>")
}
xml.WriteString("\n</node>")
return xml.String()
}
func (h *defaultHandler) LookupObject(path ObjectPath) (ServerObject, bool) {
h.RLock()
defer h.RUnlock()
object, ok := h.objects[path]
if ok {
return object, ok
}
// If an object wasn't found for this exact path,
// look for a matching subtree registration
subtreeObject := newExportedObject()
path = path[:strings.LastIndex(string(path), "/")]
for len(path) > 0 {
object, ok = h.objects[path]
if ok {
for name, iface := range object.interfaces {
// Only include this handler if it registered for the subtree
if iface.isFallbackInterface() {
subtreeObject.interfaces[name] = iface
}
}
break
}
path = path[:strings.LastIndex(string(path), "/")]
}
for name, intf := range h.defaultIntf {
if _, exists := subtreeObject.interfaces[name]; exists {
continue
}
subtreeObject.interfaces[name] = intf
}
return subtreeObject, true
}
func (h *defaultHandler) AddObject(path ObjectPath, object *exportedObj) {
h.Lock()
h.objects[path] = object
h.Unlock()
}
func (h *defaultHandler) DeleteObject(path ObjectPath) {
h.Lock()
delete(h.objects, path)
h.Unlock()
}
type exportedMethod struct {
reflect.Value
}
func (m exportedMethod) Call(args ...interface{}) ([]interface{}, error) {
t := m.Type()
params := make([]reflect.Value, len(args))
for i := 0; i < len(args); i++ {
params[i] = reflect.ValueOf(args[i]).Elem()
}
ret := m.Value.Call(params)
err := ret[t.NumOut()-1].Interface().(*Error)
ret = ret[:t.NumOut()-1]
out := make([]interface{}, len(ret))
for i, val := range ret {
out[i] = val.Interface()
}
if err == nil {
//concrete type to interface nil is a special case
return out, nil
}
return out, err
}
func (m exportedMethod) NumArguments() int {
return m.Value.Type().NumIn()
}
func (m exportedMethod) ArgumentValue(i int) interface{} {
return reflect.Zero(m.Type().In(i)).Interface()
}
func (m exportedMethod) NumReturns() int {
return m.Value.Type().NumOut()
}
func (m exportedMethod) ReturnValue(i int) interface{} {
return reflect.Zero(m.Type().Out(i)).Interface()
}
func newExportedObject() *exportedObj {
return &exportedObj{
interfaces: make(map[string]*exportedIntf),
}
}
type exportedObj struct {
interfaces map[string]*exportedIntf
}
func (obj *exportedObj) LookupInterface(name string) (Interface, bool) {
if name == "" {
return obj, true
}
intf, exists := obj.interfaces[name]
return intf, exists
}
func (obj *exportedObj) AddInterface(name string, iface *exportedIntf) {
obj.interfaces[name] = iface
}
func (obj *exportedObj) DeleteInterface(name string) {
delete(obj.interfaces, name)
}
func (obj *exportedObj) LookupMethod(name string) (Method, bool) {
for _, intf := range obj.interfaces {
method, exists := intf.LookupMethod(name)
if exists {
return method, exists
}
}
return nil, false
}
func (obj *exportedObj) isFallbackInterface() bool {
return false
}
func newExportedIntf(methods map[string]Method, includeSubtree bool) *exportedIntf {
return &exportedIntf{
methods: methods,
includeSubtree: includeSubtree,
}
}
type exportedIntf struct {
methods map[string]Method
// Whether or not this export is for the entire subtree
includeSubtree bool
}
func (obj *exportedIntf) LookupMethod(name string) (Method, bool) {
out, exists := obj.methods[name]
return out, exists
}
func (obj *exportedIntf) isFallbackInterface() bool {
return obj.includeSubtree
}
func newDefaultSignalHandler() *defaultSignalHandler {
return &defaultSignalHandler{}
}
func isDefaultSignalHandler(handler SignalHandler) bool {
_, ok := handler.(*defaultSignalHandler)
return ok
}
type defaultSignalHandler struct {
sync.RWMutex
closed bool
signals []chan<- *Signal
}
func (sh *defaultSignalHandler) DeliverSignal(intf, name string, signal *Signal) {
sh.RLock()
defer sh.RUnlock()
if sh.closed {
return
}
for _, ch := range sh.signals {
ch <- signal
}
}
func (sh *defaultSignalHandler) Init() error {
sh.Lock()
sh.signals = make([]chan<- *Signal, 0)
sh.Unlock()
return nil
}
func (sh *defaultSignalHandler) Terminate() {
sh.Lock()
sh.closed = true
for _, ch := range sh.signals {
close(ch)
}
sh.signals = nil
sh.Unlock()
}
func (sh *defaultSignalHandler) addSignal(ch chan<- *Signal) {
sh.Lock()
defer sh.Unlock()
if sh.closed {
return
}
sh.signals = append(sh.signals, ch)
}
func (sh *defaultSignalHandler) removeSignal(ch chan<- *Signal) {
sh.Lock()
defer sh.Unlock()
if sh.closed {
return
}
for i := len(sh.signals) - 1; i >= 0; i-- {
if ch == sh.signals[i] {
copy(sh.signals[i:], sh.signals[i+1:])
sh.signals[len(sh.signals)-1] = nil
sh.signals = sh.signals[:len(sh.signals)-1]
}
}
}

View File

@ -19,8 +19,6 @@ respective D-Bus equivalents:
bool | BOOLEAN bool | BOOLEAN
int16 | INT16 int16 | INT16
uint16 | UINT16 uint16 | UINT16
int | INT32
uint | UINT32
int32 | INT32 int32 | INT32
uint32 | UINT32 uint32 | UINT32
int64 | INT64 int64 | INT64
@ -30,7 +28,6 @@ respective D-Bus equivalents:
ObjectPath | OBJECT_PATH ObjectPath | OBJECT_PATH
Signature | SIGNATURE Signature | SIGNATURE
Variant | VARIANT Variant | VARIANT
interface{} | VARIANT
UnixFDIndex | UNIX_FD UnixFDIndex | UNIX_FD
Slices and arrays encode as ARRAYs of their element type. Slices and arrays encode as ARRAYs of their element type.
@ -44,9 +41,6 @@ be skipped.
Pointers encode as the value they're pointed to. Pointers encode as the value they're pointed to.
Types convertible to one of the base types above will be mapped as the
base type.
Trying to encode any other type or a slice, map or struct containing an Trying to encode any other type or a slice, map or struct containing an
unsupported type will result in an InvalidTypeError. unsupported type will result in an InvalidTypeError.

View File

@ -96,10 +96,10 @@ func (enc *encoder) encode(v reflect.Value, depth int) {
case reflect.Uint16: case reflect.Uint16:
enc.binwrite(uint16(v.Uint())) enc.binwrite(uint16(v.Uint()))
enc.pos += 2 enc.pos += 2
case reflect.Int, reflect.Int32: case reflect.Int32:
enc.binwrite(int32(v.Int())) enc.binwrite(int32(v.Int()))
enc.pos += 4 enc.pos += 4
case reflect.Uint, reflect.Uint32: case reflect.Uint32:
enc.binwrite(uint32(v.Uint())) enc.binwrite(uint32(v.Uint()))
enc.pos += 4 enc.pos += 4
case reflect.Int64: case reflect.Int64:
@ -202,8 +202,6 @@ func (enc *encoder) encode(v reflect.Value, depth int) {
panic(err) panic(err)
} }
enc.pos += length enc.pos += length
case reflect.Interface:
enc.encode(reflect.ValueOf(MakeVariant(v.Interface())), depth)
default: default:
panic(InvalidTypeError{v.Type()}) panic(InvalidTypeError{v.Type()})
} }

View File

@ -8,73 +8,167 @@ import (
) )
var ( var (
ErrMsgInvalidArg = Error{ errmsgInvalidArg = Error{
"org.freedesktop.DBus.Error.InvalidArgs", "org.freedesktop.DBus.Error.InvalidArgs",
[]interface{}{"Invalid type / number of args"}, []interface{}{"Invalid type / number of args"},
} }
ErrMsgNoObject = Error{ errmsgNoObject = Error{
"org.freedesktop.DBus.Error.NoSuchObject", "org.freedesktop.DBus.Error.NoSuchObject",
[]interface{}{"No such object"}, []interface{}{"No such object"},
} }
ErrMsgUnknownMethod = Error{ errmsgUnknownMethod = Error{
"org.freedesktop.DBus.Error.UnknownMethod", "org.freedesktop.DBus.Error.UnknownMethod",
[]interface{}{"Unknown / invalid method"}, []interface{}{"Unknown / invalid method"},
} }
ErrMsgUnknownInterface = Error{
"org.freedesktop.DBus.Error.UnknownInterface",
[]interface{}{"Object does not implement the interface"},
}
) )
func MakeFailedError(err error) *Error { // exportWithMapping represents an exported struct along with a method name
return &Error{ // mapping to allow for exporting lower-case methods, etc.
"org.freedesktop.DBus.Error.Failed", type exportWithMapping struct {
[]interface{}{err.Error()}, export interface{}
}
// Method name mapping; key -> struct method, value -> dbus method.
mapping map[string]string
// Whether or not this export is for the entire subtree
includeSubtree bool
} }
// Sender is a type which can be used in exported methods to receive the message // Sender is a type which can be used in exported methods to receive the message
// sender. // sender.
type Sender string type Sender string
func computeMethodName(name string, mapping map[string]string) string { func exportedMethod(export exportWithMapping, name string) reflect.Value {
newname, ok := mapping[name] if export.export == nil {
if ok { return reflect.Value{}
name = newname
}
return name
} }
func getMethods(in interface{}, mapping map[string]string) map[string]reflect.Value { // If a mapping was included in the export, check the map to see if we
if in == nil { // should be looking for a different method in the export.
return nil if export.mapping != nil {
for key, value := range export.mapping {
if value == name {
name = key
break
} }
methods := make(map[string]reflect.Value)
val := reflect.ValueOf(in) // Catch the case where a method is aliased but the client is calling
typ := val.Type() // the original, e.g. the "Foo" method was exported mapped to
for i := 0; i < typ.NumMethod(); i++ { // "foo," and dbus client called the original "Foo."
methtype := typ.Method(i) if key == name {
method := val.Method(i) return reflect.Value{}
t := method.Type() }
// only track valid methods must return *Error as last arg }
// and must be exported }
value := reflect.ValueOf(export.export)
m := value.MethodByName(name)
// Catch the case of attempting to call an unexported method
method, ok := value.Type().MethodByName(name)
if !m.IsValid() || !ok || method.PkgPath != "" {
return reflect.Value{}
}
t := m.Type()
if t.NumOut() == 0 || if t.NumOut() == 0 ||
t.Out(t.NumOut()-1) != reflect.TypeOf(&ErrMsgInvalidArg) || t.Out(t.NumOut()-1) != reflect.TypeOf(&errmsgInvalidArg) {
methtype.PkgPath != "" {
continue return reflect.Value{}
} }
// map names while building table return m
methods[computeMethodName(methtype.Name, mapping)] = method
}
return methods
} }
func standardMethodArgumentDecode(m Method, sender string, msg *Message, body []interface{}) ([]interface{}, error) { // searchHandlers will look through all registered handlers looking for one
pointers := make([]interface{}, m.NumArguments()) // to handle the given path. If a verbatim one isn't found, it will check for
decode := make([]interface{}, 0, len(body)) // a subtree registration for the path as well.
func (conn *Conn) searchHandlers(path ObjectPath) (map[string]exportWithMapping, bool) {
conn.handlersLck.RLock()
defer conn.handlersLck.RUnlock()
for i := 0; i < m.NumArguments(); i++ { handlers, ok := conn.handlers[path]
tp := reflect.TypeOf(m.ArgumentValue(i)) if ok {
return handlers, ok
}
// If handlers weren't found for this exact path, look for a matching subtree
// registration
handlers = make(map[string]exportWithMapping)
path = path[:strings.LastIndex(string(path), "/")]
for len(path) > 0 {
var subtreeHandlers map[string]exportWithMapping
subtreeHandlers, ok = conn.handlers[path]
if ok {
for iface, handler := range subtreeHandlers {
// Only include this handler if it registered for the subtree
if handler.includeSubtree {
handlers[iface] = handler
}
}
break
}
path = path[:strings.LastIndex(string(path), "/")]
}
return handlers, ok
}
// handleCall handles the given method call (i.e. looks if it's one of the
// pre-implemented ones and searches for a corresponding handler if not).
func (conn *Conn) handleCall(msg *Message) {
name := msg.Headers[FieldMember].value.(string)
path := msg.Headers[FieldPath].value.(ObjectPath)
ifaceName, hasIface := msg.Headers[FieldInterface].value.(string)
sender, hasSender := msg.Headers[FieldSender].value.(string)
serial := msg.serial
if ifaceName == "org.freedesktop.DBus.Peer" {
switch name {
case "Ping":
conn.sendReply(sender, serial)
case "GetMachineId":
conn.sendReply(sender, serial, conn.uuid)
default:
conn.sendError(errmsgUnknownMethod, sender, serial)
}
return
}
if len(name) == 0 {
conn.sendError(errmsgUnknownMethod, sender, serial)
}
// Find the exported handler (if any) for this path
handlers, ok := conn.searchHandlers(path)
if !ok {
conn.sendError(errmsgNoObject, sender, serial)
return
}
var m reflect.Value
if hasIface {
iface := handlers[ifaceName]
m = exportedMethod(iface, name)
} else {
for _, v := range handlers {
m = exportedMethod(v, name)
if m.IsValid() {
break
}
}
}
if !m.IsValid() {
conn.sendError(errmsgUnknownMethod, sender, serial)
return
}
t := m.Type()
vs := msg.Body
pointers := make([]interface{}, t.NumIn())
decode := make([]interface{}, 0, len(vs))
for i := 0; i < t.NumIn(); i++ {
tp := t.In(i)
val := reflect.New(tp) val := reflect.New(tp)
pointers[i] = val.Interface() pointers[i] = val.Interface()
if tp == reflect.TypeOf((*Sender)(nil)).Elem() { if tp == reflect.TypeOf((*Sender)(nil)).Elem() {
@ -86,73 +180,26 @@ func standardMethodArgumentDecode(m Method, sender string, msg *Message, body []
} }
} }
if len(decode) != len(body) { if len(decode) != len(vs) {
return nil, ErrMsgInvalidArg conn.sendError(errmsgInvalidArg, sender, serial)
}
if err := Store(body, decode...); err != nil {
return nil, ErrMsgInvalidArg
}
return pointers, nil
}
func (conn *Conn) decodeArguments(m Method, sender string, msg *Message) ([]interface{}, error) {
if decoder, ok := m.(ArgumentDecoder); ok {
return decoder.DecodeArguments(conn, sender, msg, msg.Body)
}
return standardMethodArgumentDecode(m, sender, msg, msg.Body)
}
// handleCall handles the given method call (i.e. looks if it's one of the
// pre-implemented ones and searches for a corresponding handler if not).
func (conn *Conn) handleCall(msg *Message) {
name := msg.Headers[FieldMember].value.(string)
path := msg.Headers[FieldPath].value.(ObjectPath)
ifaceName, _ := msg.Headers[FieldInterface].value.(string)
sender, hasSender := msg.Headers[FieldSender].value.(string)
serial := msg.serial
if ifaceName == "org.freedesktop.DBus.Peer" {
switch name {
case "Ping":
conn.sendReply(sender, serial)
case "GetMachineId":
conn.sendReply(sender, serial, conn.uuid)
default:
conn.sendError(ErrMsgUnknownMethod, sender, serial)
}
return
}
if len(name) == 0 {
conn.sendError(ErrMsgUnknownMethod, sender, serial)
}
object, ok := conn.handler.LookupObject(path)
if !ok {
conn.sendError(ErrMsgNoObject, sender, serial)
return return
} }
iface, exists := object.LookupInterface(ifaceName) if err := Store(vs, decode...); err != nil {
if !exists { conn.sendError(errmsgInvalidArg, sender, serial)
conn.sendError(ErrMsgUnknownInterface, sender, serial)
return return
} }
m, exists := iface.LookupMethod(name) // Extract parameters
if !exists { params := make([]reflect.Value, len(pointers))
conn.sendError(ErrMsgUnknownMethod, sender, serial) for i := 0; i < len(pointers); i++ {
return params[i] = reflect.ValueOf(pointers[i]).Elem()
}
args, err := conn.decodeArguments(m, sender, msg)
if err != nil {
conn.sendError(err, sender, serial)
return
} }
ret, err := m.Call(args...) // Call method
if err != nil { ret := m.Call(params)
conn.sendError(err, sender, serial) if em := ret[t.NumOut()-1].Interface().(*Error); em != nil {
conn.sendError(*em, sender, serial)
return return
} }
@ -165,11 +212,13 @@ func (conn *Conn) handleCall(msg *Message) {
reply.Headers[FieldDestination] = msg.Headers[FieldSender] reply.Headers[FieldDestination] = msg.Headers[FieldSender]
} }
reply.Headers[FieldReplySerial] = MakeVariant(msg.serial) reply.Headers[FieldReplySerial] = MakeVariant(msg.serial)
reply.Body = make([]interface{}, len(ret)) reply.Body = make([]interface{}, len(ret)-1)
for i := 0; i < len(ret); i++ { for i := 0; i < len(ret)-1; i++ {
reply.Body[i] = ret[i] reply.Body[i] = ret[i].Interface()
} }
if len(ret) != 1 {
reply.Headers[FieldSignature] = MakeVariant(SignatureOf(reply.Body...)) reply.Headers[FieldSignature] = MakeVariant(SignatureOf(reply.Body...))
}
conn.outLck.RLock() conn.outLck.RLock()
if !conn.closed { if !conn.closed {
conn.out <- reply conn.out <- reply
@ -254,7 +303,7 @@ func (conn *Conn) Export(v interface{}, path ObjectPath, iface string) error {
// The keys in the map are the real method names (exported on the struct), and // The keys in the map are the real method names (exported on the struct), and
// the values are the method names to be exported on DBus. // the values are the method names to be exported on DBus.
func (conn *Conn) ExportWithMap(v interface{}, mapping map[string]string, path ObjectPath, iface string) error { func (conn *Conn) ExportWithMap(v interface{}, mapping map[string]string, path ObjectPath, iface string) error {
return conn.export(getMethods(v, mapping), path, iface, false) return conn.exportWithMap(v, mapping, path, iface, false)
} }
// ExportSubtree works exactly like Export but registers the given value for // ExportSubtree works exactly like Export but registers the given value for
@ -277,89 +326,38 @@ func (conn *Conn) ExportSubtree(v interface{}, path ObjectPath, iface string) er
// The keys in the map are the real method names (exported on the struct), and // The keys in the map are the real method names (exported on the struct), and
// the values are the method names to be exported on DBus. // the values are the method names to be exported on DBus.
func (conn *Conn) ExportSubtreeWithMap(v interface{}, mapping map[string]string, path ObjectPath, iface string) error { func (conn *Conn) ExportSubtreeWithMap(v interface{}, mapping map[string]string, path ObjectPath, iface string) error {
return conn.export(getMethods(v, mapping), path, iface, true) return conn.exportWithMap(v, mapping, path, iface, true)
}
// ExportMethodTable like Export registers the given methods as an object
// on the message bus. Unlike Export the it uses a method table to define
// the object instead of a native go object.
//
// The method table is a map from method name to function closure
// representing the method. This allows an object exported on the bus to not
// necessarily be a native go object. It can be useful for generating exposed
// methods on the fly.
//
// Any non-function objects in the method table are ignored.
func (conn *Conn) ExportMethodTable(methods map[string]interface{}, path ObjectPath, iface string) error {
return conn.exportMethodTable(methods, path, iface, false)
}
// Like ExportSubtree, but with the same caveats as ExportMethodTable.
func (conn *Conn) ExportSubtreeMethodTable(methods map[string]interface{}, path ObjectPath, iface string) error {
return conn.exportMethodTable(methods, path, iface, true)
}
func (conn *Conn) exportMethodTable(methods map[string]interface{}, path ObjectPath, iface string, includeSubtree bool) error {
out := make(map[string]reflect.Value)
for name, method := range methods {
rval := reflect.ValueOf(method)
if rval.Kind() != reflect.Func {
continue
}
t := rval.Type()
// only track valid methods must return *Error as last arg
if t.NumOut() == 0 ||
t.Out(t.NumOut()-1) != reflect.TypeOf(&ErrMsgInvalidArg) {
continue
}
out[name] = rval
}
return conn.export(out, path, iface, includeSubtree)
}
func (conn *Conn) unexport(h *defaultHandler, path ObjectPath, iface string) error {
if h.PathExists(path) {
obj := h.objects[path]
obj.DeleteInterface(iface)
if len(obj.interfaces) == 0 {
h.DeleteObject(path)
}
}
return nil
} }
// exportWithMap is the worker function for all exports/registrations. // exportWithMap is the worker function for all exports/registrations.
func (conn *Conn) export(methods map[string]reflect.Value, path ObjectPath, iface string, includeSubtree bool) error { func (conn *Conn) exportWithMap(v interface{}, mapping map[string]string, path ObjectPath, iface string, includeSubtree bool) error {
h, ok := conn.handler.(*defaultHandler)
if !ok {
return fmt.Errorf(
`dbus: export only allowed on the default hander handler have %T"`,
conn.handler)
}
if !path.IsValid() { if !path.IsValid() {
return fmt.Errorf(`dbus: Invalid path name: "%s"`, path) return fmt.Errorf(`dbus: Invalid path name: "%s"`, path)
} }
conn.handlersLck.Lock()
defer conn.handlersLck.Unlock()
// Remove a previous export if the interface is nil // Remove a previous export if the interface is nil
if methods == nil { if v == nil {
return conn.unexport(h, path, iface) if _, ok := conn.handlers[path]; ok {
delete(conn.handlers[path], iface)
if len(conn.handlers[path]) == 0 {
delete(conn.handlers, path)
}
}
return nil
} }
// If this is the first handler for this path, make a new map to hold all // If this is the first handler for this path, make a new map to hold all
// handlers for this path. // handlers for this path.
if !h.PathExists(path) { if _, ok := conn.handlers[path]; !ok {
h.AddObject(path, newExportedObject()) conn.handlers[path] = make(map[string]exportWithMapping)
}
exportedMethods := make(map[string]Method)
for name, method := range methods {
exportedMethods[name] = exportedMethod{method}
} }
// Finally, save this handler // Finally, save this handler
obj := h.objects[path] conn.handlers[path][iface] = exportWithMapping{export: v, mapping: mapping, includeSubtree: includeSubtree}
obj.AddInterface(iface, newExportedIntf(exportedMethods, includeSubtree))
return nil return nil
} }

View File

@ -22,13 +22,6 @@ const (
// FlagNoAutoStart signals that the message bus should not automatically // FlagNoAutoStart signals that the message bus should not automatically
// start an application when handling this message. // start an application when handling this message.
FlagNoAutoStart FlagNoAutoStart
// FlagAllowInteractiveAuthorization may be set on a method call
// message to inform the receiving side that the caller is prepared
// to wait for interactive authorization, which might take a
// considerable time to complete. For instance, if this flag is set,
// it would be appropriate to query the user for passwords or
// confirmation via Polkit or a similar framework.
FlagAllowInteractiveAuthorization
) )
// Type represents the possible types of a D-Bus message. // Type represents the possible types of a D-Bus message.
@ -255,7 +248,7 @@ func (msg *Message) EncodeTo(out io.Writer, order binary.ByteOrder) error {
// IsValid checks whether msg is a valid message and returns an // IsValid checks whether msg is a valid message and returns an
// InvalidMessageError if it is not. // InvalidMessageError if it is not.
func (msg *Message) IsValid() error { func (msg *Message) IsValid() error {
if msg.Flags & ^(FlagNoAutoStart|FlagNoReplyExpected|FlagAllowInteractiveAuthorization) != 0 { if msg.Flags & ^(FlagNoAutoStart|FlagNoReplyExpected) != 0 {
return InvalidMessageError("invalid flags") return InvalidMessageError("invalid flags")
} }
if msg.Type == 0 || msg.Type >= typeMax { if msg.Type == 0 || msg.Type >= typeMax {

View File

@ -27,16 +27,6 @@ func (o *Object) Call(method string, flags Flags, args ...interface{}) *Call {
return <-o.Go(method, flags, make(chan *Call, 1), args...).Done return <-o.Go(method, flags, make(chan *Call, 1), args...).Done
} }
// AddMatchSignal subscribes BusObject to signals from specified interface and
// method (member).
func (o *Object) AddMatchSignal(iface, member string) *Call {
return o.Call(
"org.freedesktop.DBus.AddMatch",
0,
"type='signal',interface='"+iface+"',member='"+member+"'",
)
}
// Go calls a method with the given arguments asynchronously. It returns a // Go calls a method with the given arguments asynchronously. It returns a
// Call structure representing this method call. The passed channel will // Call structure representing this method call. The passed channel will
// return the same value once the call is done. If ch is nil, a new channel // return the same value once the call is done. If ch is nil, a new channel
@ -125,12 +115,12 @@ func (o *Object) GetProperty(p string) (Variant, error) {
return result, nil return result, nil
} }
// Destination returns the destination that calls on (o *Object) are sent to. // Destination returns the destination that calls on o are sent to.
func (o *Object) Destination() string { func (o *Object) Destination() string {
return o.dest return o.dest
} }
// Path returns the path that calls on (o *Object") are sent to. // Path returns the path that calls on o are sent to.
func (o *Object) Path() ObjectPath { func (o *Object) Path() ObjectPath {
return o.path return o.path
} }

View File

@ -1,89 +0,0 @@
package dbus
// Terminator allows a handler to implement a shutdown mechanism that
// is called when the connection terminates.
type Terminator interface {
Terminate()
}
// Handler is the representation of a D-Bus Application.
//
// The Handler must have a way to lookup objects given
// an ObjectPath. The returned object must implement the
// ServerObject interface.
type Handler interface {
LookupObject(path ObjectPath) (ServerObject, bool)
}
// ServerObject is the representation of an D-Bus Object.
//
// Objects are registered at a path for a given Handler.
// The Objects implement D-Bus interfaces. The semantics
// of Interface lookup is up to the implementation of
// the ServerObject. The ServerObject implementation may
// choose to implement empty string as a valid interface
// represeting all methods or not per the D-Bus specification.
type ServerObject interface {
LookupInterface(name string) (Interface, bool)
}
// An Interface is the representation of a D-Bus Interface.
//
// Interfaces are a grouping of methods implemented by the Objects.
// Interfaces are responsible for routing method calls.
type Interface interface {
LookupMethod(name string) (Method, bool)
}
// A Method represents the exposed methods on D-Bus.
type Method interface {
// Call requires that all arguments are decoded before being passed to it.
Call(args ...interface{}) ([]interface{}, error)
NumArguments() int
NumReturns() int
// ArgumentValue returns a representative value for the argument at position
// it should be of the proper type. reflect.Zero would be a good mechanism
// to use for this Value.
ArgumentValue(position int) interface{}
// ReturnValue returns a representative value for the return at position
// it should be of the proper type. reflect.Zero would be a good mechanism
// to use for this Value.
ReturnValue(position int) interface{}
}
// An Argument Decoder can decode arguments using the non-standard mechanism
//
// If a method implements this interface then the non-standard
// decoder will be used.
//
// Method arguments must be decoded from the message.
// The mechanism for doing this will vary based on the
// implementation of the method. A normal approach is provided
// as part of this library, but may be replaced with
// any other decoding scheme.
type ArgumentDecoder interface {
// To decode the arguments of a method the sender and message are
// provided incase the semantics of the implementer provides access
// to these as part of the method invocation.
DecodeArguments(conn *Conn, sender string, msg *Message, args []interface{}) ([]interface{}, error)
}
// A SignalHandler is responsible for delivering a signal.
//
// Signal delivery may be changed from the default channel
// based approach by Handlers implementing the SignalHandler
// interface.
type SignalHandler interface {
DeliverSignal(iface, name string, signal *Signal)
}
// A DBusError is used to convert a generic object to a D-Bus error.
//
// Any custom error mechanism may implement this interface to provide
// a custom encoding of the error on D-Bus. By default if a normal
// error is returned, it will be encoded as the generic
// "org.freedesktop.DBus.Error.Failed" error. By implementing this
// interface as well a custom encoding may be provided.
type DBusError interface {
DBusError() (string, []interface{})
}

View File

@ -57,12 +57,12 @@ func getSignature(t reflect.Type) string {
return "n" return "n"
case reflect.Uint16: case reflect.Uint16:
return "q" return "q"
case reflect.Int, reflect.Int32: case reflect.Int32:
if t == unixFDType { if t == unixFDType {
return "h" return "h"
} }
return "i" return "i"
case reflect.Uint, reflect.Uint32: case reflect.Uint32:
if t == unixFDIndexType { if t == unixFDIndexType {
return "h" return "h"
} }
@ -101,8 +101,6 @@ func getSignature(t reflect.Type) string {
panic(InvalidTypeError{t}) panic(InvalidTypeError{t})
} }
return "a{" + getSignature(t.Key()) + getSignature(t.Elem()) + "}" return "a{" + getSignature(t.Key()) + getSignature(t.Elem()) + "}"
case reflect.Interface:
return "v"
} }
panic(InvalidTypeError{t}) panic(InvalidTypeError{t})
} }
@ -164,7 +162,7 @@ func (e SignatureError) Error() string {
return fmt.Sprintf("dbus: invalid signature: %q (%s)", e.Sig, e.Reason) return fmt.Sprintf("dbus: invalid signature: %q (%s)", e.Sig, e.Reason)
} }
// Try to read a single type from this string. If it was successful, err is nil // Try to read a single type from this string. If it was successfull, err is nil
// and rem is the remaining unparsed part. Otherwise, err is a non-nil // and rem is the remaining unparsed part. Otherwise, err is a non-nil
// SignatureError and rem is "". depth is the current recursion depth which may // SignatureError and rem is "". depth is the current recursion depth which may
// not be greater than 64 and should be given as 0 on the first call. // not be greater than 64 and should be given as 0 on the first call.

View File

@ -4,23 +4,8 @@ import (
"encoding/binary" "encoding/binary"
"errors" "errors"
"io" "io"
"unsafe"
) )
var nativeEndian binary.ByteOrder
func detectEndianness() binary.ByteOrder {
var x uint32 = 0x01020304
if *(*byte)(unsafe.Pointer(&x)) == 0x01 {
return binary.BigEndian
}
return binary.LittleEndian
}
func init() {
nativeEndian = detectEndianness()
}
type genericTransport struct { type genericTransport struct {
io.ReadWriteCloser io.ReadWriteCloser
} }
@ -46,5 +31,5 @@ func (t genericTransport) SendMessage(msg *Message) error {
return errors.New("dbus: unix fd passing not enabled") return errors.New("dbus: unix fd passing not enabled")
} }
} }
return msg.EncodeTo(t, nativeEndian) return msg.EncodeTo(t, binary.LittleEndian)
} }

View File

@ -1,43 +0,0 @@
//+build !windows
package dbus
import (
"errors"
"net"
)
func init() {
transports["tcp"] = newTcpTransport
}
func tcpFamily(keys string) (string, error) {
switch getKey(keys, "family") {
case "":
return "tcp", nil
case "ipv4":
return "tcp4", nil
case "ipv6":
return "tcp6", nil
default:
return "", errors.New("dbus: invalid tcp family (must be ipv4 or ipv6)")
}
}
func newTcpTransport(keys string) (transport, error) {
host := getKey(keys, "host")
port := getKey(keys, "port")
if host == "" || port == "" {
return nil, errors.New("dbus: unsupported address (must set host and port)")
}
protocol, err := tcpFamily(keys)
if err != nil {
return nil, err
}
socket, err := net.Dial(protocol, net.JoinHostPort(host, port))
if err != nil {
return nil, err
}
return NewConn(socket)
}

View File

@ -1,4 +1,4 @@
//+build !windows,!solaris //+build !windows
package dbus package dbus
@ -175,7 +175,7 @@ func (t *unixTransport) SendMessage(msg *Message) error {
msg.Headers[FieldUnixFDs] = MakeVariant(uint32(len(fds))) msg.Headers[FieldUnixFDs] = MakeVariant(uint32(len(fds)))
oob := syscall.UnixRights(fds...) oob := syscall.UnixRights(fds...)
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
msg.EncodeTo(buf, nativeEndian) msg.EncodeTo(buf, binary.LittleEndian)
n, oobn, err := t.UnixConn.WriteMsgUnix(buf.Bytes(), oob, nil) n, oobn, err := t.UnixConn.WriteMsgUnix(buf.Bytes(), oob, nil)
if err != nil { if err != nil {
return err return err
@ -184,7 +184,7 @@ func (t *unixTransport) SendMessage(msg *Message) error {
return io.ErrShortWrite return io.ErrShortWrite
} }
} else { } else {
if err := msg.EncodeTo(t, nativeEndian); err != nil { if err := msg.EncodeTo(t, binary.LittleEndian); err != nil {
return nil return nil
} }
} }

View File

@ -1,91 +0,0 @@
// The UnixCredentials system call is currently only implemented on Linux
// http://golang.org/src/pkg/syscall/sockcmsg_linux.go
// https://golang.org/s/go1.4-syscall
// http://code.google.com/p/go/source/browse/unix/sockcmsg_linux.go?repo=sys
// Local implementation of the UnixCredentials system call for FreeBSD
package dbus
/*
const int sizeofPtr = sizeof(void*);
#define _WANT_UCRED
#include <sys/ucred.h>
*/
import "C"
import (
"io"
"os"
"syscall"
"unsafe"
)
// http://golang.org/src/pkg/syscall/ztypes_linux_amd64.go
// https://golang.org/src/syscall/ztypes_freebsd_amd64.go
type Ucred struct {
Pid int32
Uid uint32
Gid uint32
}
// http://golang.org/src/pkg/syscall/types_linux.go
// https://golang.org/src/syscall/types_freebsd.go
// https://github.com/freebsd/freebsd/blob/master/sys/sys/ucred.h
const (
SizeofUcred = C.sizeof_struct_ucred
)
// http://golang.org/src/pkg/syscall/sockcmsg_unix.go
func cmsgAlignOf(salen int) int {
salign := C.sizeofPtr
return (salen + salign - 1) & ^(salign - 1)
}
// http://golang.org/src/pkg/syscall/sockcmsg_unix.go
func cmsgData(h *syscall.Cmsghdr) unsafe.Pointer {
return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(syscall.SizeofCmsghdr)))
}
// http://golang.org/src/pkg/syscall/sockcmsg_linux.go
// UnixCredentials encodes credentials into a socket control message
// for sending to another process. This can be used for
// authentication.
func UnixCredentials(ucred *Ucred) []byte {
b := make([]byte, syscall.CmsgSpace(SizeofUcred))
h := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
h.Level = syscall.SOL_SOCKET
h.Type = syscall.SCM_CREDS
h.SetLen(syscall.CmsgLen(SizeofUcred))
*((*Ucred)(cmsgData(h))) = *ucred
return b
}
// http://golang.org/src/pkg/syscall/sockcmsg_linux.go
// ParseUnixCredentials decodes a socket control message that contains
// credentials in a Ucred structure. To receive such a message, the
// SO_PASSCRED option must be enabled on the socket.
func ParseUnixCredentials(m *syscall.SocketControlMessage) (*Ucred, error) {
if m.Header.Level != syscall.SOL_SOCKET {
return nil, syscall.EINVAL
}
if m.Header.Type != syscall.SCM_CREDS {
return nil, syscall.EINVAL
}
ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0]))
return &ucred, nil
}
func (t *unixTransport) SendNullByte() error {
ucred := &Ucred{Pid: int32(os.Getpid()), Uid: uint32(os.Getuid()), Gid: uint32(os.Getgid())}
b := UnixCredentials(ucred)
_, oobn, err := t.UnixConn.WriteMsgUnix([]byte{0}, b, nil)
if err != nil {
return err
}
if oobn != len(b) {
return io.ErrShortWrite
}
return nil
}

View File

@ -1,14 +0,0 @@
package dbus
import "io"
func (t *unixTransport) SendNullByte() error {
n, _, err := t.UnixConn.WriteMsgUnix([]byte{0}, nil, nil)
if err != nil {
return err
}
if n != 1 {
return io.ErrShortWrite
}
return nil
}

View File

@ -17,12 +17,7 @@ type Variant struct {
// MakeVariant converts the given value to a Variant. It panics if v cannot be // MakeVariant converts the given value to a Variant. It panics if v cannot be
// represented as a D-Bus type. // represented as a D-Bus type.
func MakeVariant(v interface{}) Variant { func MakeVariant(v interface{}) Variant {
return MakeVariantWithSignature(v, SignatureOf(v)) return Variant{SignatureOf(v), v}
}
// MakeVariantWithSignature converts the given value to a Variant.
func MakeVariantWithSignature(v interface{}, s Signature) Variant {
return Variant{s, v}
} }
// ParseVariant parses the given string as a variant as described at // ParseVariant parses the given string as a variant as described at

View File

@ -1262,7 +1262,6 @@ func Getpgrp() (pid int) {
//sys PivotRoot(newroot string, putold string) (err error) = SYS_PIVOT_ROOT //sys PivotRoot(newroot string, putold string) (err error) = SYS_PIVOT_ROOT
//sysnb prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) = SYS_PRLIMIT64 //sysnb prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) = SYS_PRLIMIT64
//sys Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) //sys Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error)
//sys Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) = SYS_PSELECT6
//sys read(fd int, p []byte) (n int, err error) //sys read(fd int, p []byte) (n int, err error)
//sys Removexattr(path string, attr string) (err error) //sys Removexattr(path string, attr string) (err error)
//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)

View File

@ -21,12 +21,7 @@ package unix
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6
func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
ts := Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000}
return Pselect(nfd, r, w, e, &ts, nil)
}
//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
//sys Setfsgid(gid int) (err error) //sys Setfsgid(gid int) (err error)
//sys Setfsuid(uid int) (err error) //sys Setfsuid(uid int) (err error)

View File

@ -23,12 +23,7 @@ package unix
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6
func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
ts := Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000}
return Pselect(nfd, r, w, e, &ts, nil)
}
//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
//sys Setfsgid(gid int) (err error) //sys Setfsgid(gid int) (err error)
//sys Setfsuid(uid int) (err error) //sys Setfsuid(uid int) (err error)

View File

@ -981,49 +981,6 @@ const (
MAP_STACK = 0x400 MAP_STACK = 0x400
MCL_CURRENT = 0x1 MCL_CURRENT = 0x1
MCL_FUTURE = 0x2 MCL_FUTURE = 0x2
MNT_ACLS = 0x8000000
MNT_ASYNC = 0x40
MNT_AUTOMOUNTED = 0x200000000
MNT_BYFSID = 0x8000000
MNT_CMDFLAGS = 0xd0f0000
MNT_DEFEXPORTED = 0x200
MNT_DELEXPORT = 0x20000
MNT_EXKERB = 0x800
MNT_EXPORTANON = 0x400
MNT_EXPORTED = 0x100
MNT_EXPUBLIC = 0x20000000
MNT_EXRDONLY = 0x80
MNT_FORCE = 0x80000
MNT_GJOURNAL = 0x2000000
MNT_IGNORE = 0x800000
MNT_LAZY = 0x3
MNT_LOCAL = 0x1000
MNT_MULTILABEL = 0x4000000
MNT_NFS4ACLS = 0x10
MNT_NOATIME = 0x10000000
MNT_NOCLUSTERR = 0x40000000
MNT_NOCLUSTERW = 0x80000000
MNT_NOEXEC = 0x4
MNT_NONBUSY = 0x4000000
MNT_NOSUID = 0x8
MNT_NOSYMFOLLOW = 0x400000
MNT_NOWAIT = 0x2
MNT_QUOTA = 0x2000
MNT_RDONLY = 0x1
MNT_RELOAD = 0x40000
MNT_ROOTFS = 0x4000
MNT_SNAPSHOT = 0x1000000
MNT_SOFTDEP = 0x200000
MNT_SUIDDIR = 0x100000
MNT_SUJ = 0x100000000
MNT_SUSPEND = 0x4
MNT_SYNCHRONOUS = 0x2
MNT_UNION = 0x20
MNT_UPDATE = 0x10000
MNT_UPDATEMASK = 0x2d8d0807e
MNT_USER = 0x8000
MNT_VISFLAGMASK = 0x3fef0ffff
MNT_WAIT = 0x1
MSG_CMSG_CLOEXEC = 0x40000 MSG_CMSG_CLOEXEC = 0x40000
MSG_COMPAT = 0x8000 MSG_COMPAT = 0x8000
MSG_CTRUNC = 0x20 MSG_CTRUNC = 0x20

View File

@ -982,49 +982,6 @@ const (
MAP_STACK = 0x400 MAP_STACK = 0x400
MCL_CURRENT = 0x1 MCL_CURRENT = 0x1
MCL_FUTURE = 0x2 MCL_FUTURE = 0x2
MNT_ACLS = 0x8000000
MNT_ASYNC = 0x40
MNT_AUTOMOUNTED = 0x200000000
MNT_BYFSID = 0x8000000
MNT_CMDFLAGS = 0xd0f0000
MNT_DEFEXPORTED = 0x200
MNT_DELEXPORT = 0x20000
MNT_EXKERB = 0x800
MNT_EXPORTANON = 0x400
MNT_EXPORTED = 0x100
MNT_EXPUBLIC = 0x20000000
MNT_EXRDONLY = 0x80
MNT_FORCE = 0x80000
MNT_GJOURNAL = 0x2000000
MNT_IGNORE = 0x800000
MNT_LAZY = 0x3
MNT_LOCAL = 0x1000
MNT_MULTILABEL = 0x4000000
MNT_NFS4ACLS = 0x10
MNT_NOATIME = 0x10000000
MNT_NOCLUSTERR = 0x40000000
MNT_NOCLUSTERW = 0x80000000
MNT_NOEXEC = 0x4
MNT_NONBUSY = 0x4000000
MNT_NOSUID = 0x8
MNT_NOSYMFOLLOW = 0x400000
MNT_NOWAIT = 0x2
MNT_QUOTA = 0x2000
MNT_RDONLY = 0x1
MNT_RELOAD = 0x40000
MNT_ROOTFS = 0x4000
MNT_SNAPSHOT = 0x1000000
MNT_SOFTDEP = 0x200000
MNT_SUIDDIR = 0x100000
MNT_SUJ = 0x100000000
MNT_SUSPEND = 0x4
MNT_SYNCHRONOUS = 0x2
MNT_UNION = 0x20
MNT_UPDATE = 0x10000
MNT_UPDATEMASK = 0x2d8d0807e
MNT_USER = 0x8000
MNT_VISFLAGMASK = 0x3fef0ffff
MNT_WAIT = 0x1
MSG_CMSG_CLOEXEC = 0x40000 MSG_CMSG_CLOEXEC = 0x40000
MSG_COMPAT = 0x8000 MSG_COMPAT = 0x8000
MSG_CTRUNC = 0x20 MSG_CTRUNC = 0x20

View File

@ -989,49 +989,6 @@ const (
MAP_STACK = 0x400 MAP_STACK = 0x400
MCL_CURRENT = 0x1 MCL_CURRENT = 0x1
MCL_FUTURE = 0x2 MCL_FUTURE = 0x2
MNT_ACLS = 0x8000000
MNT_ASYNC = 0x40
MNT_AUTOMOUNTED = 0x200000000
MNT_BYFSID = 0x8000000
MNT_CMDFLAGS = 0xd0f0000
MNT_DEFEXPORTED = 0x200
MNT_DELEXPORT = 0x20000
MNT_EXKERB = 0x800
MNT_EXPORTANON = 0x400
MNT_EXPORTED = 0x100
MNT_EXPUBLIC = 0x20000000
MNT_EXRDONLY = 0x80
MNT_FORCE = 0x80000
MNT_GJOURNAL = 0x2000000
MNT_IGNORE = 0x800000
MNT_LAZY = 0x3
MNT_LOCAL = 0x1000
MNT_MULTILABEL = 0x4000000
MNT_NFS4ACLS = 0x10
MNT_NOATIME = 0x10000000
MNT_NOCLUSTERR = 0x40000000
MNT_NOCLUSTERW = 0x80000000
MNT_NOEXEC = 0x4
MNT_NONBUSY = 0x4000000
MNT_NOSUID = 0x8
MNT_NOSYMFOLLOW = 0x400000
MNT_NOWAIT = 0x2
MNT_QUOTA = 0x2000
MNT_RDONLY = 0x1
MNT_RELOAD = 0x40000
MNT_ROOTFS = 0x4000
MNT_SNAPSHOT = 0x1000000
MNT_SOFTDEP = 0x200000
MNT_SUIDDIR = 0x100000
MNT_SUJ = 0x100000000
MNT_SUSPEND = 0x4
MNT_SYNCHRONOUS = 0x2
MNT_UNION = 0x20
MNT_UPDATE = 0x10000
MNT_UPDATEMASK = 0x2d8d0807e
MNT_USER = 0x8000
MNT_VISFLAGMASK = 0x3fef0ffff
MNT_WAIT = 0x1
MSG_CMSG_CLOEXEC = 0x40000 MSG_CMSG_CLOEXEC = 0x40000
MSG_COMPAT = 0x8000 MSG_COMPAT = 0x8000
MSG_CTRUNC = 0x20 MSG_CTRUNC = 0x20

View File

@ -1035,17 +1035,6 @@ func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) { func read(fd int, p []byte) (n int, err error) {
var _p0 unsafe.Pointer var _p0 unsafe.Pointer
if len(p) > 0 { if len(p) > 0 {

View File

@ -1035,17 +1035,6 @@ func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) { func read(fd int, p []byte) (n int, err error) {
var _p0 unsafe.Pointer var _p0 unsafe.Pointer
if len(p) > 0 { if len(p) > 0 {

View File

@ -1035,17 +1035,6 @@ func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) { func read(fd int, p []byte) (n int, err error) {
var _p0 unsafe.Pointer var _p0 unsafe.Pointer
if len(p) > 0 { if len(p) > 0 {

View File

@ -1035,17 +1035,6 @@ func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) { func read(fd int, p []byte) (n int, err error) {
var _p0 unsafe.Pointer var _p0 unsafe.Pointer
if len(p) > 0 { if len(p) > 0 {
@ -1678,6 +1667,17 @@ func Seek(fd int, offset int64, whence int) (off int64, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
written = int(r0) written = int(r0)

View File

@ -1035,17 +1035,6 @@ func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) { func read(fd int, p []byte) (n int, err error) {
var _p0 unsafe.Pointer var _p0 unsafe.Pointer
if len(p) > 0 { if len(p) > 0 {

View File

@ -1035,17 +1035,6 @@ func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) { func read(fd int, p []byte) (n int, err error) {
var _p0 unsafe.Pointer var _p0 unsafe.Pointer
if len(p) > 0 { if len(p) > 0 {
@ -1688,6 +1677,17 @@ func Seek(fd int, offset int64, whence int) (off int64, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
written = int(r0) written = int(r0)

View File

@ -1035,17 +1035,6 @@ func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) { func read(fd int, p []byte) (n int, err error) {
var _p0 unsafe.Pointer var _p0 unsafe.Pointer
if len(p) > 0 { if len(p) > 0 {
@ -1688,6 +1677,17 @@ func Seek(fd int, offset int64, whence int) (off int64, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
written = int(r0) written = int(r0)

View File

@ -1035,17 +1035,6 @@ func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) { func read(fd int, p []byte) (n int, err error) {
var _p0 unsafe.Pointer var _p0 unsafe.Pointer
if len(p) > 0 { if len(p) > 0 {

View File

@ -1035,17 +1035,6 @@ func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) { func read(fd int, p []byte) (n int, err error) {
var _p0 unsafe.Pointer var _p0 unsafe.Pointer
if len(p) > 0 { if len(p) > 0 {

View File

@ -1035,17 +1035,6 @@ func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) { func read(fd int, p []byte) (n int, err error) {
var _p0 unsafe.Pointer var _p0 unsafe.Pointer
if len(p) > 0 { if len(p) > 0 {

View File

@ -1035,17 +1035,6 @@ func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) { func read(fd int, p []byte) (n int, err error) {
var _p0 unsafe.Pointer var _p0 unsafe.Pointer
if len(p) > 0 { if len(p) > 0 {

View File

@ -1,270 +0,0 @@
// mksysctl_openbsd.pl
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
package unix
type mibentry struct {
ctlname string
ctloid []_C_int
}
var sysctlMib = []mibentry{
{"ddb.console", []_C_int{9, 6}},
{"ddb.log", []_C_int{9, 7}},
{"ddb.max_line", []_C_int{9, 3}},
{"ddb.max_width", []_C_int{9, 2}},
{"ddb.panic", []_C_int{9, 5}},
{"ddb.radix", []_C_int{9, 1}},
{"ddb.tab_stop_width", []_C_int{9, 4}},
{"ddb.trigger", []_C_int{9, 8}},
{"fs.posix.setuid", []_C_int{3, 1, 1}},
{"hw.allowpowerdown", []_C_int{6, 22}},
{"hw.byteorder", []_C_int{6, 4}},
{"hw.cpuspeed", []_C_int{6, 12}},
{"hw.diskcount", []_C_int{6, 10}},
{"hw.disknames", []_C_int{6, 8}},
{"hw.diskstats", []_C_int{6, 9}},
{"hw.machine", []_C_int{6, 1}},
{"hw.model", []_C_int{6, 2}},
{"hw.ncpu", []_C_int{6, 3}},
{"hw.ncpufound", []_C_int{6, 21}},
{"hw.pagesize", []_C_int{6, 7}},
{"hw.physmem", []_C_int{6, 19}},
{"hw.product", []_C_int{6, 15}},
{"hw.serialno", []_C_int{6, 17}},
{"hw.setperf", []_C_int{6, 13}},
{"hw.usermem", []_C_int{6, 20}},
{"hw.uuid", []_C_int{6, 18}},
{"hw.vendor", []_C_int{6, 14}},
{"hw.version", []_C_int{6, 16}},
{"kern.arandom", []_C_int{1, 37}},
{"kern.argmax", []_C_int{1, 8}},
{"kern.boottime", []_C_int{1, 21}},
{"kern.bufcachepercent", []_C_int{1, 72}},
{"kern.ccpu", []_C_int{1, 45}},
{"kern.clockrate", []_C_int{1, 12}},
{"kern.consdev", []_C_int{1, 75}},
{"kern.cp_time", []_C_int{1, 40}},
{"kern.cp_time2", []_C_int{1, 71}},
{"kern.cryptodevallowsoft", []_C_int{1, 53}},
{"kern.domainname", []_C_int{1, 22}},
{"kern.file", []_C_int{1, 73}},
{"kern.forkstat", []_C_int{1, 42}},
{"kern.fscale", []_C_int{1, 46}},
{"kern.fsync", []_C_int{1, 33}},
{"kern.hostid", []_C_int{1, 11}},
{"kern.hostname", []_C_int{1, 10}},
{"kern.intrcnt.nintrcnt", []_C_int{1, 63, 1}},
{"kern.job_control", []_C_int{1, 19}},
{"kern.malloc.buckets", []_C_int{1, 39, 1}},
{"kern.malloc.kmemnames", []_C_int{1, 39, 3}},
{"kern.maxclusters", []_C_int{1, 67}},
{"kern.maxfiles", []_C_int{1, 7}},
{"kern.maxlocksperuid", []_C_int{1, 70}},
{"kern.maxpartitions", []_C_int{1, 23}},
{"kern.maxproc", []_C_int{1, 6}},
{"kern.maxthread", []_C_int{1, 25}},
{"kern.maxvnodes", []_C_int{1, 5}},
{"kern.mbstat", []_C_int{1, 59}},
{"kern.msgbuf", []_C_int{1, 48}},
{"kern.msgbufsize", []_C_int{1, 38}},
{"kern.nchstats", []_C_int{1, 41}},
{"kern.netlivelocks", []_C_int{1, 76}},
{"kern.nfiles", []_C_int{1, 56}},
{"kern.ngroups", []_C_int{1, 18}},
{"kern.nosuidcoredump", []_C_int{1, 32}},
{"kern.nprocs", []_C_int{1, 47}},
{"kern.nselcoll", []_C_int{1, 43}},
{"kern.nthreads", []_C_int{1, 26}},
{"kern.numvnodes", []_C_int{1, 58}},
{"kern.osrelease", []_C_int{1, 2}},
{"kern.osrevision", []_C_int{1, 3}},
{"kern.ostype", []_C_int{1, 1}},
{"kern.osversion", []_C_int{1, 27}},
{"kern.pool_debug", []_C_int{1, 77}},
{"kern.posix1version", []_C_int{1, 17}},
{"kern.proc", []_C_int{1, 66}},
{"kern.random", []_C_int{1, 31}},
{"kern.rawpartition", []_C_int{1, 24}},
{"kern.saved_ids", []_C_int{1, 20}},
{"kern.securelevel", []_C_int{1, 9}},
{"kern.seminfo", []_C_int{1, 61}},
{"kern.shminfo", []_C_int{1, 62}},
{"kern.somaxconn", []_C_int{1, 28}},
{"kern.sominconn", []_C_int{1, 29}},
{"kern.splassert", []_C_int{1, 54}},
{"kern.stackgap_random", []_C_int{1, 50}},
{"kern.sysvipc_info", []_C_int{1, 51}},
{"kern.sysvmsg", []_C_int{1, 34}},
{"kern.sysvsem", []_C_int{1, 35}},
{"kern.sysvshm", []_C_int{1, 36}},
{"kern.timecounter.choice", []_C_int{1, 69, 4}},
{"kern.timecounter.hardware", []_C_int{1, 69, 3}},
{"kern.timecounter.tick", []_C_int{1, 69, 1}},
{"kern.timecounter.timestepwarnings", []_C_int{1, 69, 2}},
{"kern.tty.maxptys", []_C_int{1, 44, 6}},
{"kern.tty.nptys", []_C_int{1, 44, 7}},
{"kern.tty.tk_cancc", []_C_int{1, 44, 4}},
{"kern.tty.tk_nin", []_C_int{1, 44, 1}},
{"kern.tty.tk_nout", []_C_int{1, 44, 2}},
{"kern.tty.tk_rawcc", []_C_int{1, 44, 3}},
{"kern.tty.ttyinfo", []_C_int{1, 44, 5}},
{"kern.ttycount", []_C_int{1, 57}},
{"kern.userasymcrypto", []_C_int{1, 60}},
{"kern.usercrypto", []_C_int{1, 52}},
{"kern.usermount", []_C_int{1, 30}},
{"kern.version", []_C_int{1, 4}},
{"kern.vnode", []_C_int{1, 13}},
{"kern.watchdog.auto", []_C_int{1, 64, 2}},
{"kern.watchdog.period", []_C_int{1, 64, 1}},
{"net.bpf.bufsize", []_C_int{4, 31, 1}},
{"net.bpf.maxbufsize", []_C_int{4, 31, 2}},
{"net.inet.ah.enable", []_C_int{4, 2, 51, 1}},
{"net.inet.ah.stats", []_C_int{4, 2, 51, 2}},
{"net.inet.carp.allow", []_C_int{4, 2, 112, 1}},
{"net.inet.carp.log", []_C_int{4, 2, 112, 3}},
{"net.inet.carp.preempt", []_C_int{4, 2, 112, 2}},
{"net.inet.carp.stats", []_C_int{4, 2, 112, 4}},
{"net.inet.divert.recvspace", []_C_int{4, 2, 258, 1}},
{"net.inet.divert.sendspace", []_C_int{4, 2, 258, 2}},
{"net.inet.divert.stats", []_C_int{4, 2, 258, 3}},
{"net.inet.esp.enable", []_C_int{4, 2, 50, 1}},
{"net.inet.esp.stats", []_C_int{4, 2, 50, 4}},
{"net.inet.esp.udpencap", []_C_int{4, 2, 50, 2}},
{"net.inet.esp.udpencap_port", []_C_int{4, 2, 50, 3}},
{"net.inet.etherip.allow", []_C_int{4, 2, 97, 1}},
{"net.inet.etherip.stats", []_C_int{4, 2, 97, 2}},
{"net.inet.gre.allow", []_C_int{4, 2, 47, 1}},
{"net.inet.gre.wccp", []_C_int{4, 2, 47, 2}},
{"net.inet.icmp.bmcastecho", []_C_int{4, 2, 1, 2}},
{"net.inet.icmp.errppslimit", []_C_int{4, 2, 1, 3}},
{"net.inet.icmp.maskrepl", []_C_int{4, 2, 1, 1}},
{"net.inet.icmp.rediraccept", []_C_int{4, 2, 1, 4}},
{"net.inet.icmp.redirtimeout", []_C_int{4, 2, 1, 5}},
{"net.inet.icmp.stats", []_C_int{4, 2, 1, 7}},
{"net.inet.icmp.tstamprepl", []_C_int{4, 2, 1, 6}},
{"net.inet.igmp.stats", []_C_int{4, 2, 2, 1}},
{"net.inet.ip.arpqueued", []_C_int{4, 2, 0, 36}},
{"net.inet.ip.encdebug", []_C_int{4, 2, 0, 12}},
{"net.inet.ip.forwarding", []_C_int{4, 2, 0, 1}},
{"net.inet.ip.ifq.congestion", []_C_int{4, 2, 0, 30, 4}},
{"net.inet.ip.ifq.drops", []_C_int{4, 2, 0, 30, 3}},
{"net.inet.ip.ifq.len", []_C_int{4, 2, 0, 30, 1}},
{"net.inet.ip.ifq.maxlen", []_C_int{4, 2, 0, 30, 2}},
{"net.inet.ip.maxqueue", []_C_int{4, 2, 0, 11}},
{"net.inet.ip.mforwarding", []_C_int{4, 2, 0, 31}},
{"net.inet.ip.mrtproto", []_C_int{4, 2, 0, 34}},
{"net.inet.ip.mrtstats", []_C_int{4, 2, 0, 35}},
{"net.inet.ip.mtu", []_C_int{4, 2, 0, 4}},
{"net.inet.ip.mtudisc", []_C_int{4, 2, 0, 27}},
{"net.inet.ip.mtudisctimeout", []_C_int{4, 2, 0, 28}},
{"net.inet.ip.multipath", []_C_int{4, 2, 0, 32}},
{"net.inet.ip.portfirst", []_C_int{4, 2, 0, 7}},
{"net.inet.ip.porthifirst", []_C_int{4, 2, 0, 9}},
{"net.inet.ip.porthilast", []_C_int{4, 2, 0, 10}},
{"net.inet.ip.portlast", []_C_int{4, 2, 0, 8}},
{"net.inet.ip.redirect", []_C_int{4, 2, 0, 2}},
{"net.inet.ip.sourceroute", []_C_int{4, 2, 0, 5}},
{"net.inet.ip.stats", []_C_int{4, 2, 0, 33}},
{"net.inet.ip.ttl", []_C_int{4, 2, 0, 3}},
{"net.inet.ipcomp.enable", []_C_int{4, 2, 108, 1}},
{"net.inet.ipcomp.stats", []_C_int{4, 2, 108, 2}},
{"net.inet.ipip.allow", []_C_int{4, 2, 4, 1}},
{"net.inet.ipip.stats", []_C_int{4, 2, 4, 2}},
{"net.inet.mobileip.allow", []_C_int{4, 2, 55, 1}},
{"net.inet.pfsync.stats", []_C_int{4, 2, 240, 1}},
{"net.inet.pim.stats", []_C_int{4, 2, 103, 1}},
{"net.inet.tcp.ackonpush", []_C_int{4, 2, 6, 13}},
{"net.inet.tcp.always_keepalive", []_C_int{4, 2, 6, 22}},
{"net.inet.tcp.baddynamic", []_C_int{4, 2, 6, 6}},
{"net.inet.tcp.drop", []_C_int{4, 2, 6, 19}},
{"net.inet.tcp.ecn", []_C_int{4, 2, 6, 14}},
{"net.inet.tcp.ident", []_C_int{4, 2, 6, 9}},
{"net.inet.tcp.keepidle", []_C_int{4, 2, 6, 3}},
{"net.inet.tcp.keepinittime", []_C_int{4, 2, 6, 2}},
{"net.inet.tcp.keepintvl", []_C_int{4, 2, 6, 4}},
{"net.inet.tcp.mssdflt", []_C_int{4, 2, 6, 11}},
{"net.inet.tcp.reasslimit", []_C_int{4, 2, 6, 18}},
{"net.inet.tcp.rfc1323", []_C_int{4, 2, 6, 1}},
{"net.inet.tcp.rfc3390", []_C_int{4, 2, 6, 17}},
{"net.inet.tcp.rstppslimit", []_C_int{4, 2, 6, 12}},
{"net.inet.tcp.sack", []_C_int{4, 2, 6, 10}},
{"net.inet.tcp.sackholelimit", []_C_int{4, 2, 6, 20}},
{"net.inet.tcp.slowhz", []_C_int{4, 2, 6, 5}},
{"net.inet.tcp.stats", []_C_int{4, 2, 6, 21}},
{"net.inet.tcp.synbucketlimit", []_C_int{4, 2, 6, 16}},
{"net.inet.tcp.syncachelimit", []_C_int{4, 2, 6, 15}},
{"net.inet.udp.baddynamic", []_C_int{4, 2, 17, 2}},
{"net.inet.udp.checksum", []_C_int{4, 2, 17, 1}},
{"net.inet.udp.recvspace", []_C_int{4, 2, 17, 3}},
{"net.inet.udp.sendspace", []_C_int{4, 2, 17, 4}},
{"net.inet.udp.stats", []_C_int{4, 2, 17, 5}},
{"net.inet6.divert.recvspace", []_C_int{4, 24, 86, 1}},
{"net.inet6.divert.sendspace", []_C_int{4, 24, 86, 2}},
{"net.inet6.divert.stats", []_C_int{4, 24, 86, 3}},
{"net.inet6.icmp6.errppslimit", []_C_int{4, 24, 30, 14}},
{"net.inet6.icmp6.mtudisc_hiwat", []_C_int{4, 24, 30, 16}},
{"net.inet6.icmp6.mtudisc_lowat", []_C_int{4, 24, 30, 17}},
{"net.inet6.icmp6.nd6_debug", []_C_int{4, 24, 30, 18}},
{"net.inet6.icmp6.nd6_delay", []_C_int{4, 24, 30, 8}},
{"net.inet6.icmp6.nd6_maxnudhint", []_C_int{4, 24, 30, 15}},
{"net.inet6.icmp6.nd6_mmaxtries", []_C_int{4, 24, 30, 10}},
{"net.inet6.icmp6.nd6_prune", []_C_int{4, 24, 30, 6}},
{"net.inet6.icmp6.nd6_umaxtries", []_C_int{4, 24, 30, 9}},
{"net.inet6.icmp6.nd6_useloopback", []_C_int{4, 24, 30, 11}},
{"net.inet6.icmp6.nodeinfo", []_C_int{4, 24, 30, 13}},
{"net.inet6.icmp6.rediraccept", []_C_int{4, 24, 30, 2}},
{"net.inet6.icmp6.redirtimeout", []_C_int{4, 24, 30, 3}},
{"net.inet6.ip6.accept_rtadv", []_C_int{4, 24, 17, 12}},
{"net.inet6.ip6.auto_flowlabel", []_C_int{4, 24, 17, 17}},
{"net.inet6.ip6.dad_count", []_C_int{4, 24, 17, 16}},
{"net.inet6.ip6.dad_pending", []_C_int{4, 24, 17, 49}},
{"net.inet6.ip6.defmcasthlim", []_C_int{4, 24, 17, 18}},
{"net.inet6.ip6.forwarding", []_C_int{4, 24, 17, 1}},
{"net.inet6.ip6.forwsrcrt", []_C_int{4, 24, 17, 5}},
{"net.inet6.ip6.hdrnestlimit", []_C_int{4, 24, 17, 15}},
{"net.inet6.ip6.hlim", []_C_int{4, 24, 17, 3}},
{"net.inet6.ip6.log_interval", []_C_int{4, 24, 17, 14}},
{"net.inet6.ip6.maxdynroutes", []_C_int{4, 24, 17, 48}},
{"net.inet6.ip6.maxfragpackets", []_C_int{4, 24, 17, 9}},
{"net.inet6.ip6.maxfrags", []_C_int{4, 24, 17, 41}},
{"net.inet6.ip6.maxifdefrouters", []_C_int{4, 24, 17, 47}},
{"net.inet6.ip6.maxifprefixes", []_C_int{4, 24, 17, 46}},
{"net.inet6.ip6.mforwarding", []_C_int{4, 24, 17, 42}},
{"net.inet6.ip6.mrtproto", []_C_int{4, 24, 17, 8}},
{"net.inet6.ip6.mtudisctimeout", []_C_int{4, 24, 17, 50}},
{"net.inet6.ip6.multicast_mtudisc", []_C_int{4, 24, 17, 44}},
{"net.inet6.ip6.multipath", []_C_int{4, 24, 17, 43}},
{"net.inet6.ip6.neighborgcthresh", []_C_int{4, 24, 17, 45}},
{"net.inet6.ip6.redirect", []_C_int{4, 24, 17, 2}},
{"net.inet6.ip6.rr_prune", []_C_int{4, 24, 17, 22}},
{"net.inet6.ip6.sourcecheck", []_C_int{4, 24, 17, 10}},
{"net.inet6.ip6.sourcecheck_logint", []_C_int{4, 24, 17, 11}},
{"net.inet6.ip6.use_deprecated", []_C_int{4, 24, 17, 21}},
{"net.inet6.ip6.v6only", []_C_int{4, 24, 17, 24}},
{"net.key.sadb_dump", []_C_int{4, 30, 1}},
{"net.key.spd_dump", []_C_int{4, 30, 2}},
{"net.mpls.ifq.congestion", []_C_int{4, 33, 3, 4}},
{"net.mpls.ifq.drops", []_C_int{4, 33, 3, 3}},
{"net.mpls.ifq.len", []_C_int{4, 33, 3, 1}},
{"net.mpls.ifq.maxlen", []_C_int{4, 33, 3, 2}},
{"net.mpls.mapttl_ip", []_C_int{4, 33, 5}},
{"net.mpls.mapttl_ip6", []_C_int{4, 33, 6}},
{"net.mpls.maxloop_inkernel", []_C_int{4, 33, 4}},
{"net.mpls.ttl", []_C_int{4, 33, 2}},
{"net.pflow.stats", []_C_int{4, 34, 1}},
{"net.pipex.enable", []_C_int{4, 35, 1}},
{"vm.anonmin", []_C_int{2, 7}},
{"vm.loadavg", []_C_int{2, 2}},
{"vm.maxslp", []_C_int{2, 10}},
{"vm.nkmempages", []_C_int{2, 6}},
{"vm.psstrings", []_C_int{2, 3}},
{"vm.swapencrypt.enable", []_C_int{2, 5, 0}},
{"vm.swapencrypt.keyscreated", []_C_int{2, 5, 1}},
{"vm.swapencrypt.keysdeleted", []_C_int{2, 5, 2}},
{"vm.uspace", []_C_int{2, 11}},
{"vm.uvmexp", []_C_int{2, 4}},
{"vm.vmmeter", []_C_int{2, 1}},
{"vm.vnodemin", []_C_int{2, 9}},
{"vm.vtextmin", []_C_int{2, 8}},
}

View File

@ -1,270 +0,0 @@
// mksysctl_openbsd.pl
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
package unix
type mibentry struct {
ctlname string
ctloid []_C_int
}
var sysctlMib = []mibentry{
{"ddb.console", []_C_int{9, 6}},
{"ddb.log", []_C_int{9, 7}},
{"ddb.max_line", []_C_int{9, 3}},
{"ddb.max_width", []_C_int{9, 2}},
{"ddb.panic", []_C_int{9, 5}},
{"ddb.radix", []_C_int{9, 1}},
{"ddb.tab_stop_width", []_C_int{9, 4}},
{"ddb.trigger", []_C_int{9, 8}},
{"fs.posix.setuid", []_C_int{3, 1, 1}},
{"hw.allowpowerdown", []_C_int{6, 22}},
{"hw.byteorder", []_C_int{6, 4}},
{"hw.cpuspeed", []_C_int{6, 12}},
{"hw.diskcount", []_C_int{6, 10}},
{"hw.disknames", []_C_int{6, 8}},
{"hw.diskstats", []_C_int{6, 9}},
{"hw.machine", []_C_int{6, 1}},
{"hw.model", []_C_int{6, 2}},
{"hw.ncpu", []_C_int{6, 3}},
{"hw.ncpufound", []_C_int{6, 21}},
{"hw.pagesize", []_C_int{6, 7}},
{"hw.physmem", []_C_int{6, 19}},
{"hw.product", []_C_int{6, 15}},
{"hw.serialno", []_C_int{6, 17}},
{"hw.setperf", []_C_int{6, 13}},
{"hw.usermem", []_C_int{6, 20}},
{"hw.uuid", []_C_int{6, 18}},
{"hw.vendor", []_C_int{6, 14}},
{"hw.version", []_C_int{6, 16}},
{"kern.arandom", []_C_int{1, 37}},
{"kern.argmax", []_C_int{1, 8}},
{"kern.boottime", []_C_int{1, 21}},
{"kern.bufcachepercent", []_C_int{1, 72}},
{"kern.ccpu", []_C_int{1, 45}},
{"kern.clockrate", []_C_int{1, 12}},
{"kern.consdev", []_C_int{1, 75}},
{"kern.cp_time", []_C_int{1, 40}},
{"kern.cp_time2", []_C_int{1, 71}},
{"kern.cryptodevallowsoft", []_C_int{1, 53}},
{"kern.domainname", []_C_int{1, 22}},
{"kern.file", []_C_int{1, 73}},
{"kern.forkstat", []_C_int{1, 42}},
{"kern.fscale", []_C_int{1, 46}},
{"kern.fsync", []_C_int{1, 33}},
{"kern.hostid", []_C_int{1, 11}},
{"kern.hostname", []_C_int{1, 10}},
{"kern.intrcnt.nintrcnt", []_C_int{1, 63, 1}},
{"kern.job_control", []_C_int{1, 19}},
{"kern.malloc.buckets", []_C_int{1, 39, 1}},
{"kern.malloc.kmemnames", []_C_int{1, 39, 3}},
{"kern.maxclusters", []_C_int{1, 67}},
{"kern.maxfiles", []_C_int{1, 7}},
{"kern.maxlocksperuid", []_C_int{1, 70}},
{"kern.maxpartitions", []_C_int{1, 23}},
{"kern.maxproc", []_C_int{1, 6}},
{"kern.maxthread", []_C_int{1, 25}},
{"kern.maxvnodes", []_C_int{1, 5}},
{"kern.mbstat", []_C_int{1, 59}},
{"kern.msgbuf", []_C_int{1, 48}},
{"kern.msgbufsize", []_C_int{1, 38}},
{"kern.nchstats", []_C_int{1, 41}},
{"kern.netlivelocks", []_C_int{1, 76}},
{"kern.nfiles", []_C_int{1, 56}},
{"kern.ngroups", []_C_int{1, 18}},
{"kern.nosuidcoredump", []_C_int{1, 32}},
{"kern.nprocs", []_C_int{1, 47}},
{"kern.nselcoll", []_C_int{1, 43}},
{"kern.nthreads", []_C_int{1, 26}},
{"kern.numvnodes", []_C_int{1, 58}},
{"kern.osrelease", []_C_int{1, 2}},
{"kern.osrevision", []_C_int{1, 3}},
{"kern.ostype", []_C_int{1, 1}},
{"kern.osversion", []_C_int{1, 27}},
{"kern.pool_debug", []_C_int{1, 77}},
{"kern.posix1version", []_C_int{1, 17}},
{"kern.proc", []_C_int{1, 66}},
{"kern.random", []_C_int{1, 31}},
{"kern.rawpartition", []_C_int{1, 24}},
{"kern.saved_ids", []_C_int{1, 20}},
{"kern.securelevel", []_C_int{1, 9}},
{"kern.seminfo", []_C_int{1, 61}},
{"kern.shminfo", []_C_int{1, 62}},
{"kern.somaxconn", []_C_int{1, 28}},
{"kern.sominconn", []_C_int{1, 29}},
{"kern.splassert", []_C_int{1, 54}},
{"kern.stackgap_random", []_C_int{1, 50}},
{"kern.sysvipc_info", []_C_int{1, 51}},
{"kern.sysvmsg", []_C_int{1, 34}},
{"kern.sysvsem", []_C_int{1, 35}},
{"kern.sysvshm", []_C_int{1, 36}},
{"kern.timecounter.choice", []_C_int{1, 69, 4}},
{"kern.timecounter.hardware", []_C_int{1, 69, 3}},
{"kern.timecounter.tick", []_C_int{1, 69, 1}},
{"kern.timecounter.timestepwarnings", []_C_int{1, 69, 2}},
{"kern.tty.maxptys", []_C_int{1, 44, 6}},
{"kern.tty.nptys", []_C_int{1, 44, 7}},
{"kern.tty.tk_cancc", []_C_int{1, 44, 4}},
{"kern.tty.tk_nin", []_C_int{1, 44, 1}},
{"kern.tty.tk_nout", []_C_int{1, 44, 2}},
{"kern.tty.tk_rawcc", []_C_int{1, 44, 3}},
{"kern.tty.ttyinfo", []_C_int{1, 44, 5}},
{"kern.ttycount", []_C_int{1, 57}},
{"kern.userasymcrypto", []_C_int{1, 60}},
{"kern.usercrypto", []_C_int{1, 52}},
{"kern.usermount", []_C_int{1, 30}},
{"kern.version", []_C_int{1, 4}},
{"kern.vnode", []_C_int{1, 13}},
{"kern.watchdog.auto", []_C_int{1, 64, 2}},
{"kern.watchdog.period", []_C_int{1, 64, 1}},
{"net.bpf.bufsize", []_C_int{4, 31, 1}},
{"net.bpf.maxbufsize", []_C_int{4, 31, 2}},
{"net.inet.ah.enable", []_C_int{4, 2, 51, 1}},
{"net.inet.ah.stats", []_C_int{4, 2, 51, 2}},
{"net.inet.carp.allow", []_C_int{4, 2, 112, 1}},
{"net.inet.carp.log", []_C_int{4, 2, 112, 3}},
{"net.inet.carp.preempt", []_C_int{4, 2, 112, 2}},
{"net.inet.carp.stats", []_C_int{4, 2, 112, 4}},
{"net.inet.divert.recvspace", []_C_int{4, 2, 258, 1}},
{"net.inet.divert.sendspace", []_C_int{4, 2, 258, 2}},
{"net.inet.divert.stats", []_C_int{4, 2, 258, 3}},
{"net.inet.esp.enable", []_C_int{4, 2, 50, 1}},
{"net.inet.esp.stats", []_C_int{4, 2, 50, 4}},
{"net.inet.esp.udpencap", []_C_int{4, 2, 50, 2}},
{"net.inet.esp.udpencap_port", []_C_int{4, 2, 50, 3}},
{"net.inet.etherip.allow", []_C_int{4, 2, 97, 1}},
{"net.inet.etherip.stats", []_C_int{4, 2, 97, 2}},
{"net.inet.gre.allow", []_C_int{4, 2, 47, 1}},
{"net.inet.gre.wccp", []_C_int{4, 2, 47, 2}},
{"net.inet.icmp.bmcastecho", []_C_int{4, 2, 1, 2}},
{"net.inet.icmp.errppslimit", []_C_int{4, 2, 1, 3}},
{"net.inet.icmp.maskrepl", []_C_int{4, 2, 1, 1}},
{"net.inet.icmp.rediraccept", []_C_int{4, 2, 1, 4}},
{"net.inet.icmp.redirtimeout", []_C_int{4, 2, 1, 5}},
{"net.inet.icmp.stats", []_C_int{4, 2, 1, 7}},
{"net.inet.icmp.tstamprepl", []_C_int{4, 2, 1, 6}},
{"net.inet.igmp.stats", []_C_int{4, 2, 2, 1}},
{"net.inet.ip.arpqueued", []_C_int{4, 2, 0, 36}},
{"net.inet.ip.encdebug", []_C_int{4, 2, 0, 12}},
{"net.inet.ip.forwarding", []_C_int{4, 2, 0, 1}},
{"net.inet.ip.ifq.congestion", []_C_int{4, 2, 0, 30, 4}},
{"net.inet.ip.ifq.drops", []_C_int{4, 2, 0, 30, 3}},
{"net.inet.ip.ifq.len", []_C_int{4, 2, 0, 30, 1}},
{"net.inet.ip.ifq.maxlen", []_C_int{4, 2, 0, 30, 2}},
{"net.inet.ip.maxqueue", []_C_int{4, 2, 0, 11}},
{"net.inet.ip.mforwarding", []_C_int{4, 2, 0, 31}},
{"net.inet.ip.mrtproto", []_C_int{4, 2, 0, 34}},
{"net.inet.ip.mrtstats", []_C_int{4, 2, 0, 35}},
{"net.inet.ip.mtu", []_C_int{4, 2, 0, 4}},
{"net.inet.ip.mtudisc", []_C_int{4, 2, 0, 27}},
{"net.inet.ip.mtudisctimeout", []_C_int{4, 2, 0, 28}},
{"net.inet.ip.multipath", []_C_int{4, 2, 0, 32}},
{"net.inet.ip.portfirst", []_C_int{4, 2, 0, 7}},
{"net.inet.ip.porthifirst", []_C_int{4, 2, 0, 9}},
{"net.inet.ip.porthilast", []_C_int{4, 2, 0, 10}},
{"net.inet.ip.portlast", []_C_int{4, 2, 0, 8}},
{"net.inet.ip.redirect", []_C_int{4, 2, 0, 2}},
{"net.inet.ip.sourceroute", []_C_int{4, 2, 0, 5}},
{"net.inet.ip.stats", []_C_int{4, 2, 0, 33}},
{"net.inet.ip.ttl", []_C_int{4, 2, 0, 3}},
{"net.inet.ipcomp.enable", []_C_int{4, 2, 108, 1}},
{"net.inet.ipcomp.stats", []_C_int{4, 2, 108, 2}},
{"net.inet.ipip.allow", []_C_int{4, 2, 4, 1}},
{"net.inet.ipip.stats", []_C_int{4, 2, 4, 2}},
{"net.inet.mobileip.allow", []_C_int{4, 2, 55, 1}},
{"net.inet.pfsync.stats", []_C_int{4, 2, 240, 1}},
{"net.inet.pim.stats", []_C_int{4, 2, 103, 1}},
{"net.inet.tcp.ackonpush", []_C_int{4, 2, 6, 13}},
{"net.inet.tcp.always_keepalive", []_C_int{4, 2, 6, 22}},
{"net.inet.tcp.baddynamic", []_C_int{4, 2, 6, 6}},
{"net.inet.tcp.drop", []_C_int{4, 2, 6, 19}},
{"net.inet.tcp.ecn", []_C_int{4, 2, 6, 14}},
{"net.inet.tcp.ident", []_C_int{4, 2, 6, 9}},
{"net.inet.tcp.keepidle", []_C_int{4, 2, 6, 3}},
{"net.inet.tcp.keepinittime", []_C_int{4, 2, 6, 2}},
{"net.inet.tcp.keepintvl", []_C_int{4, 2, 6, 4}},
{"net.inet.tcp.mssdflt", []_C_int{4, 2, 6, 11}},
{"net.inet.tcp.reasslimit", []_C_int{4, 2, 6, 18}},
{"net.inet.tcp.rfc1323", []_C_int{4, 2, 6, 1}},
{"net.inet.tcp.rfc3390", []_C_int{4, 2, 6, 17}},
{"net.inet.tcp.rstppslimit", []_C_int{4, 2, 6, 12}},
{"net.inet.tcp.sack", []_C_int{4, 2, 6, 10}},
{"net.inet.tcp.sackholelimit", []_C_int{4, 2, 6, 20}},
{"net.inet.tcp.slowhz", []_C_int{4, 2, 6, 5}},
{"net.inet.tcp.stats", []_C_int{4, 2, 6, 21}},
{"net.inet.tcp.synbucketlimit", []_C_int{4, 2, 6, 16}},
{"net.inet.tcp.syncachelimit", []_C_int{4, 2, 6, 15}},
{"net.inet.udp.baddynamic", []_C_int{4, 2, 17, 2}},
{"net.inet.udp.checksum", []_C_int{4, 2, 17, 1}},
{"net.inet.udp.recvspace", []_C_int{4, 2, 17, 3}},
{"net.inet.udp.sendspace", []_C_int{4, 2, 17, 4}},
{"net.inet.udp.stats", []_C_int{4, 2, 17, 5}},
{"net.inet6.divert.recvspace", []_C_int{4, 24, 86, 1}},
{"net.inet6.divert.sendspace", []_C_int{4, 24, 86, 2}},
{"net.inet6.divert.stats", []_C_int{4, 24, 86, 3}},
{"net.inet6.icmp6.errppslimit", []_C_int{4, 24, 30, 14}},
{"net.inet6.icmp6.mtudisc_hiwat", []_C_int{4, 24, 30, 16}},
{"net.inet6.icmp6.mtudisc_lowat", []_C_int{4, 24, 30, 17}},
{"net.inet6.icmp6.nd6_debug", []_C_int{4, 24, 30, 18}},
{"net.inet6.icmp6.nd6_delay", []_C_int{4, 24, 30, 8}},
{"net.inet6.icmp6.nd6_maxnudhint", []_C_int{4, 24, 30, 15}},
{"net.inet6.icmp6.nd6_mmaxtries", []_C_int{4, 24, 30, 10}},
{"net.inet6.icmp6.nd6_prune", []_C_int{4, 24, 30, 6}},
{"net.inet6.icmp6.nd6_umaxtries", []_C_int{4, 24, 30, 9}},
{"net.inet6.icmp6.nd6_useloopback", []_C_int{4, 24, 30, 11}},
{"net.inet6.icmp6.nodeinfo", []_C_int{4, 24, 30, 13}},
{"net.inet6.icmp6.rediraccept", []_C_int{4, 24, 30, 2}},
{"net.inet6.icmp6.redirtimeout", []_C_int{4, 24, 30, 3}},
{"net.inet6.ip6.accept_rtadv", []_C_int{4, 24, 17, 12}},
{"net.inet6.ip6.auto_flowlabel", []_C_int{4, 24, 17, 17}},
{"net.inet6.ip6.dad_count", []_C_int{4, 24, 17, 16}},
{"net.inet6.ip6.dad_pending", []_C_int{4, 24, 17, 49}},
{"net.inet6.ip6.defmcasthlim", []_C_int{4, 24, 17, 18}},
{"net.inet6.ip6.forwarding", []_C_int{4, 24, 17, 1}},
{"net.inet6.ip6.forwsrcrt", []_C_int{4, 24, 17, 5}},
{"net.inet6.ip6.hdrnestlimit", []_C_int{4, 24, 17, 15}},
{"net.inet6.ip6.hlim", []_C_int{4, 24, 17, 3}},
{"net.inet6.ip6.log_interval", []_C_int{4, 24, 17, 14}},
{"net.inet6.ip6.maxdynroutes", []_C_int{4, 24, 17, 48}},
{"net.inet6.ip6.maxfragpackets", []_C_int{4, 24, 17, 9}},
{"net.inet6.ip6.maxfrags", []_C_int{4, 24, 17, 41}},
{"net.inet6.ip6.maxifdefrouters", []_C_int{4, 24, 17, 47}},
{"net.inet6.ip6.maxifprefixes", []_C_int{4, 24, 17, 46}},
{"net.inet6.ip6.mforwarding", []_C_int{4, 24, 17, 42}},
{"net.inet6.ip6.mrtproto", []_C_int{4, 24, 17, 8}},
{"net.inet6.ip6.mtudisctimeout", []_C_int{4, 24, 17, 50}},
{"net.inet6.ip6.multicast_mtudisc", []_C_int{4, 24, 17, 44}},
{"net.inet6.ip6.multipath", []_C_int{4, 24, 17, 43}},
{"net.inet6.ip6.neighborgcthresh", []_C_int{4, 24, 17, 45}},
{"net.inet6.ip6.redirect", []_C_int{4, 24, 17, 2}},
{"net.inet6.ip6.rr_prune", []_C_int{4, 24, 17, 22}},
{"net.inet6.ip6.sourcecheck", []_C_int{4, 24, 17, 10}},
{"net.inet6.ip6.sourcecheck_logint", []_C_int{4, 24, 17, 11}},
{"net.inet6.ip6.use_deprecated", []_C_int{4, 24, 17, 21}},
{"net.inet6.ip6.v6only", []_C_int{4, 24, 17, 24}},
{"net.key.sadb_dump", []_C_int{4, 30, 1}},
{"net.key.spd_dump", []_C_int{4, 30, 2}},
{"net.mpls.ifq.congestion", []_C_int{4, 33, 3, 4}},
{"net.mpls.ifq.drops", []_C_int{4, 33, 3, 3}},
{"net.mpls.ifq.len", []_C_int{4, 33, 3, 1}},
{"net.mpls.ifq.maxlen", []_C_int{4, 33, 3, 2}},
{"net.mpls.mapttl_ip", []_C_int{4, 33, 5}},
{"net.mpls.mapttl_ip6", []_C_int{4, 33, 6}},
{"net.mpls.maxloop_inkernel", []_C_int{4, 33, 4}},
{"net.mpls.ttl", []_C_int{4, 33, 2}},
{"net.pflow.stats", []_C_int{4, 34, 1}},
{"net.pipex.enable", []_C_int{4, 35, 1}},
{"vm.anonmin", []_C_int{2, 7}},
{"vm.loadavg", []_C_int{2, 2}},
{"vm.maxslp", []_C_int{2, 10}},
{"vm.nkmempages", []_C_int{2, 6}},
{"vm.psstrings", []_C_int{2, 3}},
{"vm.swapencrypt.enable", []_C_int{2, 5, 0}},
{"vm.swapencrypt.keyscreated", []_C_int{2, 5, 1}},
{"vm.swapencrypt.keysdeleted", []_C_int{2, 5, 2}},
{"vm.uspace", []_C_int{2, 11}},
{"vm.uvmexp", []_C_int{2, 4}},
{"vm.vmmeter", []_C_int{2, 1}},
{"vm.vnodemin", []_C_int{2, 9}},
{"vm.vtextmin", []_C_int{2, 8}},
}

View File

@ -202,21 +202,6 @@ func NewCallbackCDecl(fn interface{}) uintptr {
// syscall interface implementation for other packages // syscall interface implementation for other packages
// GetProcAddressByOrdinal retrieves the address of the exported
// function from module by ordinal.
func GetProcAddressByOrdinal(module Handle, ordinal uintptr) (proc uintptr, err error) {
r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), ordinal, 0)
proc = uintptr(r0)
if proc == 0 {
if e1 != 0 {
err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
}
return
}
func Exit(code int) { ExitProcess(uint32(code)) } func Exit(code int) { ExitProcess(uint32(code)) }
func makeInheritSa() *SecurityAttributes { func makeInheritSa() *SecurityAttributes {