rebase: Make use of latest go ceph library

The go-ceph version 0.4.0 is available now which got some important
library changes required for ceph csi project.

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal 2020-06-17 15:07:06 +05:30 committed by mergify[bot]
parent 306d5b1da0
commit 58bf45a13e
67 changed files with 1133 additions and 362 deletions

4
go.mod
View File

@ -3,7 +3,7 @@ module github.com/ceph/ceph-csi
go 1.13 go 1.13
require ( require (
github.com/ceph/go-ceph v0.3.0 github.com/ceph/go-ceph v0.4.0
github.com/container-storage-interface/spec v1.2.0 github.com/container-storage-interface/spec v1.2.0
github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
@ -24,7 +24,7 @@ require (
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/sys v0.0.0-20200409092240-59c9f1ba88fa golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
google.golang.org/appengine v1.6.5 // indirect google.golang.org/appengine v1.6.5 // indirect
google.golang.org/genproto v0.0.0-20200413115906-b5235f65be36 // indirect google.golang.org/genproto v0.0.0-20200413115906-b5235f65be36 // indirect

11
go.sum
View File

@ -62,8 +62,8 @@ github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBT
github.com/caddyserver/caddy v1.0.3/go.mod h1:G+ouvOY32gENkJC+jhgl62TyhvqEsFaDiZ4uw0RzP1E= github.com/caddyserver/caddy v1.0.3/go.mod h1:G+ouvOY32gENkJC+jhgl62TyhvqEsFaDiZ4uw0RzP1E=
github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/ceph/go-ceph v0.3.0 h1:DBAQTu2GGznczfoiwaRroPttiZe10J8SaHdH3v/0lIE= github.com/ceph/go-ceph v0.4.0 h1:KJsT6j1IbsEtui3ZtDcZO//uZ+IVBNT6KO7u9PuMovE=
github.com/ceph/go-ceph v0.3.0/go.mod h1:6gzI3dc/5hfl98DIK25fQ0iFSdyCRjVEFTuCoGwvjEY= github.com/ceph/go-ceph v0.4.0/go.mod h1:wd+keAOqrcsN//20VQnHBGtnBnY0KHl0PA024Ng8HfQ=
github.com/cespare/prettybench v0.0.0-20150116022406-03b8cfe5406c/go.mod h1:Xe6ZsFhtM8HrDku0pxJ3/Lr51rwykrzgFwpmTzleatY= github.com/cespare/prettybench v0.0.0-20150116022406-03b8cfe5406c/go.mod h1:Xe6ZsFhtM8HrDku0pxJ3/Lr51rwykrzgFwpmTzleatY=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
@ -235,6 +235,7 @@ github.com/golang/mock v1.2.0 h1:28o5sBqPkBsMGnC6b4MvE2TzSr5/AT4c/1fLqVGIwlk=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s= github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/golang/mock v1.4.3 h1:GV+pQPG/EUUbkh47niozDcADz6go/dUwhVzdUQHIVRw=
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@ -321,7 +322,6 @@ github.com/heketi/tests v0.0.0-20151005000721-f3775cbcefd6/go.mod h1:xGMAM8JLi7U
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg= github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg=
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
@ -361,7 +361,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kubernetes-csi/csi-lib-utils v0.7.0 h1:t1cS7HTD7z5D7h9iAdjWuHtMxJPb9s1fIv34rxytzqs= github.com/kubernetes-csi/csi-lib-utils v0.7.0 h1:t1cS7HTD7z5D7h9iAdjWuHtMxJPb9s1fIv34rxytzqs=
github.com/kubernetes-csi/csi-lib-utils v0.7.0/go.mod h1:bze+2G9+cmoHxN6+WyG1qT4MDxgZJMLGwc7V4acPNm0= github.com/kubernetes-csi/csi-lib-utils v0.7.0/go.mod h1:bze+2G9+cmoHxN6+WyG1qT4MDxgZJMLGwc7V4acPNm0=
github.com/kubernetes-csi/csi-test v2.0.0+incompatible/go.mod h1:YxJ4UiuPWIhMBkxUKY5c267DyA0uDZ/MtAimhx/2TA0= github.com/kubernetes-csi/csi-test v2.0.0+incompatible/go.mod h1:YxJ4UiuPWIhMBkxUKY5c267DyA0uDZ/MtAimhx/2TA0=
github.com/kubernetes-csi/external-snapshotter v1.2.1-0.20200106204216-fd8d8a33ddb5 h1:DbKgICiVkUrp+j3+cIBDNUf1fpeb/SeFR5AM2gd+dzU=
github.com/kubernetes-csi/external-snapshotter/v2 v2.1.1-0.20200504125226-859696c419ff h1:uDoiqoGc5oF+dkV80zIz56Nkn70V2WeH+hSpVeci36g= github.com/kubernetes-csi/external-snapshotter/v2 v2.1.1-0.20200504125226-859696c419ff h1:uDoiqoGc5oF+dkV80zIz56Nkn70V2WeH+hSpVeci36g=
github.com/kubernetes-csi/external-snapshotter/v2 v2.1.1-0.20200504125226-859696c419ff/go.mod h1:gozodYSVrG83vojQOd8N2LruDu5Z+piDsIDPtmIuKgg= github.com/kubernetes-csi/external-snapshotter/v2 v2.1.1-0.20200504125226-859696c419ff/go.mod h1:gozodYSVrG83vojQOd8N2LruDu5Z+piDsIDPtmIuKgg=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
@ -684,8 +683,8 @@ golang.org/x/sys v0.0.0-20200122134326-e047566fdf82 h1:ywK/j/KkyTHcdyYSZNXGjMwgm
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200409092240-59c9f1ba88fa h1:mQTN3ECqfsViCNBgq+A40vdwhkGykrrQlYe3mPj6BoU= golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 h1:5B6i6EAiSYyejWfvc5Rc9BbI3rzIsrrXfAQBWnYfn+w=
golang.org/x/sys v0.0.0-20200409092240-59c9f1ba88fa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.0.0-20170915090833-1cbadb444a80/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915090833-1cbadb444a80/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@ -0,0 +1,62 @@
package cutil
/*
#include <stdlib.h>
*/
import "C"
import (
"unsafe"
)
// CommandInput can be used to manage the input to ceph's *_command functions.
type CommandInput struct {
cmd []*C.char
inbuf []byte
}
// NewCommandInput creates C-level pointers from go byte buffers suitable
// for passing off to ceph's *_command functions.
func NewCommandInput(cmd [][]byte, inputBuffer []byte) *CommandInput {
ci := &CommandInput{
cmd: make([]*C.char, len(cmd)),
inbuf: inputBuffer,
}
for i := range cmd {
ci.cmd[i] = C.CString(string(cmd[i]))
}
return ci
}
// Free any C memory managed by this CommandInput.
func (ci *CommandInput) Free() {
for i := range ci.cmd {
C.free(unsafe.Pointer(ci.cmd[i]))
}
ci.cmd = nil
}
// Cmd returns an unsafe wrapper around an array of C-strings.
func (ci *CommandInput) Cmd() CharPtrPtr {
ptr := &ci.cmd[0]
return CharPtrPtr(ptr)
}
// CmdLen returns the length of the array of C-strings returned by
// Cmd.
func (ci *CommandInput) CmdLen() SizeT {
return SizeT(len(ci.cmd))
}
// InBuf returns an unsafe wrapper to a C char*.
func (ci *CommandInput) InBuf() CharPtr {
if len(ci.inbuf) == 0 {
return nil
}
return CharPtr(&ci.inbuf[0])
}
// InBufLen returns the length of the buffer returned by InBuf.
func (ci *CommandInput) InBufLen() SizeT {
return SizeT(len(ci.inbuf))
}

View File

@ -0,0 +1,100 @@
package cutil
/*
#include <stdlib.h>
*/
import "C"
import (
"unsafe"
)
// CommandOutput can be used to manage the outputs of ceph's *_command
// functions.
type CommandOutput struct {
free FreeFunc
outBuf *C.char
outBufLen C.size_t
outs *C.char
outsLen C.size_t
}
// NewCommandOutput returns an empty CommandOutput. The pointers that
// a CommandOutput provides can be used to get the results of ceph's
// *_command functions.
func NewCommandOutput() *CommandOutput {
return &CommandOutput{
free: free,
}
}
// SetFreeFunc sets the function used to free memory held by CommandOutput.
// Not all uses of CommandOutput expect to use the basic C.free function
// and either require or prefer the use of a custom deallocation function.
// Use SetFreeFunc to change the free function and return the modified
// CommandOutput object.
func (co *CommandOutput) SetFreeFunc(f FreeFunc) *CommandOutput {
co.free = f
return co
}
// Free any C memory tracked by this object.
func (co *CommandOutput) Free() {
if co.outBuf != nil {
co.free(unsafe.Pointer(co.outBuf))
}
if co.outs != nil {
co.free(unsafe.Pointer(co.outs))
}
}
// OutBuf returns an unsafe wrapper around a pointer to a `char*`.
func (co *CommandOutput) OutBuf() CharPtrPtr {
return CharPtrPtr(&co.outBuf)
}
// OutBufLen returns an unsafe wrapper around a pointer to a size_t.
func (co *CommandOutput) OutBufLen() SizeTPtr {
return SizeTPtr(&co.outBufLen)
}
// Outs returns an unsafe wrapper around a pointer to a `char*`.
func (co *CommandOutput) Outs() CharPtrPtr {
return CharPtrPtr(&co.outs)
}
// OutsLen returns an unsafe wrapper around a pointer to a size_t.
func (co *CommandOutput) OutsLen() SizeTPtr {
return SizeTPtr(&co.outsLen)
}
// GoValues returns native go values converted from the internal C-language
// values tracked by this object.
func (co *CommandOutput) GoValues() (buf []byte, status string) {
if co.outBufLen > 0 {
buf = C.GoBytes(unsafe.Pointer(co.outBuf), C.int(co.outBufLen))
}
if co.outsLen > 0 {
status = C.GoStringN(co.outs, C.int(co.outsLen))
}
return buf, status
}
// testSetString is only used by the unit tests for this file.
// It is located here due to the restriction on having import "C" in
// go test files. :-(
// It mimics a C function that takes a pointer to a
// string and length and allocates memory and sets the pointers
// to the new string and its length.
func testSetString(strp CharPtrPtr, lenp SizeTPtr, s string) {
sp := (**C.char)(strp)
lp := (*C.size_t)(lenp)
*sp = C.CString(s)
*lp = C.size_t(len(s))
}
// free wraps C.free.
// Required for unit tests that may not use cgo directly.
func free(p unsafe.Pointer) {
C.free(p)
}

View File

@ -0,0 +1,28 @@
package cutil
import "C"
import (
"unsafe"
)
// Basic types from C that we can make "public" without too much fuss.
// SizeT wraps size_t from C.
type SizeT C.size_t
// This section contains a bunch of types that are basically just
// unsafe.Pointer but have specific types to help "self document" what the
// underlying pointer is really meant to represent.
// CharPtrPtr is an unsafe pointer wrapping C's `char**`.
type CharPtrPtr unsafe.Pointer
// CharPtr is an unsafe pointer wrapping C's `char*`.
type CharPtr unsafe.Pointer
// SizeTPtr is an unsafe pointer wrapping C's `size_t*`.
type SizeTPtr unsafe.Pointer
// FreeFunc is a wrapper around calls to, or act like, C's free function.
type FreeFunc func(unsafe.Pointer)

64
vendor/github.com/ceph/go-ceph/internal/retry/sizer.go generated vendored Normal file
View File

@ -0,0 +1,64 @@
package retry
// Hint is a type for retry hints
type Hint interface {
If(bool) Hint
size() int
}
type hintInt int
func (hint hintInt) size() int {
return int(hint)
}
// If is a convenience function, that returns a given hint only if a certain
// condition is met (for example a test for a "buffer too small" error).
// Otherwise it returns a nil which stops the retries.
func (hint hintInt) If(cond bool) Hint {
if cond {
return hint
}
return nil
}
// DoubleSize is a hint to retry with double the size
const DoubleSize = hintInt(0)
// Size returns a hint for a specific size
func Size(s int) Hint {
return hintInt(s)
}
// SizeFunc is used to implement 'resize loops' that hides the complexity of the
// sizing away from most of the application. It's a function that takes a size
// argument and returns nil, if no retry is necessary, or a hint indicating the
// size for the next retry. If errors or other results are required from the
// function, the function can write them to function closures of the surrounding
// scope. See tests for examples.
type SizeFunc func(size int) (hint Hint)
// WithSizes repeatingly calls a SizeFunc with increasing sizes until either it
// returns nil, or the max size has been reached. If the returned hint is
// DoubleSize or indicating a size not greater than the current size, the size
// is doubled. If the hint or next size is greater than the max size, the max
// size is used for a last retry.
func WithSizes(size int, max int, f SizeFunc) {
if size > max {
return
}
for {
hint := f(size)
if hint == nil || size == max {
break
}
if hint.size() > size {
size = hint.size()
} else {
size *= 2
}
if size > max {
size = max
}
}
}

193
vendor/github.com/ceph/go-ceph/rados/command.go generated vendored Normal file
View File

@ -0,0 +1,193 @@
package rados
// #cgo LDFLAGS: -lrados
// #include <stdlib.h>
// #include <rados/librados.h>
import "C"
import (
"unsafe"
"github.com/ceph/go-ceph/internal/cutil"
)
func radosBufferFree(p unsafe.Pointer) {
C.rados_buffer_free((*C.char)(p))
}
// MonCommand sends a command to one of the monitors
func (c *Conn) MonCommand(args []byte) ([]byte, string, error) {
return c.MonCommandWithInputBuffer(args, nil)
}
// MonCommandWithInputBuffer sends a command to one of the monitors, with an input buffer
func (c *Conn) MonCommandWithInputBuffer(args, inputBuffer []byte) ([]byte, string, error) {
ci := cutil.NewCommandInput([][]byte{args}, inputBuffer)
defer ci.Free()
co := cutil.NewCommandOutput().SetFreeFunc(radosBufferFree)
defer co.Free()
ret := C.rados_mon_command(
c.cluster,
(**C.char)(ci.Cmd()),
C.size_t(ci.CmdLen()),
(*C.char)(ci.InBuf()),
C.size_t(ci.InBufLen()),
(**C.char)(co.OutBuf()),
(*C.size_t)(co.OutBufLen()),
(**C.char)(co.Outs()),
(*C.size_t)(co.OutsLen()))
buf, status := co.GoValues()
return buf, status, getError(ret)
}
// PGCommand sends a command to one of the PGs
//
// Implements:
// int rados_pg_command(rados_t cluster, const char *pgstr,
// const char **cmd, size_t cmdlen,
// const char *inbuf, size_t inbuflen,
// char **outbuf, size_t *outbuflen,
// char **outs, size_t *outslen);
func (c *Conn) PGCommand(pgid []byte, args [][]byte) ([]byte, string, error) {
return c.PGCommandWithInputBuffer(pgid, args, nil)
}
// PGCommandWithInputBuffer sends a command to one of the PGs, with an input buffer
//
// Implements:
// int rados_pg_command(rados_t cluster, const char *pgstr,
// const char **cmd, size_t cmdlen,
// const char *inbuf, size_t inbuflen,
// char **outbuf, size_t *outbuflen,
// char **outs, size_t *outslen);
func (c *Conn) PGCommandWithInputBuffer(pgid []byte, args [][]byte, inputBuffer []byte) ([]byte, string, error) {
name := C.CString(string(pgid))
defer C.free(unsafe.Pointer(name))
ci := cutil.NewCommandInput(args, inputBuffer)
defer ci.Free()
co := cutil.NewCommandOutput().SetFreeFunc(radosBufferFree)
defer co.Free()
ret := C.rados_pg_command(
c.cluster,
name,
(**C.char)(ci.Cmd()),
C.size_t(ci.CmdLen()),
(*C.char)(ci.InBuf()),
C.size_t(ci.InBufLen()),
(**C.char)(co.OutBuf()),
(*C.size_t)(co.OutBufLen()),
(**C.char)(co.Outs()),
(*C.size_t)(co.OutsLen()))
buf, status := co.GoValues()
return buf, status, getError(ret)
}
// MgrCommand sends a command to a ceph-mgr.
func (c *Conn) MgrCommand(args [][]byte) ([]byte, string, error) {
return c.MgrCommandWithInputBuffer(args, nil)
}
// MgrCommandWithInputBuffer sends a command, with an input buffer, to a ceph-mgr.
//
// Implements:
// int rados_mgr_command(rados_t cluster, const char **cmd,
// size_t cmdlen, const char *inbuf,
// size_t inbuflen, char **outbuf,
// size_t *outbuflen, char **outs,
// size_t *outslen);
func (c *Conn) MgrCommandWithInputBuffer(args [][]byte, inputBuffer []byte) ([]byte, string, error) {
ci := cutil.NewCommandInput(args, inputBuffer)
defer ci.Free()
co := cutil.NewCommandOutput().SetFreeFunc(radosBufferFree)
defer co.Free()
ret := C.rados_mgr_command(
c.cluster,
(**C.char)(ci.Cmd()),
C.size_t(ci.CmdLen()),
(*C.char)(ci.InBuf()),
C.size_t(ci.InBufLen()),
(**C.char)(co.OutBuf()),
(*C.size_t)(co.OutBufLen()),
(**C.char)(co.Outs()),
(*C.size_t)(co.OutsLen()))
buf, status := co.GoValues()
return buf, status, getError(ret)
}
// OsdCommand sends a command to the specified ceph OSD.
func (c *Conn) OsdCommand(osd int, args [][]byte) ([]byte, string, error) {
return c.OsdCommandWithInputBuffer(osd, args, nil)
}
// OsdCommandWithInputBuffer sends a command, with an input buffer, to the
// specified ceph OSD.
//
// Implements:
// int rados_osd_command(rados_t cluster, int osdid,
// const char **cmd, size_t cmdlen,
// const char *inbuf, size_t inbuflen,
// char **outbuf, size_t *outbuflen,
// char **outs, size_t *outslen);
func (c *Conn) OsdCommandWithInputBuffer(
osd int, args [][]byte, inputBuffer []byte) ([]byte, string, error) {
ci := cutil.NewCommandInput(args, inputBuffer)
defer ci.Free()
co := cutil.NewCommandOutput().SetFreeFunc(radosBufferFree)
defer co.Free()
ret := C.rados_osd_command(
c.cluster,
C.int(osd),
(**C.char)(ci.Cmd()),
C.size_t(ci.CmdLen()),
(*C.char)(ci.InBuf()),
C.size_t(ci.InBufLen()),
(**C.char)(co.OutBuf()),
(*C.size_t)(co.OutBufLen()),
(**C.char)(co.Outs()),
(*C.size_t)(co.OutsLen()))
buf, status := co.GoValues()
return buf, status, getError(ret)
}
// MonCommandTarget sends a command to a specified monitor.
func (c *Conn) MonCommandTarget(name string, args [][]byte) ([]byte, string, error) {
return c.MonCommandTargetWithInputBuffer(name, args, nil)
}
// MonCommandTargetWithInputBuffer sends a command, with an input buffer, to a specified monitor.
//
// Implements:
// int rados_mon_command_target(rados_t cluster, const char *name,
// const char **cmd, size_t cmdlen,
// const char *inbuf, size_t inbuflen,
// char **outbuf, size_t *outbuflen,
// char **outs, size_t *outslen);
func (c *Conn) MonCommandTargetWithInputBuffer(
name string, args [][]byte, inputBuffer []byte) ([]byte, string, error) {
cName := C.CString(name)
defer C.free(unsafe.Pointer(cName))
ci := cutil.NewCommandInput(args, inputBuffer)
defer ci.Free()
co := cutil.NewCommandOutput().SetFreeFunc(radosBufferFree)
defer co.Free()
ret := C.rados_mon_command_target(
c.cluster,
cName,
(**C.char)(ci.Cmd()),
C.size_t(ci.CmdLen()),
(*C.char)(ci.InBuf()),
C.size_t(ci.InBufLen()),
(**C.char)(co.OutBuf()),
(*C.size_t)(co.OutBufLen()),
(**C.char)(co.Outs()),
(*C.size_t)(co.OutsLen()))
buf, status := co.GoValues()
return buf, status, getError(ret)
}

View File

@ -8,6 +8,8 @@ import "C"
import ( import (
"bytes" "bytes"
"unsafe" "unsafe"
"github.com/ceph/go-ceph/internal/retry"
) )
// ClusterStat represents Ceph cluster statistics. // ClusterStat represents Ceph cluster statistics.
@ -140,19 +142,26 @@ func (c *Conn) SetConfigOption(option, value string) error {
// GetConfigOption returns the value of the Ceph configuration option // GetConfigOption returns the value of the Ceph configuration option
// identified by the given name. // identified by the given name.
func (c *Conn) GetConfigOption(name string) (value string, err error) { func (c *Conn) GetConfigOption(name string) (value string, err error) {
buf := make([]byte, 4096) cOption := C.CString(name)
c_name := C.CString(name) defer C.free(unsafe.Pointer(cOption))
defer C.free(unsafe.Pointer(c_name))
ret := int(C.rados_conf_get(c.cluster, c_name, var buf []byte
(*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)))) // range from 4k to 256KiB
// FIXME: ret may be -ENAMETOOLONG if the buffer is not large enough. We retry.WithSizes(4096, 1<<18, func(size int) retry.Hint {
// can handle this case, but we need a reliable way to test for buf = make([]byte, size)
// -ENAMETOOLONG constant. Will the syscall/Errno stuff in Go help? ret := C.rados_conf_get(
if ret == 0 { c.cluster,
cOption,
(*C.char)(unsafe.Pointer(&buf[0])),
C.size_t(len(buf)))
err = getError(ret)
return retry.DoubleSize.If(err == errNameTooLong)
})
if err != nil {
return "", err
}
value = C.GoString((*C.char)(unsafe.Pointer(&buf[0]))) value = C.GoString((*C.char)(unsafe.Pointer(&buf[0])))
return value, nil return value, nil
}
return "", RadosError(ret)
} }
// WaitForLatestOSDMap blocks the caller until the latest OSD map has been // WaitForLatestOSDMap blocks the caller until the latest OSD map has been
@ -282,121 +291,3 @@ func (c *Conn) GetPoolByID(id int64) (string, error) {
} }
return C.GoString((*C.char)(unsafe.Pointer(&buf[0]))), nil return C.GoString((*C.char)(unsafe.Pointer(&buf[0]))), nil
} }
// MonCommand sends a command to one of the monitors
func (c *Conn) MonCommand(args []byte) (buffer []byte, info string, err error) {
return c.monCommand(args, nil)
}
// MonCommandWithInputBuffer sends a command to one of the monitors, with an input buffer
func (c *Conn) MonCommandWithInputBuffer(args, inputBuffer []byte) (buffer []byte, info string, err error) {
return c.monCommand(args, inputBuffer)
}
func (c *Conn) monCommand(args, inputBuffer []byte) (buffer []byte, info string, err error) {
argv := C.CString(string(args))
defer C.free(unsafe.Pointer(argv))
var (
outs, outbuf *C.char
outslen, outbuflen C.size_t
)
inbuf := C.CString(string(inputBuffer))
inbufLen := len(inputBuffer)
defer C.free(unsafe.Pointer(inbuf))
ret := C.rados_mon_command(c.cluster,
&argv, 1,
inbuf, // bulk input (e.g. crush map)
C.size_t(inbufLen), // length inbuf
&outbuf, // buffer
&outbuflen, // buffer length
&outs, // status string
&outslen)
if outslen > 0 {
info = C.GoStringN(outs, C.int(outslen))
C.free(unsafe.Pointer(outs))
}
if outbuflen > 0 {
buffer = C.GoBytes(unsafe.Pointer(outbuf), C.int(outbuflen))
C.free(unsafe.Pointer(outbuf))
}
if ret != 0 {
err = getError(ret)
return nil, info, err
}
return
}
// PGCommand sends a command to one of the PGs
//
// Implements:
// int rados_pg_command(rados_t cluster, const char *pgstr,
// const char **cmd, size_t cmdlen,
// const char *inbuf, size_t inbuflen,
// char **outbuf, size_t *outbuflen,
// char **outs, size_t *outslen);
func (c *Conn) PGCommand(pgid []byte, args [][]byte) (buffer []byte, info string, err error) {
return c.pgCommand(pgid, args, nil)
}
// PGCommandWithInputBuffer sends a command to one of the PGs, with an input buffer
//
// Implements:
// int rados_pg_command(rados_t cluster, const char *pgstr,
// const char **cmd, size_t cmdlen,
// const char *inbuf, size_t inbuflen,
// char **outbuf, size_t *outbuflen,
// char **outs, size_t *outslen);
func (c *Conn) PGCommandWithInputBuffer(pgid []byte, args [][]byte, inputBuffer []byte) (buffer []byte, info string, err error) {
return c.pgCommand(pgid, args, inputBuffer)
}
func (c *Conn) pgCommand(pgid []byte, args [][]byte, inputBuffer []byte) (buffer []byte, info string, err error) {
name := C.CString(string(pgid))
defer C.free(unsafe.Pointer(name))
argc := len(args)
argv := make([]*C.char, argc)
for i, arg := range args {
argv[i] = C.CString(string(arg))
defer C.free(unsafe.Pointer(argv[i]))
}
var (
outs, outbuf *C.char
outslen, outbuflen C.size_t
)
inbuf := C.CString(string(inputBuffer))
inbufLen := len(inputBuffer)
defer C.free(unsafe.Pointer(inbuf))
ret := C.rados_pg_command(c.cluster,
name,
&argv[0],
C.size_t(argc),
inbuf, // bulk input
C.size_t(inbufLen), // length inbuf
&outbuf, // buffer
&outbuflen, // buffer length
&outs, // status string
&outslen)
if outslen > 0 {
info = C.GoStringN(outs, C.int(outslen))
C.free(unsafe.Pointer(outs))
}
if outbuflen > 0 {
buffer = C.GoBytes(unsafe.Pointer(outbuf), C.int(outbuflen))
C.free(unsafe.Pointer(outbuf))
}
if ret != 0 {
err = getError(ret)
return nil, info, err
}
return
}

View File

@ -35,6 +35,16 @@ func getError(e C.int) error {
return RadosError(e) return RadosError(e)
} }
// getErrorIfNegative converts a ceph return code to error if negative.
// This is useful for functions that return a usable positive value on
// success but a negative error number on error.
func getErrorIfNegative(ret C.int) error {
if ret >= 0 {
return nil
}
return getError(ret)
}
// Public go errors: // Public go errors:
var ( var (
@ -61,3 +71,11 @@ const (
// Deprecated: use ErrPermissionDenied instead // Deprecated: use ErrPermissionDenied instead
RadosErrorPermissionDenied = ErrPermissionDenied RadosErrorPermissionDenied = ErrPermissionDenied
) )
// Private errors:
const (
errNameTooLong = RadosError(-C.ENAMETOOLONG)
errRange = RadosError(-C.ERANGE)
)

View File

@ -28,6 +28,8 @@ import (
"syscall" "syscall"
"time" "time"
"unsafe" "unsafe"
"github.com/ceph/go-ceph/internal/retry"
) )
// CreateOption is passed to IOContext.Create() and should be one of // CreateOption is passed to IOContext.Create() and should be one of
@ -249,19 +251,24 @@ func (ioctx *IOContext) GetPoolStats() (stat PoolStat, err error) {
// GetPoolName returns the name of the pool associated with the I/O context. // GetPoolName returns the name of the pool associated with the I/O context.
func (ioctx *IOContext) GetPoolName() (name string, err error) { func (ioctx *IOContext) GetPoolName() (name string, err error) {
buf := make([]byte, 128) var (
for { buf []byte
ret := C.rados_ioctx_get_pool_name(ioctx.ioctx, ret C.int
(*C.char)(unsafe.Pointer(&buf[0])), C.unsigned(len(buf))) )
if ret == -C.ERANGE { retry.WithSizes(128, 8192, func(size int) retry.Hint {
buf = make([]byte, len(buf)*2) buf = make([]byte, size)
continue ret = C.rados_ioctx_get_pool_name(
} else if ret < 0 { ioctx.ioctx,
return "", getError(ret) (*C.char)(unsafe.Pointer(&buf[0])),
C.unsigned(len(buf)))
err = getErrorIfNegative(ret)
return retry.DoubleSize.If(err == errRange)
})
if err != nil {
return "", err
} }
name = C.GoStringN((*C.char)(unsafe.Pointer(&buf[0])), ret) name = C.GoStringN((*C.char)(unsafe.Pointer(&buf[0])), ret)
return name, nil return name, nil
}
} }
// ObjectListFunc is the type of the function called for each object visited // ObjectListFunc is the type of the function called for each object visited

View File

@ -37,26 +37,47 @@ func getError(err C.int) error {
return nil return nil
} }
// getErrorIfNegative converts a ceph return code to error if negative.
// This is useful for functions that return a usable positive value on
// success but a negative error number on error.
func getErrorIfNegative(ret C.int) error {
if ret >= 0 {
return nil
}
return getError(ret)
}
// Public go errors: // Public go errors:
var ( var (
// ErrNoIOContext may be returned if an api call requires an IOContext and // ErrNoIOContext may be returned if an api call requires an IOContext and
// it is not provided. // it is not provided.
ErrNoIOContext = errors.New("RBD image does not have an IOContext") ErrNoIOContext = errors.New("IOContext is missing")
// ErrNoName may be returned if an api call requires a name and it is // ErrNoName may be returned if an api call requires a name and it is
// not provided. // not provided.
ErrNoName = errors.New("RBD image does not have a name") ErrNoName = errors.New("RBD image does not have a name")
// ErrSnapshotNoName may be returned if an aip call requires a snapshot // ErrSnapshotNoName may be returned if an api call requires a snapshot
// name and it is not provided. // name and it is not provided.
ErrSnapshotNoName = errors.New("RBD snapshot does not have a name") ErrSnapshotNoName = errors.New("RBD snapshot does not have a name")
// ErrImageNotOpen may be returnened if an api call requires an open image handle and one is not provided. // ErrImageNotOpen may be returned if an api call requires an open image handle and one is not provided.
ErrImageNotOpen = errors.New("RBD image not open") ErrImageNotOpen = errors.New("RBD image not open")
// ErrImageIsOpen may be returned if an api call requires a closed image handle and one is not provided.
ErrImageIsOpen = errors.New("RBD image is open")
// ErrNotFound may be returned from an api call when the requested item is // ErrNotFound may be returned from an api call when the requested item is
// missing. // missing.
ErrNotFound = errors.New("RBD image not found") ErrNotFound = errors.New("RBD image not found")
// ErrNoNamespaceName maye be returned if an api call requires a namespace
// name and it is not provided.
ErrNoNamespaceName = errors.New("Namespace value is missing")
// revive:disable:exported for compatibility with old versions // revive:disable:exported for compatibility with old versions
RbdErrorImageNotOpen = ErrImageNotOpen RbdErrorImageNotOpen = ErrImageNotOpen
RbdErrorNotFound = ErrNotFound RbdErrorNotFound = ErrNotFound
// revive:enable:exported // revive:enable:exported
) )
// Private errors:
const (
errRange = RBDError(-C.ERANGE)
)

View File

@ -102,7 +102,7 @@ const (
// revive:enable:exported // revive:enable:exported
) )
// FeatureSet is a combination of the bit value for multiple featurs. // FeatureSet is a combination of the bit value for multiple features.
type FeatureSet uint64 type FeatureSet uint64
var ( var (

View File

@ -0,0 +1,111 @@
// +build !luminous,!mimic
//
// Ceph Nautilus is the first release that includes rbd_namespace_create(),
// rbd_namespace_remove(), rbd_namespace_exists() and rbd_namespace_list().
package rbd
// #cgo LDFLAGS: -lrbd
// #include <rados/librados.h>
// #include <rbd/librbd.h>
// #include <stdlib.h>
// #include <errno.h>
import "C"
import (
"bytes"
"unsafe"
"github.com/ceph/go-ceph/internal/retry"
"github.com/ceph/go-ceph/rados"
)
// NamespaceCreate creates the namespace for a given Rados IOContext.
//
// Implements:
// int rbd_namespace_create(rados_ioctx_t io, const char *namespace_name);
func NamespaceCreate(ioctx *rados.IOContext, namespaceName string) error {
if ioctx == nil {
return ErrNoIOContext
}
if namespaceName == "" {
return ErrNoNamespaceName
}
cNamespaceName := C.CString(namespaceName)
defer C.free(unsafe.Pointer(cNamespaceName))
ret := C.rbd_namespace_create(cephIoctx(ioctx), cNamespaceName)
return getError(ret)
}
// NamespaceRemove removes a given namespace.
//
// Implements:
// int rbd_namespace_remove(rados_ioctx_t io, const char *namespace_name);
func NamespaceRemove(ioctx *rados.IOContext, namespaceName string) error {
if ioctx == nil {
return ErrNoIOContext
}
if namespaceName == "" {
return ErrNoNamespaceName
}
cNamespaceName := C.CString(namespaceName)
defer C.free(unsafe.Pointer(cNamespaceName))
ret := C.rbd_namespace_remove(cephIoctx(ioctx), cNamespaceName)
return getError(ret)
}
// NamespaceExists checks whether a given namespace exists or not.
//
// Implements:
// int rbd_namespace_exists(rados_ioctx_t io, const char *namespace_name, bool *exists);
func NamespaceExists(ioctx *rados.IOContext, namespaceName string) (bool, error) {
if ioctx == nil {
return false, ErrNoIOContext
}
if namespaceName == "" {
return false, ErrNoNamespaceName
}
cNamespaceName := C.CString(namespaceName)
defer C.free(unsafe.Pointer(cNamespaceName))
var exists C.bool
ret := C.rbd_namespace_exists(cephIoctx(ioctx), cNamespaceName, &exists)
return bool(exists), getErrorIfNegative(ret)
}
// NamespaceList returns a slice containing the names of existing rbd namespaces.
//
// Implements:
// int rbd_namespace_list(rados_ioctx_t io, char *namespace_names, size_t *size);
func NamespaceList(ioctx *rados.IOContext) (names []string, err error) {
if ioctx == nil {
return nil, ErrNoIOContext
}
var (
buf []byte
cSize C.size_t
)
retry.WithSizes(4096, 262144, func(size int) retry.Hint {
cSize = C.size_t(size)
buf = make([]byte, cSize)
ret := C.rbd_namespace_list(cephIoctx(ioctx),
(*C.char)(unsafe.Pointer(&buf[0])),
&cSize)
err = getErrorIfNegative(ret)
return retry.Size(int(cSize)).If(err == errRange)
})
if err != nil {
return nil, err
}
tmpList := bytes.Split(buf[:cSize-1], []byte{0})
for _, s := range tmpList {
if len(s) > 0 {
name := C.GoString((*C.char)(unsafe.Pointer(&s[0])))
names = append(names, name)
}
}
return names, nil
}

View File

@ -69,9 +69,6 @@ const (
RbdImageOptionFeaturesClear = ImageOptionFeaturesClear RbdImageOptionFeaturesClear = ImageOptionFeaturesClear
// RbdImageOptionDataPool deprecated alias for ImageOptionDataPool // RbdImageOptionDataPool deprecated alias for ImageOptionDataPool
RbdImageOptionDataPool = ImageOptionDataPool RbdImageOptionDataPool = ImageOptionDataPool
// introduced with Ceph Mimic
//RbdImageOptionFlatten = C.RBD_IMAGE_OPTION_FLATTEN
) )
// ImageOptions represents a group of configurable image options. // ImageOptions represents a group of configurable image options.

12
vendor/github.com/ceph/go-ceph/rbd/options_mimic.go generated vendored Normal file
View File

@ -0,0 +1,12 @@
// +build !luminous
package rbd
// #include <rbd/librbd.h>
import "C"
const (
// ImageOptionFlatten is the representation of RBD_IMAGE_OPTION_FLATTEN
// from librbd
ImageOptionFlatten = C.RBD_IMAGE_OPTION_FLATTEN
)

12
vendor/github.com/ceph/go-ceph/rbd/options_nautilus.go generated vendored Normal file
View File

@ -0,0 +1,12 @@
// +build !luminous,!mimic
package rbd
// #include <rbd/librbd.h>
import "C"
const (
// ImageOptionCloneFormat is the representation of
// RBD_IMAGE_OPTION_CLONE_FORMAT from librbd
ImageOptionCloneFormat = C.RBD_IMAGE_OPTION_CLONE_FORMAT
)

12
vendor/github.com/ceph/go-ceph/rbd/options_octopus.go generated vendored Normal file
View File

@ -0,0 +1,12 @@
// +build !luminous,!mimic,!nautilus
package rbd
// #include <rbd/librbd.h>
import "C"
const (
// ImageOptionMirrorImageMode is the representation of
// RBD_IMAGE_OPTION_MIRROR_IMAGE_MODE from librbd
ImageOptionMirrorImageMode = C.RBD_IMAGE_OPTION_MIRROR_IMAGE_MODE
)

86
vendor/github.com/ceph/go-ceph/rbd/pool_nautilus.go generated vendored Normal file
View File

@ -0,0 +1,86 @@
// +build !luminous,!mimic
//
// Ceph Nautilus is the first release that includes rbd_pool_metadata_get(),
// rbd_pool_metadata_set() and rbd_pool_metadata_remove().
package rbd
// #cgo LDFLAGS: -lrbd
// #include <rados/librados.h>
// #include <rbd/librbd.h>
// #include <stdlib.h>
import "C"
import (
"unsafe"
"github.com/ceph/go-ceph/internal/retry"
"github.com/ceph/go-ceph/rados"
)
// GetPoolMetadata returns pool metadata associated with the given key.
//
// Implements:
// int rbd_pool_metadata_get(rados_ioctx_t io_ctx, const char *key, char *value, size_t *val_len);
func GetPoolMetadata(ioctx *rados.IOContext, key string) (string, error) {
if ioctx == nil {
return "", ErrNoIOContext
}
cKey := C.CString(key)
defer C.free(unsafe.Pointer(cKey))
var (
buf []byte
err error
)
retry.WithSizes(4096, 262144, func(size int) retry.Hint {
cSize := C.size_t(size)
buf = make([]byte, cSize)
ret := C.rbd_pool_metadata_get(cephIoctx(ioctx),
cKey,
(*C.char)(unsafe.Pointer(&buf[0])),
&cSize)
err = getError(ret)
return retry.Size(int(cSize)).If(err == errRange)
})
if err != nil {
return "", err
}
return C.GoString((*C.char)(unsafe.Pointer(&buf[0]))), nil
}
// SetPoolMetadata updates the pool metadata string associated with the given key.
//
// Implements:
// int rbd_pool_metadata_set(rados_ioctx_t io_ctx, const char *key, const char *value);
func SetPoolMetadata(ioctx *rados.IOContext, key, value string) error {
if ioctx == nil {
return ErrNoIOContext
}
cKey := C.CString(key)
defer C.free(unsafe.Pointer(cKey))
cValue := C.CString(value)
defer C.free(unsafe.Pointer(cValue))
ret := C.rbd_pool_metadata_set(cephIoctx(ioctx), cKey, cValue)
return getError(ret)
}
// RemovePoolMetadata removes the pool metadata value for a given pool metadata key.
//
// Implements:
// int rbd_pool_metadata_remove(rados_ioctx_t io_ctx, const char *key)
func RemovePoolMetadata(ioctx *rados.IOContext, key string) error {
if ioctx == nil {
return ErrNoIOContext
}
cKey := C.CString(key)
defer C.free(unsafe.Pointer(cKey))
ret := C.rbd_pool_metadata_remove(cephIoctx(ioctx), cKey)
return getError(ret)
}

View File

@ -17,6 +17,7 @@ import (
"time" "time"
"unsafe" "unsafe"
"github.com/ceph/go-ceph/internal/retry"
"github.com/ceph/go-ceph/rados" "github.com/ceph/go-ceph/rados"
) )
@ -37,6 +38,7 @@ const (
imageNeedsName uint32 = 1 << iota imageNeedsName uint32 = 1 << iota
imageNeedsIOContext imageNeedsIOContext
imageIsOpen imageIsOpen
imageIsNotOpen
snapshotNeedsName snapshotNeedsName
// NoSnapshot indicates that no snapshot name is in use (see OpenImage) // NoSnapshot indicates that no snapshot name is in use (see OpenImage)
@ -120,6 +122,8 @@ func (image *Image) validate(req uint32) error {
return ErrNoIOContext return ErrNoIOContext
} else if hasBit(req, imageIsOpen) && image.image == nil { } else if hasBit(req, imageIsOpen) && image.image == nil {
return ErrImageNotOpen return ErrImageNotOpen
} else if hasBit(req, imageIsNotOpen) && image.image != nil {
return ErrImageIsOpen
} }
return nil return nil
@ -277,7 +281,7 @@ func (image *Image) Clone(snapname string, c_ioctx *rados.IOContext, c_name stri
// Implements: // Implements:
// int rbd_remove(rados_ioctx_t io, const char *name); // int rbd_remove(rados_ioctx_t io, const char *name);
func (image *Image) Remove() error { func (image *Image) Remove() error {
if err := image.validate(imageNeedsIOContext | imageNeedsName); err != nil { if err := image.validate(imageNeedsIOContext | imageNeedsName | imageIsNotOpen); err != nil {
return err return err
} }
return RemoveImage(image.ioctx, image.name) return RemoveImage(image.ioctx, image.name)
@ -873,22 +877,24 @@ func (image *Image) GetMetadata(key string) (string, error) {
c_key := C.CString(key) c_key := C.CString(key)
defer C.free(unsafe.Pointer(c_key)) defer C.free(unsafe.Pointer(c_key))
var c_vallen C.size_t var (
ret := C.rbd_metadata_get(image.image, c_key, nil, (*C.size_t)(&c_vallen)) buf []byte
// get size of value err error
// ret -34 because we pass nil as value pointer )
if ret != 0 && ret != -C.ERANGE { retry.WithSizes(4096, 262144, func(size int) retry.Hint {
return "", RBDError(ret) csize := C.size_t(size)
buf = make([]byte, csize)
// rbd_metadata_get is a bit quirky and *does not* update the size
// value if the size passed in >= the needed size.
ret := C.rbd_metadata_get(
image.image, c_key, (*C.char)(unsafe.Pointer(&buf[0])), &csize)
err = getError(ret)
return retry.Size(int(csize)).If(err == errRange)
})
if err != nil {
return "", err
} }
return C.GoString((*C.char)(unsafe.Pointer(&buf[0]))), nil
// make a bytes array with a good size
value := make([]byte, c_vallen-1)
ret = C.rbd_metadata_get(image.image, c_key, (*C.char)(unsafe.Pointer(&value[0])), (*C.size_t)(&c_vallen))
if ret < 0 {
return "", RBDError(ret)
}
return string(value), nil
} }
// SetMetadata updates the metadata string associated with the given key. // SetMetadata updates the metadata string associated with the given key.
@ -941,42 +947,50 @@ func (image *Image) GetId() (string, error) {
if err := image.validate(imageIsOpen); err != nil { if err := image.validate(imageIsOpen); err != nil {
return "", err return "", err
} }
size := C.size_t(1024) var (
buf := make([]byte, size) err error
for { buf []byte
)
retry.WithSizes(1, 8192, func(size int) retry.Hint {
buf = make([]byte, size)
ret := C.rbd_get_id( ret := C.rbd_get_id(
image.image, image.image,
(*C.char)(unsafe.Pointer(&buf[0])), (*C.char)(unsafe.Pointer(&buf[0])),
size) C.size_t(size))
if ret == -C.ERANGE && size <= 8192 { err = getErrorIfNegative(ret)
size *= 2 return retry.DoubleSize.If(err == errRange)
buf = make([]byte, size) })
} else if ret < 0 { if err != nil {
return "", getError(ret) return "", err
} }
id := C.GoString((*C.char)(unsafe.Pointer(&buf[0]))) id := C.GoString((*C.char)(unsafe.Pointer(&buf[0])))
return id, nil return id, nil
}
} }
// GetTrashList returns a slice of TrashInfo structs, containing information about all RBD images // GetTrashList returns a slice of TrashInfo structs, containing information about all RBD images
// currently residing in the trash. // currently residing in the trash.
func GetTrashList(ioctx *rados.IOContext) ([]TrashInfo, error) { func GetTrashList(ioctx *rados.IOContext) ([]TrashInfo, error) {
var num_entries C.size_t var (
err error
// Call rbd_trash_list with nil pointer to get number of trash entries. count C.size_t
if C.rbd_trash_list(cephIoctx(ioctx), nil, &num_entries); num_entries == 0 { entries []C.rbd_trash_image_info_t
return nil, nil )
retry.WithSizes(32, 1024, func(size int) retry.Hint {
count = C.size_t(size)
entries = make([]C.rbd_trash_image_info_t, count)
ret := C.rbd_trash_list(cephIoctx(ioctx), &entries[0], &count)
err = getErrorIfNegative(ret)
return retry.Size(int(count)).If(err == errRange)
})
if err != nil {
return nil, err
} }
// Free rbd_trash_image_info_t pointers
defer C.rbd_trash_list_cleanup(&entries[0], count)
c_entries := make([]C.rbd_trash_image_info_t, num_entries) trashList := make([]TrashInfo, count)
trashList := make([]TrashInfo, num_entries) for i, ti := range entries[:count] {
if ret := C.rbd_trash_list(cephIoctx(ioctx), &c_entries[0], &num_entries); ret < 0 {
return nil, RBDError(ret)
}
for i, ti := range c_entries {
trashList[i] = TrashInfo{ trashList[i] = TrashInfo{
Id: C.GoString(ti.id), Id: C.GoString(ti.id),
Name: C.GoString(ti.name), Name: C.GoString(ti.name),
@ -984,10 +998,6 @@ func GetTrashList(ioctx *rados.IOContext) ([]TrashInfo, error) {
DefermentEndTime: time.Unix(int64(ti.deferment_end_time), 0), DefermentEndTime: time.Unix(int64(ti.deferment_end_time), 0),
} }
} }
// Free rbd_trash_image_info_t pointers
C.rbd_trash_list_cleanup(&c_entries[0], num_entries)
return trashList, nil return trashList, nil
} }
@ -1018,6 +1028,13 @@ func TrashRestore(ioctx *rados.IOContext, id, name string) error {
// int rbd_open(rados_ioctx_t io, const char *name, // int rbd_open(rados_ioctx_t io, const char *name,
// rbd_image_t *image, const char *snap_name); // rbd_image_t *image, const char *snap_name);
func OpenImage(ioctx *rados.IOContext, name, snapName string) (*Image, error) { func OpenImage(ioctx *rados.IOContext, name, snapName string) (*Image, error) {
if ioctx == nil {
return nil, ErrNoIOContext
}
if name == "" {
return nil, ErrNoName
}
cName := C.CString(name) cName := C.CString(name)
defer C.free(unsafe.Pointer(cName)) defer C.free(unsafe.Pointer(cName))
@ -1054,6 +1071,13 @@ func OpenImage(ioctx *rados.IOContext, name, snapName string) (*Image, error) {
// int rbd_open_read_only(rados_ioctx_t io, const char *name, // int rbd_open_read_only(rados_ioctx_t io, const char *name,
// rbd_image_t *image, const char *snap_name); // rbd_image_t *image, const char *snap_name);
func OpenImageReadOnly(ioctx *rados.IOContext, name, snapName string) (*Image, error) { func OpenImageReadOnly(ioctx *rados.IOContext, name, snapName string) (*Image, error) {
if ioctx == nil {
return nil, ErrNoIOContext
}
if name == "" {
return nil, ErrNoName
}
cName := C.CString(name) cName := C.CString(name)
defer C.free(unsafe.Pointer(cName)) defer C.free(unsafe.Pointer(cName))
@ -1091,6 +1115,13 @@ func OpenImageReadOnly(ioctx *rados.IOContext, name, snapName string) (*Image, e
// int rbd_open_by_id(rados_ioctx_t io, const char *id, // int rbd_open_by_id(rados_ioctx_t io, const char *id,
// rbd_image_t *image, const char *snap_name); // rbd_image_t *image, const char *snap_name);
func OpenImageById(ioctx *rados.IOContext, id, snapName string) (*Image, error) { func OpenImageById(ioctx *rados.IOContext, id, snapName string) (*Image, error) {
if ioctx == nil {
return nil, ErrNoIOContext
}
if id == "" {
return nil, ErrNoName
}
cid := C.CString(id) cid := C.CString(id)
defer C.free(unsafe.Pointer(cid)) defer C.free(unsafe.Pointer(cid))
@ -1128,6 +1159,13 @@ func OpenImageById(ioctx *rados.IOContext, id, snapName string) (*Image, error)
// int rbd_open_by_id_read_only(rados_ioctx_t io, const char *id, // int rbd_open_by_id_read_only(rados_ioctx_t io, const char *id,
// rbd_image_t *image, const char *snap_name); // rbd_image_t *image, const char *snap_name);
func OpenImageByIdReadOnly(ioctx *rados.IOContext, id, snapName string) (*Image, error) { func OpenImageByIdReadOnly(ioctx *rados.IOContext, id, snapName string) (*Image, error) {
if ioctx == nil {
return nil, ErrNoIOContext
}
if id == "" {
return nil, ErrNoName
}
cid := C.CString(id) cid := C.CString(id)
defer C.free(unsafe.Pointer(cid)) defer C.free(unsafe.Pointer(cid))
@ -1160,7 +1198,12 @@ func OpenImageByIdReadOnly(ioctx *rados.IOContext, id, snapName string) (*Image,
// int rbd_create4(rados_ioctx_t io, const char *name, uint64_t size, // int rbd_create4(rados_ioctx_t io, const char *name, uint64_t size,
// rbd_image_options_t opts); // rbd_image_options_t opts);
func CreateImage(ioctx *rados.IOContext, name string, size uint64, rio *ImageOptions) error { func CreateImage(ioctx *rados.IOContext, name string, size uint64, rio *ImageOptions) error {
if ioctx == nil {
return ErrNoIOContext
}
if name == "" {
return ErrNoName
}
if rio == nil { if rio == nil {
return RBDError(C.EINVAL) return RBDError(C.EINVAL)
} }
@ -1178,6 +1221,13 @@ func CreateImage(ioctx *rados.IOContext, name string, size uint64, rio *ImageOpt
// Implements: // Implements:
// int rbd_remove(rados_ioctx_t io, const char *name); // int rbd_remove(rados_ioctx_t io, const char *name);
func RemoveImage(ioctx *rados.IOContext, name string) error { func RemoveImage(ioctx *rados.IOContext, name string) error {
if ioctx == nil {
return ErrNoIOContext
}
if name == "" {
return ErrNoName
}
c_name := C.CString(name) c_name := C.CString(name)
defer C.free(unsafe.Pointer(c_name)) defer C.free(unsafe.Pointer(c_name))
return getError(C.rbd_remove(cephIoctx(ioctx), c_name)) return getError(C.rbd_remove(cephIoctx(ioctx), c_name))

View File

@ -15,23 +15,29 @@ import (
"bytes" "bytes"
"unsafe" "unsafe"
"github.com/ceph/go-ceph/internal/retry"
"github.com/ceph/go-ceph/rados" "github.com/ceph/go-ceph/rados"
) )
// GetImageNames returns the list of current RBD images. // GetImageNames returns the list of current RBD images.
func GetImageNames(ioctx *rados.IOContext) (names []string, err error) { func GetImageNames(ioctx *rados.IOContext) (names []string, err error) {
buf := make([]byte, 4096) var (
for { buf []byte
size := C.size_t(len(buf)) csize C.size_t
)
// from 4KiB to 32KiB
retry.WithSizes(4096, 1<<15, func(size int) retry.Hint {
csize = C.size_t(size)
buf = make([]byte, csize)
ret := C.rbd_list(cephIoctx(ioctx), ret := C.rbd_list(cephIoctx(ioctx),
(*C.char)(unsafe.Pointer(&buf[0])), &size) (*C.char)(unsafe.Pointer(&buf[0])), &csize)
if ret == -C.ERANGE { err = getErrorIfNegative(ret)
buf = make([]byte, size) return retry.Size(int(csize)).If(err == errRange)
continue })
} else if ret < 0 { if err != nil {
return nil, RBDError(ret) return nil, err
} }
tmp := bytes.Split(buf[:size-1], []byte{0}) tmp := bytes.Split(buf[:csize-1], []byte{0})
for _, s := range tmp { for _, s := range tmp {
if len(s) > 0 { if len(s) > 0 {
name := C.GoString((*C.char)(unsafe.Pointer(&s[0]))) name := C.GoString((*C.char)(unsafe.Pointer(&s[0])))
@ -39,5 +45,4 @@ func GetImageNames(ioctx *rados.IOContext) (names []string, err error) {
} }
} }
return names, nil return names, nil
}
} }

View File

@ -11,34 +11,36 @@ package rbd
import "C" import "C"
import ( import (
"fmt"
"unsafe" "unsafe"
"github.com/ceph/go-ceph/internal/retry"
"github.com/ceph/go-ceph/rados" "github.com/ceph/go-ceph/rados"
) )
// GetImageNames returns the list of current RBD images. // GetImageNames returns the list of current RBD images.
func GetImageNames(ioctx *rados.IOContext) ([]string, error) { func GetImageNames(ioctx *rados.IOContext) ([]string, error) {
size := C.size_t(0) var (
ret := C.rbd_list2(cephIoctx(ioctx), nil, &size) err error
if ret < 0 && ret != -C.ERANGE { images []C.rbd_image_spec_t
return nil, RBDError(ret) size C.size_t
} else if ret > 0 { )
return nil, fmt.Errorf("rbd_list2() returned %d names, expected 0", ret) retry.WithSizes(32, 4096, func(s int) retry.Hint {
} else if ret == 0 && size == 0 { size = C.size_t(s)
return nil, nil images = make([]C.rbd_image_spec_t, size)
} ret := C.rbd_list2(
cephIoctx(ioctx),
// expected: ret == -ERANGE, size contains number of image names (*C.rbd_image_spec_t)(unsafe.Pointer(&images[0])),
images := make([]C.rbd_image_spec_t, size) &size)
ret = C.rbd_list2(cephIoctx(ioctx), (*C.rbd_image_spec_t)(unsafe.Pointer(&images[0])), &size) err = getErrorIfNegative(ret)
if ret < 0 { return retry.Size(int(size)).If(err == errRange)
return nil, RBDError(ret) })
if err != nil {
return nil, err
} }
defer C.rbd_image_spec_list_cleanup((*C.rbd_image_spec_t)(unsafe.Pointer(&images[0])), size) defer C.rbd_image_spec_list_cleanup((*C.rbd_image_spec_t)(unsafe.Pointer(&images[0])), size)
names := make([]string, size) names := make([]string, size)
for i, image := range images { for i, image := range images[:size] {
names[i] = C.GoString(image.name) names[i] = C.GoString(image.name)
} }
return names, nil return names, nil

View File

@ -11,8 +11,9 @@ package rbd
import "C" import "C"
import ( import (
"fmt"
"unsafe" "unsafe"
"github.com/ceph/go-ceph/internal/retry"
) )
// GetParentInfo looks for the parent of the image and stores the pool, name // GetParentInfo looks for the parent of the image and stores the pool, name
@ -76,27 +77,28 @@ func (image *Image) ListChildren() (pools []string, images []string, err error)
return nil, nil, err return nil, nil, err
} }
size := C.size_t(0) var (
ret := C.rbd_list_children3(image.image, nil, &size) csize C.size_t
if ret < 0 && ret != -C.ERANGE { children []C.rbd_linked_image_spec_t
return nil, nil, RBDError(ret) )
} else if ret > 0 { retry.WithSizes(16, 4096, func(size int) retry.Hint {
return nil, nil, fmt.Errorf("rbd_list_children3() returned %d, expected 0", ret) csize = C.size_t(size)
} else if ret == 0 && size == 0 { children = make([]C.rbd_linked_image_spec_t, csize)
return nil, nil, nil ret := C.rbd_list_children3(
image.image,
(*C.rbd_linked_image_spec_t)(unsafe.Pointer(&children[0])),
&csize)
err = getErrorIfNegative(ret)
return retry.Size(int(csize)).If(err == errRange)
})
if err != nil {
return nil, nil, err
} }
defer C.rbd_linked_image_spec_list_cleanup((*C.rbd_linked_image_spec_t)(unsafe.Pointer(&children[0])), csize)
// expected: ret == -ERANGE, size contains number of image names pools = make([]string, csize)
children := make([]C.rbd_linked_image_spec_t, size) images = make([]string, csize)
ret = C.rbd_list_children3(image.image, (*C.rbd_linked_image_spec_t)(unsafe.Pointer(&children[0])), &size) for i, child := range children[:csize] {
if ret < 0 {
return nil, nil, RBDError(ret)
}
defer C.rbd_linked_image_spec_list_cleanup((*C.rbd_linked_image_spec_t)(unsafe.Pointer(&children[0])), size)
pools = make([]string, size)
images = make([]string, size)
for i, child := range children {
pools[i] = C.GoString(child.pool_name) pools[i] = C.GoString(child.pool_name)
images[i] = C.GoString(child.image_name) images[i] = C.GoString(child.image_name)
} }

View File

@ -9,6 +9,10 @@ package rbd
// #include <rbd/librbd.h> // #include <rbd/librbd.h>
import "C" import "C"
import (
"github.com/ceph/go-ceph/internal/retry"
)
// ImageWatcher is a representation of the rbd_image_watcher_t from librbd.h // ImageWatcher is a representation of the rbd_image_watcher_t from librbd.h
type ImageWatcher struct { type ImageWatcher struct {
Addr string Addr string
@ -30,28 +34,28 @@ func (image *Image) ListWatchers() ([]ImageWatcher, error) {
return nil, err return nil, err
} }
count := C.ulong(0) var (
ret := C.rbd_watchers_list(image.image, nil, &count) err error
if ret != 0 && ret != -C.ERANGE { count C.size_t
return nil, getError(ret) watchers []C.rbd_image_watcher_t
} )
if ret == 0 && count == 0 { retry.WithSizes(16, 4096, func(size int) retry.Hint {
return nil, nil count = C.size_t(size)
} watchers = make([]C.rbd_image_watcher_t, count)
ret := C.rbd_watchers_list(image.image, &watchers[0], &count)
watchers := make([]C.rbd_image_watcher_t, count) err = getErrorIfNegative(ret)
ret = C.rbd_watchers_list(image.image, &watchers[0], &count) return retry.Size(int(count)).If(err == errRange)
if ret != 0 && ret != -C.ERANGE { })
return nil, getError(ret) if err != nil {
return nil, err
} }
defer C.rbd_watchers_list_cleanup(&watchers[0], count) defer C.rbd_watchers_list_cleanup(&watchers[0], count)
imageWatchers := make([]ImageWatcher, len(watchers)) imageWatchers := make([]ImageWatcher, count)
for i, watcher := range watchers { for i, watcher := range watchers[:count] {
imageWatchers[i].Addr = C.GoString(watcher.addr) imageWatchers[i].Addr = C.GoString(watcher.addr)
imageWatchers[i].Id = int64(watcher.id) imageWatchers[i].Id = int64(watcher.id)
imageWatchers[i].Cookie = uint64(watcher.cookie) imageWatchers[i].Cookie = uint64(watcher.cookie)
} }
return imageWatchers, nil return imageWatchers, nil
} }

View File

@ -0,0 +1,30 @@
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package unsafeheader contains header declarations for the Go runtime's
// slice and string implementations.
//
// This package allows x/sys to use types equivalent to
// reflect.SliceHeader and reflect.StringHeader without introducing
// a dependency on the (relatively heavy) "reflect" package.
package unsafeheader
import (
"unsafe"
)
// Slice is the runtime representation of a slice.
// It cannot be used safely or portably and its representation may change in a later release.
type Slice struct {
Data unsafe.Pointer
Len int
Cap int
}
// String is the runtime representation of a string.
// It cannot be used safely or portably and its representation may change in a later release.
type String struct {
Data unsafe.Pointer
Len int
}

View File

@ -187,6 +187,7 @@ struct ltchars {
#include <sys/select.h> #include <sys/select.h>
#include <sys/signalfd.h> #include <sys/signalfd.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/timerfd.h>
#include <sys/uio.h> #include <sys/uio.h>
#include <sys/xattr.h> #include <sys/xattr.h>
#include <linux/bpf.h> #include <linux/bpf.h>
@ -480,7 +481,7 @@ ccflags="$@"
$2 ~ /^(MS|MNT|UMOUNT)_/ || $2 ~ /^(MS|MNT|UMOUNT)_/ ||
$2 ~ /^NS_GET_/ || $2 ~ /^NS_GET_/ ||
$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ || $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
$2 ~ /^(O|F|[ES]?FD|NAME|S|PTRACE|PT)_/ || $2 ~ /^(O|F|[ES]?FD|NAME|S|PTRACE|PT|TFD)_/ ||
$2 ~ /^KEXEC_/ || $2 ~ /^KEXEC_/ ||
$2 ~ /^LINUX_REBOOT_CMD_/ || $2 ~ /^LINUX_REBOOT_CMD_/ ||
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ || $2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||

View File

@ -6,7 +6,11 @@
package unix package unix
import "unsafe" import (
"unsafe"
"golang.org/x/sys/internal/unsafeheader"
)
//sys closedir(dir uintptr) (err error) //sys closedir(dir uintptr) (err error)
//sys readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) //sys readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno)
@ -71,6 +75,7 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
cnt++ cnt++
continue continue
} }
reclen := int(entry.Reclen) reclen := int(entry.Reclen)
if reclen > len(buf) { if reclen > len(buf) {
// Not enough room. Return for now. // Not enough room. Return for now.
@ -79,13 +84,15 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
// restarting is O(n^2) in the length of the directory. Oh well. // restarting is O(n^2) in the length of the directory. Oh well.
break break
} }
// Copy entry into return buffer. // Copy entry into return buffer.
s := struct { var s []byte
ptr unsafe.Pointer hdr := (*unsafeheader.Slice)(unsafe.Pointer(&s))
siz int hdr.Data = unsafe.Pointer(&entry)
cap int hdr.Cap = reclen
}{ptr: unsafe.Pointer(&entry), siz: reclen, cap: reclen} hdr.Len = reclen
copy(buf, *(*[]byte)(unsafe.Pointer(&s))) copy(buf, s)
buf = buf[reclen:] buf = buf[reclen:]
n += reclen n += reclen
cnt++ cnt++

View File

@ -133,12 +133,6 @@ func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
return openat(dirfd, path, flags|O_LARGEFILE, mode) return openat(dirfd, path, flags|O_LARGEFILE, mode)
} }
//sys openat2(dirfd int, path string, open_how *OpenHow, size int) (fd int, err error)
func Openat2(dirfd int, path string, how *OpenHow) (fd int, err error) {
return openat2(dirfd, path, how, SizeofOpenHow)
}
//sys ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) //sys ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error)
func Ppoll(fds []PollFd, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { func Ppoll(fds []PollFd, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
@ -1639,6 +1633,15 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
//sys CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) //sys CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
//sys DeleteModule(name string, flags int) (err error) //sys DeleteModule(name string, flags int) (err error)
//sys Dup(oldfd int) (fd int, err error) //sys Dup(oldfd int) (fd int, err error)
func Dup2(oldfd, newfd int) error {
// Android O and newer blocks dup2; riscv and arm64 don't implement dup2.
if runtime.GOOS == "android" || runtime.GOARCH == "riscv64" || runtime.GOARCH == "arm64" {
return Dup3(oldfd, newfd, 0)
}
return dup2(oldfd, newfd)
}
//sys Dup3(oldfd int, newfd int, flags int) (err error) //sys Dup3(oldfd int, newfd int, flags int) (err error)
//sysnb EpollCreate1(flag int) (fd int, err error) //sysnb EpollCreate1(flag int) (fd int, err error)
//sysnb EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) //sysnb EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error)
@ -1763,6 +1766,9 @@ func Signalfd(fd int, sigmask *Sigset_t, flags int) (newfd int, err error) {
//sys Syncfs(fd int) (err error) //sys Syncfs(fd int) (err error)
//sysnb Sysinfo(info *Sysinfo_t) (err error) //sysnb Sysinfo(info *Sysinfo_t) (err error)
//sys Tee(rfd int, wfd int, len int, flags int) (n int64, err error) //sys Tee(rfd int, wfd int, len int, flags int) (n int64, err error)
//sysnb TimerfdCreate(clockid int, flags int) (fd int, err error)
//sysnb TimerfdGettime(fd int, currValue *ItimerSpec) (err error)
//sysnb TimerfdSettime(fd int, flags int, newValue *ItimerSpec, oldValue *ItimerSpec) (err error)
//sysnb Tgkill(tgid int, tid int, sig syscall.Signal) (err error) //sysnb Tgkill(tgid int, tid int, sig syscall.Signal) (err error)
//sysnb Times(tms *Tms) (ticks uintptr, err error) //sysnb Times(tms *Tms) (ticks uintptr, err error)
//sysnb Umask(mask int) (oldmask int) //sysnb Umask(mask int) (oldmask int)
@ -2184,7 +2190,6 @@ func Klogset(typ int, arg int) (err error) {
// TimerGetoverrun // TimerGetoverrun
// TimerGettime // TimerGettime
// TimerSettime // TimerSettime
// Timerfd
// Tkill (obsolete) // Tkill (obsolete)
// Tuxcall // Tuxcall
// Umount2 // Umount2

View File

@ -49,7 +49,7 @@ func Pipe2(p []int, flags int) (err error) {
// 64-bit file system and 32-bit uid calls // 64-bit file system and 32-bit uid calls
// (386 default is 32-bit file system and 16-bit uid). // (386 default is 32-bit file system and 16-bit uid).
//sys Dup2(oldfd int, newfd int) (err error) //sys dup2(oldfd int, newfd int) (err error)
//sysnb EpollCreate(size int) (fd int, err error) //sysnb EpollCreate(size int) (fd int, err error)
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64_64 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64_64

View File

@ -6,7 +6,7 @@
package unix package unix
//sys Dup2(oldfd int, newfd int) (err error) //sys dup2(oldfd int, newfd int) (err error)
//sysnb EpollCreate(size int) (fd int, err error) //sysnb EpollCreate(size int) (fd int, err error)
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64

View File

@ -80,7 +80,7 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
// 64-bit file system and 32-bit uid calls // 64-bit file system and 32-bit uid calls
// (16-bit uid calls are not always supported in newer kernels) // (16-bit uid calls are not always supported in newer kernels)
//sys Dup2(oldfd int, newfd int) (err error) //sys dup2(oldfd int, newfd int) (err error)
//sysnb EpollCreate(size int) (fd int, err error) //sysnb EpollCreate(size int) (fd int, err error)
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
//sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32 //sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32

View File

@ -25,7 +25,7 @@ func EpollCreate(size int) (fd int, err error) {
//sysnb Getegid() (egid int) //sysnb Getegid() (egid int)
//sysnb Geteuid() (euid int) //sysnb Geteuid() (euid int)
//sysnb Getgid() (gid int) //sysnb Getgid() (gid int)
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) //sysnb getrlimit(resource int, rlim *Rlimit) (err error)
//sysnb Getuid() (uid int) //sysnb Getuid() (uid int)
//sys Listen(s int, n int) (err error) //sys Listen(s int, n int) (err error)
//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
@ -47,7 +47,7 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err
//sysnb Setregid(rgid int, egid int) (err error) //sysnb Setregid(rgid int, egid int) (err error)
//sysnb Setresgid(rgid int, egid int, sgid int) (err error) //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
//sysnb Setresuid(ruid int, euid int, suid int) (err error) //sysnb Setresuid(ruid int, euid int, suid int) (err error)
//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) //sysnb setrlimit(resource int, rlim *Rlimit) (err error)
//sysnb Setreuid(ruid int, euid int) (err error) //sysnb Setreuid(ruid int, euid int) (err error)
//sys Shutdown(fd int, how int) (err error) //sys Shutdown(fd int, how int) (err error)
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
@ -168,6 +168,24 @@ func Pipe2(p []int, flags int) (err error) {
return return
} }
// Getrlimit prefers the prlimit64 system call. See issue 38604.
func Getrlimit(resource int, rlim *Rlimit) error {
err := prlimit(0, resource, nil, rlim)
if err != ENOSYS {
return err
}
return getrlimit(resource, rlim)
}
// Setrlimit prefers the prlimit64 system call. See issue 38604.
func Setrlimit(resource int, rlim *Rlimit) error {
err := prlimit(0, resource, rlim, nil)
if err != ENOSYS {
return err
}
return setrlimit(resource, rlim)
}
func (r *PtraceRegs) PC() uint64 { return r.Pc } func (r *PtraceRegs) PC() uint64 { return r.Pc }
func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc } func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
@ -192,9 +210,9 @@ func InotifyInit() (fd int, err error) {
return InotifyInit1(0) return InotifyInit1(0)
} }
func Dup2(oldfd int, newfd int) (err error) { // dup2 exists because func Dup3 in syscall_linux.go references
return Dup3(oldfd, newfd, 0) // it in an unreachable path. dup2 isn't available on arm64.
} func dup2(oldfd int, newfd int) error
func Pause() error { func Pause() error {
_, err := ppoll(nil, 0, nil, nil) _, err := ppoll(nil, 0, nil, nil)

View File

@ -7,7 +7,7 @@
package unix package unix
//sys Dup2(oldfd int, newfd int) (err error) //sys dup2(oldfd int, newfd int) (err error)
//sysnb EpollCreate(size int) (fd int, err error) //sysnb EpollCreate(size int) (fd int, err error)
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64

View File

@ -14,7 +14,7 @@ import (
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
//sys Dup2(oldfd int, newfd int) (err error) //sys dup2(oldfd int, newfd int) (err error)
//sysnb EpollCreate(size int) (fd int, err error) //sysnb EpollCreate(size int) (fd int, err error)
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64

View File

@ -7,7 +7,7 @@
package unix package unix
//sys Dup2(oldfd int, newfd int) (err error) //sys dup2(oldfd int, newfd int) (err error)
//sysnb EpollCreate(size int) (fd int, err error) //sysnb EpollCreate(size int) (fd int, err error)
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64

View File

@ -191,10 +191,6 @@ func InotifyInit() (fd int, err error) {
return InotifyInit1(0) return InotifyInit1(0)
} }
func Dup2(oldfd int, newfd int) (err error) {
return Dup3(oldfd, newfd, 0)
}
func Pause() error { func Pause() error {
_, err := ppoll(nil, 0, nil, nil) _, err := ppoll(nil, 0, nil, nil)
return err return err
@ -228,3 +224,7 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error
} }
return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
} }
// dup2 exists because func Dup3 in syscall_linux.go references
// it in an unreachable path. dup2 isn't available on arm64.
func dup2(oldfd int, newfd int) error

View File

@ -10,7 +10,7 @@ import (
"unsafe" "unsafe"
) )
//sys Dup2(oldfd int, newfd int) (err error) //sys dup2(oldfd int, newfd int) (err error)
//sysnb EpollCreate(size int) (fd int, err error) //sysnb EpollCreate(size int) (fd int, err error)
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64

View File

@ -8,7 +8,7 @@ package unix
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
//sys Dup2(oldfd int, newfd int) (err error) //sys dup2(oldfd int, newfd int) (err error)
//sys Fchown(fd int, uid int, gid int) (err error) //sys Fchown(fd int, uid int, gid int) (err error)
//sys Fstat(fd int, stat *Stat_t) (err error) //sys Fstat(fd int, stat *Stat_t) (err error)
//sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64

View File

@ -12,6 +12,8 @@ import (
"sync" "sync"
"syscall" "syscall"
"unsafe" "unsafe"
"golang.org/x/sys/internal/unsafeheader"
) )
var ( var (
@ -113,15 +115,12 @@ func (m *mmapper) Mmap(fd int, offset int64, length int, prot int, flags int) (d
return nil, errno return nil, errno
} }
// Slice memory layout // Use unsafe to convert addr into a []byte.
var sl = struct { var b []byte
addr uintptr hdr := (*unsafeheader.Slice)(unsafe.Pointer(&b))
len int hdr.Data = unsafe.Pointer(addr)
cap int hdr.Cap = length
}{addr, length, length} hdr.Len = length
// Use unsafe to turn sl into a []byte.
b := *(*[]byte)(unsafe.Pointer(&sl))
// Register mapping in m and return it. // Register mapping in m and return it.
p := &b[cap(b)-1] p := &b[cap(b)-1]

View File

@ -2165,6 +2165,8 @@ const (
TCP_USER_TIMEOUT = 0x12 TCP_USER_TIMEOUT = 0x12
TCP_WINDOW_CLAMP = 0xa TCP_WINDOW_CLAMP = 0xa
TCP_ZEROCOPY_RECEIVE = 0x23 TCP_ZEROCOPY_RECEIVE = 0x23
TFD_TIMER_ABSTIME = 0x1
TFD_TIMER_CANCEL_ON_SET = 0x2
TIMER_ABSTIME = 0x1 TIMER_ABSTIME = 0x1
TIOCM_DTR = 0x2 TIOCM_DTR = 0x2
TIOCM_LE = 0x1 TIOCM_LE = 0x1

View File

@ -342,6 +342,8 @@ const (
TCSETXF = 0x5434 TCSETXF = 0x5434
TCSETXW = 0x5435 TCSETXW = 0x5435
TCXONC = 0x540a TCXONC = 0x540a
TFD_CLOEXEC = 0x80000
TFD_NONBLOCK = 0x800
TIOCCBRK = 0x5428 TIOCCBRK = 0x5428
TIOCCONS = 0x541d TIOCCONS = 0x541d
TIOCEXCL = 0x540c TIOCEXCL = 0x540c

View File

@ -343,6 +343,8 @@ const (
TCSETXF = 0x5434 TCSETXF = 0x5434
TCSETXW = 0x5435 TCSETXW = 0x5435
TCXONC = 0x540a TCXONC = 0x540a
TFD_CLOEXEC = 0x80000
TFD_NONBLOCK = 0x800
TIOCCBRK = 0x5428 TIOCCBRK = 0x5428
TIOCCONS = 0x541d TIOCCONS = 0x541d
TIOCEXCL = 0x540c TIOCEXCL = 0x540c

View File

@ -349,6 +349,8 @@ const (
TCSETXF = 0x5434 TCSETXF = 0x5434
TCSETXW = 0x5435 TCSETXW = 0x5435
TCXONC = 0x540a TCXONC = 0x540a
TFD_CLOEXEC = 0x80000
TFD_NONBLOCK = 0x800
TIOCCBRK = 0x5428 TIOCCBRK = 0x5428
TIOCCONS = 0x541d TIOCCONS = 0x541d
TIOCEXCL = 0x540c TIOCEXCL = 0x540c

View File

@ -336,6 +336,8 @@ const (
TCSETXF = 0x5434 TCSETXF = 0x5434
TCSETXW = 0x5435 TCSETXW = 0x5435
TCXONC = 0x540a TCXONC = 0x540a
TFD_CLOEXEC = 0x80000
TFD_NONBLOCK = 0x800
TIOCCBRK = 0x5428 TIOCCBRK = 0x5428
TIOCCONS = 0x541d TIOCCONS = 0x541d
TIOCEXCL = 0x540c TIOCEXCL = 0x540c

View File

@ -339,6 +339,8 @@ const (
TCSETSW = 0x540f TCSETSW = 0x540f
TCSETSW2 = 0x8030542c TCSETSW2 = 0x8030542c
TCXONC = 0x5406 TCXONC = 0x5406
TFD_CLOEXEC = 0x80000
TFD_NONBLOCK = 0x80
TIOCCBRK = 0x5428 TIOCCBRK = 0x5428
TIOCCONS = 0x80047478 TIOCCONS = 0x80047478
TIOCEXCL = 0x740d TIOCEXCL = 0x740d

View File

@ -339,6 +339,8 @@ const (
TCSETSW = 0x540f TCSETSW = 0x540f
TCSETSW2 = 0x8030542c TCSETSW2 = 0x8030542c
TCXONC = 0x5406 TCXONC = 0x5406
TFD_CLOEXEC = 0x80000
TFD_NONBLOCK = 0x80
TIOCCBRK = 0x5428 TIOCCBRK = 0x5428
TIOCCONS = 0x80047478 TIOCCONS = 0x80047478
TIOCEXCL = 0x740d TIOCEXCL = 0x740d

View File

@ -339,6 +339,8 @@ const (
TCSETSW = 0x540f TCSETSW = 0x540f
TCSETSW2 = 0x8030542c TCSETSW2 = 0x8030542c
TCXONC = 0x5406 TCXONC = 0x5406
TFD_CLOEXEC = 0x80000
TFD_NONBLOCK = 0x80
TIOCCBRK = 0x5428 TIOCCBRK = 0x5428
TIOCCONS = 0x80047478 TIOCCONS = 0x80047478
TIOCEXCL = 0x740d TIOCEXCL = 0x740d

View File

@ -339,6 +339,8 @@ const (
TCSETSW = 0x540f TCSETSW = 0x540f
TCSETSW2 = 0x8030542c TCSETSW2 = 0x8030542c
TCXONC = 0x5406 TCXONC = 0x5406
TFD_CLOEXEC = 0x80000
TFD_NONBLOCK = 0x80
TIOCCBRK = 0x5428 TIOCCBRK = 0x5428
TIOCCONS = 0x80047478 TIOCCONS = 0x80047478
TIOCEXCL = 0x740d TIOCEXCL = 0x740d

View File

@ -393,6 +393,8 @@ const (
TCSETSF = 0x802c7416 TCSETSF = 0x802c7416
TCSETSW = 0x802c7415 TCSETSW = 0x802c7415
TCXONC = 0x2000741e TCXONC = 0x2000741e
TFD_CLOEXEC = 0x80000
TFD_NONBLOCK = 0x800
TIOCCBRK = 0x5428 TIOCCBRK = 0x5428
TIOCCONS = 0x541d TIOCCONS = 0x541d
TIOCEXCL = 0x540c TIOCEXCL = 0x540c

View File

@ -393,6 +393,8 @@ const (
TCSETSF = 0x802c7416 TCSETSF = 0x802c7416
TCSETSW = 0x802c7415 TCSETSW = 0x802c7415
TCXONC = 0x2000741e TCXONC = 0x2000741e
TFD_CLOEXEC = 0x80000
TFD_NONBLOCK = 0x800
TIOCCBRK = 0x5428 TIOCCBRK = 0x5428
TIOCCONS = 0x541d TIOCCONS = 0x541d
TIOCEXCL = 0x540c TIOCEXCL = 0x540c

View File

@ -330,6 +330,8 @@ const (
TCSETXF = 0x5434 TCSETXF = 0x5434
TCSETXW = 0x5435 TCSETXW = 0x5435
TCXONC = 0x540a TCXONC = 0x540a
TFD_CLOEXEC = 0x80000
TFD_NONBLOCK = 0x800
TIOCCBRK = 0x5428 TIOCCBRK = 0x5428
TIOCCONS = 0x541d TIOCCONS = 0x541d
TIOCEXCL = 0x540c TIOCEXCL = 0x540c

View File

@ -403,6 +403,8 @@ const (
TCSETXF = 0x5434 TCSETXF = 0x5434
TCSETXW = 0x5435 TCSETXW = 0x5435
TCXONC = 0x540a TCXONC = 0x540a
TFD_CLOEXEC = 0x80000
TFD_NONBLOCK = 0x800
TIOCCBRK = 0x5428 TIOCCBRK = 0x5428
TIOCCONS = 0x541d TIOCCONS = 0x541d
TIOCEXCL = 0x540c TIOCEXCL = 0x540c

View File

@ -392,6 +392,8 @@ const (
TCSETSW = 0x8024540a TCSETSW = 0x8024540a
TCSETSW2 = 0x802c540e TCSETSW2 = 0x802c540e
TCXONC = 0x20005406 TCXONC = 0x20005406
TFD_CLOEXEC = 0x400000
TFD_NONBLOCK = 0x4000
TIOCCBRK = 0x2000747a TIOCCBRK = 0x2000747a
TIOCCONS = 0x20007424 TIOCCONS = 0x20007424
TIOCEXCL = 0x2000740d TIOCEXCL = 0x2000740d

View File

@ -83,22 +83,6 @@ func openat(dirfd int, path string, flags int, mode uint32) (fd int, 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 openat2(dirfd int, path string, open_how *OpenHow, size int) (fd int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
r0, _, e1 := Syscall6(SYS_OPENAT2, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(open_how)), uintptr(size), 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0) r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
n = int(r0) n = int(r0)
@ -1466,6 +1450,37 @@ func Sysinfo(info *Sysinfo_t) (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 TimerfdCreate(clockid int, flags int) (fd int, err error) {
r0, _, e1 := RawSyscall(SYS_TIMERFD_CREATE, uintptr(clockid), uintptr(flags), 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func TimerfdGettime(fd int, currValue *ItimerSpec) (err error) {
_, _, e1 := RawSyscall(SYS_TIMERFD_GETTIME, uintptr(fd), uintptr(unsafe.Pointer(currValue)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func TimerfdSettime(fd int, flags int, newValue *ItimerSpec, oldValue *ItimerSpec) (err error) {
_, _, e1 := RawSyscall6(SYS_TIMERFD_SETTIME, uintptr(fd), uintptr(flags), uintptr(unsafe.Pointer(newValue)), uintptr(unsafe.Pointer(oldValue)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
_, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig))
if e1 != 0 { if e1 != 0 {

View File

@ -55,7 +55,7 @@ func pipe(p *[2]_C_int) (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 Dup2(oldfd int, newfd int) (err error) { func dup2(oldfd int, newfd int) (err error) {
_, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)

View File

@ -45,7 +45,7 @@ func Tee(rfd int, wfd int, len int, flags int) (n 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 Dup2(oldfd int, newfd int) (err error) { func dup2(oldfd int, newfd int) (err error) {
_, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)

View File

@ -234,7 +234,7 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, 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 Dup2(oldfd int, newfd int) (err error) { func dup2(oldfd int, newfd int) (err error) {
_, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)

View File

@ -151,7 +151,7 @@ func Getgid() (gid int) {
// 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 Getrlimit(resource int, rlim *Rlimit) (err error) { func getrlimit(resource int, rlim *Rlimit) (err error) {
_, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)
@ -307,7 +307,7 @@ func Setresuid(ruid int, euid int, suid int) (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 Setrlimit(resource int, rlim *Rlimit) (err error) { func setrlimit(resource int, rlim *Rlimit) (err error) {
_, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)

View File

@ -45,7 +45,7 @@ func Tee(rfd int, wfd int, len int, flags int) (n 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 Dup2(oldfd int, newfd int) (err error) { func dup2(oldfd int, newfd int) (err error) {
_, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)

View File

@ -45,7 +45,7 @@ func Tee(rfd int, wfd int, len int, flags int) (n 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 Dup2(oldfd int, newfd int) (err error) { func dup2(oldfd int, newfd int) (err error) {
_, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)

View File

@ -45,7 +45,7 @@ func Tee(rfd int, wfd int, len int, flags int) (n 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 Dup2(oldfd int, newfd int) (err error) { func dup2(oldfd int, newfd int) (err error) {
_, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)

View File

@ -45,7 +45,7 @@ func Tee(rfd int, wfd int, len int, flags int) (n 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 Dup2(oldfd int, newfd int) (err error) { func dup2(oldfd int, newfd int) (err error) {
_, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)

View File

@ -45,7 +45,7 @@ func Tee(rfd int, wfd int, len int, flags int) (n 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 Dup2(oldfd int, newfd int) (err error) { func dup2(oldfd int, newfd int) (err error) {
_, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)

View File

@ -45,7 +45,7 @@ func Tee(rfd int, wfd int, len int, flags int) (n 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 Dup2(oldfd int, newfd int) (err error) { func dup2(oldfd int, newfd int) (err error) {
_, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)

View File

@ -45,7 +45,7 @@ func Tee(rfd int, wfd int, len int, flags int) (n 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 Dup2(oldfd int, newfd int) (err error) { func dup2(oldfd int, newfd int) (err error) {
_, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)

View File

@ -72,7 +72,7 @@ func Fadvise(fd int, offset int64, length int64, advice int) (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 Dup2(oldfd int, newfd int) (err error) { func dup2(oldfd int, newfd int) (err error) {
_, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)

View File

@ -18,6 +18,11 @@ type (
_C_long_long int64 _C_long_long int64
) )
type ItimerSpec struct {
Interval Timespec
Value Timespec
}
const ( const (
TIME_OK = 0x0 TIME_OK = 0x0
TIME_INS = 0x1 TIME_INS = 0x1
@ -691,22 +696,6 @@ const (
AT_EACCESS = 0x200 AT_EACCESS = 0x200
) )
type OpenHow struct {
Flags uint64
Mode uint64
Resolve uint64
}
const SizeofOpenHow = 0x18
const (
RESOLVE_BENEATH = 0x8
RESOLVE_IN_ROOT = 0x10
RESOLVE_NO_MAGICLINKS = 0x2
RESOLVE_NO_SYMLINKS = 0x4
RESOLVE_NO_XDEV = 0x1
)
type PollFd struct { type PollFd struct {
Fd int32 Fd int32
Events int16 Events int16

7
vendor/modules.txt vendored
View File

@ -2,9 +2,11 @@
github.com/beorn7/perks/quantile github.com/beorn7/perks/quantile
# github.com/blang/semver v3.5.0+incompatible # github.com/blang/semver v3.5.0+incompatible
github.com/blang/semver github.com/blang/semver
# github.com/ceph/go-ceph v0.3.0 # github.com/ceph/go-ceph v0.4.0
github.com/ceph/go-ceph/internal/callbacks github.com/ceph/go-ceph/internal/callbacks
github.com/ceph/go-ceph/internal/cutil
github.com/ceph/go-ceph/internal/errutil github.com/ceph/go-ceph/internal/errutil
github.com/ceph/go-ceph/internal/retry
github.com/ceph/go-ceph/rados github.com/ceph/go-ceph/rados
github.com/ceph/go-ceph/rbd github.com/ceph/go-ceph/rbd
# github.com/cespare/xxhash/v2 v2.1.1 # github.com/cespare/xxhash/v2 v2.1.1
@ -206,8 +208,9 @@ golang.org/x/net/websocket
# golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d # golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/oauth2 golang.org/x/oauth2
golang.org/x/oauth2/internal golang.org/x/oauth2/internal
# golang.org/x/sys v0.0.0-20200409092240-59c9f1ba88fa # golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3
golang.org/x/sys/cpu golang.org/x/sys/cpu
golang.org/x/sys/internal/unsafeheader
golang.org/x/sys/unix golang.org/x/sys/unix
golang.org/x/sys/windows golang.org/x/sys/windows
# golang.org/x/text v0.3.2 # golang.org/x/text v0.3.2