mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-23 10:21:00 +00:00
Merge pull request #1654 from bradrydzewski/master
agents stream logs using websockets
This commit is contained in:
commit
c220466b21
198 changed files with 108547 additions and 25 deletions
|
@ -42,6 +42,28 @@ func NewClientUpdater(client client.Client) UpdateFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewStreamLogger(stream client.StreamWriter, w io.Writer, limit int64) LoggerFunc {
|
||||||
|
var err error
|
||||||
|
var size int64
|
||||||
|
return func(line *build.Line) {
|
||||||
|
|
||||||
|
if size > limit {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO remove this double-serialization
|
||||||
|
linejson, _ := json.Marshal(line)
|
||||||
|
w.Write(linejson)
|
||||||
|
w.Write([]byte{'\n'})
|
||||||
|
|
||||||
|
if err = stream.WriteJSON(line); err != nil {
|
||||||
|
logrus.Errorf("Error streaming build logs. %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
size += int64(len(line.Out))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func NewClientLogger(client client.Client, id int64, rc io.ReadCloser, wc io.WriteCloser, limit int64) LoggerFunc {
|
func NewClientLogger(client client.Client, id int64, rc io.ReadCloser, wc io.WriteCloser, limit int64) LoggerFunc {
|
||||||
var once sync.Once
|
var once sync.Once
|
||||||
var size int64
|
var size int64
|
||||||
|
|
|
@ -102,6 +102,10 @@ type Client interface {
|
||||||
// Stream streams the build logs to the server.
|
// Stream streams the build logs to the server.
|
||||||
Stream(int64, io.ReadCloser) error
|
Stream(int64, io.ReadCloser) error
|
||||||
|
|
||||||
|
LogStream(int64) (StreamWriter, error)
|
||||||
|
|
||||||
|
LogPost(int64, io.ReadCloser) error
|
||||||
|
|
||||||
// Wait waits for the job to the complete.
|
// Wait waits for the job to the complete.
|
||||||
Wait(int64) *Wait
|
Wait(int64) *Wait
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
|
|
||||||
"github.com/drone/drone/model"
|
"github.com/drone/drone/model"
|
||||||
"github.com/drone/drone/queue"
|
"github.com/drone/drone/queue"
|
||||||
|
"github.com/gorilla/websocket"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"golang.org/x/net/context/ctxhttp"
|
"golang.org/x/net/context/ctxhttp"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
|
@ -24,6 +25,8 @@ const (
|
||||||
pathStream = "%s/api/queue/stream/%d"
|
pathStream = "%s/api/queue/stream/%d"
|
||||||
pathPush = "%s/api/queue/status/%d"
|
pathPush = "%s/api/queue/status/%d"
|
||||||
pathPing = "%s/api/queue/ping"
|
pathPing = "%s/api/queue/ping"
|
||||||
|
pathLogs = "%s/api/queue/logs/%d"
|
||||||
|
pathLogsAuth = "%s/api/queue/logs/%d?access_token=%s"
|
||||||
|
|
||||||
pathSelf = "%s/api/user"
|
pathSelf = "%s/api/user"
|
||||||
pathFeed = "%s/api/user/feed"
|
pathFeed = "%s/api/user/feed"
|
||||||
|
@ -48,12 +51,13 @@ const (
|
||||||
|
|
||||||
type client struct {
|
type client struct {
|
||||||
client *http.Client
|
client *http.Client
|
||||||
|
token string // auth token
|
||||||
base string // base url
|
base string // base url
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClient returns a client at the specified url.
|
// NewClient returns a client at the specified url.
|
||||||
func NewClient(uri string) Client {
|
func NewClient(uri string) Client {
|
||||||
return &client{http.DefaultClient, uri}
|
return &client{client: http.DefaultClient, base: uri}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClientToken returns a client at the specified url that authenticates all
|
// NewClientToken returns a client at the specified url that authenticates all
|
||||||
|
@ -61,7 +65,7 @@ func NewClient(uri string) Client {
|
||||||
func NewClientToken(uri, token string) Client {
|
func NewClientToken(uri, token string) Client {
|
||||||
config := new(oauth2.Config)
|
config := new(oauth2.Config)
|
||||||
auther := config.Client(oauth2.NoContext, &oauth2.Token{AccessToken: token})
|
auther := config.Client(oauth2.NoContext, &oauth2.Token{AccessToken: token})
|
||||||
return &client{auther, uri}
|
return &client{client: auther, base: uri, token: token}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClientTokenTLS returns a client at the specified url that authenticates
|
// NewClientTokenTLS returns a client at the specified url that authenticates
|
||||||
|
@ -74,7 +78,7 @@ func NewClientTokenTLS(uri, token string, c *tls.Config) Client {
|
||||||
trans.Base = &http.Transport{TLSClientConfig: c}
|
trans.Base = &http.Transport{TLSClientConfig: c}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &client{auther, uri}
|
return &client{client: auther, base: uri, token: token}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Self returns the currently authenticated user.
|
// Self returns the currently authenticated user.
|
||||||
|
@ -304,9 +308,42 @@ func (c *client) Ping() error {
|
||||||
func (c *client) Stream(id int64, rc io.ReadCloser) error {
|
func (c *client) Stream(id int64, rc io.ReadCloser) error {
|
||||||
uri := fmt.Sprintf(pathStream, c.base, id)
|
uri := fmt.Sprintf(pathStream, c.base, id)
|
||||||
err := c.post(uri, rc, nil)
|
err := c.post(uri, rc, nil)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LogPost sends the full build logs to the server.
|
||||||
|
func (c *client) LogPost(id int64, rc io.ReadCloser) error {
|
||||||
|
uri := fmt.Sprintf(pathLogs, c.base, id)
|
||||||
|
return c.post(uri, rc, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StreamWriter implements a special writer for streaming log entries to the
|
||||||
|
// central Drone server. The standard implementation is the gorilla.Connection.
|
||||||
|
type StreamWriter interface {
|
||||||
|
Close() error
|
||||||
|
WriteJSON(interface{}) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogStream streams the build logs to the server.
|
||||||
|
func (c *client) LogStream(id int64) (StreamWriter, error) {
|
||||||
|
rawurl := fmt.Sprintf(pathLogsAuth, c.base, id, c.token)
|
||||||
|
uri, err := url.Parse(rawurl)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if uri.Scheme == "https" {
|
||||||
|
uri.Scheme = "wss"
|
||||||
|
} else {
|
||||||
|
uri.Scheme = "ws"
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO need TLS client configuration
|
||||||
|
|
||||||
|
conn, _, err := websocket.DefaultDialer.Dial(uri.String(), nil)
|
||||||
|
return conn, err
|
||||||
|
}
|
||||||
|
|
||||||
// Wait watches and waits for the build to cancel or finish.
|
// Wait watches and waits for the build to cancel or finish.
|
||||||
func (c *client) Wait(id int64) *Wait {
|
func (c *client) Wait(id int64) *Wait {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package agent
|
package agent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"bytes"
|
||||||
|
"io/ioutil"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
|
@ -40,15 +41,23 @@ func (r *pipeline) run() error {
|
||||||
engine := docker.NewClient(r.docker)
|
engine := docker.NewClient(r.docker)
|
||||||
|
|
||||||
// streaming the logs
|
// streaming the logs
|
||||||
rc, wc := io.Pipe()
|
// rc, wc := io.Pipe()
|
||||||
defer func() {
|
// defer func() {
|
||||||
wc.Close()
|
// wc.Close()
|
||||||
rc.Close()
|
// rc.Close()
|
||||||
}()
|
// }()
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
stream, err := r.drone.LogStream(w.Job.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
a := agent.Agent{
|
a := agent.Agent{
|
||||||
Update: agent.NewClientUpdater(r.drone),
|
Update: agent.NewClientUpdater(r.drone),
|
||||||
Logger: agent.NewClientLogger(r.drone, w.Job.ID, rc, wc, r.config.logs),
|
// Logger: agent.NewClientLogger(r.drone, w.Job.ID, rc, wc, r.config.logs),
|
||||||
|
Logger: agent.NewStreamLogger(stream, &buf, r.config.logs),
|
||||||
Engine: engine,
|
Engine: engine,
|
||||||
Timeout: r.config.timeout,
|
Timeout: r.config.timeout,
|
||||||
Platform: r.config.platform,
|
Platform: r.config.platform,
|
||||||
|
@ -70,8 +79,11 @@ func (r *pipeline) run() error {
|
||||||
|
|
||||||
a.Run(w, cancel)
|
a.Run(w, cancel)
|
||||||
|
|
||||||
wc.Close()
|
if err := r.drone.LogPost(w.Job.ID, ioutil.NopCloser(&buf)); err != nil {
|
||||||
rc.Close()
|
logrus.Errorf("Error sending logs for %s/%s#%d.%d",
|
||||||
|
w.Repo.Owner, w.Repo.Name, w.Build.Number, w.Job.Number)
|
||||||
|
}
|
||||||
|
stream.Close()
|
||||||
|
|
||||||
logrus.Infof("Finished build %s/%s#%d.%d",
|
logrus.Infof("Finished build %s/%s#%d.%d",
|
||||||
w.Repo.Owner, w.Repo.Name, w.Build.Number, w.Job.Number)
|
w.Repo.Owner, w.Repo.Name, w.Build.Number, w.Job.Number)
|
||||||
|
|
|
@ -156,6 +156,9 @@ func Load(middleware ...gin.HandlerFunc) http.Handler {
|
||||||
queue.POST("/stream/:id", server.Stream)
|
queue.POST("/stream/:id", server.Stream)
|
||||||
queue.POST("/status/:id", server.Update)
|
queue.POST("/status/:id", server.Update)
|
||||||
queue.POST("/ping", server.Ping)
|
queue.POST("/ping", server.Ping)
|
||||||
|
|
||||||
|
queue.POST("/logs/:id", server.PostLogs)
|
||||||
|
queue.GET("/logs/:id", server.WriteLogs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DELETE THESE
|
// DELETE THESE
|
||||||
|
|
115
server/queue.go
115
server/queue.go
|
@ -3,6 +3,7 @@ package server
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -15,6 +16,7 @@ import (
|
||||||
"github.com/drone/drone/store"
|
"github.com/drone/drone/store"
|
||||||
"github.com/drone/drone/stream"
|
"github.com/drone/drone/stream"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/gorilla/websocket"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Pull is a long request that polls and attemts to pull work off the queue stack.
|
// Pull is a long request that polls and attemts to pull work off the queue stack.
|
||||||
|
@ -25,6 +27,12 @@ func Pull(c *gin.Context) {
|
||||||
if w == nil {
|
if w == nil {
|
||||||
logrus.Debugf("Agent %s could not pull work.", c.ClientIP())
|
logrus.Debugf("Agent %s could not pull work.", c.ClientIP())
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
// setup the channel to stream logs
|
||||||
|
if err := stream.Create(c, stream.ToKey(w.Job.ID)); err != nil {
|
||||||
|
logrus.Errorf("Unable to create stream. %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
c.JSON(202, w)
|
c.JSON(202, w)
|
||||||
|
|
||||||
logrus.Debugf("Agent %s assigned work. %s/%s#%d.%d",
|
logrus.Debugf("Agent %s assigned work. %s/%s#%d.%d",
|
||||||
|
@ -99,12 +107,12 @@ func Update(c *gin.Context) {
|
||||||
store.UpdateBuild(c, build)
|
store.UpdateBuild(c, build)
|
||||||
}
|
}
|
||||||
|
|
||||||
if job.Status == model.StatusRunning {
|
// if job.Status == model.StatusRunning {
|
||||||
err := stream.Create(c, stream.ToKey(job.ID))
|
// err := stream.Create(c, stream.ToKey(job.ID))
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
logrus.Errorf("Unable to create stream. %s", err)
|
// logrus.Errorf("Unable to create stream. %s", err)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
ok, err := store.UpdateBuildJob(c, build, job)
|
ok, err := store.UpdateBuildJob(c, build, job)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -199,3 +207,98 @@ func Ping(c *gin.Context) {
|
||||||
}
|
}
|
||||||
c.String(200, "PONG")
|
c.String(200, "PONG")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Below are alternate implementations for the Queue that use websockets.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
// PostLogs handles an http request from the agent to post build logs. These
|
||||||
|
// logs are posted at the end of the build process.
|
||||||
|
func PostLogs(c *gin.Context) {
|
||||||
|
id, _ := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||||
|
job, err := store.GetJob(c, id)
|
||||||
|
if err != nil {
|
||||||
|
c.String(404, "Cannot upload logs. %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := store.WriteLog(c, job, c.Request.Body); err != nil {
|
||||||
|
c.String(500, "Cannot persist logs", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.String(200, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteLogs handles an http request from the agent to stream build logs from
|
||||||
|
// the agent to the server to enable real time streamings to the client.
|
||||||
|
func WriteLogs(c *gin.Context) {
|
||||||
|
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
c.String(500, "Invalid input. %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
conn, err := upgrader.Upgrade(c.Writer, c.Request, nil)
|
||||||
|
if err != nil {
|
||||||
|
c.String(500, "Cannot upgrade to websocket. %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
wc, err := stream.Writer(c, stream.ToKey(id))
|
||||||
|
if err != nil {
|
||||||
|
c.String(500, "Cannot create stream writer. %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
wc.Close()
|
||||||
|
stream.Delete(c, stream.ToKey(id))
|
||||||
|
}()
|
||||||
|
|
||||||
|
var msg []byte
|
||||||
|
for {
|
||||||
|
_, msg, err = conn.ReadMessage()
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
wc.Write(msg)
|
||||||
|
wc.Write(newline)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil && err != io.EOF {
|
||||||
|
c.String(500, "Error reading logs. %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// rc, err := stream.Reader(c, stream.ToKey(id))
|
||||||
|
// if err != nil {
|
||||||
|
// c.String(500, "Failed to create stream reader. %s", err)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// wg := sync.WaitGroup{}
|
||||||
|
// wg.Add(1)
|
||||||
|
//
|
||||||
|
// go func() {
|
||||||
|
// defer recover()
|
||||||
|
// store.WriteLog(c, &model.Job{ID: id}, rc)
|
||||||
|
// wg.Done()
|
||||||
|
// }()
|
||||||
|
//
|
||||||
|
// wc.Close()
|
||||||
|
// wg.Wait()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// newline defines a newline constant to separate lines in the build output
|
||||||
|
var newline = []byte{'\n'}
|
||||||
|
|
||||||
|
// upgrader defines the default behavior for upgrading the websocket.
|
||||||
|
var upgrader = websocket.Upgrader{
|
||||||
|
ReadBufferSize: 1024,
|
||||||
|
WriteBufferSize: 1024,
|
||||||
|
CheckOrigin: func(r *http.Request) bool {
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
8
vendor/github.com/gorilla/websocket/AUTHORS
generated
vendored
Normal file
8
vendor/github.com/gorilla/websocket/AUTHORS
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# This is the official list of Gorilla WebSocket authors for copyright
|
||||||
|
# purposes.
|
||||||
|
#
|
||||||
|
# Please keep the list sorted.
|
||||||
|
|
||||||
|
Gary Burd <gary@beagledreams.com>
|
||||||
|
Joachim Bauch <mail@joachim-bauch.de>
|
||||||
|
|
22
vendor/github.com/gorilla/websocket/LICENSE
generated
vendored
Normal file
22
vendor/github.com/gorilla/websocket/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
Copyright (c) 2013 The Gorilla WebSocket Authors. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
61
vendor/github.com/gorilla/websocket/README.md
generated
vendored
Normal file
61
vendor/github.com/gorilla/websocket/README.md
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
# Gorilla WebSocket
|
||||||
|
|
||||||
|
Gorilla WebSocket is a [Go](http://golang.org/) implementation of the
|
||||||
|
[WebSocket](http://www.rfc-editor.org/rfc/rfc6455.txt) protocol.
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
|
||||||
|
* [API Reference](http://godoc.org/github.com/gorilla/websocket)
|
||||||
|
* [Chat example](https://github.com/gorilla/websocket/tree/master/examples/chat)
|
||||||
|
* [Command example](https://github.com/gorilla/websocket/tree/master/examples/command)
|
||||||
|
* [Client and server example](https://github.com/gorilla/websocket/tree/master/examples/echo)
|
||||||
|
* [File watch example](https://github.com/gorilla/websocket/tree/master/examples/filewatch)
|
||||||
|
|
||||||
|
### Status
|
||||||
|
|
||||||
|
The Gorilla WebSocket package provides a complete and tested implementation of
|
||||||
|
the [WebSocket](http://www.rfc-editor.org/rfc/rfc6455.txt) protocol. The
|
||||||
|
package API is stable.
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
|
||||||
|
go get github.com/gorilla/websocket
|
||||||
|
|
||||||
|
### Protocol Compliance
|
||||||
|
|
||||||
|
The Gorilla WebSocket package passes the server tests in the [Autobahn Test
|
||||||
|
Suite](http://autobahn.ws/testsuite) using the application in the [examples/autobahn
|
||||||
|
subdirectory](https://github.com/gorilla/websocket/tree/master/examples/autobahn).
|
||||||
|
|
||||||
|
### Gorilla WebSocket compared with other packages
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th><a href="http://godoc.org/github.com/gorilla/websocket">github.com/gorilla</a></th>
|
||||||
|
<th><a href="http://godoc.org/golang.org/x/net/websocket">golang.org/x/net</a></th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<tr><td colspan="3"><a href="http://tools.ietf.org/html/rfc6455">RFC 6455</a> Features</td></tr>
|
||||||
|
<tr><td>Passes <a href="http://autobahn.ws/testsuite/">Autobahn Test Suite</a></td><td><a href="https://github.com/gorilla/websocket/tree/master/examples/autobahn">Yes</a></td><td>No</td></tr>
|
||||||
|
<tr><td>Receive <a href="https://tools.ietf.org/html/rfc6455#section-5.4">fragmented</a> message<td>Yes</td><td><a href="https://code.google.com/p/go/issues/detail?id=7632">No</a>, see note 1</td></tr>
|
||||||
|
<tr><td>Send <a href="https://tools.ietf.org/html/rfc6455#section-5.5.1">close</a> message</td><td><a href="http://godoc.org/github.com/gorilla/websocket#hdr-Control_Messages">Yes</a></td><td><a href="https://code.google.com/p/go/issues/detail?id=4588">No</a></td></tr>
|
||||||
|
<tr><td>Send <a href="https://tools.ietf.org/html/rfc6455#section-5.5.2">pings</a> and receive <a href="https://tools.ietf.org/html/rfc6455#section-5.5.3">pongs</a></td><td><a href="http://godoc.org/github.com/gorilla/websocket#hdr-Control_Messages">Yes</a></td><td>No</td></tr>
|
||||||
|
<tr><td>Get the <a href="https://tools.ietf.org/html/rfc6455#section-5.6">type</a> of a received data message</td><td>Yes</td><td>Yes, see note 2</td></tr>
|
||||||
|
<tr><td colspan="3">Other Features</tr></td>
|
||||||
|
<tr><td>Limit size of received message</td><td><a href="http://godoc.org/github.com/gorilla/websocket#Conn.SetReadLimit">Yes</a></td><td><a href="https://code.google.com/p/go/issues/detail?id=5082">No</a></td></tr>
|
||||||
|
<tr><td>Read message using io.Reader</td><td><a href="http://godoc.org/github.com/gorilla/websocket#Conn.NextReader">Yes</a></td><td>No, see note 3</td></tr>
|
||||||
|
<tr><td>Write message using io.WriteCloser</td><td><a href="http://godoc.org/github.com/gorilla/websocket#Conn.NextWriter">Yes</a></td><td>No, see note 3</td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
1. Large messages are fragmented in [Chrome's new WebSocket implementation](http://www.ietf.org/mail-archive/web/hybi/current/msg10503.html).
|
||||||
|
2. The application can get the type of a received data message by implementing
|
||||||
|
a [Codec marshal](http://godoc.org/golang.org/x/net/websocket#Codec.Marshal)
|
||||||
|
function.
|
||||||
|
3. The go.net io.Reader and io.Writer operate across WebSocket frame boundaries.
|
||||||
|
Read returns when the input buffer is full or a frame boundary is
|
||||||
|
encountered. Each call to Write sends a single frame message. The Gorilla
|
||||||
|
io.Reader and io.WriteCloser operate on a single WebSocket message.
|
||||||
|
|
375
vendor/github.com/gorilla/websocket/client.go
generated
vendored
Normal file
375
vendor/github.com/gorilla/websocket/client.go
generated
vendored
Normal file
|
@ -0,0 +1,375 @@
|
||||||
|
// Copyright 2013 The Gorilla WebSocket 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 websocket
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"bytes"
|
||||||
|
"crypto/tls"
|
||||||
|
"encoding/base64"
|
||||||
|
"errors"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ErrBadHandshake is returned when the server response to opening handshake is
|
||||||
|
// invalid.
|
||||||
|
var ErrBadHandshake = errors.New("websocket: bad handshake")
|
||||||
|
|
||||||
|
// NewClient creates a new client connection using the given net connection.
|
||||||
|
// The URL u specifies the host and request URI. Use requestHeader to specify
|
||||||
|
// the origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies
|
||||||
|
// (Cookie). Use the response.Header to get the selected subprotocol
|
||||||
|
// (Sec-WebSocket-Protocol) and cookies (Set-Cookie).
|
||||||
|
//
|
||||||
|
// If the WebSocket handshake fails, ErrBadHandshake is returned along with a
|
||||||
|
// non-nil *http.Response so that callers can handle redirects, authentication,
|
||||||
|
// etc.
|
||||||
|
//
|
||||||
|
// Deprecated: Use Dialer instead.
|
||||||
|
func NewClient(netConn net.Conn, u *url.URL, requestHeader http.Header, readBufSize, writeBufSize int) (c *Conn, response *http.Response, err error) {
|
||||||
|
d := Dialer{
|
||||||
|
ReadBufferSize: readBufSize,
|
||||||
|
WriteBufferSize: writeBufSize,
|
||||||
|
NetDial: func(net, addr string) (net.Conn, error) {
|
||||||
|
return netConn, nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return d.Dial(u.String(), requestHeader)
|
||||||
|
}
|
||||||
|
|
||||||
|
// A Dialer contains options for connecting to WebSocket server.
|
||||||
|
type Dialer struct {
|
||||||
|
// NetDial specifies the dial function for creating TCP connections. If
|
||||||
|
// NetDial is nil, net.Dial is used.
|
||||||
|
NetDial func(network, addr string) (net.Conn, error)
|
||||||
|
|
||||||
|
// Proxy specifies a function to return a proxy for a given
|
||||||
|
// Request. If the function returns a non-nil error, the
|
||||||
|
// request is aborted with the provided error.
|
||||||
|
// If Proxy is nil or returns a nil *URL, no proxy is used.
|
||||||
|
Proxy func(*http.Request) (*url.URL, error)
|
||||||
|
|
||||||
|
// TLSClientConfig specifies the TLS configuration to use with tls.Client.
|
||||||
|
// If nil, the default configuration is used.
|
||||||
|
TLSClientConfig *tls.Config
|
||||||
|
|
||||||
|
// HandshakeTimeout specifies the duration for the handshake to complete.
|
||||||
|
HandshakeTimeout time.Duration
|
||||||
|
|
||||||
|
// Input and output buffer sizes. If the buffer size is zero, then a
|
||||||
|
// default value of 4096 is used.
|
||||||
|
ReadBufferSize, WriteBufferSize int
|
||||||
|
|
||||||
|
// Subprotocols specifies the client's requested subprotocols.
|
||||||
|
Subprotocols []string
|
||||||
|
}
|
||||||
|
|
||||||
|
var errMalformedURL = errors.New("malformed ws or wss URL")
|
||||||
|
|
||||||
|
// parseURL parses the URL.
|
||||||
|
//
|
||||||
|
// This function is a replacement for the standard library url.Parse function.
|
||||||
|
// In Go 1.4 and earlier, url.Parse loses information from the path.
|
||||||
|
func parseURL(s string) (*url.URL, error) {
|
||||||
|
// From the RFC:
|
||||||
|
//
|
||||||
|
// ws-URI = "ws:" "//" host [ ":" port ] path [ "?" query ]
|
||||||
|
// wss-URI = "wss:" "//" host [ ":" port ] path [ "?" query ]
|
||||||
|
|
||||||
|
var u url.URL
|
||||||
|
switch {
|
||||||
|
case strings.HasPrefix(s, "ws://"):
|
||||||
|
u.Scheme = "ws"
|
||||||
|
s = s[len("ws://"):]
|
||||||
|
case strings.HasPrefix(s, "wss://"):
|
||||||
|
u.Scheme = "wss"
|
||||||
|
s = s[len("wss://"):]
|
||||||
|
default:
|
||||||
|
return nil, errMalformedURL
|
||||||
|
}
|
||||||
|
|
||||||
|
if i := strings.Index(s, "?"); i >= 0 {
|
||||||
|
u.RawQuery = s[i+1:]
|
||||||
|
s = s[:i]
|
||||||
|
}
|
||||||
|
|
||||||
|
if i := strings.Index(s, "/"); i >= 0 {
|
||||||
|
u.Opaque = s[i:]
|
||||||
|
s = s[:i]
|
||||||
|
} else {
|
||||||
|
u.Opaque = "/"
|
||||||
|
}
|
||||||
|
|
||||||
|
u.Host = s
|
||||||
|
|
||||||
|
if strings.Contains(u.Host, "@") {
|
||||||
|
// Don't bother parsing user information because user information is
|
||||||
|
// not allowed in websocket URIs.
|
||||||
|
return nil, errMalformedURL
|
||||||
|
}
|
||||||
|
|
||||||
|
return &u, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func hostPortNoPort(u *url.URL) (hostPort, hostNoPort string) {
|
||||||
|
hostPort = u.Host
|
||||||
|
hostNoPort = u.Host
|
||||||
|
if i := strings.LastIndex(u.Host, ":"); i > strings.LastIndex(u.Host, "]") {
|
||||||
|
hostNoPort = hostNoPort[:i]
|
||||||
|
} else {
|
||||||
|
switch u.Scheme {
|
||||||
|
case "wss":
|
||||||
|
hostPort += ":443"
|
||||||
|
case "https":
|
||||||
|
hostPort += ":443"
|
||||||
|
default:
|
||||||
|
hostPort += ":80"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hostPort, hostNoPort
|
||||||
|
}
|
||||||
|
|
||||||
|
// DefaultDialer is a dialer with all fields set to the default zero values.
|
||||||
|
var DefaultDialer = &Dialer{
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dial creates a new client connection. Use requestHeader to specify the
|
||||||
|
// origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies (Cookie).
|
||||||
|
// Use the response.Header to get the selected subprotocol
|
||||||
|
// (Sec-WebSocket-Protocol) and cookies (Set-Cookie).
|
||||||
|
//
|
||||||
|
// If the WebSocket handshake fails, ErrBadHandshake is returned along with a
|
||||||
|
// non-nil *http.Response so that callers can handle redirects, authentication,
|
||||||
|
// etcetera. The response body may not contain the entire response and does not
|
||||||
|
// need to be closed by the application.
|
||||||
|
func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Response, error) {
|
||||||
|
|
||||||
|
if d == nil {
|
||||||
|
d = &Dialer{
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
challengeKey, err := generateChallengeKey()
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
u, err := parseURL(urlStr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch u.Scheme {
|
||||||
|
case "ws":
|
||||||
|
u.Scheme = "http"
|
||||||
|
case "wss":
|
||||||
|
u.Scheme = "https"
|
||||||
|
default:
|
||||||
|
return nil, nil, errMalformedURL
|
||||||
|
}
|
||||||
|
|
||||||
|
if u.User != nil {
|
||||||
|
// User name and password are not allowed in websocket URIs.
|
||||||
|
return nil, nil, errMalformedURL
|
||||||
|
}
|
||||||
|
|
||||||
|
req := &http.Request{
|
||||||
|
Method: "GET",
|
||||||
|
URL: u,
|
||||||
|
Proto: "HTTP/1.1",
|
||||||
|
ProtoMajor: 1,
|
||||||
|
ProtoMinor: 1,
|
||||||
|
Header: make(http.Header),
|
||||||
|
Host: u.Host,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the request headers using the capitalization for names and values in
|
||||||
|
// RFC examples. Although the capitalization shouldn't matter, there are
|
||||||
|
// servers that depend on it. The Header.Set method is not used because the
|
||||||
|
// method canonicalizes the header names.
|
||||||
|
req.Header["Upgrade"] = []string{"websocket"}
|
||||||
|
req.Header["Connection"] = []string{"Upgrade"}
|
||||||
|
req.Header["Sec-WebSocket-Key"] = []string{challengeKey}
|
||||||
|
req.Header["Sec-WebSocket-Version"] = []string{"13"}
|
||||||
|
if len(d.Subprotocols) > 0 {
|
||||||
|
req.Header["Sec-WebSocket-Protocol"] = []string{strings.Join(d.Subprotocols, ", ")}
|
||||||
|
}
|
||||||
|
for k, vs := range requestHeader {
|
||||||
|
switch {
|
||||||
|
case k == "Host":
|
||||||
|
if len(vs) > 0 {
|
||||||
|
req.Host = vs[0]
|
||||||
|
}
|
||||||
|
case k == "Upgrade" ||
|
||||||
|
k == "Connection" ||
|
||||||
|
k == "Sec-Websocket-Key" ||
|
||||||
|
k == "Sec-Websocket-Version" ||
|
||||||
|
(k == "Sec-Websocket-Protocol" && len(d.Subprotocols) > 0):
|
||||||
|
return nil, nil, errors.New("websocket: duplicate header not allowed: " + k)
|
||||||
|
default:
|
||||||
|
req.Header[k] = vs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hostPort, hostNoPort := hostPortNoPort(u)
|
||||||
|
|
||||||
|
var proxyURL *url.URL
|
||||||
|
// Check wether the proxy method has been configured
|
||||||
|
if d.Proxy != nil {
|
||||||
|
proxyURL, err = d.Proxy(req)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var targetHostPort string
|
||||||
|
if proxyURL != nil {
|
||||||
|
targetHostPort, _ = hostPortNoPort(proxyURL)
|
||||||
|
} else {
|
||||||
|
targetHostPort = hostPort
|
||||||
|
}
|
||||||
|
|
||||||
|
var deadline time.Time
|
||||||
|
if d.HandshakeTimeout != 0 {
|
||||||
|
deadline = time.Now().Add(d.HandshakeTimeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
netDial := d.NetDial
|
||||||
|
if netDial == nil {
|
||||||
|
netDialer := &net.Dialer{Deadline: deadline}
|
||||||
|
netDial = netDialer.Dial
|
||||||
|
}
|
||||||
|
|
||||||
|
netConn, err := netDial("tcp", targetHostPort)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if netConn != nil {
|
||||||
|
netConn.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if err := netConn.SetDeadline(deadline); err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if proxyURL != nil {
|
||||||
|
connectHeader := make(http.Header)
|
||||||
|
if user := proxyURL.User; user != nil {
|
||||||
|
proxyUser := user.Username()
|
||||||
|
if proxyPassword, passwordSet := user.Password(); passwordSet {
|
||||||
|
credential := base64.StdEncoding.EncodeToString([]byte(proxyUser + ":" + proxyPassword))
|
||||||
|
connectHeader.Set("Proxy-Authorization", "Basic "+credential)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
connectReq := &http.Request{
|
||||||
|
Method: "CONNECT",
|
||||||
|
URL: &url.URL{Opaque: hostPort},
|
||||||
|
Host: hostPort,
|
||||||
|
Header: connectHeader,
|
||||||
|
}
|
||||||
|
|
||||||
|
connectReq.Write(netConn)
|
||||||
|
|
||||||
|
// Read response.
|
||||||
|
// Okay to use and discard buffered reader here, because
|
||||||
|
// TLS server will not speak until spoken to.
|
||||||
|
br := bufio.NewReader(netConn)
|
||||||
|
resp, err := http.ReadResponse(br, connectReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
f := strings.SplitN(resp.Status, " ", 2)
|
||||||
|
return nil, nil, errors.New(f[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if u.Scheme == "https" {
|
||||||
|
cfg := cloneTLSConfig(d.TLSClientConfig)
|
||||||
|
if cfg.ServerName == "" {
|
||||||
|
cfg.ServerName = hostNoPort
|
||||||
|
}
|
||||||
|
tlsConn := tls.Client(netConn, cfg)
|
||||||
|
netConn = tlsConn
|
||||||
|
if err := tlsConn.Handshake(); err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
if !cfg.InsecureSkipVerify {
|
||||||
|
if err := tlsConn.VerifyHostname(cfg.ServerName); err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
conn := newConn(netConn, false, d.ReadBufferSize, d.WriteBufferSize)
|
||||||
|
|
||||||
|
if err := req.Write(netConn); err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := http.ReadResponse(conn.br, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
if resp.StatusCode != 101 ||
|
||||||
|
!strings.EqualFold(resp.Header.Get("Upgrade"), "websocket") ||
|
||||||
|
!strings.EqualFold(resp.Header.Get("Connection"), "upgrade") ||
|
||||||
|
resp.Header.Get("Sec-Websocket-Accept") != computeAcceptKey(challengeKey) {
|
||||||
|
// Before closing the network connection on return from this
|
||||||
|
// function, slurp up some of the response to aid application
|
||||||
|
// debugging.
|
||||||
|
buf := make([]byte, 1024)
|
||||||
|
n, _ := io.ReadFull(resp.Body, buf)
|
||||||
|
resp.Body = ioutil.NopCloser(bytes.NewReader(buf[:n]))
|
||||||
|
return nil, resp, ErrBadHandshake
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.Body = ioutil.NopCloser(bytes.NewReader([]byte{}))
|
||||||
|
conn.subprotocol = resp.Header.Get("Sec-Websocket-Protocol")
|
||||||
|
|
||||||
|
netConn.SetDeadline(time.Time{})
|
||||||
|
netConn = nil // to avoid close in defer.
|
||||||
|
return conn, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// cloneTLSConfig clones all public fields except the fields
|
||||||
|
// SessionTicketsDisabled and SessionTicketKey. This avoids copying the
|
||||||
|
// sync.Mutex in the sync.Once and makes it safe to call cloneTLSConfig on a
|
||||||
|
// config in active use.
|
||||||
|
func cloneTLSConfig(cfg *tls.Config) *tls.Config {
|
||||||
|
if cfg == nil {
|
||||||
|
return &tls.Config{}
|
||||||
|
}
|
||||||
|
return &tls.Config{
|
||||||
|
Rand: cfg.Rand,
|
||||||
|
Time: cfg.Time,
|
||||||
|
Certificates: cfg.Certificates,
|
||||||
|
NameToCertificate: cfg.NameToCertificate,
|
||||||
|
GetCertificate: cfg.GetCertificate,
|
||||||
|
RootCAs: cfg.RootCAs,
|
||||||
|
NextProtos: cfg.NextProtos,
|
||||||
|
ServerName: cfg.ServerName,
|
||||||
|
ClientAuth: cfg.ClientAuth,
|
||||||
|
ClientCAs: cfg.ClientCAs,
|
||||||
|
InsecureSkipVerify: cfg.InsecureSkipVerify,
|
||||||
|
CipherSuites: cfg.CipherSuites,
|
||||||
|
PreferServerCipherSuites: cfg.PreferServerCipherSuites,
|
||||||
|
ClientSessionCache: cfg.ClientSessionCache,
|
||||||
|
MinVersion: cfg.MinVersion,
|
||||||
|
MaxVersion: cfg.MaxVersion,
|
||||||
|
CurvePreferences: cfg.CurvePreferences,
|
||||||
|
}
|
||||||
|
}
|
950
vendor/github.com/gorilla/websocket/conn.go
generated
vendored
Normal file
950
vendor/github.com/gorilla/websocket/conn.go
generated
vendored
Normal file
|
@ -0,0 +1,950 @@
|
||||||
|
// Copyright 2013 The Gorilla WebSocket 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 websocket
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"math/rand"
|
||||||
|
"net"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
"unicode/utf8"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
maxFrameHeaderSize = 2 + 8 + 4 // Fixed header + length + mask
|
||||||
|
maxControlFramePayloadSize = 125
|
||||||
|
finalBit = 1 << 7
|
||||||
|
maskBit = 1 << 7
|
||||||
|
writeWait = time.Second
|
||||||
|
|
||||||
|
defaultReadBufferSize = 4096
|
||||||
|
defaultWriteBufferSize = 4096
|
||||||
|
|
||||||
|
continuationFrame = 0
|
||||||
|
noFrame = -1
|
||||||
|
)
|
||||||
|
|
||||||
|
// Close codes defined in RFC 6455, section 11.7.
|
||||||
|
const (
|
||||||
|
CloseNormalClosure = 1000
|
||||||
|
CloseGoingAway = 1001
|
||||||
|
CloseProtocolError = 1002
|
||||||
|
CloseUnsupportedData = 1003
|
||||||
|
CloseNoStatusReceived = 1005
|
||||||
|
CloseAbnormalClosure = 1006
|
||||||
|
CloseInvalidFramePayloadData = 1007
|
||||||
|
ClosePolicyViolation = 1008
|
||||||
|
CloseMessageTooBig = 1009
|
||||||
|
CloseMandatoryExtension = 1010
|
||||||
|
CloseInternalServerErr = 1011
|
||||||
|
CloseServiceRestart = 1012
|
||||||
|
CloseTryAgainLater = 1013
|
||||||
|
CloseTLSHandshake = 1015
|
||||||
|
)
|
||||||
|
|
||||||
|
// The message types are defined in RFC 6455, section 11.8.
|
||||||
|
const (
|
||||||
|
// TextMessage denotes a text data message. The text message payload is
|
||||||
|
// interpreted as UTF-8 encoded text data.
|
||||||
|
TextMessage = 1
|
||||||
|
|
||||||
|
// BinaryMessage denotes a binary data message.
|
||||||
|
BinaryMessage = 2
|
||||||
|
|
||||||
|
// CloseMessage denotes a close control message. The optional message
|
||||||
|
// payload contains a numeric code and text. Use the FormatCloseMessage
|
||||||
|
// function to format a close message payload.
|
||||||
|
CloseMessage = 8
|
||||||
|
|
||||||
|
// PingMessage denotes a ping control message. The optional message payload
|
||||||
|
// is UTF-8 encoded text.
|
||||||
|
PingMessage = 9
|
||||||
|
|
||||||
|
// PongMessage denotes a ping control message. The optional message payload
|
||||||
|
// is UTF-8 encoded text.
|
||||||
|
PongMessage = 10
|
||||||
|
)
|
||||||
|
|
||||||
|
// ErrCloseSent is returned when the application writes a message to the
|
||||||
|
// connection after sending a close message.
|
||||||
|
var ErrCloseSent = errors.New("websocket: close sent")
|
||||||
|
|
||||||
|
// ErrReadLimit is returned when reading a message that is larger than the
|
||||||
|
// read limit set for the connection.
|
||||||
|
var ErrReadLimit = errors.New("websocket: read limit exceeded")
|
||||||
|
|
||||||
|
// netError satisfies the net Error interface.
|
||||||
|
type netError struct {
|
||||||
|
msg string
|
||||||
|
temporary bool
|
||||||
|
timeout bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *netError) Error() string { return e.msg }
|
||||||
|
func (e *netError) Temporary() bool { return e.temporary }
|
||||||
|
func (e *netError) Timeout() bool { return e.timeout }
|
||||||
|
|
||||||
|
// CloseError represents close frame.
|
||||||
|
type CloseError struct {
|
||||||
|
|
||||||
|
// Code is defined in RFC 6455, section 11.7.
|
||||||
|
Code int
|
||||||
|
|
||||||
|
// Text is the optional text payload.
|
||||||
|
Text string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *CloseError) Error() string {
|
||||||
|
s := []byte("websocket: close ")
|
||||||
|
s = strconv.AppendInt(s, int64(e.Code), 10)
|
||||||
|
switch e.Code {
|
||||||
|
case CloseNormalClosure:
|
||||||
|
s = append(s, " (normal)"...)
|
||||||
|
case CloseGoingAway:
|
||||||
|
s = append(s, " (going away)"...)
|
||||||
|
case CloseProtocolError:
|
||||||
|
s = append(s, " (protocol error)"...)
|
||||||
|
case CloseUnsupportedData:
|
||||||
|
s = append(s, " (unsupported data)"...)
|
||||||
|
case CloseNoStatusReceived:
|
||||||
|
s = append(s, " (no status)"...)
|
||||||
|
case CloseAbnormalClosure:
|
||||||
|
s = append(s, " (abnormal closure)"...)
|
||||||
|
case CloseInvalidFramePayloadData:
|
||||||
|
s = append(s, " (invalid payload data)"...)
|
||||||
|
case ClosePolicyViolation:
|
||||||
|
s = append(s, " (policy violation)"...)
|
||||||
|
case CloseMessageTooBig:
|
||||||
|
s = append(s, " (message too big)"...)
|
||||||
|
case CloseMandatoryExtension:
|
||||||
|
s = append(s, " (mandatory extension missing)"...)
|
||||||
|
case CloseInternalServerErr:
|
||||||
|
s = append(s, " (internal server error)"...)
|
||||||
|
case CloseTLSHandshake:
|
||||||
|
s = append(s, " (TLS handshake error)"...)
|
||||||
|
}
|
||||||
|
if e.Text != "" {
|
||||||
|
s = append(s, ": "...)
|
||||||
|
s = append(s, e.Text...)
|
||||||
|
}
|
||||||
|
return string(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCloseError returns boolean indicating whether the error is a *CloseError
|
||||||
|
// with one of the specified codes.
|
||||||
|
func IsCloseError(err error, codes ...int) bool {
|
||||||
|
if e, ok := err.(*CloseError); ok {
|
||||||
|
for _, code := range codes {
|
||||||
|
if e.Code == code {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsUnexpectedCloseError returns boolean indicating whether the error is a
|
||||||
|
// *CloseError with a code not in the list of expected codes.
|
||||||
|
func IsUnexpectedCloseError(err error, expectedCodes ...int) bool {
|
||||||
|
if e, ok := err.(*CloseError); ok {
|
||||||
|
for _, code := range expectedCodes {
|
||||||
|
if e.Code == code {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
errWriteTimeout = &netError{msg: "websocket: write timeout", timeout: true, temporary: true}
|
||||||
|
errUnexpectedEOF = &CloseError{Code: CloseAbnormalClosure, Text: io.ErrUnexpectedEOF.Error()}
|
||||||
|
errBadWriteOpCode = errors.New("websocket: bad write message type")
|
||||||
|
errWriteClosed = errors.New("websocket: write closed")
|
||||||
|
errInvalidControlFrame = errors.New("websocket: invalid control frame")
|
||||||
|
)
|
||||||
|
|
||||||
|
func hideTempErr(err error) error {
|
||||||
|
if e, ok := err.(net.Error); ok && e.Temporary() {
|
||||||
|
err = &netError{msg: e.Error(), timeout: e.Timeout()}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func isControl(frameType int) bool {
|
||||||
|
return frameType == CloseMessage || frameType == PingMessage || frameType == PongMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
func isData(frameType int) bool {
|
||||||
|
return frameType == TextMessage || frameType == BinaryMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
var validReceivedCloseCodes = map[int]bool{
|
||||||
|
// see http://www.iana.org/assignments/websocket/websocket.xhtml#close-code-number
|
||||||
|
|
||||||
|
CloseNormalClosure: true,
|
||||||
|
CloseGoingAway: true,
|
||||||
|
CloseProtocolError: true,
|
||||||
|
CloseUnsupportedData: true,
|
||||||
|
CloseNoStatusReceived: false,
|
||||||
|
CloseAbnormalClosure: false,
|
||||||
|
CloseInvalidFramePayloadData: true,
|
||||||
|
ClosePolicyViolation: true,
|
||||||
|
CloseMessageTooBig: true,
|
||||||
|
CloseMandatoryExtension: true,
|
||||||
|
CloseInternalServerErr: true,
|
||||||
|
CloseServiceRestart: true,
|
||||||
|
CloseTryAgainLater: true,
|
||||||
|
CloseTLSHandshake: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
func isValidReceivedCloseCode(code int) bool {
|
||||||
|
return validReceivedCloseCodes[code] || (code >= 3000 && code <= 4999)
|
||||||
|
}
|
||||||
|
|
||||||
|
func maskBytes(key [4]byte, pos int, b []byte) int {
|
||||||
|
for i := range b {
|
||||||
|
b[i] ^= key[pos&3]
|
||||||
|
pos++
|
||||||
|
}
|
||||||
|
return pos & 3
|
||||||
|
}
|
||||||
|
|
||||||
|
func newMaskKey() [4]byte {
|
||||||
|
n := rand.Uint32()
|
||||||
|
return [4]byte{byte(n), byte(n >> 8), byte(n >> 16), byte(n >> 24)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conn represents a WebSocket connection.
|
||||||
|
type Conn struct {
|
||||||
|
conn net.Conn
|
||||||
|
isServer bool
|
||||||
|
subprotocol string
|
||||||
|
|
||||||
|
// Write fields
|
||||||
|
mu chan bool // used as mutex to protect write to conn and closeSent
|
||||||
|
closeSent bool // true if close message was sent
|
||||||
|
|
||||||
|
// Message writer fields.
|
||||||
|
writeErr error
|
||||||
|
writeBuf []byte // frame is constructed in this buffer.
|
||||||
|
writePos int // end of data in writeBuf.
|
||||||
|
writeFrameType int // type of the current frame.
|
||||||
|
writeSeq int // incremented to invalidate message writers.
|
||||||
|
writeDeadline time.Time
|
||||||
|
isWriting bool // for best-effort concurrent write detection
|
||||||
|
|
||||||
|
// Read fields
|
||||||
|
readErr error
|
||||||
|
br *bufio.Reader
|
||||||
|
readRemaining int64 // bytes remaining in current frame.
|
||||||
|
readFinal bool // true the current message has more frames.
|
||||||
|
readSeq int // incremented to invalidate message readers.
|
||||||
|
readLength int64 // Message size.
|
||||||
|
readLimit int64 // Maximum message size.
|
||||||
|
readMaskPos int
|
||||||
|
readMaskKey [4]byte
|
||||||
|
handlePong func(string) error
|
||||||
|
handlePing func(string) error
|
||||||
|
readErrCount int
|
||||||
|
}
|
||||||
|
|
||||||
|
func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int) *Conn {
|
||||||
|
mu := make(chan bool, 1)
|
||||||
|
mu <- true
|
||||||
|
|
||||||
|
if readBufferSize == 0 {
|
||||||
|
readBufferSize = defaultReadBufferSize
|
||||||
|
}
|
||||||
|
if writeBufferSize == 0 {
|
||||||
|
writeBufferSize = defaultWriteBufferSize
|
||||||
|
}
|
||||||
|
|
||||||
|
c := &Conn{
|
||||||
|
isServer: isServer,
|
||||||
|
br: bufio.NewReaderSize(conn, readBufferSize),
|
||||||
|
conn: conn,
|
||||||
|
mu: mu,
|
||||||
|
readFinal: true,
|
||||||
|
writeBuf: make([]byte, writeBufferSize+maxFrameHeaderSize),
|
||||||
|
writeFrameType: noFrame,
|
||||||
|
writePos: maxFrameHeaderSize,
|
||||||
|
}
|
||||||
|
c.SetPingHandler(nil)
|
||||||
|
c.SetPongHandler(nil)
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subprotocol returns the negotiated protocol for the connection.
|
||||||
|
func (c *Conn) Subprotocol() string {
|
||||||
|
return c.subprotocol
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close closes the underlying network connection without sending or waiting for a close frame.
|
||||||
|
func (c *Conn) Close() error {
|
||||||
|
return c.conn.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalAddr returns the local network address.
|
||||||
|
func (c *Conn) LocalAddr() net.Addr {
|
||||||
|
return c.conn.LocalAddr()
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoteAddr returns the remote network address.
|
||||||
|
func (c *Conn) RemoteAddr() net.Addr {
|
||||||
|
return c.conn.RemoteAddr()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write methods
|
||||||
|
|
||||||
|
func (c *Conn) write(frameType int, deadline time.Time, bufs ...[]byte) error {
|
||||||
|
<-c.mu
|
||||||
|
defer func() { c.mu <- true }()
|
||||||
|
|
||||||
|
if c.closeSent {
|
||||||
|
return ErrCloseSent
|
||||||
|
} else if frameType == CloseMessage {
|
||||||
|
c.closeSent = true
|
||||||
|
}
|
||||||
|
|
||||||
|
c.conn.SetWriteDeadline(deadline)
|
||||||
|
for _, buf := range bufs {
|
||||||
|
if len(buf) > 0 {
|
||||||
|
n, err := c.conn.Write(buf)
|
||||||
|
if n != len(buf) {
|
||||||
|
// Close on partial write.
|
||||||
|
c.conn.Close()
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteControl writes a control message with the given deadline. The allowed
|
||||||
|
// message types are CloseMessage, PingMessage and PongMessage.
|
||||||
|
func (c *Conn) WriteControl(messageType int, data []byte, deadline time.Time) error {
|
||||||
|
if !isControl(messageType) {
|
||||||
|
return errBadWriteOpCode
|
||||||
|
}
|
||||||
|
if len(data) > maxControlFramePayloadSize {
|
||||||
|
return errInvalidControlFrame
|
||||||
|
}
|
||||||
|
|
||||||
|
b0 := byte(messageType) | finalBit
|
||||||
|
b1 := byte(len(data))
|
||||||
|
if !c.isServer {
|
||||||
|
b1 |= maskBit
|
||||||
|
}
|
||||||
|
|
||||||
|
buf := make([]byte, 0, maxFrameHeaderSize+maxControlFramePayloadSize)
|
||||||
|
buf = append(buf, b0, b1)
|
||||||
|
|
||||||
|
if c.isServer {
|
||||||
|
buf = append(buf, data...)
|
||||||
|
} else {
|
||||||
|
key := newMaskKey()
|
||||||
|
buf = append(buf, key[:]...)
|
||||||
|
buf = append(buf, data...)
|
||||||
|
maskBytes(key, 0, buf[6:])
|
||||||
|
}
|
||||||
|
|
||||||
|
d := time.Hour * 1000
|
||||||
|
if !deadline.IsZero() {
|
||||||
|
d = deadline.Sub(time.Now())
|
||||||
|
if d < 0 {
|
||||||
|
return errWriteTimeout
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
timer := time.NewTimer(d)
|
||||||
|
select {
|
||||||
|
case <-c.mu:
|
||||||
|
timer.Stop()
|
||||||
|
case <-timer.C:
|
||||||
|
return errWriteTimeout
|
||||||
|
}
|
||||||
|
defer func() { c.mu <- true }()
|
||||||
|
|
||||||
|
if c.closeSent {
|
||||||
|
return ErrCloseSent
|
||||||
|
} else if messageType == CloseMessage {
|
||||||
|
c.closeSent = true
|
||||||
|
}
|
||||||
|
|
||||||
|
c.conn.SetWriteDeadline(deadline)
|
||||||
|
n, err := c.conn.Write(buf)
|
||||||
|
if n != 0 && n != len(buf) {
|
||||||
|
c.conn.Close()
|
||||||
|
}
|
||||||
|
return hideTempErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NextWriter returns a writer for the next message to send. The writer's
|
||||||
|
// Close method flushes the complete message to the network.
|
||||||
|
//
|
||||||
|
// There can be at most one open writer on a connection. NextWriter closes the
|
||||||
|
// previous writer if the application has not already done so.
|
||||||
|
func (c *Conn) NextWriter(messageType int) (io.WriteCloser, error) {
|
||||||
|
if c.writeErr != nil {
|
||||||
|
return nil, c.writeErr
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.writeFrameType != noFrame {
|
||||||
|
if err := c.flushFrame(true, nil); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !isControl(messageType) && !isData(messageType) {
|
||||||
|
return nil, errBadWriteOpCode
|
||||||
|
}
|
||||||
|
|
||||||
|
c.writeFrameType = messageType
|
||||||
|
return messageWriter{c, c.writeSeq}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Conn) flushFrame(final bool, extra []byte) error {
|
||||||
|
length := c.writePos - maxFrameHeaderSize + len(extra)
|
||||||
|
|
||||||
|
// Check for invalid control frames.
|
||||||
|
if isControl(c.writeFrameType) &&
|
||||||
|
(!final || length > maxControlFramePayloadSize) {
|
||||||
|
c.writeSeq++
|
||||||
|
c.writeFrameType = noFrame
|
||||||
|
c.writePos = maxFrameHeaderSize
|
||||||
|
return errInvalidControlFrame
|
||||||
|
}
|
||||||
|
|
||||||
|
b0 := byte(c.writeFrameType)
|
||||||
|
if final {
|
||||||
|
b0 |= finalBit
|
||||||
|
}
|
||||||
|
b1 := byte(0)
|
||||||
|
if !c.isServer {
|
||||||
|
b1 |= maskBit
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assume that the frame starts at beginning of c.writeBuf.
|
||||||
|
framePos := 0
|
||||||
|
if c.isServer {
|
||||||
|
// Adjust up if mask not included in the header.
|
||||||
|
framePos = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case length >= 65536:
|
||||||
|
c.writeBuf[framePos] = b0
|
||||||
|
c.writeBuf[framePos+1] = b1 | 127
|
||||||
|
binary.BigEndian.PutUint64(c.writeBuf[framePos+2:], uint64(length))
|
||||||
|
case length > 125:
|
||||||
|
framePos += 6
|
||||||
|
c.writeBuf[framePos] = b0
|
||||||
|
c.writeBuf[framePos+1] = b1 | 126
|
||||||
|
binary.BigEndian.PutUint16(c.writeBuf[framePos+2:], uint16(length))
|
||||||
|
default:
|
||||||
|
framePos += 8
|
||||||
|
c.writeBuf[framePos] = b0
|
||||||
|
c.writeBuf[framePos+1] = b1 | byte(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !c.isServer {
|
||||||
|
key := newMaskKey()
|
||||||
|
copy(c.writeBuf[maxFrameHeaderSize-4:], key[:])
|
||||||
|
maskBytes(key, 0, c.writeBuf[maxFrameHeaderSize:c.writePos])
|
||||||
|
if len(extra) > 0 {
|
||||||
|
c.writeErr = errors.New("websocket: internal error, extra used in client mode")
|
||||||
|
return c.writeErr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write the buffers to the connection with best-effort detection of
|
||||||
|
// concurrent writes. See the concurrency section in the package
|
||||||
|
// documentation for more info.
|
||||||
|
|
||||||
|
if c.isWriting {
|
||||||
|
panic("concurrent write to websocket connection")
|
||||||
|
}
|
||||||
|
c.isWriting = true
|
||||||
|
|
||||||
|
c.writeErr = c.write(c.writeFrameType, c.writeDeadline, c.writeBuf[framePos:c.writePos], extra)
|
||||||
|
|
||||||
|
if !c.isWriting {
|
||||||
|
panic("concurrent write to websocket connection")
|
||||||
|
}
|
||||||
|
c.isWriting = false
|
||||||
|
|
||||||
|
// Setup for next frame.
|
||||||
|
c.writePos = maxFrameHeaderSize
|
||||||
|
c.writeFrameType = continuationFrame
|
||||||
|
if final {
|
||||||
|
c.writeSeq++
|
||||||
|
c.writeFrameType = noFrame
|
||||||
|
}
|
||||||
|
return c.writeErr
|
||||||
|
}
|
||||||
|
|
||||||
|
type messageWriter struct {
|
||||||
|
c *Conn
|
||||||
|
seq int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w messageWriter) err() error {
|
||||||
|
c := w.c
|
||||||
|
if c.writeSeq != w.seq {
|
||||||
|
return errWriteClosed
|
||||||
|
}
|
||||||
|
if c.writeErr != nil {
|
||||||
|
return c.writeErr
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w messageWriter) ncopy(max int) (int, error) {
|
||||||
|
n := len(w.c.writeBuf) - w.c.writePos
|
||||||
|
if n <= 0 {
|
||||||
|
if err := w.c.flushFrame(false, nil); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
n = len(w.c.writeBuf) - w.c.writePos
|
||||||
|
}
|
||||||
|
if n > max {
|
||||||
|
n = max
|
||||||
|
}
|
||||||
|
return n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w messageWriter) write(final bool, p []byte) (int, error) {
|
||||||
|
if err := w.err(); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(p) > 2*len(w.c.writeBuf) && w.c.isServer {
|
||||||
|
// Don't buffer large messages.
|
||||||
|
err := w.c.flushFrame(final, p)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return len(p), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
nn := len(p)
|
||||||
|
for len(p) > 0 {
|
||||||
|
n, err := w.ncopy(len(p))
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
copy(w.c.writeBuf[w.c.writePos:], p[:n])
|
||||||
|
w.c.writePos += n
|
||||||
|
p = p[n:]
|
||||||
|
}
|
||||||
|
return nn, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w messageWriter) Write(p []byte) (int, error) {
|
||||||
|
return w.write(false, p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w messageWriter) WriteString(p string) (int, error) {
|
||||||
|
if err := w.err(); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
nn := len(p)
|
||||||
|
for len(p) > 0 {
|
||||||
|
n, err := w.ncopy(len(p))
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
copy(w.c.writeBuf[w.c.writePos:], p[:n])
|
||||||
|
w.c.writePos += n
|
||||||
|
p = p[n:]
|
||||||
|
}
|
||||||
|
return nn, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w messageWriter) ReadFrom(r io.Reader) (nn int64, err error) {
|
||||||
|
if err := w.err(); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
if w.c.writePos == len(w.c.writeBuf) {
|
||||||
|
err = w.c.flushFrame(false, nil)
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var n int
|
||||||
|
n, err = r.Read(w.c.writeBuf[w.c.writePos:])
|
||||||
|
w.c.writePos += n
|
||||||
|
nn += int64(n)
|
||||||
|
if err != nil {
|
||||||
|
if err == io.EOF {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nn, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w messageWriter) Close() error {
|
||||||
|
if err := w.err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return w.c.flushFrame(true, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteMessage is a helper method for getting a writer using NextWriter,
|
||||||
|
// writing the message and closing the writer.
|
||||||
|
func (c *Conn) WriteMessage(messageType int, data []byte) error {
|
||||||
|
wr, err := c.NextWriter(messageType)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
w := wr.(messageWriter)
|
||||||
|
if _, err := w.write(true, data); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if c.writeSeq == w.seq {
|
||||||
|
if err := c.flushFrame(true, nil); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetWriteDeadline sets the write deadline on the underlying network
|
||||||
|
// connection. After a write has timed out, the websocket state is corrupt and
|
||||||
|
// all future writes will return an error. A zero value for t means writes will
|
||||||
|
// not time out.
|
||||||
|
func (c *Conn) SetWriteDeadline(t time.Time) error {
|
||||||
|
c.writeDeadline = t
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read methods
|
||||||
|
|
||||||
|
// readFull is like io.ReadFull except that io.EOF is never returned.
|
||||||
|
func (c *Conn) readFull(p []byte) (err error) {
|
||||||
|
var n int
|
||||||
|
for n < len(p) && err == nil {
|
||||||
|
var nn int
|
||||||
|
nn, err = c.br.Read(p[n:])
|
||||||
|
n += nn
|
||||||
|
}
|
||||||
|
if n == len(p) {
|
||||||
|
err = nil
|
||||||
|
} else if err == io.EOF {
|
||||||
|
err = errUnexpectedEOF
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Conn) advanceFrame() (int, error) {
|
||||||
|
|
||||||
|
// 1. Skip remainder of previous frame.
|
||||||
|
|
||||||
|
if c.readRemaining > 0 {
|
||||||
|
if _, err := io.CopyN(ioutil.Discard, c.br, c.readRemaining); err != nil {
|
||||||
|
return noFrame, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Read and parse first two bytes of frame header.
|
||||||
|
|
||||||
|
var b [8]byte
|
||||||
|
if err := c.readFull(b[:2]); err != nil {
|
||||||
|
return noFrame, err
|
||||||
|
}
|
||||||
|
|
||||||
|
final := b[0]&finalBit != 0
|
||||||
|
frameType := int(b[0] & 0xf)
|
||||||
|
reserved := int((b[0] >> 4) & 0x7)
|
||||||
|
mask := b[1]&maskBit != 0
|
||||||
|
c.readRemaining = int64(b[1] & 0x7f)
|
||||||
|
|
||||||
|
if reserved != 0 {
|
||||||
|
return noFrame, c.handleProtocolError("unexpected reserved bits " + strconv.Itoa(reserved))
|
||||||
|
}
|
||||||
|
|
||||||
|
switch frameType {
|
||||||
|
case CloseMessage, PingMessage, PongMessage:
|
||||||
|
if c.readRemaining > maxControlFramePayloadSize {
|
||||||
|
return noFrame, c.handleProtocolError("control frame length > 125")
|
||||||
|
}
|
||||||
|
if !final {
|
||||||
|
return noFrame, c.handleProtocolError("control frame not final")
|
||||||
|
}
|
||||||
|
case TextMessage, BinaryMessage:
|
||||||
|
if !c.readFinal {
|
||||||
|
return noFrame, c.handleProtocolError("message start before final message frame")
|
||||||
|
}
|
||||||
|
c.readFinal = final
|
||||||
|
case continuationFrame:
|
||||||
|
if c.readFinal {
|
||||||
|
return noFrame, c.handleProtocolError("continuation after final message frame")
|
||||||
|
}
|
||||||
|
c.readFinal = final
|
||||||
|
default:
|
||||||
|
return noFrame, c.handleProtocolError("unknown opcode " + strconv.Itoa(frameType))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Read and parse frame length.
|
||||||
|
|
||||||
|
switch c.readRemaining {
|
||||||
|
case 126:
|
||||||
|
if err := c.readFull(b[:2]); err != nil {
|
||||||
|
return noFrame, err
|
||||||
|
}
|
||||||
|
c.readRemaining = int64(binary.BigEndian.Uint16(b[:2]))
|
||||||
|
case 127:
|
||||||
|
if err := c.readFull(b[:8]); err != nil {
|
||||||
|
return noFrame, err
|
||||||
|
}
|
||||||
|
c.readRemaining = int64(binary.BigEndian.Uint64(b[:8]))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Handle frame masking.
|
||||||
|
|
||||||
|
if mask != c.isServer {
|
||||||
|
return noFrame, c.handleProtocolError("incorrect mask flag")
|
||||||
|
}
|
||||||
|
|
||||||
|
if mask {
|
||||||
|
c.readMaskPos = 0
|
||||||
|
if err := c.readFull(c.readMaskKey[:]); err != nil {
|
||||||
|
return noFrame, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. For text and binary messages, enforce read limit and return.
|
||||||
|
|
||||||
|
if frameType == continuationFrame || frameType == TextMessage || frameType == BinaryMessage {
|
||||||
|
|
||||||
|
c.readLength += c.readRemaining
|
||||||
|
if c.readLimit > 0 && c.readLength > c.readLimit {
|
||||||
|
c.WriteControl(CloseMessage, FormatCloseMessage(CloseMessageTooBig, ""), time.Now().Add(writeWait))
|
||||||
|
return noFrame, ErrReadLimit
|
||||||
|
}
|
||||||
|
|
||||||
|
return frameType, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. Read control frame payload.
|
||||||
|
|
||||||
|
var payload []byte
|
||||||
|
if c.readRemaining > 0 {
|
||||||
|
payload = make([]byte, c.readRemaining)
|
||||||
|
c.readRemaining = 0
|
||||||
|
if err := c.readFull(payload); err != nil {
|
||||||
|
return noFrame, err
|
||||||
|
}
|
||||||
|
if c.isServer {
|
||||||
|
maskBytes(c.readMaskKey, 0, payload)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. Process control frame payload.
|
||||||
|
|
||||||
|
switch frameType {
|
||||||
|
case PongMessage:
|
||||||
|
if err := c.handlePong(string(payload)); err != nil {
|
||||||
|
return noFrame, err
|
||||||
|
}
|
||||||
|
case PingMessage:
|
||||||
|
if err := c.handlePing(string(payload)); err != nil {
|
||||||
|
return noFrame, err
|
||||||
|
}
|
||||||
|
case CloseMessage:
|
||||||
|
echoMessage := []byte{}
|
||||||
|
closeCode := CloseNoStatusReceived
|
||||||
|
closeText := ""
|
||||||
|
if len(payload) >= 2 {
|
||||||
|
echoMessage = payload[:2]
|
||||||
|
closeCode = int(binary.BigEndian.Uint16(payload))
|
||||||
|
if !isValidReceivedCloseCode(closeCode) {
|
||||||
|
return noFrame, c.handleProtocolError("invalid close code")
|
||||||
|
}
|
||||||
|
closeText = string(payload[2:])
|
||||||
|
if !utf8.ValidString(closeText) {
|
||||||
|
return noFrame, c.handleProtocolError("invalid utf8 payload in close frame")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.WriteControl(CloseMessage, echoMessage, time.Now().Add(writeWait))
|
||||||
|
return noFrame, &CloseError{Code: closeCode, Text: closeText}
|
||||||
|
}
|
||||||
|
|
||||||
|
return frameType, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Conn) handleProtocolError(message string) error {
|
||||||
|
c.WriteControl(CloseMessage, FormatCloseMessage(CloseProtocolError, message), time.Now().Add(writeWait))
|
||||||
|
return errors.New("websocket: " + message)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NextReader returns the next data message received from the peer. The
|
||||||
|
// returned messageType is either TextMessage or BinaryMessage.
|
||||||
|
//
|
||||||
|
// There can be at most one open reader on a connection. NextReader discards
|
||||||
|
// the previous message if the application has not already consumed it.
|
||||||
|
//
|
||||||
|
// Applications must break out of the application's read loop when this method
|
||||||
|
// returns a non-nil error value. Errors returned from this method are
|
||||||
|
// permanent. Once this method returns a non-nil error, all subsequent calls to
|
||||||
|
// this method return the same error.
|
||||||
|
func (c *Conn) NextReader() (messageType int, r io.Reader, err error) {
|
||||||
|
|
||||||
|
c.readSeq++
|
||||||
|
c.readLength = 0
|
||||||
|
|
||||||
|
for c.readErr == nil {
|
||||||
|
frameType, err := c.advanceFrame()
|
||||||
|
if err != nil {
|
||||||
|
c.readErr = hideTempErr(err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if frameType == TextMessage || frameType == BinaryMessage {
|
||||||
|
return frameType, messageReader{c, c.readSeq}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Applications that do handle the error returned from this method spin in
|
||||||
|
// tight loop on connection failure. To help application developers detect
|
||||||
|
// this error, panic on repeated reads to the failed connection.
|
||||||
|
c.readErrCount++
|
||||||
|
if c.readErrCount >= 1000 {
|
||||||
|
panic("repeated read on failed websocket connection")
|
||||||
|
}
|
||||||
|
|
||||||
|
return noFrame, nil, c.readErr
|
||||||
|
}
|
||||||
|
|
||||||
|
type messageReader struct {
|
||||||
|
c *Conn
|
||||||
|
seq int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r messageReader) Read(b []byte) (int, error) {
|
||||||
|
|
||||||
|
if r.seq != r.c.readSeq {
|
||||||
|
return 0, io.EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
for r.c.readErr == nil {
|
||||||
|
|
||||||
|
if r.c.readRemaining > 0 {
|
||||||
|
if int64(len(b)) > r.c.readRemaining {
|
||||||
|
b = b[:r.c.readRemaining]
|
||||||
|
}
|
||||||
|
n, err := r.c.br.Read(b)
|
||||||
|
r.c.readErr = hideTempErr(err)
|
||||||
|
if r.c.isServer {
|
||||||
|
r.c.readMaskPos = maskBytes(r.c.readMaskKey, r.c.readMaskPos, b[:n])
|
||||||
|
}
|
||||||
|
r.c.readRemaining -= int64(n)
|
||||||
|
if r.c.readRemaining > 0 && r.c.readErr == io.EOF {
|
||||||
|
r.c.readErr = errUnexpectedEOF
|
||||||
|
}
|
||||||
|
return n, r.c.readErr
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.c.readFinal {
|
||||||
|
r.c.readSeq++
|
||||||
|
return 0, io.EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
frameType, err := r.c.advanceFrame()
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
r.c.readErr = hideTempErr(err)
|
||||||
|
case frameType == TextMessage || frameType == BinaryMessage:
|
||||||
|
r.c.readErr = errors.New("websocket: internal error, unexpected text or binary in Reader")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err := r.c.readErr
|
||||||
|
if err == io.EOF && r.seq == r.c.readSeq {
|
||||||
|
err = errUnexpectedEOF
|
||||||
|
}
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadMessage is a helper method for getting a reader using NextReader and
|
||||||
|
// reading from that reader to a buffer.
|
||||||
|
func (c *Conn) ReadMessage() (messageType int, p []byte, err error) {
|
||||||
|
var r io.Reader
|
||||||
|
messageType, r, err = c.NextReader()
|
||||||
|
if err != nil {
|
||||||
|
return messageType, nil, err
|
||||||
|
}
|
||||||
|
p, err = ioutil.ReadAll(r)
|
||||||
|
return messageType, p, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetReadDeadline sets the read deadline on the underlying network connection.
|
||||||
|
// After a read has timed out, the websocket connection state is corrupt and
|
||||||
|
// all future reads will return an error. A zero value for t means reads will
|
||||||
|
// not time out.
|
||||||
|
func (c *Conn) SetReadDeadline(t time.Time) error {
|
||||||
|
return c.conn.SetReadDeadline(t)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetReadLimit sets the maximum size for a message read from the peer. If a
|
||||||
|
// message exceeds the limit, the connection sends a close frame to the peer
|
||||||
|
// and returns ErrReadLimit to the application.
|
||||||
|
func (c *Conn) SetReadLimit(limit int64) {
|
||||||
|
c.readLimit = limit
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPingHandler sets the handler for ping messages received from the peer.
|
||||||
|
// The appData argument to h is the PING frame application data. The default
|
||||||
|
// ping handler sends a pong to the peer.
|
||||||
|
func (c *Conn) SetPingHandler(h func(appData string) error) {
|
||||||
|
if h == nil {
|
||||||
|
h = func(message string) error {
|
||||||
|
err := c.WriteControl(PongMessage, []byte(message), time.Now().Add(writeWait))
|
||||||
|
if err == ErrCloseSent {
|
||||||
|
return nil
|
||||||
|
} else if e, ok := err.(net.Error); ok && e.Temporary() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.handlePing = h
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPongHandler sets the handler for pong messages received from the peer.
|
||||||
|
// The appData argument to h is the PONG frame application data. The default
|
||||||
|
// pong handler does nothing.
|
||||||
|
func (c *Conn) SetPongHandler(h func(appData string) error) {
|
||||||
|
if h == nil {
|
||||||
|
h = func(string) error { return nil }
|
||||||
|
}
|
||||||
|
c.handlePong = h
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnderlyingConn returns the internal net.Conn. This can be used to further
|
||||||
|
// modifications to connection specific flags.
|
||||||
|
func (c *Conn) UnderlyingConn() net.Conn {
|
||||||
|
return c.conn
|
||||||
|
}
|
||||||
|
|
||||||
|
// FormatCloseMessage formats closeCode and text as a WebSocket close message.
|
||||||
|
func FormatCloseMessage(closeCode int, text string) []byte {
|
||||||
|
buf := make([]byte, 2+len(text))
|
||||||
|
binary.BigEndian.PutUint16(buf, uint16(closeCode))
|
||||||
|
copy(buf[2:], text)
|
||||||
|
return buf
|
||||||
|
}
|
152
vendor/github.com/gorilla/websocket/doc.go
generated
vendored
Normal file
152
vendor/github.com/gorilla/websocket/doc.go
generated
vendored
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
// Copyright 2013 The Gorilla WebSocket 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 websocket implements the WebSocket protocol defined in RFC 6455.
|
||||||
|
//
|
||||||
|
// Overview
|
||||||
|
//
|
||||||
|
// The Conn type represents a WebSocket connection. A server application uses
|
||||||
|
// the Upgrade function from an Upgrader object with a HTTP request handler
|
||||||
|
// to get a pointer to a Conn:
|
||||||
|
//
|
||||||
|
// var upgrader = websocket.Upgrader{
|
||||||
|
// ReadBufferSize: 1024,
|
||||||
|
// WriteBufferSize: 1024,
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// conn, err := upgrader.Upgrade(w, r, nil)
|
||||||
|
// if err != nil {
|
||||||
|
// log.Println(err)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// ... Use conn to send and receive messages.
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Call the connection's WriteMessage and ReadMessage methods to send and
|
||||||
|
// receive messages as a slice of bytes. This snippet of code shows how to echo
|
||||||
|
// messages using these methods:
|
||||||
|
//
|
||||||
|
// for {
|
||||||
|
// messageType, p, err := conn.ReadMessage()
|
||||||
|
// if err != nil {
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// if err = conn.WriteMessage(messageType, p); err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// In above snippet of code, p is a []byte and messageType is an int with value
|
||||||
|
// websocket.BinaryMessage or websocket.TextMessage.
|
||||||
|
//
|
||||||
|
// An application can also send and receive messages using the io.WriteCloser
|
||||||
|
// and io.Reader interfaces. To send a message, call the connection NextWriter
|
||||||
|
// method to get an io.WriteCloser, write the message to the writer and close
|
||||||
|
// the writer when done. To receive a message, call the connection NextReader
|
||||||
|
// method to get an io.Reader and read until io.EOF is returned. This snippet
|
||||||
|
// shows how to echo messages using the NextWriter and NextReader methods:
|
||||||
|
//
|
||||||
|
// for {
|
||||||
|
// messageType, r, err := conn.NextReader()
|
||||||
|
// if err != nil {
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// w, err := conn.NextWriter(messageType)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// if _, err := io.Copy(w, r); err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// if err := w.Close(); err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Data Messages
|
||||||
|
//
|
||||||
|
// The WebSocket protocol distinguishes between text and binary data messages.
|
||||||
|
// Text messages are interpreted as UTF-8 encoded text. The interpretation of
|
||||||
|
// binary messages is left to the application.
|
||||||
|
//
|
||||||
|
// This package uses the TextMessage and BinaryMessage integer constants to
|
||||||
|
// identify the two data message types. The ReadMessage and NextReader methods
|
||||||
|
// return the type of the received message. The messageType argument to the
|
||||||
|
// WriteMessage and NextWriter methods specifies the type of a sent message.
|
||||||
|
//
|
||||||
|
// It is the application's responsibility to ensure that text messages are
|
||||||
|
// valid UTF-8 encoded text.
|
||||||
|
//
|
||||||
|
// Control Messages
|
||||||
|
//
|
||||||
|
// The WebSocket protocol defines three types of control messages: close, ping
|
||||||
|
// and pong. Call the connection WriteControl, WriteMessage or NextWriter
|
||||||
|
// methods to send a control message to the peer.
|
||||||
|
//
|
||||||
|
// Connections handle received close messages by sending a close message to the
|
||||||
|
// peer and returning a *CloseError from the the NextReader, ReadMessage or the
|
||||||
|
// message Read method.
|
||||||
|
//
|
||||||
|
// Connections handle received ping and pong messages by invoking callback
|
||||||
|
// functions set with SetPingHandler and SetPongHandler methods. The callback
|
||||||
|
// functions are called from the NextReader, ReadMessage and the message Read
|
||||||
|
// methods.
|
||||||
|
//
|
||||||
|
// The default ping handler sends a pong to the peer. The application's reading
|
||||||
|
// goroutine can block for a short time while the handler writes the pong data
|
||||||
|
// to the connection.
|
||||||
|
//
|
||||||
|
// The application must read the connection to process ping, pong and close
|
||||||
|
// messages sent from the peer. If the application is not otherwise interested
|
||||||
|
// in messages from the peer, then the application should start a goroutine to
|
||||||
|
// read and discard messages from the peer. A simple example is:
|
||||||
|
//
|
||||||
|
// func readLoop(c *websocket.Conn) {
|
||||||
|
// for {
|
||||||
|
// if _, _, err := c.NextReader(); err != nil {
|
||||||
|
// c.Close()
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Concurrency
|
||||||
|
//
|
||||||
|
// Connections support one concurrent reader and one concurrent writer.
|
||||||
|
//
|
||||||
|
// Applications are responsible for ensuring that no more than one goroutine
|
||||||
|
// calls the write methods (NextWriter, SetWriteDeadline, WriteMessage,
|
||||||
|
// WriteJSON) concurrently and that no more than one goroutine calls the read
|
||||||
|
// methods (NextReader, SetReadDeadline, ReadMessage, ReadJSON, SetPongHandler,
|
||||||
|
// SetPingHandler) concurrently.
|
||||||
|
//
|
||||||
|
// The Close and WriteControl methods can be called concurrently with all other
|
||||||
|
// methods.
|
||||||
|
//
|
||||||
|
// Origin Considerations
|
||||||
|
//
|
||||||
|
// Web browsers allow Javascript applications to open a WebSocket connection to
|
||||||
|
// any host. It's up to the server to enforce an origin policy using the Origin
|
||||||
|
// request header sent by the browser.
|
||||||
|
//
|
||||||
|
// The Upgrader calls the function specified in the CheckOrigin field to check
|
||||||
|
// the origin. If the CheckOrigin function returns false, then the Upgrade
|
||||||
|
// method fails the WebSocket handshake with HTTP status 403.
|
||||||
|
//
|
||||||
|
// If the CheckOrigin field is nil, then the Upgrader uses a safe default: fail
|
||||||
|
// the handshake if the Origin request header is present and not equal to the
|
||||||
|
// Host request header.
|
||||||
|
//
|
||||||
|
// An application can allow connections from any origin by specifying a
|
||||||
|
// function that always returns true:
|
||||||
|
//
|
||||||
|
// var upgrader = websocket.Upgrader{
|
||||||
|
// CheckOrigin: func(r *http.Request) bool { return true },
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// The deprecated Upgrade function does not enforce an origin policy. It's the
|
||||||
|
// application's responsibility to check the Origin header before calling
|
||||||
|
// Upgrade.
|
||||||
|
package websocket
|
55
vendor/github.com/gorilla/websocket/json.go
generated
vendored
Normal file
55
vendor/github.com/gorilla/websocket/json.go
generated
vendored
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
// Copyright 2013 The Gorilla WebSocket 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 websocket
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
// WriteJSON is deprecated, use c.WriteJSON instead.
|
||||||
|
func WriteJSON(c *Conn, v interface{}) error {
|
||||||
|
return c.WriteJSON(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteJSON writes the JSON encoding of v to the connection.
|
||||||
|
//
|
||||||
|
// See the documentation for encoding/json Marshal for details about the
|
||||||
|
// conversion of Go values to JSON.
|
||||||
|
func (c *Conn) WriteJSON(v interface{}) error {
|
||||||
|
w, err := c.NextWriter(TextMessage)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err1 := json.NewEncoder(w).Encode(v)
|
||||||
|
err2 := w.Close()
|
||||||
|
if err1 != nil {
|
||||||
|
return err1
|
||||||
|
}
|
||||||
|
return err2
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadJSON is deprecated, use c.ReadJSON instead.
|
||||||
|
func ReadJSON(c *Conn, v interface{}) error {
|
||||||
|
return c.ReadJSON(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadJSON reads the next JSON-encoded message from the connection and stores
|
||||||
|
// it in the value pointed to by v.
|
||||||
|
//
|
||||||
|
// See the documentation for the encoding/json Unmarshal function for details
|
||||||
|
// about the conversion of JSON to a Go value.
|
||||||
|
func (c *Conn) ReadJSON(v interface{}) error {
|
||||||
|
_, r, err := c.NextReader()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = json.NewDecoder(r).Decode(v)
|
||||||
|
if err == io.EOF {
|
||||||
|
// One value is expected in the message.
|
||||||
|
err = io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
260
vendor/github.com/gorilla/websocket/server.go
generated
vendored
Normal file
260
vendor/github.com/gorilla/websocket/server.go
generated
vendored
Normal file
|
@ -0,0 +1,260 @@
|
||||||
|
// Copyright 2013 The Gorilla WebSocket 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 websocket
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"errors"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// HandshakeError describes an error with the handshake from the peer.
|
||||||
|
type HandshakeError struct {
|
||||||
|
message string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e HandshakeError) Error() string { return e.message }
|
||||||
|
|
||||||
|
// Upgrader specifies parameters for upgrading an HTTP connection to a
|
||||||
|
// WebSocket connection.
|
||||||
|
type Upgrader struct {
|
||||||
|
// HandshakeTimeout specifies the duration for the handshake to complete.
|
||||||
|
HandshakeTimeout time.Duration
|
||||||
|
|
||||||
|
// ReadBufferSize and WriteBufferSize specify I/O buffer sizes. If a buffer
|
||||||
|
// size is zero, then a default value of 4096 is used. The I/O buffer sizes
|
||||||
|
// do not limit the size of the messages that can be sent or received.
|
||||||
|
ReadBufferSize, WriteBufferSize int
|
||||||
|
|
||||||
|
// Subprotocols specifies the server's supported protocols in order of
|
||||||
|
// preference. If this field is set, then the Upgrade method negotiates a
|
||||||
|
// subprotocol by selecting the first match in this list with a protocol
|
||||||
|
// requested by the client.
|
||||||
|
Subprotocols []string
|
||||||
|
|
||||||
|
// Error specifies the function for generating HTTP error responses. If Error
|
||||||
|
// is nil, then http.Error is used to generate the HTTP response.
|
||||||
|
Error func(w http.ResponseWriter, r *http.Request, status int, reason error)
|
||||||
|
|
||||||
|
// CheckOrigin returns true if the request Origin header is acceptable. If
|
||||||
|
// CheckOrigin is nil, the host in the Origin header must not be set or
|
||||||
|
// must match the host of the request.
|
||||||
|
CheckOrigin func(r *http.Request) bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Upgrader) returnError(w http.ResponseWriter, r *http.Request, status int, reason string) (*Conn, error) {
|
||||||
|
err := HandshakeError{reason}
|
||||||
|
if u.Error != nil {
|
||||||
|
u.Error(w, r, status, err)
|
||||||
|
} else {
|
||||||
|
http.Error(w, http.StatusText(status), status)
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// checkSameOrigin returns true if the origin is not set or is equal to the request host.
|
||||||
|
func checkSameOrigin(r *http.Request) bool {
|
||||||
|
origin := r.Header["Origin"]
|
||||||
|
if len(origin) == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
u, err := url.Parse(origin[0])
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return u.Host == r.Host
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Upgrader) selectSubprotocol(r *http.Request, responseHeader http.Header) string {
|
||||||
|
if u.Subprotocols != nil {
|
||||||
|
clientProtocols := Subprotocols(r)
|
||||||
|
for _, serverProtocol := range u.Subprotocols {
|
||||||
|
for _, clientProtocol := range clientProtocols {
|
||||||
|
if clientProtocol == serverProtocol {
|
||||||
|
return clientProtocol
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if responseHeader != nil {
|
||||||
|
return responseHeader.Get("Sec-Websocket-Protocol")
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// Upgrade upgrades the HTTP server connection to the WebSocket protocol.
|
||||||
|
//
|
||||||
|
// The responseHeader is included in the response to the client's upgrade
|
||||||
|
// request. Use the responseHeader to specify cookies (Set-Cookie) and the
|
||||||
|
// application negotiated subprotocol (Sec-Websocket-Protocol).
|
||||||
|
//
|
||||||
|
// If the upgrade fails, then Upgrade replies to the client with an HTTP error
|
||||||
|
// response.
|
||||||
|
func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*Conn, error) {
|
||||||
|
if r.Method != "GET" {
|
||||||
|
return u.returnError(w, r, http.StatusMethodNotAllowed, "websocket: method not GET")
|
||||||
|
}
|
||||||
|
if values := r.Header["Sec-Websocket-Version"]; len(values) == 0 || values[0] != "13" {
|
||||||
|
return u.returnError(w, r, http.StatusBadRequest, "websocket: version != 13")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !tokenListContainsValue(r.Header, "Connection", "upgrade") {
|
||||||
|
return u.returnError(w, r, http.StatusBadRequest, "websocket: could not find connection header with token 'upgrade'")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !tokenListContainsValue(r.Header, "Upgrade", "websocket") {
|
||||||
|
return u.returnError(w, r, http.StatusBadRequest, "websocket: could not find upgrade header with token 'websocket'")
|
||||||
|
}
|
||||||
|
|
||||||
|
checkOrigin := u.CheckOrigin
|
||||||
|
if checkOrigin == nil {
|
||||||
|
checkOrigin = checkSameOrigin
|
||||||
|
}
|
||||||
|
if !checkOrigin(r) {
|
||||||
|
return u.returnError(w, r, http.StatusForbidden, "websocket: origin not allowed")
|
||||||
|
}
|
||||||
|
|
||||||
|
challengeKey := r.Header.Get("Sec-Websocket-Key")
|
||||||
|
if challengeKey == "" {
|
||||||
|
return u.returnError(w, r, http.StatusBadRequest, "websocket: key missing or blank")
|
||||||
|
}
|
||||||
|
|
||||||
|
subprotocol := u.selectSubprotocol(r, responseHeader)
|
||||||
|
|
||||||
|
var (
|
||||||
|
netConn net.Conn
|
||||||
|
br *bufio.Reader
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
h, ok := w.(http.Hijacker)
|
||||||
|
if !ok {
|
||||||
|
return u.returnError(w, r, http.StatusInternalServerError, "websocket: response does not implement http.Hijacker")
|
||||||
|
}
|
||||||
|
var rw *bufio.ReadWriter
|
||||||
|
netConn, rw, err = h.Hijack()
|
||||||
|
if err != nil {
|
||||||
|
return u.returnError(w, r, http.StatusInternalServerError, err.Error())
|
||||||
|
}
|
||||||
|
br = rw.Reader
|
||||||
|
|
||||||
|
if br.Buffered() > 0 {
|
||||||
|
netConn.Close()
|
||||||
|
return nil, errors.New("websocket: client sent data before handshake is complete")
|
||||||
|
}
|
||||||
|
|
||||||
|
c := newConn(netConn, true, u.ReadBufferSize, u.WriteBufferSize)
|
||||||
|
c.subprotocol = subprotocol
|
||||||
|
|
||||||
|
p := c.writeBuf[:0]
|
||||||
|
p = append(p, "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: "...)
|
||||||
|
p = append(p, computeAcceptKey(challengeKey)...)
|
||||||
|
p = append(p, "\r\n"...)
|
||||||
|
if c.subprotocol != "" {
|
||||||
|
p = append(p, "Sec-Websocket-Protocol: "...)
|
||||||
|
p = append(p, c.subprotocol...)
|
||||||
|
p = append(p, "\r\n"...)
|
||||||
|
}
|
||||||
|
for k, vs := range responseHeader {
|
||||||
|
if k == "Sec-Websocket-Protocol" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, v := range vs {
|
||||||
|
p = append(p, k...)
|
||||||
|
p = append(p, ": "...)
|
||||||
|
for i := 0; i < len(v); i++ {
|
||||||
|
b := v[i]
|
||||||
|
if b <= 31 {
|
||||||
|
// prevent response splitting.
|
||||||
|
b = ' '
|
||||||
|
}
|
||||||
|
p = append(p, b)
|
||||||
|
}
|
||||||
|
p = append(p, "\r\n"...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p = append(p, "\r\n"...)
|
||||||
|
|
||||||
|
// Clear deadlines set by HTTP server.
|
||||||
|
netConn.SetDeadline(time.Time{})
|
||||||
|
|
||||||
|
if u.HandshakeTimeout > 0 {
|
||||||
|
netConn.SetWriteDeadline(time.Now().Add(u.HandshakeTimeout))
|
||||||
|
}
|
||||||
|
if _, err = netConn.Write(p); err != nil {
|
||||||
|
netConn.Close()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if u.HandshakeTimeout > 0 {
|
||||||
|
netConn.SetWriteDeadline(time.Time{})
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Upgrade upgrades the HTTP server connection to the WebSocket protocol.
|
||||||
|
//
|
||||||
|
// This function is deprecated, use websocket.Upgrader instead.
|
||||||
|
//
|
||||||
|
// The application is responsible for checking the request origin before
|
||||||
|
// calling Upgrade. An example implementation of the same origin policy is:
|
||||||
|
//
|
||||||
|
// if req.Header.Get("Origin") != "http://"+req.Host {
|
||||||
|
// http.Error(w, "Origin not allowed", 403)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// If the endpoint supports subprotocols, then the application is responsible
|
||||||
|
// for negotiating the protocol used on the connection. Use the Subprotocols()
|
||||||
|
// function to get the subprotocols requested by the client. Use the
|
||||||
|
// Sec-Websocket-Protocol response header to specify the subprotocol selected
|
||||||
|
// by the application.
|
||||||
|
//
|
||||||
|
// The responseHeader is included in the response to the client's upgrade
|
||||||
|
// request. Use the responseHeader to specify cookies (Set-Cookie) and the
|
||||||
|
// negotiated subprotocol (Sec-Websocket-Protocol).
|
||||||
|
//
|
||||||
|
// The connection buffers IO to the underlying network connection. The
|
||||||
|
// readBufSize and writeBufSize parameters specify the size of the buffers to
|
||||||
|
// use. Messages can be larger than the buffers.
|
||||||
|
//
|
||||||
|
// If the request is not a valid WebSocket handshake, then Upgrade returns an
|
||||||
|
// error of type HandshakeError. Applications should handle this error by
|
||||||
|
// replying to the client with an HTTP error response.
|
||||||
|
func Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header, readBufSize, writeBufSize int) (*Conn, error) {
|
||||||
|
u := Upgrader{ReadBufferSize: readBufSize, WriteBufferSize: writeBufSize}
|
||||||
|
u.Error = func(w http.ResponseWriter, r *http.Request, status int, reason error) {
|
||||||
|
// don't return errors to maintain backwards compatibility
|
||||||
|
}
|
||||||
|
u.CheckOrigin = func(r *http.Request) bool {
|
||||||
|
// allow all connections by default
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return u.Upgrade(w, r, responseHeader)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subprotocols returns the subprotocols requested by the client in the
|
||||||
|
// Sec-Websocket-Protocol header.
|
||||||
|
func Subprotocols(r *http.Request) []string {
|
||||||
|
h := strings.TrimSpace(r.Header.Get("Sec-Websocket-Protocol"))
|
||||||
|
if h == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
protocols := strings.Split(h, ",")
|
||||||
|
for i := range protocols {
|
||||||
|
protocols[i] = strings.TrimSpace(protocols[i])
|
||||||
|
}
|
||||||
|
return protocols
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsWebSocketUpgrade returns true if the client requested upgrade to the
|
||||||
|
// WebSocket protocol.
|
||||||
|
func IsWebSocketUpgrade(r *http.Request) bool {
|
||||||
|
return tokenListContainsValue(r.Header, "Connection", "upgrade") &&
|
||||||
|
tokenListContainsValue(r.Header, "Upgrade", "websocket")
|
||||||
|
}
|
44
vendor/github.com/gorilla/websocket/util.go
generated
vendored
Normal file
44
vendor/github.com/gorilla/websocket/util.go
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
// Copyright 2013 The Gorilla WebSocket 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 websocket
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/rand"
|
||||||
|
"crypto/sha1"
|
||||||
|
"encoding/base64"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// tokenListContainsValue returns true if the 1#token header with the given
|
||||||
|
// name contains token.
|
||||||
|
func tokenListContainsValue(header http.Header, name string, value string) bool {
|
||||||
|
for _, v := range header[name] {
|
||||||
|
for _, s := range strings.Split(v, ",") {
|
||||||
|
if strings.EqualFold(value, strings.TrimSpace(s)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var keyGUID = []byte("258EAFA5-E914-47DA-95CA-C5AB0DC85B11")
|
||||||
|
|
||||||
|
func computeAcceptKey(challengeKey string) string {
|
||||||
|
h := sha1.New()
|
||||||
|
h.Write([]byte(challengeKey))
|
||||||
|
h.Write(keyGUID)
|
||||||
|
return base64.StdEncoding.EncodeToString(h.Sum(nil))
|
||||||
|
}
|
||||||
|
|
||||||
|
func generateChallengeKey() (string, error) {
|
||||||
|
p := make([]byte, 16)
|
||||||
|
if _, err := io.ReadFull(rand.Reader, p); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return base64.StdEncoding.EncodeToString(p), nil
|
||||||
|
}
|
27
vendor/golang.org/x/sys/LICENSE
generated
vendored
Normal file
27
vendor/golang.org/x/sys/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
22
vendor/golang.org/x/sys/PATENTS
generated
vendored
Normal file
22
vendor/golang.org/x/sys/PATENTS
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
Additional IP Rights Grant (Patents)
|
||||||
|
|
||||||
|
"This implementation" means the copyrightable works distributed by
|
||||||
|
Google as part of the Go project.
|
||||||
|
|
||||||
|
Google hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||||
|
no-charge, royalty-free, irrevocable (except as stated in this section)
|
||||||
|
patent license to make, have made, use, offer to sell, sell, import,
|
||||||
|
transfer and otherwise run, modify and propagate the contents of this
|
||||||
|
implementation of Go, where such license applies only to those patent
|
||||||
|
claims, both currently owned or controlled by Google and acquired in
|
||||||
|
the future, licensable by Google that are necessarily infringed by this
|
||||||
|
implementation of Go. This grant does not include claims that would be
|
||||||
|
infringed only as a consequence of further modification of this
|
||||||
|
implementation. If you or your agent or exclusive licensee institute or
|
||||||
|
order or agree to the institution of patent litigation against any
|
||||||
|
entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
||||||
|
that this implementation of Go or any code incorporated within this
|
||||||
|
implementation of Go constitutes direct or contributory patent
|
||||||
|
infringement, or inducement of patent infringement, then any patent
|
||||||
|
rights granted to you under this License for this implementation of Go
|
||||||
|
shall terminate as of the date such litigation is filed.
|
10
vendor/golang.org/x/sys/unix/asm.s
generated
vendored
Normal file
10
vendor/golang.org/x/sys/unix/asm.s
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
TEXT ·use(SB),NOSPLIT,$0
|
||||||
|
RET
|
29
vendor/golang.org/x/sys/unix/asm_darwin_386.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_darwin_386.s
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for 386, Darwin
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_darwin_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_darwin_amd64.s
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for AMD64, Darwin
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
30
vendor/golang.org/x/sys/unix/asm_darwin_arm.s
generated
vendored
Normal file
30
vendor/golang.org/x/sys/unix/asm_darwin_arm.s
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright 2015 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
// +build arm,darwin
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for ARM, Darwin
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
B syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·RawSyscall6(SB)
|
30
vendor/golang.org/x/sys/unix/asm_darwin_arm64.s
generated
vendored
Normal file
30
vendor/golang.org/x/sys/unix/asm_darwin_arm64.s
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright 2015 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
// +build arm64,darwin
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for AMD64, Darwin
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
B syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
B syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_dragonfly_386.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_dragonfly_386.s
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for 386, FreeBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-32
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-44
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-32
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-44
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for AMD64, DragonFly
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-64
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-88
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-112
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-64
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-88
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_freebsd_386.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_freebsd_386.s
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for 386, FreeBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for AMD64, FreeBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_freebsd_arm.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_freebsd_arm.s
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for ARM, FreeBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
B syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·RawSyscall6(SB)
|
35
vendor/golang.org/x/sys/unix/asm_linux_386.s
generated
vendored
Normal file
35
vendor/golang.org/x/sys/unix/asm_linux_386.s
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for 386, Linux
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·socketcall(SB),NOSPLIT,$0-36
|
||||||
|
JMP syscall·socketcall(SB)
|
||||||
|
|
||||||
|
TEXT ·rawsocketcall(SB),NOSPLIT,$0-36
|
||||||
|
JMP syscall·rawsocketcall(SB)
|
||||||
|
|
||||||
|
TEXT ·seek(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·seek(SB)
|
29
vendor/golang.org/x/sys/unix/asm_linux_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_linux_amd64.s
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for AMD64, Linux
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·gettimeofday(SB),NOSPLIT,$0-16
|
||||||
|
JMP syscall·gettimeofday(SB)
|
29
vendor/golang.org/x/sys/unix/asm_linux_arm.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_linux_arm.s
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for arm, Linux
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·RawSyscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·seek(SB),NOSPLIT,$0-32
|
||||||
|
B syscall·seek(SB)
|
24
vendor/golang.org/x/sys/unix/asm_linux_arm64.s
generated
vendored
Normal file
24
vendor/golang.org/x/sys/unix/asm_linux_arm64.s
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// Copyright 2015 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.
|
||||||
|
|
||||||
|
// +build linux
|
||||||
|
// +build arm64
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
B syscall·RawSyscall6(SB)
|
28
vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
generated
vendored
Normal file
28
vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// Copyright 2015 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.
|
||||||
|
|
||||||
|
// +build linux
|
||||||
|
// +build mips64 mips64le
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for mips64, Linux
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
28
vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
generated
vendored
Normal file
28
vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
// +build linux
|
||||||
|
// +build ppc64 ppc64le
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for ppc64, Linux
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
BR syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
BR syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
BR syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
BR syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_netbsd_386.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_netbsd_386.s
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for 386, NetBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for AMD64, NetBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_netbsd_arm.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_netbsd_arm.s
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for ARM, NetBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
B syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_openbsd_386.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_openbsd_386.s
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for 386, OpenBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for AMD64, OpenBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
17
vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
generated
vendored
Normal file
17
vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go
|
||||||
|
//
|
||||||
|
|
||||||
|
TEXT ·sysvicall6(SB),NOSPLIT,$0-64
|
||||||
|
JMP syscall·sysvicall6(SB)
|
||||||
|
|
||||||
|
TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64
|
||||||
|
JMP syscall·rawSysvicall6(SB)
|
35
vendor/golang.org/x/sys/unix/bluetooth_linux.go
generated
vendored
Normal file
35
vendor/golang.org/x/sys/unix/bluetooth_linux.go
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
// Bluetooth sockets and messages
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Bluetooth Protocols
|
||||||
|
const (
|
||||||
|
BTPROTO_L2CAP = 0
|
||||||
|
BTPROTO_HCI = 1
|
||||||
|
BTPROTO_SCO = 2
|
||||||
|
BTPROTO_RFCOMM = 3
|
||||||
|
BTPROTO_BNEP = 4
|
||||||
|
BTPROTO_CMTP = 5
|
||||||
|
BTPROTO_HIDP = 6
|
||||||
|
BTPROTO_AVDTP = 7
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
HCI_CHANNEL_RAW = 0
|
||||||
|
HCI_CHANNEL_USER = 1
|
||||||
|
HCI_CHANNEL_MONITOR = 2
|
||||||
|
HCI_CHANNEL_CONTROL = 3
|
||||||
|
)
|
||||||
|
|
||||||
|
// Socketoption Level
|
||||||
|
const (
|
||||||
|
SOL_BLUETOOTH = 0x112
|
||||||
|
SOL_HCI = 0x0
|
||||||
|
SOL_L2CAP = 0x6
|
||||||
|
SOL_RFCOMM = 0x12
|
||||||
|
SOL_SCO = 0x11
|
||||||
|
)
|
13
vendor/golang.org/x/sys/unix/constants.go
generated
vendored
Normal file
13
vendor/golang.org/x/sys/unix/constants.go
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright 2015 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.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
R_OK = 0x4
|
||||||
|
W_OK = 0x2
|
||||||
|
X_OK = 0x1
|
||||||
|
)
|
27
vendor/golang.org/x/sys/unix/env_unix.go
generated
vendored
Normal file
27
vendor/golang.org/x/sys/unix/env_unix.go
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// Copyright 2010 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.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
// Unix environment variables.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func Getenv(key string) (value string, found bool) {
|
||||||
|
return syscall.Getenv(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Setenv(key, value string) error {
|
||||||
|
return syscall.Setenv(key, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Clearenv() {
|
||||||
|
syscall.Clearenv()
|
||||||
|
}
|
||||||
|
|
||||||
|
func Environ() []string {
|
||||||
|
return syscall.Environ()
|
||||||
|
}
|
14
vendor/golang.org/x/sys/unix/env_unset.go
generated
vendored
Normal file
14
vendor/golang.org/x/sys/unix/env_unset.go
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
// +build go1.4
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func Unsetenv(key string) error {
|
||||||
|
// This was added in Go 1.4.
|
||||||
|
return syscall.Unsetenv(key)
|
||||||
|
}
|
24
vendor/golang.org/x/sys/unix/flock.go
generated
vendored
Normal file
24
vendor/golang.org/x/sys/unix/flock.go
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// +build linux darwin freebsd openbsd netbsd dragonfly
|
||||||
|
|
||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
|
||||||
|
// systems by flock_linux_32bit.go to be SYS_FCNTL64.
|
||||||
|
var fcntl64Syscall uintptr = SYS_FCNTL
|
||||||
|
|
||||||
|
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
||||||
|
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
||||||
|
_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
|
||||||
|
if errno == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return errno
|
||||||
|
}
|
13
vendor/golang.org/x/sys/unix/flock_linux_32bit.go
generated
vendored
Normal file
13
vendor/golang.org/x/sys/unix/flock_linux_32bit.go
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// +build linux,386 linux,arm
|
||||||
|
|
||||||
|
// Copyright 2014 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 unix
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// On 32-bit Linux systems, the fcntl syscall that matches Go's
|
||||||
|
// Flock_t type is SYS_FCNTL64, not SYS_FCNTL.
|
||||||
|
fcntl64Syscall = SYS_FCNTL64
|
||||||
|
}
|
46
vendor/golang.org/x/sys/unix/gccgo.go
generated
vendored
Normal file
46
vendor/golang.org/x/sys/unix/gccgo.go
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
// Copyright 2015 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.
|
||||||
|
|
||||||
|
// +build gccgo
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
// We can't use the gc-syntax .s files for gccgo. On the plus side
|
||||||
|
// much of the functionality can be written directly in Go.
|
||||||
|
|
||||||
|
//extern gccgoRealSyscall
|
||||||
|
func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
|
||||||
|
|
||||||
|
func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
||||||
|
syscall.Entersyscall()
|
||||||
|
r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
|
||||||
|
syscall.Exitsyscall()
|
||||||
|
return r, 0, syscall.Errno(errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
||||||
|
syscall.Entersyscall()
|
||||||
|
r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
|
||||||
|
syscall.Exitsyscall()
|
||||||
|
return r, 0, syscall.Errno(errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
||||||
|
syscall.Entersyscall()
|
||||||
|
r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9)
|
||||||
|
syscall.Exitsyscall()
|
||||||
|
return r, 0, syscall.Errno(errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
||||||
|
r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
|
||||||
|
return r, 0, syscall.Errno(errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
||||||
|
r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
|
||||||
|
return r, 0, syscall.Errno(errno)
|
||||||
|
}
|
41
vendor/golang.org/x/sys/unix/gccgo_c.c
generated
vendored
Normal file
41
vendor/golang.org/x/sys/unix/gccgo_c.c
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
// Copyright 2015 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.
|
||||||
|
|
||||||
|
// +build gccgo
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define _STRINGIFY2_(x) #x
|
||||||
|
#define _STRINGIFY_(x) _STRINGIFY2_(x)
|
||||||
|
#define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
|
||||||
|
|
||||||
|
// Call syscall from C code because the gccgo support for calling from
|
||||||
|
// Go to C does not support varargs functions.
|
||||||
|
|
||||||
|
struct ret {
|
||||||
|
uintptr_t r;
|
||||||
|
uintptr_t err;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ret
|
||||||
|
gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
|
||||||
|
{
|
||||||
|
struct ret r;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||||
|
r.err = errno;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define the use function in C so that it is not inlined.
|
||||||
|
|
||||||
|
extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline));
|
||||||
|
|
||||||
|
void
|
||||||
|
use(void *p __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
}
|
20
vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
generated
vendored
Normal file
20
vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright 2015 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.
|
||||||
|
|
||||||
|
// +build gccgo,linux,amd64
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
//extern gettimeofday
|
||||||
|
func realGettimeofday(*Timeval, *byte) int32
|
||||||
|
|
||||||
|
func gettimeofday(tv *Timeval) (err syscall.Errno) {
|
||||||
|
r := realGettimeofday(tv, nil)
|
||||||
|
if r < 0 {
|
||||||
|
return syscall.GetErrno()
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
274
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
Executable file
274
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
Executable file
|
@ -0,0 +1,274 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright 2009 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.
|
||||||
|
|
||||||
|
# The unix package provides access to the raw system call
|
||||||
|
# interface of the underlying operating system. Porting Go to
|
||||||
|
# a new architecture/operating system combination requires
|
||||||
|
# some manual effort, though there are tools that automate
|
||||||
|
# much of the process. The auto-generated files have names
|
||||||
|
# beginning with z.
|
||||||
|
#
|
||||||
|
# This script runs or (given -n) prints suggested commands to generate z files
|
||||||
|
# for the current system. Running those commands is not automatic.
|
||||||
|
# This script is documentation more than anything else.
|
||||||
|
#
|
||||||
|
# * asm_${GOOS}_${GOARCH}.s
|
||||||
|
#
|
||||||
|
# This hand-written assembly file implements system call dispatch.
|
||||||
|
# There are three entry points:
|
||||||
|
#
|
||||||
|
# func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr);
|
||||||
|
# func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
|
||||||
|
# func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr);
|
||||||
|
#
|
||||||
|
# The first and second are the standard ones; they differ only in
|
||||||
|
# how many arguments can be passed to the kernel.
|
||||||
|
# The third is for low-level use by the ForkExec wrapper;
|
||||||
|
# unlike the first two, it does not call into the scheduler to
|
||||||
|
# let it know that a system call is running.
|
||||||
|
#
|
||||||
|
# * syscall_${GOOS}.go
|
||||||
|
#
|
||||||
|
# This hand-written Go file implements system calls that need
|
||||||
|
# special handling and lists "//sys" comments giving prototypes
|
||||||
|
# for ones that can be auto-generated. Mksyscall reads those
|
||||||
|
# comments to generate the stubs.
|
||||||
|
#
|
||||||
|
# * syscall_${GOOS}_${GOARCH}.go
|
||||||
|
#
|
||||||
|
# Same as syscall_${GOOS}.go except that it contains code specific
|
||||||
|
# to ${GOOS} on one particular architecture.
|
||||||
|
#
|
||||||
|
# * types_${GOOS}.c
|
||||||
|
#
|
||||||
|
# This hand-written C file includes standard C headers and then
|
||||||
|
# creates typedef or enum names beginning with a dollar sign
|
||||||
|
# (use of $ in variable names is a gcc extension). The hardest
|
||||||
|
# part about preparing this file is figuring out which headers to
|
||||||
|
# include and which symbols need to be #defined to get the
|
||||||
|
# actual data structures that pass through to the kernel system calls.
|
||||||
|
# Some C libraries present alternate versions for binary compatibility
|
||||||
|
# and translate them on the way in and out of system calls, but
|
||||||
|
# there is almost always a #define that can get the real ones.
|
||||||
|
# See types_darwin.c and types_linux.c for examples.
|
||||||
|
#
|
||||||
|
# * zerror_${GOOS}_${GOARCH}.go
|
||||||
|
#
|
||||||
|
# This machine-generated file defines the system's error numbers,
|
||||||
|
# error strings, and signal numbers. The generator is "mkerrors.sh".
|
||||||
|
# Usually no arguments are needed, but mkerrors.sh will pass its
|
||||||
|
# arguments on to godefs.
|
||||||
|
#
|
||||||
|
# * zsyscall_${GOOS}_${GOARCH}.go
|
||||||
|
#
|
||||||
|
# Generated by mksyscall.pl; see syscall_${GOOS}.go above.
|
||||||
|
#
|
||||||
|
# * zsysnum_${GOOS}_${GOARCH}.go
|
||||||
|
#
|
||||||
|
# Generated by mksysnum_${GOOS}.
|
||||||
|
#
|
||||||
|
# * ztypes_${GOOS}_${GOARCH}.go
|
||||||
|
#
|
||||||
|
# Generated by godefs; see types_${GOOS}.c above.
|
||||||
|
|
||||||
|
GOOSARCH="${GOOS}_${GOARCH}"
|
||||||
|
|
||||||
|
# defaults
|
||||||
|
mksyscall="./mksyscall.pl"
|
||||||
|
mkerrors="./mkerrors.sh"
|
||||||
|
zerrors="zerrors_$GOOSARCH.go"
|
||||||
|
mksysctl=""
|
||||||
|
zsysctl="zsysctl_$GOOSARCH.go"
|
||||||
|
mksysnum=
|
||||||
|
mktypes=
|
||||||
|
run="sh"
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
-syscalls)
|
||||||
|
for i in zsyscall*go
|
||||||
|
do
|
||||||
|
sed 1q $i | sed 's;^// ;;' | sh > _$i && gofmt < _$i > $i
|
||||||
|
rm _$i
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-n)
|
||||||
|
run="cat"
|
||||||
|
shift
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$#" in
|
||||||
|
0)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo 'usage: mkall.sh [-n]' 1>&2
|
||||||
|
exit 2
|
||||||
|
esac
|
||||||
|
|
||||||
|
GOOSARCH_in=syscall_$GOOSARCH.go
|
||||||
|
case "$GOOSARCH" in
|
||||||
|
_* | *_ | _)
|
||||||
|
echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
darwin_386)
|
||||||
|
mkerrors="$mkerrors -m32"
|
||||||
|
mksyscall="./mksyscall.pl -l32"
|
||||||
|
mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
darwin_amd64)
|
||||||
|
mkerrors="$mkerrors -m64"
|
||||||
|
mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
darwin_arm)
|
||||||
|
mkerrors="$mkerrors"
|
||||||
|
mksysnum="./mksysnum_darwin.pl /usr/include/sys/syscall.h"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
darwin_arm64)
|
||||||
|
mkerrors="$mkerrors -m64"
|
||||||
|
mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
dragonfly_386)
|
||||||
|
mkerrors="$mkerrors -m32"
|
||||||
|
mksyscall="./mksyscall.pl -l32 -dragonfly"
|
||||||
|
mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
dragonfly_amd64)
|
||||||
|
mkerrors="$mkerrors -m64"
|
||||||
|
mksyscall="./mksyscall.pl -dragonfly"
|
||||||
|
mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
freebsd_386)
|
||||||
|
mkerrors="$mkerrors -m32"
|
||||||
|
mksyscall="./mksyscall.pl -l32"
|
||||||
|
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
freebsd_amd64)
|
||||||
|
mkerrors="$mkerrors -m64"
|
||||||
|
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
freebsd_arm)
|
||||||
|
mkerrors="$mkerrors"
|
||||||
|
mksyscall="./mksyscall.pl -l32 -arm"
|
||||||
|
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
|
||||||
|
# Let the type of C char be singed for making the bare syscall
|
||||||
|
# API consistent across over platforms.
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
||||||
|
;;
|
||||||
|
linux_386)
|
||||||
|
mkerrors="$mkerrors -m32"
|
||||||
|
mksyscall="./mksyscall.pl -l32"
|
||||||
|
mksysnum="./mksysnum_linux.pl /usr/include/asm/unistd_32.h"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
linux_amd64)
|
||||||
|
unistd_h=$(ls -1 /usr/include/asm/unistd_64.h /usr/include/x86_64-linux-gnu/asm/unistd_64.h 2>/dev/null | head -1)
|
||||||
|
if [ "$unistd_h" = "" ]; then
|
||||||
|
echo >&2 cannot find unistd_64.h
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
mkerrors="$mkerrors -m64"
|
||||||
|
mksysnum="./mksysnum_linux.pl $unistd_h"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
linux_arm)
|
||||||
|
mkerrors="$mkerrors"
|
||||||
|
mksyscall="./mksyscall.pl -l32 -arm"
|
||||||
|
mksysnum="curl -s 'http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/arch/arm/include/uapi/asm/unistd.h' | ./mksysnum_linux.pl -"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
linux_arm64)
|
||||||
|
unistd_h=$(ls -1 /usr/include/asm/unistd.h /usr/include/asm-generic/unistd.h 2>/dev/null | head -1)
|
||||||
|
if [ "$unistd_h" = "" ]; then
|
||||||
|
echo >&2 cannot find unistd_64.h
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
mksysnum="./mksysnum_linux.pl $unistd_h"
|
||||||
|
# Let the type of C char be singed for making the bare syscall
|
||||||
|
# API consistent across over platforms.
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
||||||
|
;;
|
||||||
|
linux_ppc64)
|
||||||
|
GOOSARCH_in=syscall_linux_ppc64x.go
|
||||||
|
unistd_h=/usr/include/asm/unistd.h
|
||||||
|
mkerrors="$mkerrors -m64"
|
||||||
|
mksysnum="./mksysnum_linux.pl $unistd_h"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
linux_ppc64le)
|
||||||
|
GOOSARCH_in=syscall_linux_ppc64x.go
|
||||||
|
unistd_h=/usr/include/powerpc64le-linux-gnu/asm/unistd.h
|
||||||
|
mkerrors="$mkerrors -m64"
|
||||||
|
mksysnum="./mksysnum_linux.pl $unistd_h"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
netbsd_386)
|
||||||
|
mkerrors="$mkerrors -m32"
|
||||||
|
mksyscall="./mksyscall.pl -l32 -netbsd"
|
||||||
|
mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
netbsd_amd64)
|
||||||
|
mkerrors="$mkerrors -m64"
|
||||||
|
mksyscall="./mksyscall.pl -netbsd"
|
||||||
|
mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
openbsd_386)
|
||||||
|
mkerrors="$mkerrors -m32"
|
||||||
|
mksyscall="./mksyscall.pl -l32 -openbsd"
|
||||||
|
mksysctl="./mksysctl_openbsd.pl"
|
||||||
|
zsysctl="zsysctl_openbsd.go"
|
||||||
|
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
openbsd_amd64)
|
||||||
|
mkerrors="$mkerrors -m64"
|
||||||
|
mksyscall="./mksyscall.pl -openbsd"
|
||||||
|
mksysctl="./mksysctl_openbsd.pl"
|
||||||
|
zsysctl="zsysctl_openbsd.go"
|
||||||
|
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
solaris_amd64)
|
||||||
|
mksyscall="./mksyscall_solaris.pl"
|
||||||
|
mkerrors="$mkerrors -m64"
|
||||||
|
mksysnum=
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
(
|
||||||
|
if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt >$zerrors"; fi
|
||||||
|
case "$GOOS" in
|
||||||
|
*)
|
||||||
|
syscall_goos="syscall_$GOOS.go"
|
||||||
|
case "$GOOS" in
|
||||||
|
darwin | dragonfly | freebsd | netbsd | openbsd)
|
||||||
|
syscall_goos="syscall_bsd.go $syscall_goos"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if [ -n "$mksyscall" ]; then echo "$mksyscall $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go"; fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
|
||||||
|
if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
|
||||||
|
if [ -n "$mktypes" ]; then
|
||||||
|
echo "echo // +build $GOARCH,$GOOS > ztypes_$GOOSARCH.go";
|
||||||
|
echo "$mktypes types_$GOOS.go | gofmt >>ztypes_$GOOSARCH.go";
|
||||||
|
fi
|
||||||
|
) | $run
|
476
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
Executable file
476
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
Executable file
|
@ -0,0 +1,476 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright 2009 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.
|
||||||
|
|
||||||
|
# Generate Go code listing errors and other #defined constant
|
||||||
|
# values (ENAMETOOLONG etc.), by asking the preprocessor
|
||||||
|
# about the definitions.
|
||||||
|
|
||||||
|
unset LANG
|
||||||
|
export LC_ALL=C
|
||||||
|
export LC_CTYPE=C
|
||||||
|
|
||||||
|
if test -z "$GOARCH" -o -z "$GOOS"; then
|
||||||
|
echo 1>&2 "GOARCH or GOOS not defined in environment"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
CC=${CC:-cc}
|
||||||
|
|
||||||
|
if [[ "$GOOS" -eq "solaris" ]]; then
|
||||||
|
# Assumes GNU versions of utilities in PATH.
|
||||||
|
export PATH=/usr/gnu/bin:$PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
uname=$(uname)
|
||||||
|
|
||||||
|
includes_Darwin='
|
||||||
|
#define _DARWIN_C_SOURCE
|
||||||
|
#define KERNEL
|
||||||
|
#define _DARWIN_USE_64_BIT_INODE
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/event.h>
|
||||||
|
#include <sys/ptrace.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/sockio.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <net/bpf.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <net/if_types.h>
|
||||||
|
#include <net/route.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/ip.h>
|
||||||
|
#include <termios.h>
|
||||||
|
'
|
||||||
|
|
||||||
|
includes_DragonFly='
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/event.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/sockio.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <net/bpf.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <net/if_types.h>
|
||||||
|
#include <net/route.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <netinet/ip.h>
|
||||||
|
#include <net/ip_mroute/ip_mroute.h>
|
||||||
|
'
|
||||||
|
|
||||||
|
includes_FreeBSD='
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/event.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/sockio.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <net/bpf.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <net/if_types.h>
|
||||||
|
#include <net/route.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <netinet/ip.h>
|
||||||
|
#include <netinet/ip_mroute.h>
|
||||||
|
#include <sys/extattr.h>
|
||||||
|
|
||||||
|
#if __FreeBSD__ >= 10
|
||||||
|
#define IFT_CARP 0xf8 // IFT_CARP is deprecated in FreeBSD 10
|
||||||
|
#undef SIOCAIFADDR
|
||||||
|
#define SIOCAIFADDR _IOW(105, 26, struct oifaliasreq) // ifaliasreq contains if_data
|
||||||
|
#undef SIOCSIFPHYADDR
|
||||||
|
#define SIOCSIFPHYADDR _IOW(105, 70, struct oifaliasreq) // ifaliasreq contains if_data
|
||||||
|
#endif
|
||||||
|
'
|
||||||
|
|
||||||
|
includes_Linux='
|
||||||
|
#define _LARGEFILE_SOURCE
|
||||||
|
#define _LARGEFILE64_SOURCE
|
||||||
|
#ifndef __LP64__
|
||||||
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
#endif
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
#include <bits/sockaddr.h>
|
||||||
|
#include <sys/epoll.h>
|
||||||
|
#include <sys/inotify.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <linux/if.h>
|
||||||
|
#include <linux/if_arp.h>
|
||||||
|
#include <linux/if_ether.h>
|
||||||
|
#include <linux/if_tun.h>
|
||||||
|
#include <linux/if_packet.h>
|
||||||
|
#include <linux/if_addr.h>
|
||||||
|
#include <linux/filter.h>
|
||||||
|
#include <linux/netlink.h>
|
||||||
|
#include <linux/reboot.h>
|
||||||
|
#include <linux/rtnetlink.h>
|
||||||
|
#include <linux/ptrace.h>
|
||||||
|
#include <linux/sched.h>
|
||||||
|
#include <linux/wait.h>
|
||||||
|
#include <linux/icmpv6.h>
|
||||||
|
#include <net/route.h>
|
||||||
|
#include <asm/termbits.h>
|
||||||
|
|
||||||
|
#ifndef MSG_FASTOPEN
|
||||||
|
#define MSG_FASTOPEN 0x20000000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PTRACE_GETREGS
|
||||||
|
#define PTRACE_GETREGS 0xc
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PTRACE_SETREGS
|
||||||
|
#define PTRACE_SETREGS 0xd
|
||||||
|
#endif
|
||||||
|
'
|
||||||
|
|
||||||
|
includes_NetBSD='
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/event.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/sockio.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <sys/termios.h>
|
||||||
|
#include <sys/ttycom.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <net/bpf.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <net/if_types.h>
|
||||||
|
#include <net/route.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/in_systm.h>
|
||||||
|
#include <netinet/ip.h>
|
||||||
|
#include <netinet/ip_mroute.h>
|
||||||
|
#include <netinet/if_ether.h>
|
||||||
|
|
||||||
|
// Needed since <sys/param.h> refers to it...
|
||||||
|
#define schedppq 1
|
||||||
|
'
|
||||||
|
|
||||||
|
includes_OpenBSD='
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/event.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/sockio.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <sys/termios.h>
|
||||||
|
#include <sys/ttycom.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <net/bpf.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <net/if_types.h>
|
||||||
|
#include <net/if_var.h>
|
||||||
|
#include <net/route.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/in_systm.h>
|
||||||
|
#include <netinet/ip.h>
|
||||||
|
#include <netinet/ip_mroute.h>
|
||||||
|
#include <netinet/if_ether.h>
|
||||||
|
#include <net/if_bridge.h>
|
||||||
|
|
||||||
|
// We keep some constants not supported in OpenBSD 5.5 and beyond for
|
||||||
|
// the promise of compatibility.
|
||||||
|
#define EMUL_ENABLED 0x1
|
||||||
|
#define EMUL_NATIVE 0x2
|
||||||
|
#define IPV6_FAITH 0x1d
|
||||||
|
#define IPV6_OPTIONS 0x1
|
||||||
|
#define IPV6_RTHDR_STRICT 0x1
|
||||||
|
#define IPV6_SOCKOPT_RESERVED1 0x3
|
||||||
|
#define SIOCGIFGENERIC 0xc020693a
|
||||||
|
#define SIOCSIFGENERIC 0x80206939
|
||||||
|
#define WALTSIG 0x4
|
||||||
|
'
|
||||||
|
|
||||||
|
includes_SunOS='
|
||||||
|
#include <limits.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/sockio.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <net/bpf.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <net/if_arp.h>
|
||||||
|
#include <net/if_types.h>
|
||||||
|
#include <net/route.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <netinet/ip.h>
|
||||||
|
#include <netinet/ip_mroute.h>
|
||||||
|
'
|
||||||
|
|
||||||
|
|
||||||
|
includes='
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/ip.h>
|
||||||
|
#include <netinet/ip6.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/signal.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <time.h>
|
||||||
|
'
|
||||||
|
ccflags="$@"
|
||||||
|
|
||||||
|
# Write go tool cgo -godefs input.
|
||||||
|
(
|
||||||
|
echo package unix
|
||||||
|
echo
|
||||||
|
echo '/*'
|
||||||
|
indirect="includes_$(uname)"
|
||||||
|
echo "${!indirect} $includes"
|
||||||
|
echo '*/'
|
||||||
|
echo 'import "C"'
|
||||||
|
echo 'import "syscall"'
|
||||||
|
echo
|
||||||
|
echo 'const ('
|
||||||
|
|
||||||
|
# The gcc command line prints all the #defines
|
||||||
|
# it encounters while processing the input
|
||||||
|
echo "${!indirect} $includes" | $CC -x c - -E -dM $ccflags |
|
||||||
|
awk '
|
||||||
|
$1 != "#define" || $2 ~ /\(/ || $3 == "" {next}
|
||||||
|
|
||||||
|
$2 ~ /^E([ABCD]X|[BIS]P|[SD]I|S|FL)$/ {next} # 386 registers
|
||||||
|
$2 ~ /^(SIGEV_|SIGSTKSZ|SIGRT(MIN|MAX))/ {next}
|
||||||
|
$2 ~ /^(SCM_SRCRT)$/ {next}
|
||||||
|
$2 ~ /^(MAP_FAILED)$/ {next}
|
||||||
|
$2 ~ /^ELF_.*$/ {next}# <asm/elf.h> contains ELF_ARCH, etc.
|
||||||
|
|
||||||
|
$2 ~ /^EXTATTR_NAMESPACE_NAMES/ ||
|
||||||
|
$2 ~ /^EXTATTR_NAMESPACE_[A-Z]+_STRING/ {next}
|
||||||
|
|
||||||
|
$2 !~ /^ETH_/ &&
|
||||||
|
$2 !~ /^EPROC_/ &&
|
||||||
|
$2 !~ /^EQUIV_/ &&
|
||||||
|
$2 !~ /^EXPR_/ &&
|
||||||
|
$2 ~ /^E[A-Z0-9_]+$/ ||
|
||||||
|
$2 ~ /^B[0-9_]+$/ ||
|
||||||
|
$2 == "BOTHER" ||
|
||||||
|
$2 ~ /^CI?BAUD(EX)?$/ ||
|
||||||
|
$2 == "IBSHIFT" ||
|
||||||
|
$2 ~ /^V[A-Z0-9]+$/ ||
|
||||||
|
$2 ~ /^CS[A-Z0-9]/ ||
|
||||||
|
$2 ~ /^I(SIG|CANON|CRNL|UCLC|EXTEN|MAXBEL|STRIP|UTF8)$/ ||
|
||||||
|
$2 ~ /^IGN/ ||
|
||||||
|
$2 ~ /^IX(ON|ANY|OFF)$/ ||
|
||||||
|
$2 ~ /^IN(LCR|PCK)$/ ||
|
||||||
|
$2 ~ /(^FLU?SH)|(FLU?SH$)/ ||
|
||||||
|
$2 ~ /^C(LOCAL|READ|MSPAR|RTSCTS)$/ ||
|
||||||
|
$2 == "BRKINT" ||
|
||||||
|
$2 == "HUPCL" ||
|
||||||
|
$2 == "PENDIN" ||
|
||||||
|
$2 == "TOSTOP" ||
|
||||||
|
$2 == "XCASE" ||
|
||||||
|
$2 == "ALTWERASE" ||
|
||||||
|
$2 == "NOKERNINFO" ||
|
||||||
|
$2 ~ /^PAR/ ||
|
||||||
|
$2 ~ /^SIG[^_]/ ||
|
||||||
|
$2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ ||
|
||||||
|
$2 ~ /^(NL|CR|TAB|BS|VT|FF)DLY$/ ||
|
||||||
|
$2 ~ /^(NL|CR|TAB|BS|VT|FF)[0-9]$/ ||
|
||||||
|
$2 ~ /^O?XTABS$/ ||
|
||||||
|
$2 ~ /^TC[IO](ON|OFF)$/ ||
|
||||||
|
$2 ~ /^IN_/ ||
|
||||||
|
$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
|
||||||
|
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
|
||||||
|
$2 == "ICMPV6_FILTER" ||
|
||||||
|
$2 == "SOMAXCONN" ||
|
||||||
|
$2 == "NAME_MAX" ||
|
||||||
|
$2 == "IFNAMSIZ" ||
|
||||||
|
$2 ~ /^CTL_(MAXNAME|NET|QUERY)$/ ||
|
||||||
|
$2 ~ /^SYSCTL_VERS/ ||
|
||||||
|
$2 ~ /^(MS|MNT)_/ ||
|
||||||
|
$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
|
||||||
|
$2 ~ /^(O|F|FD|NAME|S|PTRACE|PT)_/ ||
|
||||||
|
$2 ~ /^LINUX_REBOOT_CMD_/ ||
|
||||||
|
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
|
||||||
|
$2 !~ "NLA_TYPE_MASK" &&
|
||||||
|
$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P)_/ ||
|
||||||
|
$2 ~ /^SIOC/ ||
|
||||||
|
$2 ~ /^TIOC/ ||
|
||||||
|
$2 ~ /^TCGET/ ||
|
||||||
|
$2 ~ /^TCSET/ ||
|
||||||
|
$2 ~ /^TC(FLSH|SBRKP?|XONC)$/ ||
|
||||||
|
$2 !~ "RTF_BITS" &&
|
||||||
|
$2 ~ /^(IFF|IFT|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ ||
|
||||||
|
$2 ~ /^BIOC/ ||
|
||||||
|
$2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
|
||||||
|
$2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|NOFILE|STACK)|RLIM_INFINITY/ ||
|
||||||
|
$2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
|
||||||
|
$2 ~ /^CLONE_[A-Z_]+/ ||
|
||||||
|
$2 !~ /^(BPF_TIMEVAL)$/ &&
|
||||||
|
$2 ~ /^(BPF|DLT)_/ ||
|
||||||
|
$2 ~ /^CLOCK_/ ||
|
||||||
|
$2 !~ "WMESGLEN" &&
|
||||||
|
$2 ~ /^W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", $2, $2)}
|
||||||
|
$2 ~ /^__WCOREFLAG$/ {next}
|
||||||
|
$2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
|
||||||
|
|
||||||
|
{next}
|
||||||
|
' | sort
|
||||||
|
|
||||||
|
echo ')'
|
||||||
|
) >_const.go
|
||||||
|
|
||||||
|
# Pull out the error names for later.
|
||||||
|
errors=$(
|
||||||
|
echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
|
||||||
|
awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print $2 }' |
|
||||||
|
sort
|
||||||
|
)
|
||||||
|
|
||||||
|
# Pull out the signal names for later.
|
||||||
|
signals=$(
|
||||||
|
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
||||||
|
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
|
||||||
|
egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
|
||||||
|
sort
|
||||||
|
)
|
||||||
|
|
||||||
|
# Again, writing regexps to a file.
|
||||||
|
echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
|
||||||
|
awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print "^\t" $2 "[ \t]*=" }' |
|
||||||
|
sort >_error.grep
|
||||||
|
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
||||||
|
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
|
||||||
|
egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
|
||||||
|
sort >_signal.grep
|
||||||
|
|
||||||
|
echo '// mkerrors.sh' "$@"
|
||||||
|
echo '// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT'
|
||||||
|
echo
|
||||||
|
echo "// +build ${GOARCH},${GOOS}"
|
||||||
|
echo
|
||||||
|
go tool cgo -godefs -- "$@" _const.go >_error.out
|
||||||
|
cat _error.out | grep -vf _error.grep | grep -vf _signal.grep
|
||||||
|
echo
|
||||||
|
echo '// Errors'
|
||||||
|
echo 'const ('
|
||||||
|
cat _error.out | grep -f _error.grep | sed 's/=\(.*\)/= syscall.Errno(\1)/'
|
||||||
|
echo ')'
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo '// Signals'
|
||||||
|
echo 'const ('
|
||||||
|
cat _error.out | grep -f _signal.grep | sed 's/=\(.*\)/= syscall.Signal(\1)/'
|
||||||
|
echo ')'
|
||||||
|
|
||||||
|
# Run C program to print error and syscall strings.
|
||||||
|
(
|
||||||
|
echo -E "
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#define nelem(x) (sizeof(x)/sizeof((x)[0]))
|
||||||
|
|
||||||
|
enum { A = 'A', Z = 'Z', a = 'a', z = 'z' }; // avoid need for single quotes below
|
||||||
|
|
||||||
|
int errors[] = {
|
||||||
|
"
|
||||||
|
for i in $errors
|
||||||
|
do
|
||||||
|
echo -E ' '$i,
|
||||||
|
done
|
||||||
|
|
||||||
|
echo -E "
|
||||||
|
};
|
||||||
|
|
||||||
|
int signals[] = {
|
||||||
|
"
|
||||||
|
for i in $signals
|
||||||
|
do
|
||||||
|
echo -E ' '$i,
|
||||||
|
done
|
||||||
|
|
||||||
|
# Use -E because on some systems bash builtin interprets \n itself.
|
||||||
|
echo -E '
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
intcmp(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
return *(int*)a - *(int*)b;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
int i, j, e;
|
||||||
|
char buf[1024], *p;
|
||||||
|
|
||||||
|
printf("\n\n// Error table\n");
|
||||||
|
printf("var errors = [...]string {\n");
|
||||||
|
qsort(errors, nelem(errors), sizeof errors[0], intcmp);
|
||||||
|
for(i=0; i<nelem(errors); i++) {
|
||||||
|
e = errors[i];
|
||||||
|
if(i > 0 && errors[i-1] == e)
|
||||||
|
continue;
|
||||||
|
strcpy(buf, strerror(e));
|
||||||
|
// lowercase first letter: Bad -> bad, but STREAM -> STREAM.
|
||||||
|
if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
|
||||||
|
buf[0] += a - A;
|
||||||
|
printf("\t%d: \"%s\",\n", e, buf);
|
||||||
|
}
|
||||||
|
printf("}\n\n");
|
||||||
|
|
||||||
|
printf("\n\n// Signal table\n");
|
||||||
|
printf("var signals = [...]string {\n");
|
||||||
|
qsort(signals, nelem(signals), sizeof signals[0], intcmp);
|
||||||
|
for(i=0; i<nelem(signals); i++) {
|
||||||
|
e = signals[i];
|
||||||
|
if(i > 0 && signals[i-1] == e)
|
||||||
|
continue;
|
||||||
|
strcpy(buf, strsignal(e));
|
||||||
|
// lowercase first letter: Bad -> bad, but STREAM -> STREAM.
|
||||||
|
if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
|
||||||
|
buf[0] += a - A;
|
||||||
|
// cut trailing : number.
|
||||||
|
p = strrchr(buf, ":"[0]);
|
||||||
|
if(p)
|
||||||
|
*p = '\0';
|
||||||
|
printf("\t%d: \"%s\",\n", e, buf);
|
||||||
|
}
|
||||||
|
printf("}\n\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
'
|
||||||
|
) >_errors.c
|
||||||
|
|
||||||
|
$CC $ccflags -o _errors _errors.c && $GORUN ./_errors && rm -f _errors.c _errors _const.go _error.grep _signal.grep _error.out
|
323
vendor/golang.org/x/sys/unix/mksyscall.pl
generated
vendored
Executable file
323
vendor/golang.org/x/sys/unix/mksyscall.pl
generated
vendored
Executable file
|
@ -0,0 +1,323 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
# Copyright 2009 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.
|
||||||
|
|
||||||
|
# This program reads a file containing function prototypes
|
||||||
|
# (like syscall_darwin.go) and generates system call bodies.
|
||||||
|
# The prototypes are marked by lines beginning with "//sys"
|
||||||
|
# and read like func declarations if //sys is replaced by func, but:
|
||||||
|
# * The parameter lists must give a name for each argument.
|
||||||
|
# This includes return parameters.
|
||||||
|
# * The parameter lists must give a type for each argument:
|
||||||
|
# the (x, y, z int) shorthand is not allowed.
|
||||||
|
# * If the return parameter is an error number, it must be named errno.
|
||||||
|
|
||||||
|
# A line beginning with //sysnb is like //sys, except that the
|
||||||
|
# goroutine will not be suspended during the execution of the system
|
||||||
|
# call. This must only be used for system calls which can never
|
||||||
|
# block, as otherwise the system call could cause all goroutines to
|
||||||
|
# hang.
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
my $cmdline = "mksyscall.pl " . join(' ', @ARGV);
|
||||||
|
my $errors = 0;
|
||||||
|
my $_32bit = "";
|
||||||
|
my $plan9 = 0;
|
||||||
|
my $openbsd = 0;
|
||||||
|
my $netbsd = 0;
|
||||||
|
my $dragonfly = 0;
|
||||||
|
my $arm = 0; # 64-bit value should use (even, odd)-pair
|
||||||
|
|
||||||
|
if($ARGV[0] eq "-b32") {
|
||||||
|
$_32bit = "big-endian";
|
||||||
|
shift;
|
||||||
|
} elsif($ARGV[0] eq "-l32") {
|
||||||
|
$_32bit = "little-endian";
|
||||||
|
shift;
|
||||||
|
}
|
||||||
|
if($ARGV[0] eq "-plan9") {
|
||||||
|
$plan9 = 1;
|
||||||
|
shift;
|
||||||
|
}
|
||||||
|
if($ARGV[0] eq "-openbsd") {
|
||||||
|
$openbsd = 1;
|
||||||
|
shift;
|
||||||
|
}
|
||||||
|
if($ARGV[0] eq "-netbsd") {
|
||||||
|
$netbsd = 1;
|
||||||
|
shift;
|
||||||
|
}
|
||||||
|
if($ARGV[0] eq "-dragonfly") {
|
||||||
|
$dragonfly = 1;
|
||||||
|
shift;
|
||||||
|
}
|
||||||
|
if($ARGV[0] eq "-arm") {
|
||||||
|
$arm = 1;
|
||||||
|
shift;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($ARGV[0] =~ /^-/) {
|
||||||
|
print STDERR "usage: mksyscall.pl [-b32 | -l32] [file ...]\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
||||||
|
print STDERR "GOARCH or GOOS not defined in environment\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub parseparamlist($) {
|
||||||
|
my ($list) = @_;
|
||||||
|
$list =~ s/^\s*//;
|
||||||
|
$list =~ s/\s*$//;
|
||||||
|
if($list eq "") {
|
||||||
|
return ();
|
||||||
|
}
|
||||||
|
return split(/\s*,\s*/, $list);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub parseparam($) {
|
||||||
|
my ($p) = @_;
|
||||||
|
if($p !~ /^(\S*) (\S*)$/) {
|
||||||
|
print STDERR "$ARGV:$.: malformed parameter: $p\n";
|
||||||
|
$errors = 1;
|
||||||
|
return ("xx", "int");
|
||||||
|
}
|
||||||
|
return ($1, $2);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $text = "";
|
||||||
|
while(<>) {
|
||||||
|
chomp;
|
||||||
|
s/\s+/ /g;
|
||||||
|
s/^\s+//;
|
||||||
|
s/\s+$//;
|
||||||
|
my $nonblock = /^\/\/sysnb /;
|
||||||
|
next if !/^\/\/sys / && !$nonblock;
|
||||||
|
|
||||||
|
# Line must be of the form
|
||||||
|
# func Open(path string, mode int, perm int) (fd int, errno error)
|
||||||
|
# Split into name, in params, out params.
|
||||||
|
if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$/) {
|
||||||
|
print STDERR "$ARGV:$.: malformed //sys declaration\n";
|
||||||
|
$errors = 1;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
my ($func, $in, $out, $sysname) = ($2, $3, $4, $5);
|
||||||
|
|
||||||
|
# Split argument lists on comma.
|
||||||
|
my @in = parseparamlist($in);
|
||||||
|
my @out = parseparamlist($out);
|
||||||
|
|
||||||
|
# Try in vain to keep people from editing this file.
|
||||||
|
# The theory is that they jump into the middle of the file
|
||||||
|
# without reading the header.
|
||||||
|
$text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n";
|
||||||
|
|
||||||
|
# Go function header.
|
||||||
|
my $out_decl = @out ? sprintf(" (%s)", join(', ', @out)) : "";
|
||||||
|
$text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out_decl;
|
||||||
|
|
||||||
|
# Check if err return available
|
||||||
|
my $errvar = "";
|
||||||
|
foreach my $p (@out) {
|
||||||
|
my ($name, $type) = parseparam($p);
|
||||||
|
if($type eq "error") {
|
||||||
|
$errvar = $name;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Prepare arguments to Syscall.
|
||||||
|
my @args = ();
|
||||||
|
my @uses = ();
|
||||||
|
my $n = 0;
|
||||||
|
foreach my $p (@in) {
|
||||||
|
my ($name, $type) = parseparam($p);
|
||||||
|
if($type =~ /^\*/) {
|
||||||
|
push @args, "uintptr(unsafe.Pointer($name))";
|
||||||
|
} elsif($type eq "string" && $errvar ne "") {
|
||||||
|
$text .= "\tvar _p$n *byte\n";
|
||||||
|
$text .= "\t_p$n, $errvar = BytePtrFromString($name)\n";
|
||||||
|
$text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
|
||||||
|
push @args, "uintptr(unsafe.Pointer(_p$n))";
|
||||||
|
push @uses, "use(unsafe.Pointer(_p$n))";
|
||||||
|
$n++;
|
||||||
|
} elsif($type eq "string") {
|
||||||
|
print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
|
||||||
|
$text .= "\tvar _p$n *byte\n";
|
||||||
|
$text .= "\t_p$n, _ = BytePtrFromString($name)\n";
|
||||||
|
push @args, "uintptr(unsafe.Pointer(_p$n))";
|
||||||
|
push @uses, "use(unsafe.Pointer(_p$n))";
|
||||||
|
$n++;
|
||||||
|
} elsif($type =~ /^\[\](.*)/) {
|
||||||
|
# Convert slice into pointer, length.
|
||||||
|
# Have to be careful not to take address of &a[0] if len == 0:
|
||||||
|
# pass dummy pointer in that case.
|
||||||
|
# Used to pass nil, but some OSes or simulators reject write(fd, nil, 0).
|
||||||
|
$text .= "\tvar _p$n unsafe.Pointer\n";
|
||||||
|
$text .= "\tif len($name) > 0 {\n\t\t_p$n = unsafe.Pointer(\&${name}[0])\n\t}";
|
||||||
|
$text .= " else {\n\t\t_p$n = unsafe.Pointer(&_zero)\n\t}";
|
||||||
|
$text .= "\n";
|
||||||
|
push @args, "uintptr(_p$n)", "uintptr(len($name))";
|
||||||
|
$n++;
|
||||||
|
} elsif($type eq "int64" && ($openbsd || $netbsd)) {
|
||||||
|
push @args, "0";
|
||||||
|
if($_32bit eq "big-endian") {
|
||||||
|
push @args, "uintptr($name>>32)", "uintptr($name)";
|
||||||
|
} elsif($_32bit eq "little-endian") {
|
||||||
|
push @args, "uintptr($name)", "uintptr($name>>32)";
|
||||||
|
} else {
|
||||||
|
push @args, "uintptr($name)";
|
||||||
|
}
|
||||||
|
} elsif($type eq "int64" && $dragonfly) {
|
||||||
|
if ($func !~ /^extp(read|write)/i) {
|
||||||
|
push @args, "0";
|
||||||
|
}
|
||||||
|
if($_32bit eq "big-endian") {
|
||||||
|
push @args, "uintptr($name>>32)", "uintptr($name)";
|
||||||
|
} elsif($_32bit eq "little-endian") {
|
||||||
|
push @args, "uintptr($name)", "uintptr($name>>32)";
|
||||||
|
} else {
|
||||||
|
push @args, "uintptr($name)";
|
||||||
|
}
|
||||||
|
} elsif($type eq "int64" && $_32bit ne "") {
|
||||||
|
if(@args % 2 && $arm) {
|
||||||
|
# arm abi specifies 64-bit argument uses
|
||||||
|
# (even, odd) pair
|
||||||
|
push @args, "0"
|
||||||
|
}
|
||||||
|
if($_32bit eq "big-endian") {
|
||||||
|
push @args, "uintptr($name>>32)", "uintptr($name)";
|
||||||
|
} else {
|
||||||
|
push @args, "uintptr($name)", "uintptr($name>>32)";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
push @args, "uintptr($name)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Determine which form to use; pad args with zeros.
|
||||||
|
my $asm = "Syscall";
|
||||||
|
if ($nonblock) {
|
||||||
|
$asm = "RawSyscall";
|
||||||
|
}
|
||||||
|
if(@args <= 3) {
|
||||||
|
while(@args < 3) {
|
||||||
|
push @args, "0";
|
||||||
|
}
|
||||||
|
} elsif(@args <= 6) {
|
||||||
|
$asm .= "6";
|
||||||
|
while(@args < 6) {
|
||||||
|
push @args, "0";
|
||||||
|
}
|
||||||
|
} elsif(@args <= 9) {
|
||||||
|
$asm .= "9";
|
||||||
|
while(@args < 9) {
|
||||||
|
push @args, "0";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print STDERR "$ARGV:$.: too many arguments to system call\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# System call number.
|
||||||
|
if($sysname eq "") {
|
||||||
|
$sysname = "SYS_$func";
|
||||||
|
$sysname =~ s/([a-z])([A-Z])/${1}_$2/g; # turn FooBar into Foo_Bar
|
||||||
|
$sysname =~ y/a-z/A-Z/;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Actual call.
|
||||||
|
my $args = join(', ', @args);
|
||||||
|
my $call = "$asm($sysname, $args)";
|
||||||
|
|
||||||
|
# Assign return values.
|
||||||
|
my $body = "";
|
||||||
|
my @ret = ("_", "_", "_");
|
||||||
|
my $do_errno = 0;
|
||||||
|
for(my $i=0; $i<@out; $i++) {
|
||||||
|
my $p = $out[$i];
|
||||||
|
my ($name, $type) = parseparam($p);
|
||||||
|
my $reg = "";
|
||||||
|
if($name eq "err" && !$plan9) {
|
||||||
|
$reg = "e1";
|
||||||
|
$ret[2] = $reg;
|
||||||
|
$do_errno = 1;
|
||||||
|
} elsif($name eq "err" && $plan9) {
|
||||||
|
$ret[0] = "r0";
|
||||||
|
$ret[2] = "e1";
|
||||||
|
next;
|
||||||
|
} else {
|
||||||
|
$reg = sprintf("r%d", $i);
|
||||||
|
$ret[$i] = $reg;
|
||||||
|
}
|
||||||
|
if($type eq "bool") {
|
||||||
|
$reg = "$reg != 0";
|
||||||
|
}
|
||||||
|
if($type eq "int64" && $_32bit ne "") {
|
||||||
|
# 64-bit number in r1:r0 or r0:r1.
|
||||||
|
if($i+2 > @out) {
|
||||||
|
print STDERR "$ARGV:$.: not enough registers for int64 return\n";
|
||||||
|
}
|
||||||
|
if($_32bit eq "big-endian") {
|
||||||
|
$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1);
|
||||||
|
} else {
|
||||||
|
$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i);
|
||||||
|
}
|
||||||
|
$ret[$i] = sprintf("r%d", $i);
|
||||||
|
$ret[$i+1] = sprintf("r%d", $i+1);
|
||||||
|
}
|
||||||
|
if($reg ne "e1" || $plan9) {
|
||||||
|
$body .= "\t$name = $type($reg)\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
|
||||||
|
$text .= "\t$call\n";
|
||||||
|
} else {
|
||||||
|
$text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
|
||||||
|
}
|
||||||
|
foreach my $use (@uses) {
|
||||||
|
$text .= "\t$use\n";
|
||||||
|
}
|
||||||
|
$text .= $body;
|
||||||
|
|
||||||
|
if ($plan9 && $ret[2] eq "e1") {
|
||||||
|
$text .= "\tif int32(r0) == -1 {\n";
|
||||||
|
$text .= "\t\terr = e1\n";
|
||||||
|
$text .= "\t}\n";
|
||||||
|
} elsif ($do_errno) {
|
||||||
|
$text .= "\tif e1 != 0 {\n";
|
||||||
|
$text .= "\t\terr = errnoErr(e1)\n";
|
||||||
|
$text .= "\t}\n";
|
||||||
|
}
|
||||||
|
$text .= "\treturn\n";
|
||||||
|
$text .= "}\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
chomp $text;
|
||||||
|
chomp $text;
|
||||||
|
|
||||||
|
if($errors) {
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
// $cmdline
|
||||||
|
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
||||||
|
|
||||||
|
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ syscall.Errno
|
||||||
|
|
||||||
|
$text
|
||||||
|
EOF
|
||||||
|
exit 0;
|
294
vendor/golang.org/x/sys/unix/mksyscall_solaris.pl
generated
vendored
Executable file
294
vendor/golang.org/x/sys/unix/mksyscall_solaris.pl
generated
vendored
Executable file
|
@ -0,0 +1,294 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
# Copyright 2009 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.
|
||||||
|
|
||||||
|
# This program reads a file containing function prototypes
|
||||||
|
# (like syscall_solaris.go) and generates system call bodies.
|
||||||
|
# The prototypes are marked by lines beginning with "//sys"
|
||||||
|
# and read like func declarations if //sys is replaced by func, but:
|
||||||
|
# * The parameter lists must give a name for each argument.
|
||||||
|
# This includes return parameters.
|
||||||
|
# * The parameter lists must give a type for each argument:
|
||||||
|
# the (x, y, z int) shorthand is not allowed.
|
||||||
|
# * If the return parameter is an error number, it must be named err.
|
||||||
|
# * If go func name needs to be different than its libc name,
|
||||||
|
# * or the function is not in libc, name could be specified
|
||||||
|
# * at the end, after "=" sign, like
|
||||||
|
# //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
my $cmdline = "mksyscall_solaris.pl " . join(' ', @ARGV);
|
||||||
|
my $errors = 0;
|
||||||
|
my $_32bit = "";
|
||||||
|
|
||||||
|
binmode STDOUT;
|
||||||
|
|
||||||
|
if($ARGV[0] eq "-b32") {
|
||||||
|
$_32bit = "big-endian";
|
||||||
|
shift;
|
||||||
|
} elsif($ARGV[0] eq "-l32") {
|
||||||
|
$_32bit = "little-endian";
|
||||||
|
shift;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($ARGV[0] =~ /^-/) {
|
||||||
|
print STDERR "usage: mksyscall_solaris.pl [-b32 | -l32] [file ...]\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
||||||
|
print STDERR "GOARCH or GOOS not defined in environment\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub parseparamlist($) {
|
||||||
|
my ($list) = @_;
|
||||||
|
$list =~ s/^\s*//;
|
||||||
|
$list =~ s/\s*$//;
|
||||||
|
if($list eq "") {
|
||||||
|
return ();
|
||||||
|
}
|
||||||
|
return split(/\s*,\s*/, $list);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub parseparam($) {
|
||||||
|
my ($p) = @_;
|
||||||
|
if($p !~ /^(\S*) (\S*)$/) {
|
||||||
|
print STDERR "$ARGV:$.: malformed parameter: $p\n";
|
||||||
|
$errors = 1;
|
||||||
|
return ("xx", "int");
|
||||||
|
}
|
||||||
|
return ($1, $2);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $package = "";
|
||||||
|
my $text = "";
|
||||||
|
my $dynimports = "";
|
||||||
|
my $linknames = "";
|
||||||
|
my @vars = ();
|
||||||
|
while(<>) {
|
||||||
|
chomp;
|
||||||
|
s/\s+/ /g;
|
||||||
|
s/^\s+//;
|
||||||
|
s/\s+$//;
|
||||||
|
$package = $1 if !$package && /^package (\S+)$/;
|
||||||
|
my $nonblock = /^\/\/sysnb /;
|
||||||
|
next if !/^\/\/sys / && !$nonblock;
|
||||||
|
|
||||||
|
# Line must be of the form
|
||||||
|
# func Open(path string, mode int, perm int) (fd int, err error)
|
||||||
|
# Split into name, in params, out params.
|
||||||
|
if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$/) {
|
||||||
|
print STDERR "$ARGV:$.: malformed //sys declaration\n";
|
||||||
|
$errors = 1;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
my ($nb, $func, $in, $out, $modname, $sysname) = ($1, $2, $3, $4, $5, $6);
|
||||||
|
|
||||||
|
# Split argument lists on comma.
|
||||||
|
my @in = parseparamlist($in);
|
||||||
|
my @out = parseparamlist($out);
|
||||||
|
|
||||||
|
# So file name.
|
||||||
|
if($modname eq "") {
|
||||||
|
$modname = "libc";
|
||||||
|
}
|
||||||
|
|
||||||
|
# System call name.
|
||||||
|
if($sysname eq "") {
|
||||||
|
$sysname = "$func";
|
||||||
|
}
|
||||||
|
|
||||||
|
# System call pointer variable name.
|
||||||
|
my $sysvarname = "proc$sysname";
|
||||||
|
|
||||||
|
my $strconvfunc = "BytePtrFromString";
|
||||||
|
my $strconvtype = "*byte";
|
||||||
|
|
||||||
|
$sysname =~ y/A-Z/a-z/; # All libc functions are lowercase.
|
||||||
|
|
||||||
|
# Runtime import of function to allow cross-platform builds.
|
||||||
|
$dynimports .= "//go:cgo_import_dynamic libc_${sysname} ${sysname} \"$modname.so\"\n";
|
||||||
|
# Link symbol to proc address variable.
|
||||||
|
$linknames .= "//go:linkname ${sysvarname} libc_${sysname}\n";
|
||||||
|
# Library proc address variable.
|
||||||
|
push @vars, $sysvarname;
|
||||||
|
|
||||||
|
# Go function header.
|
||||||
|
$out = join(', ', @out);
|
||||||
|
if($out ne "") {
|
||||||
|
$out = " ($out)";
|
||||||
|
}
|
||||||
|
if($text ne "") {
|
||||||
|
$text .= "\n"
|
||||||
|
}
|
||||||
|
$text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out;
|
||||||
|
|
||||||
|
# Check if err return available
|
||||||
|
my $errvar = "";
|
||||||
|
foreach my $p (@out) {
|
||||||
|
my ($name, $type) = parseparam($p);
|
||||||
|
if($type eq "error") {
|
||||||
|
$errvar = $name;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Prepare arguments to Syscall.
|
||||||
|
my @args = ();
|
||||||
|
my @uses = ();
|
||||||
|
my $n = 0;
|
||||||
|
foreach my $p (@in) {
|
||||||
|
my ($name, $type) = parseparam($p);
|
||||||
|
if($type =~ /^\*/) {
|
||||||
|
push @args, "uintptr(unsafe.Pointer($name))";
|
||||||
|
} elsif($type eq "string" && $errvar ne "") {
|
||||||
|
$text .= "\tvar _p$n $strconvtype\n";
|
||||||
|
$text .= "\t_p$n, $errvar = $strconvfunc($name)\n";
|
||||||
|
$text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
|
||||||
|
push @args, "uintptr(unsafe.Pointer(_p$n))";
|
||||||
|
push @uses, "use(unsafe.Pointer(_p$n))";
|
||||||
|
$n++;
|
||||||
|
} elsif($type eq "string") {
|
||||||
|
print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
|
||||||
|
$text .= "\tvar _p$n $strconvtype\n";
|
||||||
|
$text .= "\t_p$n, _ = $strconvfunc($name)\n";
|
||||||
|
push @args, "uintptr(unsafe.Pointer(_p$n))";
|
||||||
|
push @uses, "use(unsafe.Pointer(_p$n))";
|
||||||
|
$n++;
|
||||||
|
} elsif($type =~ /^\[\](.*)/) {
|
||||||
|
# Convert slice into pointer, length.
|
||||||
|
# Have to be careful not to take address of &a[0] if len == 0:
|
||||||
|
# pass nil in that case.
|
||||||
|
$text .= "\tvar _p$n *$1\n";
|
||||||
|
$text .= "\tif len($name) > 0 {\n\t\t_p$n = \&$name\[0]\n\t}\n";
|
||||||
|
push @args, "uintptr(unsafe.Pointer(_p$n))", "uintptr(len($name))";
|
||||||
|
$n++;
|
||||||
|
} elsif($type eq "int64" && $_32bit ne "") {
|
||||||
|
if($_32bit eq "big-endian") {
|
||||||
|
push @args, "uintptr($name >> 32)", "uintptr($name)";
|
||||||
|
} else {
|
||||||
|
push @args, "uintptr($name)", "uintptr($name >> 32)";
|
||||||
|
}
|
||||||
|
} elsif($type eq "bool") {
|
||||||
|
$text .= "\tvar _p$n uint32\n";
|
||||||
|
$text .= "\tif $name {\n\t\t_p$n = 1\n\t} else {\n\t\t_p$n = 0\n\t}\n";
|
||||||
|
push @args, "uintptr(_p$n)";
|
||||||
|
$n++;
|
||||||
|
} else {
|
||||||
|
push @args, "uintptr($name)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
my $nargs = @args;
|
||||||
|
|
||||||
|
# Determine which form to use; pad args with zeros.
|
||||||
|
my $asm = "sysvicall6";
|
||||||
|
if ($nonblock) {
|
||||||
|
$asm = "rawSysvicall6";
|
||||||
|
}
|
||||||
|
if(@args <= 6) {
|
||||||
|
while(@args < 6) {
|
||||||
|
push @args, "0";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print STDERR "$ARGV:$.: too many arguments to system call\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Actual call.
|
||||||
|
my $args = join(', ', @args);
|
||||||
|
my $call = "$asm(uintptr(unsafe.Pointer(&$sysvarname)), $nargs, $args)";
|
||||||
|
|
||||||
|
# Assign return values.
|
||||||
|
my $body = "";
|
||||||
|
my $failexpr = "";
|
||||||
|
my @ret = ("_", "_", "_");
|
||||||
|
my @pout= ();
|
||||||
|
my $do_errno = 0;
|
||||||
|
for(my $i=0; $i<@out; $i++) {
|
||||||
|
my $p = $out[$i];
|
||||||
|
my ($name, $type) = parseparam($p);
|
||||||
|
my $reg = "";
|
||||||
|
if($name eq "err") {
|
||||||
|
$reg = "e1";
|
||||||
|
$ret[2] = $reg;
|
||||||
|
$do_errno = 1;
|
||||||
|
} else {
|
||||||
|
$reg = sprintf("r%d", $i);
|
||||||
|
$ret[$i] = $reg;
|
||||||
|
}
|
||||||
|
if($type eq "bool") {
|
||||||
|
$reg = "$reg != 0";
|
||||||
|
}
|
||||||
|
if($type eq "int64" && $_32bit ne "") {
|
||||||
|
# 64-bit number in r1:r0 or r0:r1.
|
||||||
|
if($i+2 > @out) {
|
||||||
|
print STDERR "$ARGV:$.: not enough registers for int64 return\n";
|
||||||
|
}
|
||||||
|
if($_32bit eq "big-endian") {
|
||||||
|
$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1);
|
||||||
|
} else {
|
||||||
|
$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i);
|
||||||
|
}
|
||||||
|
$ret[$i] = sprintf("r%d", $i);
|
||||||
|
$ret[$i+1] = sprintf("r%d", $i+1);
|
||||||
|
}
|
||||||
|
if($reg ne "e1") {
|
||||||
|
$body .= "\t$name = $type($reg)\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
|
||||||
|
$text .= "\t$call\n";
|
||||||
|
} else {
|
||||||
|
$text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
|
||||||
|
}
|
||||||
|
foreach my $use (@uses) {
|
||||||
|
$text .= "\t$use\n";
|
||||||
|
}
|
||||||
|
$text .= $body;
|
||||||
|
|
||||||
|
if ($do_errno) {
|
||||||
|
$text .= "\tif e1 != 0 {\n";
|
||||||
|
$text .= "\t\terr = e1\n";
|
||||||
|
$text .= "\t}\n";
|
||||||
|
}
|
||||||
|
$text .= "\treturn\n";
|
||||||
|
$text .= "}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($errors) {
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
// $cmdline
|
||||||
|
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
||||||
|
|
||||||
|
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
||||||
|
|
||||||
|
package $package
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
EOF
|
||||||
|
|
||||||
|
print "import \"golang.org/x/sys/unix\"\n" if $package ne "unix";
|
||||||
|
|
||||||
|
my $vardecls = "\t" . join(",\n\t", @vars);
|
||||||
|
$vardecls .= " syscallFunc";
|
||||||
|
|
||||||
|
chomp($_=<<EOF);
|
||||||
|
|
||||||
|
$dynimports
|
||||||
|
$linknames
|
||||||
|
var (
|
||||||
|
$vardecls
|
||||||
|
)
|
||||||
|
|
||||||
|
$text
|
||||||
|
EOF
|
||||||
|
print $_;
|
||||||
|
exit 0;
|
264
vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl
generated
vendored
Executable file
264
vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl
generated
vendored
Executable file
|
@ -0,0 +1,264 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
# Copyright 2011 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.
|
||||||
|
|
||||||
|
#
|
||||||
|
# Parse the header files for OpenBSD and generate a Go usable sysctl MIB.
|
||||||
|
#
|
||||||
|
# Build a MIB with each entry being an array containing the level, type and
|
||||||
|
# a hash that will contain additional entries if the current entry is a node.
|
||||||
|
# We then walk this MIB and create a flattened sysctl name to OID hash.
|
||||||
|
#
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
||||||
|
print STDERR "GOARCH or GOOS not defined in environment\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $debug = 0;
|
||||||
|
my %ctls = ();
|
||||||
|
|
||||||
|
my @headers = qw (
|
||||||
|
sys/sysctl.h
|
||||||
|
sys/socket.h
|
||||||
|
sys/tty.h
|
||||||
|
sys/malloc.h
|
||||||
|
sys/mount.h
|
||||||
|
sys/namei.h
|
||||||
|
sys/sem.h
|
||||||
|
sys/shm.h
|
||||||
|
sys/vmmeter.h
|
||||||
|
uvm/uvm_param.h
|
||||||
|
uvm/uvm_swap_encrypt.h
|
||||||
|
ddb/db_var.h
|
||||||
|
net/if.h
|
||||||
|
net/if_pfsync.h
|
||||||
|
net/pipex.h
|
||||||
|
netinet/in.h
|
||||||
|
netinet/icmp_var.h
|
||||||
|
netinet/igmp_var.h
|
||||||
|
netinet/ip_ah.h
|
||||||
|
netinet/ip_carp.h
|
||||||
|
netinet/ip_divert.h
|
||||||
|
netinet/ip_esp.h
|
||||||
|
netinet/ip_ether.h
|
||||||
|
netinet/ip_gre.h
|
||||||
|
netinet/ip_ipcomp.h
|
||||||
|
netinet/ip_ipip.h
|
||||||
|
netinet/pim_var.h
|
||||||
|
netinet/tcp_var.h
|
||||||
|
netinet/udp_var.h
|
||||||
|
netinet6/in6.h
|
||||||
|
netinet6/ip6_divert.h
|
||||||
|
netinet6/pim6_var.h
|
||||||
|
netinet/icmp6.h
|
||||||
|
netmpls/mpls.h
|
||||||
|
);
|
||||||
|
|
||||||
|
my @ctls = qw (
|
||||||
|
kern
|
||||||
|
vm
|
||||||
|
fs
|
||||||
|
net
|
||||||
|
#debug # Special handling required
|
||||||
|
hw
|
||||||
|
#machdep # Arch specific
|
||||||
|
user
|
||||||
|
ddb
|
||||||
|
#vfs # Special handling required
|
||||||
|
fs.posix
|
||||||
|
kern.forkstat
|
||||||
|
kern.intrcnt
|
||||||
|
kern.malloc
|
||||||
|
kern.nchstats
|
||||||
|
kern.seminfo
|
||||||
|
kern.shminfo
|
||||||
|
kern.timecounter
|
||||||
|
kern.tty
|
||||||
|
kern.watchdog
|
||||||
|
net.bpf
|
||||||
|
net.ifq
|
||||||
|
net.inet
|
||||||
|
net.inet.ah
|
||||||
|
net.inet.carp
|
||||||
|
net.inet.divert
|
||||||
|
net.inet.esp
|
||||||
|
net.inet.etherip
|
||||||
|
net.inet.gre
|
||||||
|
net.inet.icmp
|
||||||
|
net.inet.igmp
|
||||||
|
net.inet.ip
|
||||||
|
net.inet.ip.ifq
|
||||||
|
net.inet.ipcomp
|
||||||
|
net.inet.ipip
|
||||||
|
net.inet.mobileip
|
||||||
|
net.inet.pfsync
|
||||||
|
net.inet.pim
|
||||||
|
net.inet.tcp
|
||||||
|
net.inet.udp
|
||||||
|
net.inet6
|
||||||
|
net.inet6.divert
|
||||||
|
net.inet6.ip6
|
||||||
|
net.inet6.icmp6
|
||||||
|
net.inet6.pim6
|
||||||
|
net.inet6.tcp6
|
||||||
|
net.inet6.udp6
|
||||||
|
net.mpls
|
||||||
|
net.mpls.ifq
|
||||||
|
net.key
|
||||||
|
net.pflow
|
||||||
|
net.pfsync
|
||||||
|
net.pipex
|
||||||
|
net.rt
|
||||||
|
vm.swapencrypt
|
||||||
|
#vfsgenctl # Special handling required
|
||||||
|
);
|
||||||
|
|
||||||
|
# Node name "fixups"
|
||||||
|
my %ctl_map = (
|
||||||
|
"ipproto" => "net.inet",
|
||||||
|
"net.inet.ipproto" => "net.inet",
|
||||||
|
"net.inet6.ipv6proto" => "net.inet6",
|
||||||
|
"net.inet6.ipv6" => "net.inet6.ip6",
|
||||||
|
"net.inet.icmpv6" => "net.inet6.icmp6",
|
||||||
|
"net.inet6.divert6" => "net.inet6.divert",
|
||||||
|
"net.inet6.tcp6" => "net.inet.tcp",
|
||||||
|
"net.inet6.udp6" => "net.inet.udp",
|
||||||
|
"mpls" => "net.mpls",
|
||||||
|
"swpenc" => "vm.swapencrypt"
|
||||||
|
);
|
||||||
|
|
||||||
|
# Node mappings
|
||||||
|
my %node_map = (
|
||||||
|
"net.inet.ip.ifq" => "net.ifq",
|
||||||
|
"net.inet.pfsync" => "net.pfsync",
|
||||||
|
"net.mpls.ifq" => "net.ifq"
|
||||||
|
);
|
||||||
|
|
||||||
|
my $ctlname;
|
||||||
|
my %mib = ();
|
||||||
|
my %sysctl = ();
|
||||||
|
my $node;
|
||||||
|
|
||||||
|
sub debug() {
|
||||||
|
print STDERR "$_[0]\n" if $debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Walk the MIB and build a sysctl name to OID mapping.
|
||||||
|
sub build_sysctl() {
|
||||||
|
my ($node, $name, $oid) = @_;
|
||||||
|
my %node = %{$node};
|
||||||
|
my @oid = @{$oid};
|
||||||
|
|
||||||
|
foreach my $key (sort keys %node) {
|
||||||
|
my @node = @{$node{$key}};
|
||||||
|
my $nodename = $name.($name ne '' ? '.' : '').$key;
|
||||||
|
my @nodeoid = (@oid, $node[0]);
|
||||||
|
if ($node[1] eq 'CTLTYPE_NODE') {
|
||||||
|
if (exists $node_map{$nodename}) {
|
||||||
|
$node = \%mib;
|
||||||
|
$ctlname = $node_map{$nodename};
|
||||||
|
foreach my $part (split /\./, $ctlname) {
|
||||||
|
$node = \%{@{$$node{$part}}[2]};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$node = $node[2];
|
||||||
|
}
|
||||||
|
&build_sysctl($node, $nodename, \@nodeoid);
|
||||||
|
} elsif ($node[1] ne '') {
|
||||||
|
$sysctl{$nodename} = \@nodeoid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $ctl (@ctls) {
|
||||||
|
$ctls{$ctl} = $ctl;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Build MIB
|
||||||
|
foreach my $header (@headers) {
|
||||||
|
&debug("Processing $header...");
|
||||||
|
open HEADER, "/usr/include/$header" ||
|
||||||
|
print STDERR "Failed to open $header\n";
|
||||||
|
while (<HEADER>) {
|
||||||
|
if ($_ =~ /^#define\s+(CTL_NAMES)\s+{/ ||
|
||||||
|
$_ =~ /^#define\s+(CTL_(.*)_NAMES)\s+{/ ||
|
||||||
|
$_ =~ /^#define\s+((.*)CTL_NAMES)\s+{/) {
|
||||||
|
if ($1 eq 'CTL_NAMES') {
|
||||||
|
# Top level.
|
||||||
|
$node = \%mib;
|
||||||
|
} else {
|
||||||
|
# Node.
|
||||||
|
my $nodename = lc($2);
|
||||||
|
if ($header =~ /^netinet\//) {
|
||||||
|
$ctlname = "net.inet.$nodename";
|
||||||
|
} elsif ($header =~ /^netinet6\//) {
|
||||||
|
$ctlname = "net.inet6.$nodename";
|
||||||
|
} elsif ($header =~ /^net\//) {
|
||||||
|
$ctlname = "net.$nodename";
|
||||||
|
} else {
|
||||||
|
$ctlname = "$nodename";
|
||||||
|
$ctlname =~ s/^(fs|net|kern)_/$1\./;
|
||||||
|
}
|
||||||
|
if (exists $ctl_map{$ctlname}) {
|
||||||
|
$ctlname = $ctl_map{$ctlname};
|
||||||
|
}
|
||||||
|
if (not exists $ctls{$ctlname}) {
|
||||||
|
&debug("Ignoring $ctlname...");
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Walk down from the top of the MIB.
|
||||||
|
$node = \%mib;
|
||||||
|
foreach my $part (split /\./, $ctlname) {
|
||||||
|
if (not exists $$node{$part}) {
|
||||||
|
&debug("Missing node $part");
|
||||||
|
$$node{$part} = [ 0, '', {} ];
|
||||||
|
}
|
||||||
|
$node = \%{@{$$node{$part}}[2]};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Populate current node with entries.
|
||||||
|
my $i = -1;
|
||||||
|
while (defined($_) && $_ !~ /^}/) {
|
||||||
|
$_ = <HEADER>;
|
||||||
|
$i++ if $_ =~ /{.*}/;
|
||||||
|
next if $_ !~ /{\s+"(\w+)",\s+(CTLTYPE_[A-Z]+)\s+}/;
|
||||||
|
$$node{$1} = [ $i, $2, {} ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close HEADER;
|
||||||
|
}
|
||||||
|
|
||||||
|
&build_sysctl(\%mib, "", []);
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
// mksysctl_openbsd.pl
|
||||||
|
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
|
||||||
|
|
||||||
|
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
||||||
|
|
||||||
|
package unix;
|
||||||
|
|
||||||
|
type mibentry struct {
|
||||||
|
ctlname string
|
||||||
|
ctloid []_C_int
|
||||||
|
}
|
||||||
|
|
||||||
|
var sysctlMib = []mibentry {
|
||||||
|
EOF
|
||||||
|
|
||||||
|
foreach my $name (sort keys %sysctl) {
|
||||||
|
my @oid = @{$sysctl{$name}};
|
||||||
|
print "\t{ \"$name\", []_C_int{ ", join(', ', @oid), " } }, \n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
}
|
||||||
|
EOF
|
39
vendor/golang.org/x/sys/unix/mksysnum_darwin.pl
generated
vendored
Executable file
39
vendor/golang.org/x/sys/unix/mksysnum_darwin.pl
generated
vendored
Executable file
|
@ -0,0 +1,39 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
# Copyright 2009 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.
|
||||||
|
#
|
||||||
|
# Generate system call table for Darwin from sys/syscall.h
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
||||||
|
print STDERR "GOARCH or GOOS not defined in environment\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $command = "mksysnum_darwin.pl " . join(' ', @ARGV);
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
// $command
|
||||||
|
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
|
||||||
|
|
||||||
|
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
EOF
|
||||||
|
|
||||||
|
while(<>){
|
||||||
|
if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){
|
||||||
|
my $name = $1;
|
||||||
|
my $num = $2;
|
||||||
|
$name =~ y/a-z/A-Z/;
|
||||||
|
print " SYS_$name = $num;"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
)
|
||||||
|
EOF
|
50
vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl
generated
vendored
Executable file
50
vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl
generated
vendored
Executable file
|
@ -0,0 +1,50 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
# Copyright 2009 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.
|
||||||
|
#
|
||||||
|
# Generate system call table for DragonFly from master list
|
||||||
|
# (for example, /usr/src/sys/kern/syscalls.master).
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
||||||
|
print STDERR "GOARCH or GOOS not defined in environment\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $command = "mksysnum_dragonfly.pl " . join(' ', @ARGV);
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
// $command
|
||||||
|
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
|
||||||
|
|
||||||
|
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
EOF
|
||||||
|
|
||||||
|
while(<>){
|
||||||
|
if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){
|
||||||
|
my $num = $1;
|
||||||
|
my $proto = $2;
|
||||||
|
my $name = "SYS_$3";
|
||||||
|
$name =~ y/a-z/A-Z/;
|
||||||
|
|
||||||
|
# There are multiple entries for enosys and nosys, so comment them out.
|
||||||
|
if($name =~ /^SYS_E?NOSYS$/){
|
||||||
|
$name = "// $name";
|
||||||
|
}
|
||||||
|
if($name eq 'SYS_SYS_EXIT'){
|
||||||
|
$name = 'SYS_EXIT';
|
||||||
|
}
|
||||||
|
|
||||||
|
print " $name = $num; // $proto\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
)
|
||||||
|
EOF
|
63
vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl
generated
vendored
Executable file
63
vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl
generated
vendored
Executable file
|
@ -0,0 +1,63 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
# Copyright 2009 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.
|
||||||
|
#
|
||||||
|
# Generate system call table for FreeBSD from master list
|
||||||
|
# (for example, /usr/src/sys/kern/syscalls.master).
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
||||||
|
print STDERR "GOARCH or GOOS not defined in environment\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $command = "mksysnum_freebsd.pl " . join(' ', @ARGV);
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
// $command
|
||||||
|
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
|
||||||
|
|
||||||
|
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
EOF
|
||||||
|
|
||||||
|
while(<>){
|
||||||
|
if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){
|
||||||
|
my $num = $1;
|
||||||
|
my $proto = $2;
|
||||||
|
my $name = "SYS_$3";
|
||||||
|
$name =~ y/a-z/A-Z/;
|
||||||
|
|
||||||
|
# There are multiple entries for enosys and nosys, so comment them out.
|
||||||
|
if($name =~ /^SYS_E?NOSYS$/){
|
||||||
|
$name = "// $name";
|
||||||
|
}
|
||||||
|
if($name eq 'SYS_SYS_EXIT'){
|
||||||
|
$name = 'SYS_EXIT';
|
||||||
|
}
|
||||||
|
if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
|
print " $name = $num; // $proto\n";
|
||||||
|
|
||||||
|
# We keep Capsicum syscall numbers for FreeBSD
|
||||||
|
# 9-STABLE here because we are not sure whether they
|
||||||
|
# are mature and stable.
|
||||||
|
if($num == 513){
|
||||||
|
print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n";
|
||||||
|
print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n";
|
||||||
|
print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n";
|
||||||
|
print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
)
|
||||||
|
EOF
|
58
vendor/golang.org/x/sys/unix/mksysnum_linux.pl
generated
vendored
Executable file
58
vendor/golang.org/x/sys/unix/mksysnum_linux.pl
generated
vendored
Executable file
|
@ -0,0 +1,58 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
# Copyright 2009 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.
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
||||||
|
print STDERR "GOARCH or GOOS not defined in environment\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $command = "mksysnum_linux.pl ". join(' ', @ARGV);
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
// $command
|
||||||
|
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
|
||||||
|
|
||||||
|
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const(
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sub fmt {
|
||||||
|
my ($name, $num) = @_;
|
||||||
|
if($num > 999){
|
||||||
|
# ignore deprecated syscalls that are no longer implemented
|
||||||
|
# https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$name =~ y/a-z/A-Z/;
|
||||||
|
print " SYS_$name = $num;\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $prev;
|
||||||
|
open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc";
|
||||||
|
while(<GCC>){
|
||||||
|
if(/^#define __NR_syscalls\s+/) {
|
||||||
|
# ignore redefinitions of __NR_syscalls
|
||||||
|
}
|
||||||
|
elsif(/^#define __NR_(\w+)\s+([0-9]+)/){
|
||||||
|
$prev = $2;
|
||||||
|
fmt($1, $2);
|
||||||
|
}
|
||||||
|
elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){
|
||||||
|
$prev = $2;
|
||||||
|
fmt($1, $2);
|
||||||
|
}
|
||||||
|
elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){
|
||||||
|
fmt($1, $prev+$2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
)
|
||||||
|
EOF
|
58
vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl
generated
vendored
Executable file
58
vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl
generated
vendored
Executable file
|
@ -0,0 +1,58 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
# Copyright 2009 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.
|
||||||
|
#
|
||||||
|
# Generate system call table for OpenBSD from master list
|
||||||
|
# (for example, /usr/src/sys/kern/syscalls.master).
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
||||||
|
print STDERR "GOARCH or GOOS not defined in environment\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $command = "mksysnum_netbsd.pl " . join(' ', @ARGV);
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
// $command
|
||||||
|
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
|
||||||
|
|
||||||
|
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
EOF
|
||||||
|
|
||||||
|
my $line = '';
|
||||||
|
while(<>){
|
||||||
|
if($line =~ /^(.*)\\$/) {
|
||||||
|
# Handle continuation
|
||||||
|
$line = $1;
|
||||||
|
$_ =~ s/^\s+//;
|
||||||
|
$line .= $_;
|
||||||
|
} else {
|
||||||
|
# New line
|
||||||
|
$line = $_;
|
||||||
|
}
|
||||||
|
next if $line =~ /\\$/;
|
||||||
|
if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) {
|
||||||
|
my $num = $1;
|
||||||
|
my $proto = $6;
|
||||||
|
my $compat = $8;
|
||||||
|
my $name = "$7_$9";
|
||||||
|
|
||||||
|
$name = "$7_$11" if $11 ne '';
|
||||||
|
$name =~ y/a-z/A-Z/;
|
||||||
|
|
||||||
|
if($compat eq '' || $compat eq '30' || $compat eq '50') {
|
||||||
|
print " $name = $num; // $proto\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
)
|
||||||
|
EOF
|
50
vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl
generated
vendored
Executable file
50
vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl
generated
vendored
Executable file
|
@ -0,0 +1,50 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
# Copyright 2009 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.
|
||||||
|
#
|
||||||
|
# Generate system call table for OpenBSD from master list
|
||||||
|
# (for example, /usr/src/sys/kern/syscalls.master).
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
||||||
|
print STDERR "GOARCH or GOOS not defined in environment\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $command = "mksysnum_openbsd.pl " . join(' ', @ARGV);
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
// $command
|
||||||
|
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
|
||||||
|
|
||||||
|
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
EOF
|
||||||
|
|
||||||
|
while(<>){
|
||||||
|
if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){
|
||||||
|
my $num = $1;
|
||||||
|
my $proto = $3;
|
||||||
|
my $name = $4;
|
||||||
|
$name =~ y/a-z/A-Z/;
|
||||||
|
|
||||||
|
# There are multiple entries for enosys and nosys, so comment them out.
|
||||||
|
if($name =~ /^SYS_E?NOSYS$/){
|
||||||
|
$name = "// $name";
|
||||||
|
}
|
||||||
|
if($name eq 'SYS_SYS_EXIT'){
|
||||||
|
$name = 'SYS_EXIT';
|
||||||
|
}
|
||||||
|
|
||||||
|
print " $name = $num; // $proto\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
)
|
||||||
|
EOF
|
30
vendor/golang.org/x/sys/unix/race.go
generated
vendored
Normal file
30
vendor/golang.org/x/sys/unix/race.go
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
// +build darwin,race linux,race freebsd,race
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
const raceenabled = true
|
||||||
|
|
||||||
|
func raceAcquire(addr unsafe.Pointer) {
|
||||||
|
runtime.RaceAcquire(addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func raceReleaseMerge(addr unsafe.Pointer) {
|
||||||
|
runtime.RaceReleaseMerge(addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func raceReadRange(addr unsafe.Pointer, len int) {
|
||||||
|
runtime.RaceReadRange(addr, len)
|
||||||
|
}
|
||||||
|
|
||||||
|
func raceWriteRange(addr unsafe.Pointer, len int) {
|
||||||
|
runtime.RaceWriteRange(addr, len)
|
||||||
|
}
|
25
vendor/golang.org/x/sys/unix/race0.go
generated
vendored
Normal file
25
vendor/golang.org/x/sys/unix/race0.go
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
// +build darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
const raceenabled = false
|
||||||
|
|
||||||
|
func raceAcquire(addr unsafe.Pointer) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func raceReleaseMerge(addr unsafe.Pointer) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func raceReadRange(addr unsafe.Pointer, len int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func raceWriteRange(addr unsafe.Pointer, len int) {
|
||||||
|
}
|
36
vendor/golang.org/x/sys/unix/sockcmsg_linux.go
generated
vendored
Normal file
36
vendor/golang.org/x/sys/unix/sockcmsg_linux.go
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
// Copyright 2011 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.
|
||||||
|
|
||||||
|
// Socket control messages
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
// 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, CmsgSpace(SizeofUcred))
|
||||||
|
h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
|
||||||
|
h.Level = SOL_SOCKET
|
||||||
|
h.Type = SCM_CREDENTIALS
|
||||||
|
h.SetLen(CmsgLen(SizeofUcred))
|
||||||
|
*((*Ucred)(cmsgData(h))) = *ucred
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 *SocketControlMessage) (*Ucred, error) {
|
||||||
|
if m.Header.Level != SOL_SOCKET {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
if m.Header.Type != SCM_CREDENTIALS {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0]))
|
||||||
|
return &ucred, nil
|
||||||
|
}
|
103
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
generated
vendored
Normal file
103
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
generated
vendored
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
// Copyright 2011 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.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
// Socket control messages
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
// Round the length of a raw sockaddr up to align it properly.
|
||||||
|
func cmsgAlignOf(salen int) int {
|
||||||
|
salign := sizeofPtr
|
||||||
|
// NOTE: It seems like 64-bit Darwin and DragonFly BSD kernels
|
||||||
|
// still require 32-bit aligned access to network subsystem.
|
||||||
|
if darwin64Bit || dragonfly64Bit {
|
||||||
|
salign = 4
|
||||||
|
}
|
||||||
|
return (salen + salign - 1) & ^(salign - 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CmsgLen returns the value to store in the Len field of the Cmsghdr
|
||||||
|
// structure, taking into account any necessary alignment.
|
||||||
|
func CmsgLen(datalen int) int {
|
||||||
|
return cmsgAlignOf(SizeofCmsghdr) + datalen
|
||||||
|
}
|
||||||
|
|
||||||
|
// CmsgSpace returns the number of bytes an ancillary element with
|
||||||
|
// payload of the passed data length occupies.
|
||||||
|
func CmsgSpace(datalen int) int {
|
||||||
|
return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen)
|
||||||
|
}
|
||||||
|
|
||||||
|
func cmsgData(h *Cmsghdr) unsafe.Pointer {
|
||||||
|
return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SocketControlMessage represents a socket control message.
|
||||||
|
type SocketControlMessage struct {
|
||||||
|
Header Cmsghdr
|
||||||
|
Data []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseSocketControlMessage parses b as an array of socket control
|
||||||
|
// messages.
|
||||||
|
func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) {
|
||||||
|
var msgs []SocketControlMessage
|
||||||
|
i := 0
|
||||||
|
for i+CmsgLen(0) <= len(b) {
|
||||||
|
h, dbuf, err := socketControlMessageHeaderAndData(b[i:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
m := SocketControlMessage{Header: *h, Data: dbuf}
|
||||||
|
msgs = append(msgs, m)
|
||||||
|
i += cmsgAlignOf(int(h.Len))
|
||||||
|
}
|
||||||
|
return msgs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) {
|
||||||
|
h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
|
||||||
|
if h.Len < SizeofCmsghdr || int(h.Len) > len(b) {
|
||||||
|
return nil, nil, EINVAL
|
||||||
|
}
|
||||||
|
return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnixRights encodes a set of open file descriptors into a socket
|
||||||
|
// control message for sending to another process.
|
||||||
|
func UnixRights(fds ...int) []byte {
|
||||||
|
datalen := len(fds) * 4
|
||||||
|
b := make([]byte, CmsgSpace(datalen))
|
||||||
|
h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
|
||||||
|
h.Level = SOL_SOCKET
|
||||||
|
h.Type = SCM_RIGHTS
|
||||||
|
h.SetLen(CmsgLen(datalen))
|
||||||
|
data := cmsgData(h)
|
||||||
|
for _, fd := range fds {
|
||||||
|
*(*int32)(data) = int32(fd)
|
||||||
|
data = unsafe.Pointer(uintptr(data) + 4)
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseUnixRights decodes a socket control message that contains an
|
||||||
|
// integer array of open file descriptors from another process.
|
||||||
|
func ParseUnixRights(m *SocketControlMessage) ([]int, error) {
|
||||||
|
if m.Header.Level != SOL_SOCKET {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
if m.Header.Type != SCM_RIGHTS {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
fds := make([]int, len(m.Data)>>2)
|
||||||
|
for i, j := 0, 0; i < len(m.Data); i += 4 {
|
||||||
|
fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i])))
|
||||||
|
j++
|
||||||
|
}
|
||||||
|
return fds, nil
|
||||||
|
}
|
26
vendor/golang.org/x/sys/unix/str.go
generated
vendored
Normal file
26
vendor/golang.org/x/sys/unix/str.go
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
func itoa(val int) string { // do it here rather than with fmt to avoid dependency
|
||||||
|
if val < 0 {
|
||||||
|
return "-" + uitoa(uint(-val))
|
||||||
|
}
|
||||||
|
return uitoa(uint(val))
|
||||||
|
}
|
||||||
|
|
||||||
|
func uitoa(val uint) string {
|
||||||
|
var buf [32]byte // big enough for int64
|
||||||
|
i := len(buf) - 1
|
||||||
|
for val >= 10 {
|
||||||
|
buf[i] = byte(val%10 + '0')
|
||||||
|
i--
|
||||||
|
val /= 10
|
||||||
|
}
|
||||||
|
buf[i] = byte(val + '0')
|
||||||
|
return string(buf[i:])
|
||||||
|
}
|
76
vendor/golang.org/x/sys/unix/syscall.go
generated
vendored
Normal file
76
vendor/golang.org/x/sys/unix/syscall.go
generated
vendored
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
// Package unix contains an interface to the low-level operating system
|
||||||
|
// primitives. OS details vary depending on the underlying system, and
|
||||||
|
// by default, godoc will display OS-specific documentation for the current
|
||||||
|
// system. If you want godoc to display OS documentation for another
|
||||||
|
// system, set $GOOS and $GOARCH to the desired system. For example, if
|
||||||
|
// you want to view documentation for freebsd/arm on linux/amd64, set $GOOS
|
||||||
|
// to freebsd and $GOARCH to arm.
|
||||||
|
// The primary use of this package is inside other packages that provide a more
|
||||||
|
// portable interface to the system, such as "os", "time" and "net". Use
|
||||||
|
// those packages rather than this one if you can.
|
||||||
|
// For details of the functions and data types in this package consult
|
||||||
|
// the manuals for the appropriate operating system.
|
||||||
|
// These calls return err == nil to indicate success; otherwise
|
||||||
|
// err represents an operating system error describing the failure and
|
||||||
|
// holds a value of type syscall.Errno.
|
||||||
|
package unix // import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
// ByteSliceFromString returns a NUL-terminated slice of bytes
|
||||||
|
// containing the text of s. If s contains a NUL byte at any
|
||||||
|
// location, it returns (nil, EINVAL).
|
||||||
|
func ByteSliceFromString(s string) ([]byte, error) {
|
||||||
|
for i := 0; i < len(s); i++ {
|
||||||
|
if s[i] == 0 {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a := make([]byte, len(s)+1)
|
||||||
|
copy(a, s)
|
||||||
|
return a, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BytePtrFromString returns a pointer to a NUL-terminated array of
|
||||||
|
// bytes containing the text of s. If s contains a NUL byte at any
|
||||||
|
// location, it returns (nil, EINVAL).
|
||||||
|
func BytePtrFromString(s string) (*byte, error) {
|
||||||
|
a, err := ByteSliceFromString(s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &a[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Single-word zero for use when we need a valid pointer to 0 bytes.
|
||||||
|
// See mkunix.pl.
|
||||||
|
var _zero uintptr
|
||||||
|
|
||||||
|
func (ts *Timespec) Unix() (sec int64, nsec int64) {
|
||||||
|
return int64(ts.Sec), int64(ts.Nsec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tv *Timeval) Unix() (sec int64, nsec int64) {
|
||||||
|
return int64(tv.Sec), int64(tv.Usec) * 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ts *Timespec) Nano() int64 {
|
||||||
|
return int64(ts.Sec)*1e9 + int64(ts.Nsec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tv *Timeval) Nano() int64 {
|
||||||
|
return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000
|
||||||
|
}
|
||||||
|
|
||||||
|
func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
|
||||||
|
|
||||||
|
// use is a no-op, but the compiler cannot see that it is.
|
||||||
|
// Calling use(p) ensures that p is kept live until that point.
|
||||||
|
//go:noescape
|
||||||
|
func use(p unsafe.Pointer)
|
628
vendor/golang.org/x/sys/unix/syscall_bsd.go
generated
vendored
Normal file
628
vendor/golang.org/x/sys/unix/syscall_bsd.go
generated
vendored
Normal file
|
@ -0,0 +1,628 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd netbsd openbsd
|
||||||
|
|
||||||
|
// BSD system call wrappers shared by *BSD based systems
|
||||||
|
// including OS X (Darwin) and FreeBSD. Like the other
|
||||||
|
// syscall_*.go files it is compiled as Go code but also
|
||||||
|
// used as input to mksyscall which parses the //sys
|
||||||
|
// lines and generates system call stubs.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wrapped
|
||||||
|
*/
|
||||||
|
|
||||||
|
//sysnb getgroups(ngid int, gid *_Gid_t) (n int, err error)
|
||||||
|
//sysnb setgroups(ngid int, gid *_Gid_t) (err error)
|
||||||
|
|
||||||
|
func Getgroups() (gids []int, err error) {
|
||||||
|
n, err := getgroups(0, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if n == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sanity check group count. Max is 16 on BSD.
|
||||||
|
if n < 0 || n > 1000 {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
a := make([]_Gid_t, n)
|
||||||
|
n, err = getgroups(n, &a[0])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
gids = make([]int, n)
|
||||||
|
for i, v := range a[0:n] {
|
||||||
|
gids[i] = int(v)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Setgroups(gids []int) (err error) {
|
||||||
|
if len(gids) == 0 {
|
||||||
|
return setgroups(0, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
a := make([]_Gid_t, len(gids))
|
||||||
|
for i, v := range gids {
|
||||||
|
a[i] = _Gid_t(v)
|
||||||
|
}
|
||||||
|
return setgroups(len(a), &a[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
func ReadDirent(fd int, buf []byte) (n int, err error) {
|
||||||
|
// Final argument is (basep *uintptr) and the syscall doesn't take nil.
|
||||||
|
// 64 bits should be enough. (32 bits isn't even on 386). Since the
|
||||||
|
// actual system call is getdirentries64, 64 is a good guess.
|
||||||
|
// TODO(rsc): Can we use a single global basep for all calls?
|
||||||
|
var base = (*uintptr)(unsafe.Pointer(new(uint64)))
|
||||||
|
return Getdirentries(fd, buf, base)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait status is 7 bits at bottom, either 0 (exited),
|
||||||
|
// 0x7F (stopped), or a signal number that caused an exit.
|
||||||
|
// The 0x80 bit is whether there was a core dump.
|
||||||
|
// An extra number (exit code, signal causing a stop)
|
||||||
|
// is in the high bits.
|
||||||
|
|
||||||
|
type WaitStatus uint32
|
||||||
|
|
||||||
|
const (
|
||||||
|
mask = 0x7F
|
||||||
|
core = 0x80
|
||||||
|
shift = 8
|
||||||
|
|
||||||
|
exited = 0
|
||||||
|
stopped = 0x7F
|
||||||
|
)
|
||||||
|
|
||||||
|
func (w WaitStatus) Exited() bool { return w&mask == exited }
|
||||||
|
|
||||||
|
func (w WaitStatus) ExitStatus() int {
|
||||||
|
if w&mask != exited {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return int(w >> shift)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != 0 }
|
||||||
|
|
||||||
|
func (w WaitStatus) Signal() syscall.Signal {
|
||||||
|
sig := syscall.Signal(w & mask)
|
||||||
|
if sig == stopped || sig == 0 {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return sig
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 }
|
||||||
|
|
||||||
|
func (w WaitStatus) Stopped() bool { return w&mask == stopped && syscall.Signal(w>>shift) != SIGSTOP }
|
||||||
|
|
||||||
|
func (w WaitStatus) Continued() bool { return w&mask == stopped && syscall.Signal(w>>shift) == SIGSTOP }
|
||||||
|
|
||||||
|
func (w WaitStatus) StopSignal() syscall.Signal {
|
||||||
|
if !w.Stopped() {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return syscall.Signal(w>>shift) & 0xFF
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WaitStatus) TrapCause() int { return -1 }
|
||||||
|
|
||||||
|
//sys wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error)
|
||||||
|
|
||||||
|
func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
|
||||||
|
var status _C_int
|
||||||
|
wpid, err = wait4(pid, &status, options, rusage)
|
||||||
|
if wstatus != nil {
|
||||||
|
*wstatus = WaitStatus(status)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||||
|
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
||||||
|
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
|
||||||
|
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
|
||||||
|
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sys Shutdown(s int, how int) (err error)
|
||||||
|
|
||||||
|
func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
if sa.Port < 0 || sa.Port > 0xFFFF {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
sa.raw.Len = SizeofSockaddrInet4
|
||||||
|
sa.raw.Family = AF_INET
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
|
||||||
|
p[0] = byte(sa.Port >> 8)
|
||||||
|
p[1] = byte(sa.Port)
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.raw.Addr[i] = sa.Addr[i]
|
||||||
|
}
|
||||||
|
return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
if sa.Port < 0 || sa.Port > 0xFFFF {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
sa.raw.Len = SizeofSockaddrInet6
|
||||||
|
sa.raw.Family = AF_INET6
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
|
||||||
|
p[0] = byte(sa.Port >> 8)
|
||||||
|
p[1] = byte(sa.Port)
|
||||||
|
sa.raw.Scope_id = sa.ZoneId
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.raw.Addr[i] = sa.Addr[i]
|
||||||
|
}
|
||||||
|
return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
name := sa.Name
|
||||||
|
n := len(name)
|
||||||
|
if n >= len(sa.raw.Path) || n == 0 {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
sa.raw.Len = byte(3 + n) // 2 for Family, Len; 1 for NUL
|
||||||
|
sa.raw.Family = AF_UNIX
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
sa.raw.Path[i] = int8(name[i])
|
||||||
|
}
|
||||||
|
return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sa *SockaddrDatalink) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
if sa.Index == 0 {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
sa.raw.Len = sa.Len
|
||||||
|
sa.raw.Family = AF_LINK
|
||||||
|
sa.raw.Index = sa.Index
|
||||||
|
sa.raw.Type = sa.Type
|
||||||
|
sa.raw.Nlen = sa.Nlen
|
||||||
|
sa.raw.Alen = sa.Alen
|
||||||
|
sa.raw.Slen = sa.Slen
|
||||||
|
for i := 0; i < len(sa.raw.Data); i++ {
|
||||||
|
sa.raw.Data[i] = sa.Data[i]
|
||||||
|
}
|
||||||
|
return unsafe.Pointer(&sa.raw), SizeofSockaddrDatalink, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||||
|
switch rsa.Addr.Family {
|
||||||
|
case AF_LINK:
|
||||||
|
pp := (*RawSockaddrDatalink)(unsafe.Pointer(rsa))
|
||||||
|
sa := new(SockaddrDatalink)
|
||||||
|
sa.Len = pp.Len
|
||||||
|
sa.Family = pp.Family
|
||||||
|
sa.Index = pp.Index
|
||||||
|
sa.Type = pp.Type
|
||||||
|
sa.Nlen = pp.Nlen
|
||||||
|
sa.Alen = pp.Alen
|
||||||
|
sa.Slen = pp.Slen
|
||||||
|
for i := 0; i < len(sa.Data); i++ {
|
||||||
|
sa.Data[i] = pp.Data[i]
|
||||||
|
}
|
||||||
|
return sa, nil
|
||||||
|
|
||||||
|
case AF_UNIX:
|
||||||
|
pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
|
||||||
|
if pp.Len < 2 || pp.Len > SizeofSockaddrUnix {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
sa := new(SockaddrUnix)
|
||||||
|
|
||||||
|
// Some BSDs include the trailing NUL in the length, whereas
|
||||||
|
// others do not. Work around this by subtracting the leading
|
||||||
|
// family and len. The path is then scanned to see if a NUL
|
||||||
|
// terminator still exists within the length.
|
||||||
|
n := int(pp.Len) - 2 // subtract leading Family, Len
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
if pp.Path[i] == 0 {
|
||||||
|
// found early NUL; assume Len included the NUL
|
||||||
|
// or was overestimating.
|
||||||
|
n = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
|
||||||
|
sa.Name = string(bytes)
|
||||||
|
return sa, nil
|
||||||
|
|
||||||
|
case AF_INET:
|
||||||
|
pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
|
||||||
|
sa := new(SockaddrInet4)
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&pp.Port))
|
||||||
|
sa.Port = int(p[0])<<8 + int(p[1])
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.Addr[i] = pp.Addr[i]
|
||||||
|
}
|
||||||
|
return sa, nil
|
||||||
|
|
||||||
|
case AF_INET6:
|
||||||
|
pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
|
||||||
|
sa := new(SockaddrInet6)
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&pp.Port))
|
||||||
|
sa.Port = int(p[0])<<8 + int(p[1])
|
||||||
|
sa.ZoneId = pp.Scope_id
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.Addr[i] = pp.Addr[i]
|
||||||
|
}
|
||||||
|
return sa, nil
|
||||||
|
}
|
||||||
|
return nil, EAFNOSUPPORT
|
||||||
|
}
|
||||||
|
|
||||||
|
func Accept(fd int) (nfd int, sa Sockaddr, err error) {
|
||||||
|
var rsa RawSockaddrAny
|
||||||
|
var len _Socklen = SizeofSockaddrAny
|
||||||
|
nfd, err = accept(fd, &rsa, &len)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if runtime.GOOS == "darwin" && len == 0 {
|
||||||
|
// Accepted socket has no address.
|
||||||
|
// This is likely due to a bug in xnu kernels,
|
||||||
|
// where instead of ECONNABORTED error socket
|
||||||
|
// is accepted, but has no address.
|
||||||
|
Close(nfd)
|
||||||
|
return 0, nil, ECONNABORTED
|
||||||
|
}
|
||||||
|
sa, err = anyToSockaddr(&rsa)
|
||||||
|
if err != nil {
|
||||||
|
Close(nfd)
|
||||||
|
nfd = 0
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Getsockname(fd int) (sa Sockaddr, err error) {
|
||||||
|
var rsa RawSockaddrAny
|
||||||
|
var len _Socklen = SizeofSockaddrAny
|
||||||
|
if err = getsockname(fd, &rsa, &len); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// TODO(jsing): DragonFly has a "bug" (see issue 3349), which should be
|
||||||
|
// reported upstream.
|
||||||
|
if runtime.GOOS == "dragonfly" && rsa.Addr.Family == AF_UNSPEC && rsa.Addr.Len == 0 {
|
||||||
|
rsa.Addr.Family = AF_UNIX
|
||||||
|
rsa.Addr.Len = SizeofSockaddrUnix
|
||||||
|
}
|
||||||
|
return anyToSockaddr(&rsa)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||||
|
|
||||||
|
func GetsockoptByte(fd, level, opt int) (value byte, err error) {
|
||||||
|
var n byte
|
||||||
|
vallen := _Socklen(1)
|
||||||
|
err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen)
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) {
|
||||||
|
vallen := _Socklen(4)
|
||||||
|
err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
|
||||||
|
return value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) {
|
||||||
|
var value IPMreq
|
||||||
|
vallen := _Socklen(SizeofIPMreq)
|
||||||
|
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) {
|
||||||
|
var value IPv6Mreq
|
||||||
|
vallen := _Socklen(SizeofIPv6Mreq)
|
||||||
|
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
|
||||||
|
var value IPv6MTUInfo
|
||||||
|
vallen := _Socklen(SizeofIPv6MTUInfo)
|
||||||
|
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) {
|
||||||
|
var value ICMPv6Filter
|
||||||
|
vallen := _Socklen(SizeofICMPv6Filter)
|
||||||
|
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||||
|
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
|
||||||
|
func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
|
||||||
|
var msg Msghdr
|
||||||
|
var rsa RawSockaddrAny
|
||||||
|
msg.Name = (*byte)(unsafe.Pointer(&rsa))
|
||||||
|
msg.Namelen = uint32(SizeofSockaddrAny)
|
||||||
|
var iov Iovec
|
||||||
|
if len(p) > 0 {
|
||||||
|
iov.Base = (*byte)(unsafe.Pointer(&p[0]))
|
||||||
|
iov.SetLen(len(p))
|
||||||
|
}
|
||||||
|
var dummy byte
|
||||||
|
if len(oob) > 0 {
|
||||||
|
// receive at least one normal byte
|
||||||
|
if len(p) == 0 {
|
||||||
|
iov.Base = &dummy
|
||||||
|
iov.SetLen(1)
|
||||||
|
}
|
||||||
|
msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
|
||||||
|
msg.SetControllen(len(oob))
|
||||||
|
}
|
||||||
|
msg.Iov = &iov
|
||||||
|
msg.Iovlen = 1
|
||||||
|
if n, err = recvmsg(fd, &msg, flags); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
oobn = int(msg.Controllen)
|
||||||
|
recvflags = int(msg.Flags)
|
||||||
|
// source address is only specified if the socket is unconnected
|
||||||
|
if rsa.Addr.Family != AF_UNSPEC {
|
||||||
|
from, err = anyToSockaddr(&rsa)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
|
||||||
|
func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
|
||||||
|
_, err = SendmsgN(fd, p, oob, to, flags)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
|
||||||
|
var ptr unsafe.Pointer
|
||||||
|
var salen _Socklen
|
||||||
|
if to != nil {
|
||||||
|
ptr, salen, err = to.sockaddr()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var msg Msghdr
|
||||||
|
msg.Name = (*byte)(unsafe.Pointer(ptr))
|
||||||
|
msg.Namelen = uint32(salen)
|
||||||
|
var iov Iovec
|
||||||
|
if len(p) > 0 {
|
||||||
|
iov.Base = (*byte)(unsafe.Pointer(&p[0]))
|
||||||
|
iov.SetLen(len(p))
|
||||||
|
}
|
||||||
|
var dummy byte
|
||||||
|
if len(oob) > 0 {
|
||||||
|
// send at least one normal byte
|
||||||
|
if len(p) == 0 {
|
||||||
|
iov.Base = &dummy
|
||||||
|
iov.SetLen(1)
|
||||||
|
}
|
||||||
|
msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
|
||||||
|
msg.SetControllen(len(oob))
|
||||||
|
}
|
||||||
|
msg.Iov = &iov
|
||||||
|
msg.Iovlen = 1
|
||||||
|
if n, err = sendmsg(fd, &msg, flags); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if len(oob) > 0 && len(p) == 0 {
|
||||||
|
n = 0
|
||||||
|
}
|
||||||
|
return n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error)
|
||||||
|
|
||||||
|
func Kevent(kq int, changes, events []Kevent_t, timeout *Timespec) (n int, err error) {
|
||||||
|
var change, event unsafe.Pointer
|
||||||
|
if len(changes) > 0 {
|
||||||
|
change = unsafe.Pointer(&changes[0])
|
||||||
|
}
|
||||||
|
if len(events) > 0 {
|
||||||
|
event = unsafe.Pointer(&events[0])
|
||||||
|
}
|
||||||
|
return kevent(kq, change, len(changes), event, len(events), timeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
|
||||||
|
|
||||||
|
// sysctlmib translates name to mib number and appends any additional args.
|
||||||
|
func sysctlmib(name string, args ...int) ([]_C_int, error) {
|
||||||
|
// Translate name to mib number.
|
||||||
|
mib, err := nametomib(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, a := range args {
|
||||||
|
mib = append(mib, _C_int(a))
|
||||||
|
}
|
||||||
|
|
||||||
|
return mib, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Sysctl(name string) (string, error) {
|
||||||
|
return SysctlArgs(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SysctlArgs(name string, args ...int) (string, error) {
|
||||||
|
mib, err := sysctlmib(name, args...)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find size.
|
||||||
|
n := uintptr(0)
|
||||||
|
if err := sysctl(mib, nil, &n, nil, 0); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if n == 0 {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read into buffer of that size.
|
||||||
|
buf := make([]byte, n)
|
||||||
|
if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Throw away terminating NUL.
|
||||||
|
if n > 0 && buf[n-1] == '\x00' {
|
||||||
|
n--
|
||||||
|
}
|
||||||
|
return string(buf[0:n]), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SysctlUint32(name string) (uint32, error) {
|
||||||
|
return SysctlUint32Args(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SysctlUint32Args(name string, args ...int) (uint32, error) {
|
||||||
|
mib, err := sysctlmib(name, args...)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
n := uintptr(4)
|
||||||
|
buf := make([]byte, 4)
|
||||||
|
if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if n != 4 {
|
||||||
|
return 0, EIO
|
||||||
|
}
|
||||||
|
return *(*uint32)(unsafe.Pointer(&buf[0])), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SysctlUint64(name string, args ...int) (uint64, error) {
|
||||||
|
mib, err := sysctlmib(name, args...)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
n := uintptr(8)
|
||||||
|
buf := make([]byte, 8)
|
||||||
|
if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if n != 8 {
|
||||||
|
return 0, EIO
|
||||||
|
}
|
||||||
|
return *(*uint64)(unsafe.Pointer(&buf[0])), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SysctlRaw(name string, args ...int) ([]byte, error) {
|
||||||
|
mib, err := sysctlmib(name, args...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find size.
|
||||||
|
n := uintptr(0)
|
||||||
|
if err := sysctl(mib, nil, &n, nil, 0); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if n == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read into buffer of that size.
|
||||||
|
buf := make([]byte, n)
|
||||||
|
if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// The actual call may return less than the original reported required
|
||||||
|
// size so ensure we deal with that.
|
||||||
|
return buf[:n], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys utimes(path string, timeval *[2]Timeval) (err error)
|
||||||
|
|
||||||
|
func Utimes(path string, tv []Timeval) error {
|
||||||
|
if tv == nil {
|
||||||
|
return utimes(path, nil)
|
||||||
|
}
|
||||||
|
if len(tv) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||||
|
}
|
||||||
|
|
||||||
|
func UtimesNano(path string, ts []Timespec) error {
|
||||||
|
if ts == nil {
|
||||||
|
return utimes(path, nil)
|
||||||
|
}
|
||||||
|
// TODO: The BSDs can do utimensat with SYS_UTIMENSAT but it
|
||||||
|
// isn't supported by darwin so this uses utimes instead
|
||||||
|
if len(ts) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
// Not as efficient as it could be because Timespec and
|
||||||
|
// Timeval have different types in the different OSes
|
||||||
|
tv := [2]Timeval{
|
||||||
|
NsecToTimeval(TimespecToNsec(ts[0])),
|
||||||
|
NsecToTimeval(TimespecToNsec(ts[1])),
|
||||||
|
}
|
||||||
|
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys futimes(fd int, timeval *[2]Timeval) (err error)
|
||||||
|
|
||||||
|
func Futimes(fd int, tv []Timeval) error {
|
||||||
|
if tv == nil {
|
||||||
|
return futimes(fd, nil)
|
||||||
|
}
|
||||||
|
if len(tv) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys fcntl(fd int, cmd int, arg int) (val int, err error)
|
||||||
|
|
||||||
|
// TODO: wrap
|
||||||
|
// Acct(name nil-string) (err error)
|
||||||
|
// Gethostuuid(uuid *byte, timeout *Timespec) (err error)
|
||||||
|
// Madvise(addr *byte, len int, behav int) (err error)
|
||||||
|
// Mprotect(addr *byte, len int, prot int) (err error)
|
||||||
|
// Msync(addr *byte, len int, flags int) (err error)
|
||||||
|
// Ptrace(req int, pid int, addr uintptr, data int) (ret uintptr, err error)
|
||||||
|
|
||||||
|
var mapper = &mmapper{
|
||||||
|
active: make(map[*byte][]byte),
|
||||||
|
mmap: mmap,
|
||||||
|
munmap: munmap,
|
||||||
|
}
|
||||||
|
|
||||||
|
func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
|
||||||
|
return mapper.Mmap(fd, offset, length, prot, flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Munmap(b []byte) (err error) {
|
||||||
|
return mapper.Munmap(b)
|
||||||
|
}
|
509
vendor/golang.org/x/sys/unix/syscall_darwin.go
generated
vendored
Normal file
509
vendor/golang.org/x/sys/unix/syscall_darwin.go
generated
vendored
Normal file
|
@ -0,0 +1,509 @@
|
||||||
|
// Copyright 2009,2010 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.
|
||||||
|
|
||||||
|
// Darwin system calls.
|
||||||
|
// This file is compiled as ordinary Go code,
|
||||||
|
// but it is also input to mksyscall,
|
||||||
|
// which parses the //sys lines and generates system call stubs.
|
||||||
|
// Note that sometimes we use a lowercase //sys name and wrap
|
||||||
|
// it in our own nicer implementation, either here or in
|
||||||
|
// syscall_bsd.go or syscall_unix.go.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
errorspkg "errors"
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
const ImplementsGetwd = true
|
||||||
|
|
||||||
|
func Getwd() (string, error) {
|
||||||
|
buf := make([]byte, 2048)
|
||||||
|
attrs, err := getAttrList(".", attrList{CommonAttr: attrCmnFullpath}, buf, 0)
|
||||||
|
if err == nil && len(attrs) == 1 && len(attrs[0]) >= 2 {
|
||||||
|
wd := string(attrs[0])
|
||||||
|
// Sanity check that it's an absolute path and ends
|
||||||
|
// in a null byte, which we then strip.
|
||||||
|
if wd[0] == '/' && wd[len(wd)-1] == 0 {
|
||||||
|
return wd[:len(wd)-1], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If pkg/os/getwd.go gets ENOTSUP, it will fall back to the
|
||||||
|
// slow algorithm.
|
||||||
|
return "", ENOTSUP
|
||||||
|
}
|
||||||
|
|
||||||
|
type SockaddrDatalink struct {
|
||||||
|
Len uint8
|
||||||
|
Family uint8
|
||||||
|
Index uint16
|
||||||
|
Type uint8
|
||||||
|
Nlen uint8
|
||||||
|
Alen uint8
|
||||||
|
Slen uint8
|
||||||
|
Data [12]int8
|
||||||
|
raw RawSockaddrDatalink
|
||||||
|
}
|
||||||
|
|
||||||
|
// Translate "kern.hostname" to []_C_int{0,1,2,3}.
|
||||||
|
func nametomib(name string) (mib []_C_int, err error) {
|
||||||
|
const siz = unsafe.Sizeof(mib[0])
|
||||||
|
|
||||||
|
// NOTE(rsc): It seems strange to set the buffer to have
|
||||||
|
// size CTL_MAXNAME+2 but use only CTL_MAXNAME
|
||||||
|
// as the size. I don't know why the +2 is here, but the
|
||||||
|
// kernel uses +2 for its own implementation of this function.
|
||||||
|
// I am scared that if we don't include the +2 here, the kernel
|
||||||
|
// will silently write 2 words farther than we specify
|
||||||
|
// and we'll get memory corruption.
|
||||||
|
var buf [CTL_MAXNAME + 2]_C_int
|
||||||
|
n := uintptr(CTL_MAXNAME) * siz
|
||||||
|
|
||||||
|
p := (*byte)(unsafe.Pointer(&buf[0]))
|
||||||
|
bytes, err := ByteSliceFromString(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Magic sysctl: "setting" 0.3 to a string name
|
||||||
|
// lets you read back the array of integers form.
|
||||||
|
if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return buf[0 : n/siz], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseDirent parses up to max directory entries in buf,
|
||||||
|
// appending the names to names. It returns the number
|
||||||
|
// bytes consumed from buf, the number of entries added
|
||||||
|
// to names, and the new names slice.
|
||||||
|
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
||||||
|
origlen := len(buf)
|
||||||
|
for max != 0 && len(buf) > 0 {
|
||||||
|
dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
|
||||||
|
if dirent.Reclen == 0 {
|
||||||
|
buf = nil
|
||||||
|
break
|
||||||
|
}
|
||||||
|
buf = buf[dirent.Reclen:]
|
||||||
|
if dirent.Ino == 0 { // File absent in directory.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
|
||||||
|
var name = string(bytes[0:dirent.Namlen])
|
||||||
|
if name == "." || name == ".." { // Useless names
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
max--
|
||||||
|
count++
|
||||||
|
names = append(names, name)
|
||||||
|
}
|
||||||
|
return origlen - len(buf), count, names
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
|
||||||
|
func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
|
||||||
|
func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
|
||||||
|
|
||||||
|
const (
|
||||||
|
attrBitMapCount = 5
|
||||||
|
attrCmnFullpath = 0x08000000
|
||||||
|
)
|
||||||
|
|
||||||
|
type attrList struct {
|
||||||
|
bitmapCount uint16
|
||||||
|
_ uint16
|
||||||
|
CommonAttr uint32
|
||||||
|
VolAttr uint32
|
||||||
|
DirAttr uint32
|
||||||
|
FileAttr uint32
|
||||||
|
Forkattr uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (attrs [][]byte, err error) {
|
||||||
|
if len(attrBuf) < 4 {
|
||||||
|
return nil, errorspkg.New("attrBuf too small")
|
||||||
|
}
|
||||||
|
attrList.bitmapCount = attrBitMapCount
|
||||||
|
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, e1 := Syscall6(
|
||||||
|
SYS_GETATTRLIST,
|
||||||
|
uintptr(unsafe.Pointer(_p0)),
|
||||||
|
uintptr(unsafe.Pointer(&attrList)),
|
||||||
|
uintptr(unsafe.Pointer(&attrBuf[0])),
|
||||||
|
uintptr(len(attrBuf)),
|
||||||
|
uintptr(options),
|
||||||
|
0,
|
||||||
|
)
|
||||||
|
if e1 != 0 {
|
||||||
|
return nil, e1
|
||||||
|
}
|
||||||
|
size := *(*uint32)(unsafe.Pointer(&attrBuf[0]))
|
||||||
|
|
||||||
|
// dat is the section of attrBuf that contains valid data,
|
||||||
|
// without the 4 byte length header. All attribute offsets
|
||||||
|
// are relative to dat.
|
||||||
|
dat := attrBuf
|
||||||
|
if int(size) < len(attrBuf) {
|
||||||
|
dat = dat[:size]
|
||||||
|
}
|
||||||
|
dat = dat[4:] // remove length prefix
|
||||||
|
|
||||||
|
for i := uint32(0); int(i) < len(dat); {
|
||||||
|
header := dat[i:]
|
||||||
|
if len(header) < 8 {
|
||||||
|
return attrs, errorspkg.New("truncated attribute header")
|
||||||
|
}
|
||||||
|
datOff := *(*int32)(unsafe.Pointer(&header[0]))
|
||||||
|
attrLen := *(*uint32)(unsafe.Pointer(&header[4]))
|
||||||
|
if datOff < 0 || uint32(datOff)+attrLen > uint32(len(dat)) {
|
||||||
|
return attrs, errorspkg.New("truncated results; attrBuf too small")
|
||||||
|
}
|
||||||
|
end := uint32(datOff) + attrLen
|
||||||
|
attrs = append(attrs, dat[datOff:end])
|
||||||
|
i = end
|
||||||
|
if r := i % 4; r != 0 {
|
||||||
|
i += (4 - r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe() (r int, w int, err error)
|
||||||
|
|
||||||
|
func Pipe(p []int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
p[0], p[1], err = pipe()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
|
||||||
|
var _p0 unsafe.Pointer
|
||||||
|
var bufsize uintptr
|
||||||
|
if len(buf) > 0 {
|
||||||
|
_p0 = unsafe.Pointer(&buf[0])
|
||||||
|
bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
|
||||||
|
}
|
||||||
|
r0, _, e1 := Syscall(SYS_GETFSSTAT64, uintptr(_p0), bufsize, uintptr(flags))
|
||||||
|
n = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wrapped
|
||||||
|
*/
|
||||||
|
|
||||||
|
//sys kill(pid int, signum int, posix int) (err error)
|
||||||
|
|
||||||
|
func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) }
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Exposed directly
|
||||||
|
*/
|
||||||
|
//sys Access(path string, mode uint32) (err error)
|
||||||
|
//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
|
||||||
|
//sys Chdir(path string) (err error)
|
||||||
|
//sys Chflags(path string, flags int) (err error)
|
||||||
|
//sys Chmod(path string, mode uint32) (err error)
|
||||||
|
//sys Chown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Chroot(path string) (err error)
|
||||||
|
//sys Close(fd int) (err error)
|
||||||
|
//sys Dup(fd int) (nfd int, err error)
|
||||||
|
//sys Dup2(from int, to int) (err error)
|
||||||
|
//sys Exchangedata(path1 string, path2 string, options int) (err error)
|
||||||
|
//sys Exit(code int)
|
||||||
|
//sys Fchdir(fd int) (err error)
|
||||||
|
//sys Fchflags(fd int, flags int) (err error)
|
||||||
|
//sys Fchmod(fd int, mode uint32) (err error)
|
||||||
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
|
//sys Flock(fd int, how int) (err error)
|
||||||
|
//sys Fpathconf(fd int, name int) (val int, err error)
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
|
||||||
|
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
|
||||||
|
//sys Fsync(fd int) (err error)
|
||||||
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
|
//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64
|
||||||
|
//sys Getdtablesize() (size int)
|
||||||
|
//sysnb Getegid() (egid int)
|
||||||
|
//sysnb Geteuid() (uid int)
|
||||||
|
//sysnb Getgid() (gid int)
|
||||||
|
//sysnb Getpgid(pid int) (pgid int, err error)
|
||||||
|
//sysnb Getpgrp() (pgrp int)
|
||||||
|
//sysnb Getpid() (pid int)
|
||||||
|
//sysnb Getppid() (ppid int)
|
||||||
|
//sys Getpriority(which int, who int) (prio int, err error)
|
||||||
|
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
|
||||||
|
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||||
|
//sysnb Getsid(pid int) (sid int, err error)
|
||||||
|
//sysnb Getuid() (uid int)
|
||||||
|
//sysnb Issetugid() (tainted bool)
|
||||||
|
//sys Kqueue() (fd int, err error)
|
||||||
|
//sys Lchown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Link(path string, link string) (err error)
|
||||||
|
//sys Listen(s int, backlog int) (err error)
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
||||||
|
//sys Mkdir(path string, mode uint32) (err error)
|
||||||
|
//sys Mkfifo(path string, mode uint32) (err error)
|
||||||
|
//sys Mknod(path string, mode uint32, dev int) (err error)
|
||||||
|
//sys Mlock(b []byte) (err error)
|
||||||
|
//sys Mlockall(flags int) (err error)
|
||||||
|
//sys Mprotect(b []byte, prot int) (err error)
|
||||||
|
//sys Munlock(b []byte) (err error)
|
||||||
|
//sys Munlockall() (err error)
|
||||||
|
//sys Open(path string, mode int, perm uint32) (fd int, err error)
|
||||||
|
//sys Pathconf(path string, name int) (val int, err error)
|
||||||
|
//sys Pread(fd int, p []byte, offset int64) (n int, err error)
|
||||||
|
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
|
||||||
|
//sys read(fd int, p []byte) (n int, err error)
|
||||||
|
//sys Readlink(path string, buf []byte) (n int, err error)
|
||||||
|
//sys Rename(from string, to string) (err error)
|
||||||
|
//sys Revoke(path string) (err error)
|
||||||
|
//sys Rmdir(path string) (err error)
|
||||||
|
//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
|
||||||
|
//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
|
||||||
|
//sys Setegid(egid int) (err error)
|
||||||
|
//sysnb Seteuid(euid int) (err error)
|
||||||
|
//sysnb Setgid(gid int) (err error)
|
||||||
|
//sys Setlogin(name string) (err error)
|
||||||
|
//sysnb Setpgid(pid int, pgid int) (err error)
|
||||||
|
//sys Setpriority(which int, who int, prio int) (err error)
|
||||||
|
//sys Setprivexec(flag int) (err error)
|
||||||
|
//sysnb Setregid(rgid int, egid int) (err error)
|
||||||
|
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||||
|
//sysnb Setrlimit(which int, lim *Rlimit) (err error)
|
||||||
|
//sysnb Setsid() (pid int, err error)
|
||||||
|
//sysnb Settimeofday(tp *Timeval) (err error)
|
||||||
|
//sysnb Setuid(uid int) (err error)
|
||||||
|
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
||||||
|
//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
|
||||||
|
//sys Symlink(path string, link string) (err error)
|
||||||
|
//sys Sync() (err error)
|
||||||
|
//sys Truncate(path string, length int64) (err error)
|
||||||
|
//sys Umask(newmask int) (oldmask int)
|
||||||
|
//sys Undelete(path string) (err error)
|
||||||
|
//sys Unlink(path string) (err error)
|
||||||
|
//sys Unmount(path string, flags int) (err error)
|
||||||
|
//sys write(fd int, p []byte) (n int, err error)
|
||||||
|
//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
|
||||||
|
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||||
|
//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
|
||||||
|
//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unimplemented
|
||||||
|
*/
|
||||||
|
// Profil
|
||||||
|
// Sigaction
|
||||||
|
// Sigprocmask
|
||||||
|
// Getlogin
|
||||||
|
// Sigpending
|
||||||
|
// Sigaltstack
|
||||||
|
// Ioctl
|
||||||
|
// Reboot
|
||||||
|
// Execve
|
||||||
|
// Vfork
|
||||||
|
// Sbrk
|
||||||
|
// Sstk
|
||||||
|
// Ovadvise
|
||||||
|
// Mincore
|
||||||
|
// Setitimer
|
||||||
|
// Swapon
|
||||||
|
// Select
|
||||||
|
// Sigsuspend
|
||||||
|
// Readv
|
||||||
|
// Writev
|
||||||
|
// Nfssvc
|
||||||
|
// Getfh
|
||||||
|
// Quotactl
|
||||||
|
// Mount
|
||||||
|
// Csops
|
||||||
|
// Waitid
|
||||||
|
// Add_profil
|
||||||
|
// Kdebug_trace
|
||||||
|
// Sigreturn
|
||||||
|
// Mmap
|
||||||
|
// Mlock
|
||||||
|
// Munlock
|
||||||
|
// Atsocket
|
||||||
|
// Kqueue_from_portset_np
|
||||||
|
// Kqueue_portset
|
||||||
|
// Getattrlist
|
||||||
|
// Setattrlist
|
||||||
|
// Getdirentriesattr
|
||||||
|
// Searchfs
|
||||||
|
// Delete
|
||||||
|
// Copyfile
|
||||||
|
// Poll
|
||||||
|
// Watchevent
|
||||||
|
// Waitevent
|
||||||
|
// Modwatch
|
||||||
|
// Getxattr
|
||||||
|
// Fgetxattr
|
||||||
|
// Setxattr
|
||||||
|
// Fsetxattr
|
||||||
|
// Removexattr
|
||||||
|
// Fremovexattr
|
||||||
|
// Listxattr
|
||||||
|
// Flistxattr
|
||||||
|
// Fsctl
|
||||||
|
// Initgroups
|
||||||
|
// Posix_spawn
|
||||||
|
// Nfsclnt
|
||||||
|
// Fhopen
|
||||||
|
// Minherit
|
||||||
|
// Semsys
|
||||||
|
// Msgsys
|
||||||
|
// Shmsys
|
||||||
|
// Semctl
|
||||||
|
// Semget
|
||||||
|
// Semop
|
||||||
|
// Msgctl
|
||||||
|
// Msgget
|
||||||
|
// Msgsnd
|
||||||
|
// Msgrcv
|
||||||
|
// Shmat
|
||||||
|
// Shmctl
|
||||||
|
// Shmdt
|
||||||
|
// Shmget
|
||||||
|
// Shm_open
|
||||||
|
// Shm_unlink
|
||||||
|
// Sem_open
|
||||||
|
// Sem_close
|
||||||
|
// Sem_unlink
|
||||||
|
// Sem_wait
|
||||||
|
// Sem_trywait
|
||||||
|
// Sem_post
|
||||||
|
// Sem_getvalue
|
||||||
|
// Sem_init
|
||||||
|
// Sem_destroy
|
||||||
|
// Open_extended
|
||||||
|
// Umask_extended
|
||||||
|
// Stat_extended
|
||||||
|
// Lstat_extended
|
||||||
|
// Fstat_extended
|
||||||
|
// Chmod_extended
|
||||||
|
// Fchmod_extended
|
||||||
|
// Access_extended
|
||||||
|
// Settid
|
||||||
|
// Gettid
|
||||||
|
// Setsgroups
|
||||||
|
// Getsgroups
|
||||||
|
// Setwgroups
|
||||||
|
// Getwgroups
|
||||||
|
// Mkfifo_extended
|
||||||
|
// Mkdir_extended
|
||||||
|
// Identitysvc
|
||||||
|
// Shared_region_check_np
|
||||||
|
// Shared_region_map_np
|
||||||
|
// __pthread_mutex_destroy
|
||||||
|
// __pthread_mutex_init
|
||||||
|
// __pthread_mutex_lock
|
||||||
|
// __pthread_mutex_trylock
|
||||||
|
// __pthread_mutex_unlock
|
||||||
|
// __pthread_cond_init
|
||||||
|
// __pthread_cond_destroy
|
||||||
|
// __pthread_cond_broadcast
|
||||||
|
// __pthread_cond_signal
|
||||||
|
// Setsid_with_pid
|
||||||
|
// __pthread_cond_timedwait
|
||||||
|
// Aio_fsync
|
||||||
|
// Aio_return
|
||||||
|
// Aio_suspend
|
||||||
|
// Aio_cancel
|
||||||
|
// Aio_error
|
||||||
|
// Aio_read
|
||||||
|
// Aio_write
|
||||||
|
// Lio_listio
|
||||||
|
// __pthread_cond_wait
|
||||||
|
// Iopolicysys
|
||||||
|
// Mlockall
|
||||||
|
// Munlockall
|
||||||
|
// __pthread_kill
|
||||||
|
// __pthread_sigmask
|
||||||
|
// __sigwait
|
||||||
|
// __disable_threadsignal
|
||||||
|
// __pthread_markcancel
|
||||||
|
// __pthread_canceled
|
||||||
|
// __semwait_signal
|
||||||
|
// Proc_info
|
||||||
|
// sendfile
|
||||||
|
// Stat64_extended
|
||||||
|
// Lstat64_extended
|
||||||
|
// Fstat64_extended
|
||||||
|
// __pthread_chdir
|
||||||
|
// __pthread_fchdir
|
||||||
|
// Audit
|
||||||
|
// Auditon
|
||||||
|
// Getauid
|
||||||
|
// Setauid
|
||||||
|
// Getaudit
|
||||||
|
// Setaudit
|
||||||
|
// Getaudit_addr
|
||||||
|
// Setaudit_addr
|
||||||
|
// Auditctl
|
||||||
|
// Bsdthread_create
|
||||||
|
// Bsdthread_terminate
|
||||||
|
// Stack_snapshot
|
||||||
|
// Bsdthread_register
|
||||||
|
// Workq_open
|
||||||
|
// Workq_ops
|
||||||
|
// __mac_execve
|
||||||
|
// __mac_syscall
|
||||||
|
// __mac_get_file
|
||||||
|
// __mac_set_file
|
||||||
|
// __mac_get_link
|
||||||
|
// __mac_set_link
|
||||||
|
// __mac_get_proc
|
||||||
|
// __mac_set_proc
|
||||||
|
// __mac_get_fd
|
||||||
|
// __mac_set_fd
|
||||||
|
// __mac_get_pid
|
||||||
|
// __mac_get_lcid
|
||||||
|
// __mac_get_lctx
|
||||||
|
// __mac_set_lctx
|
||||||
|
// Setlcid
|
||||||
|
// Read_nocancel
|
||||||
|
// Write_nocancel
|
||||||
|
// Open_nocancel
|
||||||
|
// Close_nocancel
|
||||||
|
// Wait4_nocancel
|
||||||
|
// Recvmsg_nocancel
|
||||||
|
// Sendmsg_nocancel
|
||||||
|
// Recvfrom_nocancel
|
||||||
|
// Accept_nocancel
|
||||||
|
// Msync_nocancel
|
||||||
|
// Fcntl_nocancel
|
||||||
|
// Select_nocancel
|
||||||
|
// Fsync_nocancel
|
||||||
|
// Connect_nocancel
|
||||||
|
// Sigsuspend_nocancel
|
||||||
|
// Readv_nocancel
|
||||||
|
// Writev_nocancel
|
||||||
|
// Sendto_nocancel
|
||||||
|
// Pread_nocancel
|
||||||
|
// Pwrite_nocancel
|
||||||
|
// Waitid_nocancel
|
||||||
|
// Poll_nocancel
|
||||||
|
// Msgsnd_nocancel
|
||||||
|
// Msgrcv_nocancel
|
||||||
|
// Sem_wait_nocancel
|
||||||
|
// Aio_suspend_nocancel
|
||||||
|
// __sigwait_nocancel
|
||||||
|
// __semwait_signal_nocancel
|
||||||
|
// __mac_mount
|
||||||
|
// __mac_get_mount
|
||||||
|
// __mac_getfsstat
|
77
vendor/golang.org/x/sys/unix/syscall_darwin_386.go
generated
vendored
Normal file
77
vendor/golang.org/x/sys/unix/syscall_darwin_386.go
generated
vendored
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build 386,darwin
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = int32(nsec / 1e9)
|
||||||
|
ts.Nsec = int32(nsec % 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||||
|
tv.Sec = int32(nsec / 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
|
||||||
|
func Gettimeofday(tv *Timeval) (err error) {
|
||||||
|
// The tv passed to gettimeofday must be non-nil
|
||||||
|
// but is otherwise unused. The answers come back
|
||||||
|
// in the two registers.
|
||||||
|
sec, usec, err := gettimeofday(tv)
|
||||||
|
tv.Sec = int32(sec)
|
||||||
|
tv.Usec = int32(usec)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint32(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
var length = uint64(count)
|
||||||
|
|
||||||
|
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
|
||||||
|
|
||||||
|
written = int(length)
|
||||||
|
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
|
||||||
|
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
|
||||||
|
// of darwin/386 the syscall is called sysctl instead of __sysctl.
|
||||||
|
const SYS___SYSCTL = SYS_SYSCTL
|
79
vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
generated
vendored
Normal file
79
vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
generated
vendored
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build amd64,darwin
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = nsec / 1e9
|
||||||
|
ts.Nsec = nsec % 1e9
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||||
|
tv.Sec = int64(nsec / 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
|
||||||
|
func Gettimeofday(tv *Timeval) (err error) {
|
||||||
|
// The tv passed to gettimeofday must be non-nil
|
||||||
|
// but is otherwise unused. The answers come back
|
||||||
|
// in the two registers.
|
||||||
|
sec, usec, err := gettimeofday(tv)
|
||||||
|
tv.Sec = sec
|
||||||
|
tv.Usec = usec
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint64(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
var length = uint64(count)
|
||||||
|
|
||||||
|
_, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
|
||||||
|
|
||||||
|
written = int(length)
|
||||||
|
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
|
||||||
|
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
|
||||||
|
// of darwin/amd64 the syscall is called sysctl instead of __sysctl.
|
||||||
|
const SYS___SYSCTL = SYS_SYSCTL
|
71
vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
generated
vendored
Normal file
71
vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
generated
vendored
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
// Copyright 2015 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 unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = int32(nsec / 1e9)
|
||||||
|
ts.Nsec = int32(nsec % 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||||
|
tv.Sec = int32(nsec / 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
|
||||||
|
func Gettimeofday(tv *Timeval) (err error) {
|
||||||
|
// The tv passed to gettimeofday must be non-nil
|
||||||
|
// but is otherwise unused. The answers come back
|
||||||
|
// in the two registers.
|
||||||
|
sec, usec, err := gettimeofday(tv)
|
||||||
|
tv.Sec = int32(sec)
|
||||||
|
tv.Usec = int32(usec)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint32(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
var length = uint64(count)
|
||||||
|
|
||||||
|
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
|
||||||
|
|
||||||
|
written = int(length)
|
||||||
|
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
|
77
vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
generated
vendored
Normal file
77
vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
generated
vendored
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
// Copyright 2015 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.
|
||||||
|
|
||||||
|
// +build arm64,darwin
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Getpagesize() int { return 16384 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = nsec / 1e9
|
||||||
|
ts.Nsec = nsec % 1e9
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||||
|
tv.Sec = int64(nsec / 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
|
||||||
|
func Gettimeofday(tv *Timeval) (err error) {
|
||||||
|
// The tv passed to gettimeofday must be non-nil
|
||||||
|
// but is otherwise unused. The answers come back
|
||||||
|
// in the two registers.
|
||||||
|
sec, usec, err := gettimeofday(tv)
|
||||||
|
tv.Sec = sec
|
||||||
|
tv.Usec = usec
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint64(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
var length = uint64(count)
|
||||||
|
|
||||||
|
_, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
|
||||||
|
|
||||||
|
written = int(length)
|
||||||
|
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
|
||||||
|
|
||||||
|
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
|
||||||
|
// of darwin/arm64 the syscall is called sysctl instead of __sysctl.
|
||||||
|
const SYS___SYSCTL = SYS_SYSCTL
|
411
vendor/golang.org/x/sys/unix/syscall_dragonfly.go
generated
vendored
Normal file
411
vendor/golang.org/x/sys/unix/syscall_dragonfly.go
generated
vendored
Normal file
|
@ -0,0 +1,411 @@
|
||||||
|
// Copyright 2009,2010 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.
|
||||||
|
|
||||||
|
// FreeBSD system calls.
|
||||||
|
// This file is compiled as ordinary Go code,
|
||||||
|
// but it is also input to mksyscall,
|
||||||
|
// which parses the //sys lines and generates system call stubs.
|
||||||
|
// Note that sometimes we use a lowercase //sys name and wrap
|
||||||
|
// it in our own nicer implementation, either here or in
|
||||||
|
// syscall_bsd.go or syscall_unix.go.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
type SockaddrDatalink struct {
|
||||||
|
Len uint8
|
||||||
|
Family uint8
|
||||||
|
Index uint16
|
||||||
|
Type uint8
|
||||||
|
Nlen uint8
|
||||||
|
Alen uint8
|
||||||
|
Slen uint8
|
||||||
|
Data [12]int8
|
||||||
|
Rcf uint16
|
||||||
|
Route [16]uint16
|
||||||
|
raw RawSockaddrDatalink
|
||||||
|
}
|
||||||
|
|
||||||
|
// Translate "kern.hostname" to []_C_int{0,1,2,3}.
|
||||||
|
func nametomib(name string) (mib []_C_int, err error) {
|
||||||
|
const siz = unsafe.Sizeof(mib[0])
|
||||||
|
|
||||||
|
// NOTE(rsc): It seems strange to set the buffer to have
|
||||||
|
// size CTL_MAXNAME+2 but use only CTL_MAXNAME
|
||||||
|
// as the size. I don't know why the +2 is here, but the
|
||||||
|
// kernel uses +2 for its own implementation of this function.
|
||||||
|
// I am scared that if we don't include the +2 here, the kernel
|
||||||
|
// will silently write 2 words farther than we specify
|
||||||
|
// and we'll get memory corruption.
|
||||||
|
var buf [CTL_MAXNAME + 2]_C_int
|
||||||
|
n := uintptr(CTL_MAXNAME) * siz
|
||||||
|
|
||||||
|
p := (*byte)(unsafe.Pointer(&buf[0]))
|
||||||
|
bytes, err := ByteSliceFromString(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Magic sysctl: "setting" 0.3 to a string name
|
||||||
|
// lets you read back the array of integers form.
|
||||||
|
if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return buf[0 : n/siz], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseDirent parses up to max directory entries in buf,
|
||||||
|
// appending the names to names. It returns the number
|
||||||
|
// bytes consumed from buf, the number of entries added
|
||||||
|
// to names, and the new names slice.
|
||||||
|
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
||||||
|
origlen := len(buf)
|
||||||
|
for max != 0 && len(buf) > 0 {
|
||||||
|
dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
|
||||||
|
reclen := int(16+dirent.Namlen+1+7) & ^7
|
||||||
|
buf = buf[reclen:]
|
||||||
|
if dirent.Fileno == 0 { // File absent in directory.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
|
||||||
|
var name = string(bytes[0:dirent.Namlen])
|
||||||
|
if name == "." || name == ".." { // Useless names
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
max--
|
||||||
|
count++
|
||||||
|
names = append(names, name)
|
||||||
|
}
|
||||||
|
return origlen - len(buf), count, names
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe() (r int, w int, err error)
|
||||||
|
|
||||||
|
func Pipe(p []int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
p[0], p[1], err = pipe()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys extpread(fd int, p []byte, flags int, offset int64) (n int, err error)
|
||||||
|
func Pread(fd int, p []byte, offset int64) (n int, err error) {
|
||||||
|
return extpread(fd, p, 0, offset)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error)
|
||||||
|
func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
|
||||||
|
return extpwrite(fd, p, 0, offset)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
|
||||||
|
var _p0 unsafe.Pointer
|
||||||
|
var bufsize uintptr
|
||||||
|
if len(buf) > 0 {
|
||||||
|
_p0 = unsafe.Pointer(&buf[0])
|
||||||
|
bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
|
||||||
|
}
|
||||||
|
r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
|
||||||
|
n = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Exposed directly
|
||||||
|
*/
|
||||||
|
//sys Access(path string, mode uint32) (err error)
|
||||||
|
//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
|
||||||
|
//sys Chdir(path string) (err error)
|
||||||
|
//sys Chflags(path string, flags int) (err error)
|
||||||
|
//sys Chmod(path string, mode uint32) (err error)
|
||||||
|
//sys Chown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Chroot(path string) (err error)
|
||||||
|
//sys Close(fd int) (err error)
|
||||||
|
//sys Dup(fd int) (nfd int, err error)
|
||||||
|
//sys Dup2(from int, to int) (err error)
|
||||||
|
//sys Exit(code int)
|
||||||
|
//sys Fchdir(fd int) (err error)
|
||||||
|
//sys Fchflags(fd int, flags int) (err error)
|
||||||
|
//sys Fchmod(fd int, mode uint32) (err error)
|
||||||
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
|
//sys Flock(fd int, how int) (err error)
|
||||||
|
//sys Fpathconf(fd int, name int) (val int, err error)
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||||
|
//sys Fstatfs(fd int, stat *Statfs_t) (err error)
|
||||||
|
//sys Fsync(fd int) (err error)
|
||||||
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
|
//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error)
|
||||||
|
//sys Getdtablesize() (size int)
|
||||||
|
//sysnb Getegid() (egid int)
|
||||||
|
//sysnb Geteuid() (uid int)
|
||||||
|
//sysnb Getgid() (gid int)
|
||||||
|
//sysnb Getpgid(pid int) (pgid int, err error)
|
||||||
|
//sysnb Getpgrp() (pgrp int)
|
||||||
|
//sysnb Getpid() (pid int)
|
||||||
|
//sysnb Getppid() (ppid int)
|
||||||
|
//sys Getpriority(which int, who int) (prio int, err error)
|
||||||
|
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
|
||||||
|
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||||
|
//sysnb Getsid(pid int) (sid int, err error)
|
||||||
|
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||||
|
//sysnb Getuid() (uid int)
|
||||||
|
//sys Issetugid() (tainted bool)
|
||||||
|
//sys Kill(pid int, signum syscall.Signal) (err error)
|
||||||
|
//sys Kqueue() (fd int, err error)
|
||||||
|
//sys Lchown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Link(path string, link string) (err error)
|
||||||
|
//sys Listen(s int, backlog int) (err error)
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Mkdir(path string, mode uint32) (err error)
|
||||||
|
//sys Mkfifo(path string, mode uint32) (err error)
|
||||||
|
//sys Mknod(path string, mode uint32, dev int) (err error)
|
||||||
|
//sys Mlock(b []byte) (err error)
|
||||||
|
//sys Mlockall(flags int) (err error)
|
||||||
|
//sys Mprotect(b []byte, prot int) (err error)
|
||||||
|
//sys Munlock(b []byte) (err error)
|
||||||
|
//sys Munlockall() (err error)
|
||||||
|
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
||||||
|
//sys Open(path string, mode int, perm uint32) (fd int, err error)
|
||||||
|
//sys Pathconf(path string, name int) (val int, err error)
|
||||||
|
//sys read(fd int, p []byte) (n int, err error)
|
||||||
|
//sys Readlink(path string, buf []byte) (n int, err error)
|
||||||
|
//sys Rename(from string, to string) (err error)
|
||||||
|
//sys Revoke(path string) (err error)
|
||||||
|
//sys Rmdir(path string) (err error)
|
||||||
|
//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
|
||||||
|
//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
|
||||||
|
//sysnb Setegid(egid int) (err error)
|
||||||
|
//sysnb Seteuid(euid int) (err error)
|
||||||
|
//sysnb Setgid(gid int) (err error)
|
||||||
|
//sys Setlogin(name string) (err error)
|
||||||
|
//sysnb Setpgid(pid int, pgid int) (err error)
|
||||||
|
//sys Setpriority(which int, who int, prio int) (err error)
|
||||||
|
//sysnb Setregid(rgid int, egid int) (err error)
|
||||||
|
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||||
|
//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
|
||||||
|
//sysnb Setresuid(ruid int, euid int, suid int) (err error)
|
||||||
|
//sysnb Setrlimit(which int, lim *Rlimit) (err error)
|
||||||
|
//sysnb Setsid() (pid int, err error)
|
||||||
|
//sysnb Settimeofday(tp *Timeval) (err error)
|
||||||
|
//sysnb Setuid(uid int) (err error)
|
||||||
|
//sys Stat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Statfs(path string, stat *Statfs_t) (err error)
|
||||||
|
//sys Symlink(path string, link string) (err error)
|
||||||
|
//sys Sync() (err error)
|
||||||
|
//sys Truncate(path string, length int64) (err error)
|
||||||
|
//sys Umask(newmask int) (oldmask int)
|
||||||
|
//sys Undelete(path string) (err error)
|
||||||
|
//sys Unlink(path string) (err error)
|
||||||
|
//sys Unmount(path string, flags int) (err error)
|
||||||
|
//sys write(fd int, p []byte) (n int, err error)
|
||||||
|
//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
|
||||||
|
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||||
|
//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
|
||||||
|
//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unimplemented
|
||||||
|
* TODO(jsing): Update this list for DragonFly.
|
||||||
|
*/
|
||||||
|
// Profil
|
||||||
|
// Sigaction
|
||||||
|
// Sigprocmask
|
||||||
|
// Getlogin
|
||||||
|
// Sigpending
|
||||||
|
// Sigaltstack
|
||||||
|
// Ioctl
|
||||||
|
// Reboot
|
||||||
|
// Execve
|
||||||
|
// Vfork
|
||||||
|
// Sbrk
|
||||||
|
// Sstk
|
||||||
|
// Ovadvise
|
||||||
|
// Mincore
|
||||||
|
// Setitimer
|
||||||
|
// Swapon
|
||||||
|
// Select
|
||||||
|
// Sigsuspend
|
||||||
|
// Readv
|
||||||
|
// Writev
|
||||||
|
// Nfssvc
|
||||||
|
// Getfh
|
||||||
|
// Quotactl
|
||||||
|
// Mount
|
||||||
|
// Csops
|
||||||
|
// Waitid
|
||||||
|
// Add_profil
|
||||||
|
// Kdebug_trace
|
||||||
|
// Sigreturn
|
||||||
|
// Mmap
|
||||||
|
// Atsocket
|
||||||
|
// Kqueue_from_portset_np
|
||||||
|
// Kqueue_portset
|
||||||
|
// Getattrlist
|
||||||
|
// Setattrlist
|
||||||
|
// Getdirentriesattr
|
||||||
|
// Searchfs
|
||||||
|
// Delete
|
||||||
|
// Copyfile
|
||||||
|
// Poll
|
||||||
|
// Watchevent
|
||||||
|
// Waitevent
|
||||||
|
// Modwatch
|
||||||
|
// Getxattr
|
||||||
|
// Fgetxattr
|
||||||
|
// Setxattr
|
||||||
|
// Fsetxattr
|
||||||
|
// Removexattr
|
||||||
|
// Fremovexattr
|
||||||
|
// Listxattr
|
||||||
|
// Flistxattr
|
||||||
|
// Fsctl
|
||||||
|
// Initgroups
|
||||||
|
// Posix_spawn
|
||||||
|
// Nfsclnt
|
||||||
|
// Fhopen
|
||||||
|
// Minherit
|
||||||
|
// Semsys
|
||||||
|
// Msgsys
|
||||||
|
// Shmsys
|
||||||
|
// Semctl
|
||||||
|
// Semget
|
||||||
|
// Semop
|
||||||
|
// Msgctl
|
||||||
|
// Msgget
|
||||||
|
// Msgsnd
|
||||||
|
// Msgrcv
|
||||||
|
// Shmat
|
||||||
|
// Shmctl
|
||||||
|
// Shmdt
|
||||||
|
// Shmget
|
||||||
|
// Shm_open
|
||||||
|
// Shm_unlink
|
||||||
|
// Sem_open
|
||||||
|
// Sem_close
|
||||||
|
// Sem_unlink
|
||||||
|
// Sem_wait
|
||||||
|
// Sem_trywait
|
||||||
|
// Sem_post
|
||||||
|
// Sem_getvalue
|
||||||
|
// Sem_init
|
||||||
|
// Sem_destroy
|
||||||
|
// Open_extended
|
||||||
|
// Umask_extended
|
||||||
|
// Stat_extended
|
||||||
|
// Lstat_extended
|
||||||
|
// Fstat_extended
|
||||||
|
// Chmod_extended
|
||||||
|
// Fchmod_extended
|
||||||
|
// Access_extended
|
||||||
|
// Settid
|
||||||
|
// Gettid
|
||||||
|
// Setsgroups
|
||||||
|
// Getsgroups
|
||||||
|
// Setwgroups
|
||||||
|
// Getwgroups
|
||||||
|
// Mkfifo_extended
|
||||||
|
// Mkdir_extended
|
||||||
|
// Identitysvc
|
||||||
|
// Shared_region_check_np
|
||||||
|
// Shared_region_map_np
|
||||||
|
// __pthread_mutex_destroy
|
||||||
|
// __pthread_mutex_init
|
||||||
|
// __pthread_mutex_lock
|
||||||
|
// __pthread_mutex_trylock
|
||||||
|
// __pthread_mutex_unlock
|
||||||
|
// __pthread_cond_init
|
||||||
|
// __pthread_cond_destroy
|
||||||
|
// __pthread_cond_broadcast
|
||||||
|
// __pthread_cond_signal
|
||||||
|
// Setsid_with_pid
|
||||||
|
// __pthread_cond_timedwait
|
||||||
|
// Aio_fsync
|
||||||
|
// Aio_return
|
||||||
|
// Aio_suspend
|
||||||
|
// Aio_cancel
|
||||||
|
// Aio_error
|
||||||
|
// Aio_read
|
||||||
|
// Aio_write
|
||||||
|
// Lio_listio
|
||||||
|
// __pthread_cond_wait
|
||||||
|
// Iopolicysys
|
||||||
|
// __pthread_kill
|
||||||
|
// __pthread_sigmask
|
||||||
|
// __sigwait
|
||||||
|
// __disable_threadsignal
|
||||||
|
// __pthread_markcancel
|
||||||
|
// __pthread_canceled
|
||||||
|
// __semwait_signal
|
||||||
|
// Proc_info
|
||||||
|
// Stat64_extended
|
||||||
|
// Lstat64_extended
|
||||||
|
// Fstat64_extended
|
||||||
|
// __pthread_chdir
|
||||||
|
// __pthread_fchdir
|
||||||
|
// Audit
|
||||||
|
// Auditon
|
||||||
|
// Getauid
|
||||||
|
// Setauid
|
||||||
|
// Getaudit
|
||||||
|
// Setaudit
|
||||||
|
// Getaudit_addr
|
||||||
|
// Setaudit_addr
|
||||||
|
// Auditctl
|
||||||
|
// Bsdthread_create
|
||||||
|
// Bsdthread_terminate
|
||||||
|
// Stack_snapshot
|
||||||
|
// Bsdthread_register
|
||||||
|
// Workq_open
|
||||||
|
// Workq_ops
|
||||||
|
// __mac_execve
|
||||||
|
// __mac_syscall
|
||||||
|
// __mac_get_file
|
||||||
|
// __mac_set_file
|
||||||
|
// __mac_get_link
|
||||||
|
// __mac_set_link
|
||||||
|
// __mac_get_proc
|
||||||
|
// __mac_set_proc
|
||||||
|
// __mac_get_fd
|
||||||
|
// __mac_set_fd
|
||||||
|
// __mac_get_pid
|
||||||
|
// __mac_get_lcid
|
||||||
|
// __mac_get_lctx
|
||||||
|
// __mac_set_lctx
|
||||||
|
// Setlcid
|
||||||
|
// Read_nocancel
|
||||||
|
// Write_nocancel
|
||||||
|
// Open_nocancel
|
||||||
|
// Close_nocancel
|
||||||
|
// Wait4_nocancel
|
||||||
|
// Recvmsg_nocancel
|
||||||
|
// Sendmsg_nocancel
|
||||||
|
// Recvfrom_nocancel
|
||||||
|
// Accept_nocancel
|
||||||
|
// Msync_nocancel
|
||||||
|
// Fcntl_nocancel
|
||||||
|
// Select_nocancel
|
||||||
|
// Fsync_nocancel
|
||||||
|
// Connect_nocancel
|
||||||
|
// Sigsuspend_nocancel
|
||||||
|
// Readv_nocancel
|
||||||
|
// Writev_nocancel
|
||||||
|
// Sendto_nocancel
|
||||||
|
// Pread_nocancel
|
||||||
|
// Pwrite_nocancel
|
||||||
|
// Waitid_nocancel
|
||||||
|
// Poll_nocancel
|
||||||
|
// Msgsnd_nocancel
|
||||||
|
// Msgrcv_nocancel
|
||||||
|
// Sem_wait_nocancel
|
||||||
|
// Aio_suspend_nocancel
|
||||||
|
// __sigwait_nocancel
|
||||||
|
// __semwait_signal_nocancel
|
||||||
|
// __mac_mount
|
||||||
|
// __mac_get_mount
|
||||||
|
// __mac_getfsstat
|
61
vendor/golang.org/x/sys/unix/syscall_dragonfly_386.go
generated
vendored
Normal file
61
vendor/golang.org/x/sys/unix/syscall_dragonfly_386.go
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build 386,dragonfly
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = int32(nsec / 1e9)
|
||||||
|
ts.Nsec = int32(nsec % 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||||
|
tv.Sec = int32(nsec / 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint32(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
var writtenOut uint64 = 0
|
||||||
|
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
|
||||||
|
|
||||||
|
written = int(writtenOut)
|
||||||
|
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
61
vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go
generated
vendored
Normal file
61
vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build amd64,dragonfly
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = nsec / 1e9
|
||||||
|
ts.Nsec = nsec % 1e9
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Usec = nsec % 1e9 / 1e3
|
||||||
|
tv.Sec = int64(nsec / 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint64(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
var writtenOut uint64 = 0
|
||||||
|
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
|
||||||
|
|
||||||
|
written = int(writtenOut)
|
||||||
|
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
682
vendor/golang.org/x/sys/unix/syscall_freebsd.go
generated
vendored
Normal file
682
vendor/golang.org/x/sys/unix/syscall_freebsd.go
generated
vendored
Normal file
|
@ -0,0 +1,682 @@
|
||||||
|
// Copyright 2009,2010 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.
|
||||||
|
|
||||||
|
// FreeBSD system calls.
|
||||||
|
// This file is compiled as ordinary Go code,
|
||||||
|
// but it is also input to mksyscall,
|
||||||
|
// which parses the //sys lines and generates system call stubs.
|
||||||
|
// Note that sometimes we use a lowercase //sys name and wrap
|
||||||
|
// it in our own nicer implementation, either here or in
|
||||||
|
// syscall_bsd.go or syscall_unix.go.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
type SockaddrDatalink struct {
|
||||||
|
Len uint8
|
||||||
|
Family uint8
|
||||||
|
Index uint16
|
||||||
|
Type uint8
|
||||||
|
Nlen uint8
|
||||||
|
Alen uint8
|
||||||
|
Slen uint8
|
||||||
|
Data [46]int8
|
||||||
|
raw RawSockaddrDatalink
|
||||||
|
}
|
||||||
|
|
||||||
|
// Translate "kern.hostname" to []_C_int{0,1,2,3}.
|
||||||
|
func nametomib(name string) (mib []_C_int, err error) {
|
||||||
|
const siz = unsafe.Sizeof(mib[0])
|
||||||
|
|
||||||
|
// NOTE(rsc): It seems strange to set the buffer to have
|
||||||
|
// size CTL_MAXNAME+2 but use only CTL_MAXNAME
|
||||||
|
// as the size. I don't know why the +2 is here, but the
|
||||||
|
// kernel uses +2 for its own implementation of this function.
|
||||||
|
// I am scared that if we don't include the +2 here, the kernel
|
||||||
|
// will silently write 2 words farther than we specify
|
||||||
|
// and we'll get memory corruption.
|
||||||
|
var buf [CTL_MAXNAME + 2]_C_int
|
||||||
|
n := uintptr(CTL_MAXNAME) * siz
|
||||||
|
|
||||||
|
p := (*byte)(unsafe.Pointer(&buf[0]))
|
||||||
|
bytes, err := ByteSliceFromString(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Magic sysctl: "setting" 0.3 to a string name
|
||||||
|
// lets you read back the array of integers form.
|
||||||
|
if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return buf[0 : n/siz], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseDirent parses up to max directory entries in buf,
|
||||||
|
// appending the names to names. It returns the number
|
||||||
|
// bytes consumed from buf, the number of entries added
|
||||||
|
// to names, and the new names slice.
|
||||||
|
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
||||||
|
origlen := len(buf)
|
||||||
|
for max != 0 && len(buf) > 0 {
|
||||||
|
dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
|
||||||
|
if dirent.Reclen == 0 {
|
||||||
|
buf = nil
|
||||||
|
break
|
||||||
|
}
|
||||||
|
buf = buf[dirent.Reclen:]
|
||||||
|
if dirent.Fileno == 0 { // File absent in directory.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
|
||||||
|
var name = string(bytes[0:dirent.Namlen])
|
||||||
|
if name == "." || name == ".." { // Useless names
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
max--
|
||||||
|
count++
|
||||||
|
names = append(names, name)
|
||||||
|
}
|
||||||
|
return origlen - len(buf), count, names
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe() (r int, w int, err error)
|
||||||
|
|
||||||
|
func Pipe(p []int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
p[0], p[1], err = pipe()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
|
||||||
|
var value IPMreqn
|
||||||
|
vallen := _Socklen(SizeofIPMreqn)
|
||||||
|
errno := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||||
|
return &value, errno
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
|
||||||
|
return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
|
||||||
|
}
|
||||||
|
|
||||||
|
func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) {
|
||||||
|
var rsa RawSockaddrAny
|
||||||
|
var len _Socklen = SizeofSockaddrAny
|
||||||
|
nfd, err = accept4(fd, &rsa, &len, flags)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len > SizeofSockaddrAny {
|
||||||
|
panic("RawSockaddrAny too small")
|
||||||
|
}
|
||||||
|
sa, err = anyToSockaddr(&rsa)
|
||||||
|
if err != nil {
|
||||||
|
Close(nfd)
|
||||||
|
nfd = 0
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
|
||||||
|
var _p0 unsafe.Pointer
|
||||||
|
var bufsize uintptr
|
||||||
|
if len(buf) > 0 {
|
||||||
|
_p0 = unsafe.Pointer(&buf[0])
|
||||||
|
bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
|
||||||
|
}
|
||||||
|
r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
|
||||||
|
n = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Derive extattr namespace and attribute name
|
||||||
|
|
||||||
|
func xattrnamespace(fullattr string) (ns int, attr string, err error) {
|
||||||
|
s := -1
|
||||||
|
for idx, val := range fullattr {
|
||||||
|
if val == '.' {
|
||||||
|
s = idx
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if s == -1 {
|
||||||
|
return -1, "", ENOATTR
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace := fullattr[0:s]
|
||||||
|
attr = fullattr[s+1:]
|
||||||
|
|
||||||
|
switch namespace {
|
||||||
|
case "user":
|
||||||
|
return EXTATTR_NAMESPACE_USER, attr, nil
|
||||||
|
case "system":
|
||||||
|
return EXTATTR_NAMESPACE_SYSTEM, attr, nil
|
||||||
|
default:
|
||||||
|
return -1, "", ENOATTR
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func initxattrdest(dest []byte, idx int) (d unsafe.Pointer) {
|
||||||
|
if len(dest) > idx {
|
||||||
|
return unsafe.Pointer(&dest[idx])
|
||||||
|
} else {
|
||||||
|
return unsafe.Pointer(_zero)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FreeBSD implements its own syscalls to handle extended attributes
|
||||||
|
|
||||||
|
func Getxattr(file string, attr string, dest []byte) (sz int, err error) {
|
||||||
|
d := initxattrdest(dest, 0)
|
||||||
|
destsize := len(dest)
|
||||||
|
|
||||||
|
nsid, a, err := xattrnamespace(attr)
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ExtattrGetFile(file, nsid, a, uintptr(d), destsize)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) {
|
||||||
|
d := initxattrdest(dest, 0)
|
||||||
|
destsize := len(dest)
|
||||||
|
|
||||||
|
nsid, a, err := xattrnamespace(attr)
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ExtattrGetFd(fd, nsid, a, uintptr(d), destsize)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Lgetxattr(link string, attr string, dest []byte) (sz int, err error) {
|
||||||
|
d := initxattrdest(dest, 0)
|
||||||
|
destsize := len(dest)
|
||||||
|
|
||||||
|
nsid, a, err := xattrnamespace(attr)
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ExtattrGetLink(link, nsid, a, uintptr(d), destsize)
|
||||||
|
}
|
||||||
|
|
||||||
|
// flags are unused on FreeBSD
|
||||||
|
|
||||||
|
func Fsetxattr(fd int, attr string, data []byte, flags int) (err error) {
|
||||||
|
d := unsafe.Pointer(&data[0])
|
||||||
|
datasiz := len(data)
|
||||||
|
|
||||||
|
nsid, a, err := xattrnamespace(attr)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = ExtattrSetFd(fd, nsid, a, uintptr(d), datasiz)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Setxattr(file string, attr string, data []byte, flags int) (err error) {
|
||||||
|
d := unsafe.Pointer(&data[0])
|
||||||
|
datasiz := len(data)
|
||||||
|
|
||||||
|
nsid, a, err := xattrnamespace(attr)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = ExtattrSetFile(file, nsid, a, uintptr(d), datasiz)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Lsetxattr(link string, attr string, data []byte, flags int) (err error) {
|
||||||
|
d := unsafe.Pointer(&data[0])
|
||||||
|
datasiz := len(data)
|
||||||
|
|
||||||
|
nsid, a, err := xattrnamespace(attr)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = ExtattrSetLink(link, nsid, a, uintptr(d), datasiz)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Removexattr(file string, attr string) (err error) {
|
||||||
|
nsid, a, err := xattrnamespace(attr)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ExtattrDeleteFile(file, nsid, a)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Fremovexattr(fd int, attr string) (err error) {
|
||||||
|
nsid, a, err := xattrnamespace(attr)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ExtattrDeleteFd(fd, nsid, a)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Lremovexattr(link string, attr string) (err error) {
|
||||||
|
nsid, a, err := xattrnamespace(attr)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ExtattrDeleteLink(link, nsid, a)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Listxattr(file string, dest []byte) (sz int, err error) {
|
||||||
|
d := initxattrdest(dest, 0)
|
||||||
|
destsiz := len(dest)
|
||||||
|
|
||||||
|
// FreeBSD won't allow you to list xattrs from multiple namespaces
|
||||||
|
s := 0
|
||||||
|
var e error
|
||||||
|
for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
|
||||||
|
stmp, e := ExtattrListFile(file, nsid, uintptr(d), destsiz)
|
||||||
|
|
||||||
|
/* Errors accessing system attrs are ignored so that
|
||||||
|
* we can implement the Linux-like behavior of omitting errors that
|
||||||
|
* we don't have read permissions on
|
||||||
|
*
|
||||||
|
* Linux will still error if we ask for user attributes on a file that
|
||||||
|
* we don't have read permissions on, so don't ignore those errors
|
||||||
|
*/
|
||||||
|
if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
|
||||||
|
e = nil
|
||||||
|
continue
|
||||||
|
} else if e != nil {
|
||||||
|
return s, e
|
||||||
|
}
|
||||||
|
|
||||||
|
s += stmp
|
||||||
|
destsiz -= s
|
||||||
|
if destsiz < 0 {
|
||||||
|
destsiz = 0
|
||||||
|
}
|
||||||
|
d = initxattrdest(dest, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
return s, e
|
||||||
|
}
|
||||||
|
|
||||||
|
func Flistxattr(fd int, dest []byte) (sz int, err error) {
|
||||||
|
d := initxattrdest(dest, 0)
|
||||||
|
destsiz := len(dest)
|
||||||
|
|
||||||
|
s := 0
|
||||||
|
var e error
|
||||||
|
for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
|
||||||
|
stmp, e := ExtattrListFd(fd, nsid, uintptr(d), destsiz)
|
||||||
|
if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
|
||||||
|
e = nil
|
||||||
|
continue
|
||||||
|
} else if e != nil {
|
||||||
|
return s, e
|
||||||
|
}
|
||||||
|
|
||||||
|
s += stmp
|
||||||
|
destsiz -= s
|
||||||
|
if destsiz < 0 {
|
||||||
|
destsiz = 0
|
||||||
|
}
|
||||||
|
d = initxattrdest(dest, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
return s, e
|
||||||
|
}
|
||||||
|
|
||||||
|
func Llistxattr(link string, dest []byte) (sz int, err error) {
|
||||||
|
d := initxattrdest(dest, 0)
|
||||||
|
destsiz := len(dest)
|
||||||
|
|
||||||
|
s := 0
|
||||||
|
var e error
|
||||||
|
for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
|
||||||
|
stmp, e := ExtattrListLink(link, nsid, uintptr(d), destsiz)
|
||||||
|
if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
|
||||||
|
e = nil
|
||||||
|
continue
|
||||||
|
} else if e != nil {
|
||||||
|
return s, e
|
||||||
|
}
|
||||||
|
|
||||||
|
s += stmp
|
||||||
|
destsiz -= s
|
||||||
|
if destsiz < 0 {
|
||||||
|
destsiz = 0
|
||||||
|
}
|
||||||
|
d = initxattrdest(dest, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
return s, e
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Exposed directly
|
||||||
|
*/
|
||||||
|
//sys Access(path string, mode uint32) (err error)
|
||||||
|
//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
|
||||||
|
//sys Chdir(path string) (err error)
|
||||||
|
//sys Chflags(path string, flags int) (err error)
|
||||||
|
//sys Chmod(path string, mode uint32) (err error)
|
||||||
|
//sys Chown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Chroot(path string) (err error)
|
||||||
|
//sys Close(fd int) (err error)
|
||||||
|
//sys Dup(fd int) (nfd int, err error)
|
||||||
|
//sys Dup2(from int, to int) (err error)
|
||||||
|
//sys Exit(code int)
|
||||||
|
//sys ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
||||||
|
//sys ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
||||||
|
//sys ExtattrDeleteFd(fd int, attrnamespace int, attrname string) (err error)
|
||||||
|
//sys ExtattrListFd(fd int, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
|
||||||
|
//sys ExtattrGetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
||||||
|
//sys ExtattrSetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
||||||
|
//sys ExtattrDeleteFile(file string, attrnamespace int, attrname string) (err error)
|
||||||
|
//sys ExtattrListFile(file string, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
|
||||||
|
//sys ExtattrGetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
||||||
|
//sys ExtattrSetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
||||||
|
//sys ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error)
|
||||||
|
//sys ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
|
||||||
|
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_POSIX_FADVISE
|
||||||
|
//sys Fchdir(fd int) (err error)
|
||||||
|
//sys Fchflags(fd int, flags int) (err error)
|
||||||
|
//sys Fchmod(fd int, mode uint32) (err error)
|
||||||
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
|
//sys Flock(fd int, how int) (err error)
|
||||||
|
//sys Fpathconf(fd int, name int) (val int, err error)
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||||
|
//sys Fstatfs(fd int, stat *Statfs_t) (err error)
|
||||||
|
//sys Fsync(fd int) (err error)
|
||||||
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
|
//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error)
|
||||||
|
//sys Getdtablesize() (size int)
|
||||||
|
//sysnb Getegid() (egid int)
|
||||||
|
//sysnb Geteuid() (uid int)
|
||||||
|
//sysnb Getgid() (gid int)
|
||||||
|
//sysnb Getpgid(pid int) (pgid int, err error)
|
||||||
|
//sysnb Getpgrp() (pgrp int)
|
||||||
|
//sysnb Getpid() (pid int)
|
||||||
|
//sysnb Getppid() (ppid int)
|
||||||
|
//sys Getpriority(which int, who int) (prio int, err error)
|
||||||
|
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
|
||||||
|
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||||
|
//sysnb Getsid(pid int) (sid int, err error)
|
||||||
|
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||||
|
//sysnb Getuid() (uid int)
|
||||||
|
//sys Issetugid() (tainted bool)
|
||||||
|
//sys Kill(pid int, signum syscall.Signal) (err error)
|
||||||
|
//sys Kqueue() (fd int, err error)
|
||||||
|
//sys Lchown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Link(path string, link string) (err error)
|
||||||
|
//sys Listen(s int, backlog int) (err error)
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Mkdir(path string, mode uint32) (err error)
|
||||||
|
//sys Mkfifo(path string, mode uint32) (err error)
|
||||||
|
//sys Mknod(path string, mode uint32, dev int) (err error)
|
||||||
|
//sys Mlock(b []byte) (err error)
|
||||||
|
//sys Mlockall(flags int) (err error)
|
||||||
|
//sys Mprotect(b []byte, prot int) (err error)
|
||||||
|
//sys Munlock(b []byte) (err error)
|
||||||
|
//sys Munlockall() (err error)
|
||||||
|
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
||||||
|
//sys Open(path string, mode int, perm uint32) (fd int, err error)
|
||||||
|
//sys Pathconf(path string, name int) (val int, err error)
|
||||||
|
//sys Pread(fd int, p []byte, offset int64) (n int, err error)
|
||||||
|
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
|
||||||
|
//sys read(fd int, p []byte) (n int, err error)
|
||||||
|
//sys Readlink(path string, buf []byte) (n int, err error)
|
||||||
|
//sys Rename(from string, to string) (err error)
|
||||||
|
//sys Revoke(path string) (err error)
|
||||||
|
//sys Rmdir(path string) (err error)
|
||||||
|
//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
|
||||||
|
//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
|
||||||
|
//sysnb Setegid(egid int) (err error)
|
||||||
|
//sysnb Seteuid(euid int) (err error)
|
||||||
|
//sysnb Setgid(gid int) (err error)
|
||||||
|
//sys Setlogin(name string) (err error)
|
||||||
|
//sysnb Setpgid(pid int, pgid int) (err error)
|
||||||
|
//sys Setpriority(which int, who int, prio int) (err error)
|
||||||
|
//sysnb Setregid(rgid int, egid int) (err error)
|
||||||
|
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||||
|
//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
|
||||||
|
//sysnb Setresuid(ruid int, euid int, suid int) (err error)
|
||||||
|
//sysnb Setrlimit(which int, lim *Rlimit) (err error)
|
||||||
|
//sysnb Setsid() (pid int, err error)
|
||||||
|
//sysnb Settimeofday(tp *Timeval) (err error)
|
||||||
|
//sysnb Setuid(uid int) (err error)
|
||||||
|
//sys Stat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Statfs(path string, stat *Statfs_t) (err error)
|
||||||
|
//sys Symlink(path string, link string) (err error)
|
||||||
|
//sys Sync() (err error)
|
||||||
|
//sys Truncate(path string, length int64) (err error)
|
||||||
|
//sys Umask(newmask int) (oldmask int)
|
||||||
|
//sys Undelete(path string) (err error)
|
||||||
|
//sys Unlink(path string) (err error)
|
||||||
|
//sys Unmount(path string, flags int) (err error)
|
||||||
|
//sys write(fd int, p []byte) (n int, err error)
|
||||||
|
//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
|
||||||
|
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||||
|
//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
|
||||||
|
//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
|
||||||
|
//sys accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unimplemented
|
||||||
|
*/
|
||||||
|
// Profil
|
||||||
|
// Sigaction
|
||||||
|
// Sigprocmask
|
||||||
|
// Getlogin
|
||||||
|
// Sigpending
|
||||||
|
// Sigaltstack
|
||||||
|
// Ioctl
|
||||||
|
// Reboot
|
||||||
|
// Execve
|
||||||
|
// Vfork
|
||||||
|
// Sbrk
|
||||||
|
// Sstk
|
||||||
|
// Ovadvise
|
||||||
|
// Mincore
|
||||||
|
// Setitimer
|
||||||
|
// Swapon
|
||||||
|
// Select
|
||||||
|
// Sigsuspend
|
||||||
|
// Readv
|
||||||
|
// Writev
|
||||||
|
// Nfssvc
|
||||||
|
// Getfh
|
||||||
|
// Quotactl
|
||||||
|
// Mount
|
||||||
|
// Csops
|
||||||
|
// Waitid
|
||||||
|
// Add_profil
|
||||||
|
// Kdebug_trace
|
||||||
|
// Sigreturn
|
||||||
|
// Mmap
|
||||||
|
// Mlock
|
||||||
|
// Munlock
|
||||||
|
// Atsocket
|
||||||
|
// Kqueue_from_portset_np
|
||||||
|
// Kqueue_portset
|
||||||
|
// Getattrlist
|
||||||
|
// Setattrlist
|
||||||
|
// Getdirentriesattr
|
||||||
|
// Searchfs
|
||||||
|
// Delete
|
||||||
|
// Copyfile
|
||||||
|
// Poll
|
||||||
|
// Watchevent
|
||||||
|
// Waitevent
|
||||||
|
// Modwatch
|
||||||
|
// Getxattr
|
||||||
|
// Fgetxattr
|
||||||
|
// Setxattr
|
||||||
|
// Fsetxattr
|
||||||
|
// Removexattr
|
||||||
|
// Fremovexattr
|
||||||
|
// Listxattr
|
||||||
|
// Flistxattr
|
||||||
|
// Fsctl
|
||||||
|
// Initgroups
|
||||||
|
// Posix_spawn
|
||||||
|
// Nfsclnt
|
||||||
|
// Fhopen
|
||||||
|
// Minherit
|
||||||
|
// Semsys
|
||||||
|
// Msgsys
|
||||||
|
// Shmsys
|
||||||
|
// Semctl
|
||||||
|
// Semget
|
||||||
|
// Semop
|
||||||
|
// Msgctl
|
||||||
|
// Msgget
|
||||||
|
// Msgsnd
|
||||||
|
// Msgrcv
|
||||||
|
// Shmat
|
||||||
|
// Shmctl
|
||||||
|
// Shmdt
|
||||||
|
// Shmget
|
||||||
|
// Shm_open
|
||||||
|
// Shm_unlink
|
||||||
|
// Sem_open
|
||||||
|
// Sem_close
|
||||||
|
// Sem_unlink
|
||||||
|
// Sem_wait
|
||||||
|
// Sem_trywait
|
||||||
|
// Sem_post
|
||||||
|
// Sem_getvalue
|
||||||
|
// Sem_init
|
||||||
|
// Sem_destroy
|
||||||
|
// Open_extended
|
||||||
|
// Umask_extended
|
||||||
|
// Stat_extended
|
||||||
|
// Lstat_extended
|
||||||
|
// Fstat_extended
|
||||||
|
// Chmod_extended
|
||||||
|
// Fchmod_extended
|
||||||
|
// Access_extended
|
||||||
|
// Settid
|
||||||
|
// Gettid
|
||||||
|
// Setsgroups
|
||||||
|
// Getsgroups
|
||||||
|
// Setwgroups
|
||||||
|
// Getwgroups
|
||||||
|
// Mkfifo_extended
|
||||||
|
// Mkdir_extended
|
||||||
|
// Identitysvc
|
||||||
|
// Shared_region_check_np
|
||||||
|
// Shared_region_map_np
|
||||||
|
// __pthread_mutex_destroy
|
||||||
|
// __pthread_mutex_init
|
||||||
|
// __pthread_mutex_lock
|
||||||
|
// __pthread_mutex_trylock
|
||||||
|
// __pthread_mutex_unlock
|
||||||
|
// __pthread_cond_init
|
||||||
|
// __pthread_cond_destroy
|
||||||
|
// __pthread_cond_broadcast
|
||||||
|
// __pthread_cond_signal
|
||||||
|
// Setsid_with_pid
|
||||||
|
// __pthread_cond_timedwait
|
||||||
|
// Aio_fsync
|
||||||
|
// Aio_return
|
||||||
|
// Aio_suspend
|
||||||
|
// Aio_cancel
|
||||||
|
// Aio_error
|
||||||
|
// Aio_read
|
||||||
|
// Aio_write
|
||||||
|
// Lio_listio
|
||||||
|
// __pthread_cond_wait
|
||||||
|
// Iopolicysys
|
||||||
|
// Mlockall
|
||||||
|
// Munlockall
|
||||||
|
// __pthread_kill
|
||||||
|
// __pthread_sigmask
|
||||||
|
// __sigwait
|
||||||
|
// __disable_threadsignal
|
||||||
|
// __pthread_markcancel
|
||||||
|
// __pthread_canceled
|
||||||
|
// __semwait_signal
|
||||||
|
// Proc_info
|
||||||
|
// Stat64_extended
|
||||||
|
// Lstat64_extended
|
||||||
|
// Fstat64_extended
|
||||||
|
// __pthread_chdir
|
||||||
|
// __pthread_fchdir
|
||||||
|
// Audit
|
||||||
|
// Auditon
|
||||||
|
// Getauid
|
||||||
|
// Setauid
|
||||||
|
// Getaudit
|
||||||
|
// Setaudit
|
||||||
|
// Getaudit_addr
|
||||||
|
// Setaudit_addr
|
||||||
|
// Auditctl
|
||||||
|
// Bsdthread_create
|
||||||
|
// Bsdthread_terminate
|
||||||
|
// Stack_snapshot
|
||||||
|
// Bsdthread_register
|
||||||
|
// Workq_open
|
||||||
|
// Workq_ops
|
||||||
|
// __mac_execve
|
||||||
|
// __mac_syscall
|
||||||
|
// __mac_get_file
|
||||||
|
// __mac_set_file
|
||||||
|
// __mac_get_link
|
||||||
|
// __mac_set_link
|
||||||
|
// __mac_get_proc
|
||||||
|
// __mac_set_proc
|
||||||
|
// __mac_get_fd
|
||||||
|
// __mac_set_fd
|
||||||
|
// __mac_get_pid
|
||||||
|
// __mac_get_lcid
|
||||||
|
// __mac_get_lctx
|
||||||
|
// __mac_set_lctx
|
||||||
|
// Setlcid
|
||||||
|
// Read_nocancel
|
||||||
|
// Write_nocancel
|
||||||
|
// Open_nocancel
|
||||||
|
// Close_nocancel
|
||||||
|
// Wait4_nocancel
|
||||||
|
// Recvmsg_nocancel
|
||||||
|
// Sendmsg_nocancel
|
||||||
|
// Recvfrom_nocancel
|
||||||
|
// Accept_nocancel
|
||||||
|
// Msync_nocancel
|
||||||
|
// Fcntl_nocancel
|
||||||
|
// Select_nocancel
|
||||||
|
// Fsync_nocancel
|
||||||
|
// Connect_nocancel
|
||||||
|
// Sigsuspend_nocancel
|
||||||
|
// Readv_nocancel
|
||||||
|
// Writev_nocancel
|
||||||
|
// Sendto_nocancel
|
||||||
|
// Pread_nocancel
|
||||||
|
// Pwrite_nocancel
|
||||||
|
// Waitid_nocancel
|
||||||
|
// Poll_nocancel
|
||||||
|
// Msgsnd_nocancel
|
||||||
|
// Msgrcv_nocancel
|
||||||
|
// Sem_wait_nocancel
|
||||||
|
// Aio_suspend_nocancel
|
||||||
|
// __sigwait_nocancel
|
||||||
|
// __semwait_signal_nocancel
|
||||||
|
// __mac_mount
|
||||||
|
// __mac_get_mount
|
||||||
|
// __mac_getfsstat
|
61
vendor/golang.org/x/sys/unix/syscall_freebsd_386.go
generated
vendored
Normal file
61
vendor/golang.org/x/sys/unix/syscall_freebsd_386.go
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build 386,freebsd
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = int32(nsec / 1e9)
|
||||||
|
ts.Nsec = int32(nsec % 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||||
|
tv.Sec = int32(nsec / 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint32(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
var writtenOut uint64 = 0
|
||||||
|
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
|
||||||
|
|
||||||
|
written = int(writtenOut)
|
||||||
|
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
61
vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go
generated
vendored
Normal file
61
vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build amd64,freebsd
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = nsec / 1e9
|
||||||
|
ts.Nsec = nsec % 1e9
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Usec = nsec % 1e9 / 1e3
|
||||||
|
tv.Sec = int64(nsec / 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint64(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
var writtenOut uint64 = 0
|
||||||
|
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
|
||||||
|
|
||||||
|
written = int(writtenOut)
|
||||||
|
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
61
vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go
generated
vendored
Normal file
61
vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
// +build arm,freebsd
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = nsec / 1e9
|
||||||
|
ts.Nsec = int32(nsec % 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||||
|
tv.Sec = nsec / 1e9
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint32(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
var writtenOut uint64 = 0
|
||||||
|
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
|
||||||
|
|
||||||
|
written = int(writtenOut)
|
||||||
|
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
1108
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
Normal file
1108
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
390
vendor/golang.org/x/sys/unix/syscall_linux_386.go
generated
vendored
Normal file
390
vendor/golang.org/x/sys/unix/syscall_linux_386.go
generated
vendored
Normal file
|
@ -0,0 +1,390 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// TODO(rsc): Rewrite all nn(SP) references into name+(nn-8)(FP)
|
||||||
|
// so that go vet can check that they are correct.
|
||||||
|
|
||||||
|
// +build 386,linux
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = int32(nsec / 1e9)
|
||||||
|
ts.Nsec = int32(nsec % 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Sec = int32(nsec / 1e9)
|
||||||
|
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe(p *[2]_C_int) (err error)
|
||||||
|
|
||||||
|
func Pipe(p []int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe(&pp)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
||||||
|
|
||||||
|
func Pipe2(p []int, flags int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe2(&pp, flags)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 64-bit file system and 32-bit uid calls
|
||||||
|
// (386 default is 32-bit file system and 16-bit uid).
|
||||||
|
//sys Dup2(oldfd int, newfd int) (err error)
|
||||||
|
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64_64
|
||||||
|
//sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
|
||||||
|
//sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64
|
||||||
|
//sysnb Getegid() (egid int) = SYS_GETEGID32
|
||||||
|
//sysnb Geteuid() (euid int) = SYS_GETEUID32
|
||||||
|
//sysnb Getgid() (gid int) = SYS_GETGID32
|
||||||
|
//sysnb Getuid() (uid int) = SYS_GETUID32
|
||||||
|
//sysnb InotifyInit() (fd int, err error)
|
||||||
|
//sys Ioperm(from int, num int, on int) (err error)
|
||||||
|
//sys Iopl(level int) (err error)
|
||||||
|
//sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
||||||
|
//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 sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64
|
||||||
|
//sys Setfsgid(gid int) (err error) = SYS_SETFSGID32
|
||||||
|
//sys Setfsuid(uid int) (err error) = SYS_SETFSUID32
|
||||||
|
//sysnb Setregid(rgid int, egid int) (err error) = SYS_SETREGID32
|
||||||
|
//sysnb Setresgid(rgid int, egid int, sgid int) (err error) = SYS_SETRESGID32
|
||||||
|
//sysnb Setresuid(ruid int, euid int, suid int) (err error) = SYS_SETRESUID32
|
||||||
|
//sysnb Setreuid(ruid int, euid int) (err error) = SYS_SETREUID32
|
||||||
|
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
|
||||||
|
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
||||||
|
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
|
||||||
|
//sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64
|
||||||
|
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) = SYS_GETGROUPS32
|
||||||
|
//sysnb setgroups(n int, list *_Gid_t) (err error) = SYS_SETGROUPS32
|
||||||
|
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT
|
||||||
|
|
||||||
|
//sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error)
|
||||||
|
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
|
||||||
|
//sys Pause() (err error)
|
||||||
|
|
||||||
|
func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
|
||||||
|
page := uintptr(offset / 4096)
|
||||||
|
if offset != int64(page)*4096 {
|
||||||
|
return 0, EINVAL
|
||||||
|
}
|
||||||
|
return mmap2(addr, length, prot, flags, fd, page)
|
||||||
|
}
|
||||||
|
|
||||||
|
type rlimit32 struct {
|
||||||
|
Cur uint32
|
||||||
|
Max uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_GETRLIMIT
|
||||||
|
|
||||||
|
const rlimInf32 = ^uint32(0)
|
||||||
|
const rlimInf64 = ^uint64(0)
|
||||||
|
|
||||||
|
func Getrlimit(resource int, rlim *Rlimit) (err error) {
|
||||||
|
err = prlimit(0, resource, nil, rlim)
|
||||||
|
if err != ENOSYS {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
rl := rlimit32{}
|
||||||
|
err = getrlimit(resource, &rl)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if rl.Cur == rlimInf32 {
|
||||||
|
rlim.Cur = rlimInf64
|
||||||
|
} else {
|
||||||
|
rlim.Cur = uint64(rl.Cur)
|
||||||
|
}
|
||||||
|
|
||||||
|
if rl.Max == rlimInf32 {
|
||||||
|
rlim.Max = rlimInf64
|
||||||
|
} else {
|
||||||
|
rlim.Max = uint64(rl.Max)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT
|
||||||
|
|
||||||
|
func Setrlimit(resource int, rlim *Rlimit) (err error) {
|
||||||
|
err = prlimit(0, resource, rlim, nil)
|
||||||
|
if err != ENOSYS {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
rl := rlimit32{}
|
||||||
|
if rlim.Cur == rlimInf64 {
|
||||||
|
rl.Cur = rlimInf32
|
||||||
|
} else if rlim.Cur < uint64(rlimInf32) {
|
||||||
|
rl.Cur = uint32(rlim.Cur)
|
||||||
|
} else {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
if rlim.Max == rlimInf64 {
|
||||||
|
rl.Max = rlimInf32
|
||||||
|
} else if rlim.Max < uint64(rlimInf32) {
|
||||||
|
rl.Max = uint32(rlim.Max)
|
||||||
|
} else {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
return setrlimit(resource, &rl)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Underlying system call writes to newoffset via pointer.
|
||||||
|
// Implemented in assembly to avoid allocation.
|
||||||
|
func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno)
|
||||||
|
|
||||||
|
func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
|
||||||
|
newoffset, errno := seek(fd, offset, whence)
|
||||||
|
if errno != 0 {
|
||||||
|
return 0, errno
|
||||||
|
}
|
||||||
|
return newoffset, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vsyscalls on amd64.
|
||||||
|
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||||
|
//sysnb Time(t *Time_t) (tt Time_t, err error)
|
||||||
|
|
||||||
|
//sys Utime(path string, buf *Utimbuf) (err error)
|
||||||
|
|
||||||
|
// On x86 Linux, all the socket calls go through an extra indirection,
|
||||||
|
// I think because the 5-register system call interface can't handle
|
||||||
|
// the 6-argument calls like sendto and recvfrom. Instead the
|
||||||
|
// arguments to the underlying system call are the number below
|
||||||
|
// and a pointer to an array of uintptr. We hide the pointer in the
|
||||||
|
// socketcall assembly to avoid allocation on every system call.
|
||||||
|
|
||||||
|
const (
|
||||||
|
// see linux/net.h
|
||||||
|
_SOCKET = 1
|
||||||
|
_BIND = 2
|
||||||
|
_CONNECT = 3
|
||||||
|
_LISTEN = 4
|
||||||
|
_ACCEPT = 5
|
||||||
|
_GETSOCKNAME = 6
|
||||||
|
_GETPEERNAME = 7
|
||||||
|
_SOCKETPAIR = 8
|
||||||
|
_SEND = 9
|
||||||
|
_RECV = 10
|
||||||
|
_SENDTO = 11
|
||||||
|
_RECVFROM = 12
|
||||||
|
_SHUTDOWN = 13
|
||||||
|
_SETSOCKOPT = 14
|
||||||
|
_GETSOCKOPT = 15
|
||||||
|
_SENDMSG = 16
|
||||||
|
_RECVMSG = 17
|
||||||
|
_ACCEPT4 = 18
|
||||||
|
_RECVMMSG = 19
|
||||||
|
_SENDMMSG = 20
|
||||||
|
)
|
||||||
|
|
||||||
|
func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno)
|
||||||
|
func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno)
|
||||||
|
|
||||||
|
func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
|
||||||
|
fd, e := socketcall(_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
|
||||||
|
fd, e := socketcall(_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func getsockname(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
|
||||||
|
_, e := rawsocketcall(_GETSOCKNAME, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func getpeername(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
|
||||||
|
_, e := rawsocketcall(_GETPEERNAME, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func socketpair(domain int, typ int, flags int, fd *[2]int32) (err error) {
|
||||||
|
_, e := rawsocketcall(_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(flags), uintptr(unsafe.Pointer(fd)), 0, 0)
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
|
||||||
|
_, e := socketcall(_BIND, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0)
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
|
||||||
|
_, e := socketcall(_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0)
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func socket(domain int, typ int, proto int) (fd int, err error) {
|
||||||
|
fd, e := rawsocketcall(_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto), 0, 0, 0)
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
|
||||||
|
_, e := socketcall(_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
|
||||||
|
_, e := socketcall(_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), vallen, 0)
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func recvfrom(s int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
|
||||||
|
var base uintptr
|
||||||
|
if len(p) > 0 {
|
||||||
|
base = uintptr(unsafe.Pointer(&p[0]))
|
||||||
|
}
|
||||||
|
n, e := socketcall(_RECVFROM, uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendto(s int, p []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
|
||||||
|
var base uintptr
|
||||||
|
if len(p) > 0 {
|
||||||
|
base = uintptr(unsafe.Pointer(&p[0]))
|
||||||
|
}
|
||||||
|
_, e := socketcall(_SENDTO, uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(to), uintptr(addrlen))
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
|
||||||
|
n, e := socketcall(_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0)
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
|
||||||
|
n, e := socketcall(_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0)
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Listen(s int, n int) (err error) {
|
||||||
|
_, e := socketcall(_LISTEN, uintptr(s), uintptr(n), 0, 0, 0, 0)
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Shutdown(s, how int) (err error) {
|
||||||
|
_, e := socketcall(_SHUTDOWN, uintptr(s), uintptr(how), 0, 0, 0, 0)
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Fstatfs(fd int, buf *Statfs_t) (err error) {
|
||||||
|
_, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Statfs(path string, buf *Statfs_t) (err error) {
|
||||||
|
pathp, err := BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(pathp)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *PtraceRegs) PC() uint64 { return uint64(uint32(r.Eip)) }
|
||||||
|
|
||||||
|
func (r *PtraceRegs) SetPC(pc uint64) { r.Eip = int32(pc) }
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
148
vendor/golang.org/x/sys/unix/syscall_linux_amd64.go
generated
vendored
Normal file
148
vendor/golang.org/x/sys/unix/syscall_linux_amd64.go
generated
vendored
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build amd64,linux
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
//sys Dup2(oldfd int, newfd 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 Fchown(fd int, uid int, gid int) (err error)
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||||
|
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
|
||||||
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
|
//sysnb Getegid() (egid int)
|
||||||
|
//sysnb Geteuid() (euid int)
|
||||||
|
//sysnb Getgid() (gid int)
|
||||||
|
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
|
||||||
|
//sysnb Getuid() (uid int)
|
||||||
|
//sysnb InotifyInit() (fd int, err error)
|
||||||
|
//sys Ioperm(from int, num int, on int) (err error)
|
||||||
|
//sys Iopl(level int) (err error)
|
||||||
|
//sys Lchown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Listen(s int, n int) (err error)
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Pause() (err error)
|
||||||
|
//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 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 sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
|
||||||
|
//sys Setfsgid(gid int) (err error)
|
||||||
|
//sys Setfsuid(uid int) (err error)
|
||||||
|
//sysnb Setregid(rgid int, egid int) (err error)
|
||||||
|
//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
|
||||||
|
//sysnb Setresuid(ruid int, euid int, suid int) (err error)
|
||||||
|
//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
|
||||||
|
//sysnb Setreuid(ruid int, euid 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 Stat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Statfs(path string, buf *Statfs_t) (err error)
|
||||||
|
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
|
||||||
|
//sys Truncate(path string, length int64) (err error)
|
||||||
|
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||||
|
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
|
||||||
|
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
|
||||||
|
//sysnb setgroups(n int, list *_Gid_t) (err error)
|
||||||
|
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
|
||||||
|
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
|
||||||
|
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
||||||
|
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||||
|
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||||
|
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
|
||||||
|
|
||||||
|
//go:noescape
|
||||||
|
func gettimeofday(tv *Timeval) (err syscall.Errno)
|
||||||
|
|
||||||
|
func Gettimeofday(tv *Timeval) (err error) {
|
||||||
|
errno := gettimeofday(tv)
|
||||||
|
if errno != 0 {
|
||||||
|
return errno
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func Time(t *Time_t) (tt Time_t, err error) {
|
||||||
|
var tv Timeval
|
||||||
|
errno := gettimeofday(&tv)
|
||||||
|
if errno != 0 {
|
||||||
|
return 0, errno
|
||||||
|
}
|
||||||
|
if t != nil {
|
||||||
|
*t = Time_t(tv.Sec)
|
||||||
|
}
|
||||||
|
return Time_t(tv.Sec), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys Utime(path string, buf *Utimbuf) (err error)
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = nsec / 1e9
|
||||||
|
ts.Nsec = nsec % 1e9
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Sec = nsec / 1e9
|
||||||
|
tv.Usec = nsec % 1e9 / 1e3
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe(p *[2]_C_int) (err error)
|
||||||
|
|
||||||
|
func Pipe(p []int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe(&pp)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
||||||
|
|
||||||
|
func Pipe2(p []int, flags int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe2(&pp, flags)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *PtraceRegs) PC() uint64 { return r.Rip }
|
||||||
|
|
||||||
|
func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc }
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint64(length)
|
||||||
|
}
|
254
vendor/golang.org/x/sys/unix/syscall_linux_arm.go
generated
vendored
Normal file
254
vendor/golang.org/x/sys/unix/syscall_linux_arm.go
generated
vendored
Normal file
|
@ -0,0 +1,254 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build arm,linux
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = int32(nsec / 1e9)
|
||||||
|
ts.Nsec = int32(nsec % 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Sec = int32(nsec / 1e9)
|
||||||
|
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Pipe(p []int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe2(&pp, 0)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
||||||
|
|
||||||
|
func Pipe2(p []int, flags int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe2(&pp, flags)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Underlying system call writes to newoffset via pointer.
|
||||||
|
// Implemented in assembly to avoid allocation.
|
||||||
|
func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno)
|
||||||
|
|
||||||
|
func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
|
||||||
|
newoffset, errno := seek(fd, offset, whence)
|
||||||
|
if errno != 0 {
|
||||||
|
return 0, errno
|
||||||
|
}
|
||||||
|
return newoffset, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||||
|
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
|
||||||
|
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) = SYS_GETGROUPS32
|
||||||
|
//sysnb setgroups(n int, list *_Gid_t) (err error) = SYS_SETGROUPS32
|
||||||
|
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
|
||||||
|
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
|
||||||
|
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
||||||
|
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||||
|
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sysnb socketpair(domain int, typ int, flags int, fd *[2]int32) (err error)
|
||||||
|
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
|
||||||
|
// 64-bit file system and 32-bit uid calls
|
||||||
|
// (16-bit uid calls are not always supported in newer kernels)
|
||||||
|
//sys Dup2(oldfd int, newfd int) (err error)
|
||||||
|
//sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
|
||||||
|
//sysnb Getegid() (egid int) = SYS_GETEGID32
|
||||||
|
//sysnb Geteuid() (euid int) = SYS_GETEUID32
|
||||||
|
//sysnb Getgid() (gid int) = SYS_GETGID32
|
||||||
|
//sysnb Getuid() (uid int) = SYS_GETUID32
|
||||||
|
//sysnb InotifyInit() (fd int, err error)
|
||||||
|
//sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32
|
||||||
|
//sys Listen(s int, n int) (err error)
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
||||||
|
//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64
|
||||||
|
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT
|
||||||
|
//sys Setfsgid(gid int) (err error) = SYS_SETFSGID32
|
||||||
|
//sys Setfsuid(uid int) (err error) = SYS_SETFSUID32
|
||||||
|
//sysnb Setregid(rgid int, egid int) (err error) = SYS_SETREGID32
|
||||||
|
//sysnb Setresgid(rgid int, egid int, sgid int) (err error) = SYS_SETRESGID32
|
||||||
|
//sysnb Setresuid(ruid int, euid int, suid int) (err error) = SYS_SETRESUID32
|
||||||
|
//sysnb Setreuid(ruid int, euid int) (err error) = SYS_SETREUID32
|
||||||
|
//sys Shutdown(fd int, how int) (err error)
|
||||||
|
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
|
||||||
|
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
||||||
|
|
||||||
|
// Vsyscalls on amd64.
|
||||||
|
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||||
|
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
|
||||||
|
//sys Pause() (err error)
|
||||||
|
|
||||||
|
func Time(t *Time_t) (Time_t, error) {
|
||||||
|
var tv Timeval
|
||||||
|
err := Gettimeofday(&tv)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if t != nil {
|
||||||
|
*t = Time_t(tv.Sec)
|
||||||
|
}
|
||||||
|
return Time_t(tv.Sec), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Utime(path string, buf *Utimbuf) error {
|
||||||
|
tv := []Timeval{
|
||||||
|
{Sec: buf.Actime},
|
||||||
|
{Sec: buf.Modtime},
|
||||||
|
}
|
||||||
|
return Utimes(path, tv)
|
||||||
|
}
|
||||||
|
|
||||||
|
//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 Truncate(path string, length int64) (err error) = SYS_TRUNCATE64
|
||||||
|
//sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64
|
||||||
|
|
||||||
|
func Fadvise(fd int, offset int64, length int64, advice int) (err error) {
|
||||||
|
_, _, e1 := Syscall6(SYS_ARM_FADVISE64_64, uintptr(fd), uintptr(advice), uintptr(offset), uintptr(offset>>32), uintptr(length), uintptr(length>>32))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error)
|
||||||
|
|
||||||
|
func Fstatfs(fd int, buf *Statfs_t) (err error) {
|
||||||
|
_, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Statfs(path string, buf *Statfs_t) (err error) {
|
||||||
|
pathp, err := BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(pathp)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
|
||||||
|
if e != 0 {
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
|
||||||
|
page := uintptr(offset / 4096)
|
||||||
|
if offset != int64(page)*4096 {
|
||||||
|
return 0, EINVAL
|
||||||
|
}
|
||||||
|
return mmap2(addr, length, prot, flags, fd, page)
|
||||||
|
}
|
||||||
|
|
||||||
|
type rlimit32 struct {
|
||||||
|
Cur uint32
|
||||||
|
Max uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_UGETRLIMIT
|
||||||
|
|
||||||
|
const rlimInf32 = ^uint32(0)
|
||||||
|
const rlimInf64 = ^uint64(0)
|
||||||
|
|
||||||
|
func Getrlimit(resource int, rlim *Rlimit) (err error) {
|
||||||
|
err = prlimit(0, resource, nil, rlim)
|
||||||
|
if err != ENOSYS {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
rl := rlimit32{}
|
||||||
|
err = getrlimit(resource, &rl)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if rl.Cur == rlimInf32 {
|
||||||
|
rlim.Cur = rlimInf64
|
||||||
|
} else {
|
||||||
|
rlim.Cur = uint64(rl.Cur)
|
||||||
|
}
|
||||||
|
|
||||||
|
if rl.Max == rlimInf32 {
|
||||||
|
rlim.Max = rlimInf64
|
||||||
|
} else {
|
||||||
|
rlim.Max = uint64(rl.Max)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT
|
||||||
|
|
||||||
|
func Setrlimit(resource int, rlim *Rlimit) (err error) {
|
||||||
|
err = prlimit(0, resource, rlim, nil)
|
||||||
|
if err != ENOSYS {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
rl := rlimit32{}
|
||||||
|
if rlim.Cur == rlimInf64 {
|
||||||
|
rl.Cur = rlimInf32
|
||||||
|
} else if rlim.Cur < uint64(rlimInf32) {
|
||||||
|
rl.Cur = uint32(rlim.Cur)
|
||||||
|
} else {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
if rlim.Max == rlimInf64 {
|
||||||
|
rl.Max = rlimInf32
|
||||||
|
} else if rlim.Max < uint64(rlimInf32) {
|
||||||
|
rl.Max = uint32(rlim.Max)
|
||||||
|
} else {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
return setrlimit(resource, &rl)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *PtraceRegs) PC() uint64 { return uint64(r.Uregs[15]) }
|
||||||
|
|
||||||
|
func (r *PtraceRegs) SetPC(pc uint64) { r.Uregs[15] = uint32(pc) }
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
180
vendor/golang.org/x/sys/unix/syscall_linux_arm64.go
generated
vendored
Normal file
180
vendor/golang.org/x/sys/unix/syscall_linux_arm64.go
generated
vendored
Normal file
|
@ -0,0 +1,180 @@
|
||||||
|
// Copyright 2015 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.
|
||||||
|
|
||||||
|
// +build arm64,linux
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const _SYS_dup = SYS_DUP3
|
||||||
|
|
||||||
|
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT
|
||||||
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||||
|
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
|
||||||
|
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
|
||||||
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
|
//sysnb Getegid() (egid int)
|
||||||
|
//sysnb Geteuid() (euid int)
|
||||||
|
//sysnb Getgid() (gid int)
|
||||||
|
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
|
||||||
|
//sysnb Getuid() (uid int)
|
||||||
|
//sys Listen(s int, n int) (err error)
|
||||||
|
//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 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
|
||||||
|
//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
|
||||||
|
//sys Setfsgid(gid int) (err error)
|
||||||
|
//sys Setfsuid(uid int) (err error)
|
||||||
|
//sysnb Setregid(rgid int, egid int) (err error)
|
||||||
|
//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
|
||||||
|
//sysnb Setresuid(ruid int, euid int, suid int) (err error)
|
||||||
|
//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
|
||||||
|
//sysnb Setreuid(ruid int, euid 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)
|
||||||
|
|
||||||
|
func Stat(path string, stat *Stat_t) (err error) {
|
||||||
|
return Fstatat(AT_FDCWD, path, stat, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Lchown(path string, uid int, gid int) (err error) {
|
||||||
|
return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Lstat(path string, stat *Stat_t) (err error) {
|
||||||
|
return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys Statfs(path string, buf *Statfs_t) (err error)
|
||||||
|
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
|
||||||
|
//sys Truncate(path string, length int64) (err error)
|
||||||
|
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||||
|
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
|
||||||
|
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
|
||||||
|
//sysnb setgroups(n int, list *_Gid_t) (err error)
|
||||||
|
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
|
||||||
|
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
|
||||||
|
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
||||||
|
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||||
|
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||||
|
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
|
||||||
|
|
||||||
|
func Getpagesize() int { return 65536 }
|
||||||
|
|
||||||
|
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = nsec / 1e9
|
||||||
|
ts.Nsec = nsec % 1e9
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Sec = nsec / 1e9
|
||||||
|
tv.Usec = nsec % 1e9 / 1e3
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Time(t *Time_t) (Time_t, error) {
|
||||||
|
var tv Timeval
|
||||||
|
err := Gettimeofday(&tv)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if t != nil {
|
||||||
|
*t = Time_t(tv.Sec)
|
||||||
|
}
|
||||||
|
return Time_t(tv.Sec), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Utime(path string, buf *Utimbuf) error {
|
||||||
|
tv := []Timeval{
|
||||||
|
{Sec: buf.Actime},
|
||||||
|
{Sec: buf.Modtime},
|
||||||
|
}
|
||||||
|
return Utimes(path, tv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Pipe(p []int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe2(&pp, 0)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
||||||
|
|
||||||
|
func Pipe2(p []int, flags int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe2(&pp, flags)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *PtraceRegs) PC() uint64 { return r.Pc }
|
||||||
|
|
||||||
|
func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func InotifyInit() (fd int, err error) {
|
||||||
|
return InotifyInit1(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Dup2(oldfd int, newfd int) (err error) {
|
||||||
|
return Dup3(oldfd, newfd, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Pause() (err error) {
|
||||||
|
_, _, e1 := Syscall6(SYS_PPOLL, 0, 0, 0, 0, 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(dfc): constants that should be in zsysnum_linux_arm64.go, remove
|
||||||
|
// these when the deprecated syscalls that the syscall package relies on
|
||||||
|
// are removed.
|
||||||
|
const (
|
||||||
|
SYS_GETPGRP = 1060
|
||||||
|
SYS_UTIMES = 1037
|
||||||
|
SYS_FUTIMESAT = 1066
|
||||||
|
SYS_PAUSE = 1061
|
||||||
|
SYS_USTAT = 1070
|
||||||
|
SYS_UTIME = 1063
|
||||||
|
SYS_LCHOWN = 1032
|
||||||
|
SYS_TIME = 1062
|
||||||
|
SYS_EPOLL_CREATE = 1042
|
||||||
|
SYS_EPOLL_WAIT = 1069
|
||||||
|
)
|
206
vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go
generated
vendored
Normal file
206
vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go
generated
vendored
Normal file
|
@ -0,0 +1,206 @@
|
||||||
|
// Copyright 2015 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.
|
||||||
|
|
||||||
|
// +build linux
|
||||||
|
// +build mips64 mips64le
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Linux introduced getdents64 syscall for N64 ABI only in 3.10
|
||||||
|
// (May 21 2013, rev dec33abaafc89bcbd78f85fad0513170415a26d5),
|
||||||
|
// to support older kernels, we have to use getdents for mips64.
|
||||||
|
// Also note that struct dirent is different for these two.
|
||||||
|
// Lookup linux_dirent{,64} in kernel source code for details.
|
||||||
|
const _SYS_getdents = SYS_GETDENTS
|
||||||
|
|
||||||
|
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
|
||||||
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
|
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
|
||||||
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
|
//sysnb Getegid() (egid int)
|
||||||
|
//sysnb Geteuid() (euid int)
|
||||||
|
//sysnb Getgid() (gid int)
|
||||||
|
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
|
||||||
|
//sysnb Getuid() (uid int)
|
||||||
|
//sys Lchown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Listen(s int, n int) (err error)
|
||||||
|
//sys Pause() (err error)
|
||||||
|
//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 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
|
||||||
|
//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
|
||||||
|
//sys Setfsgid(gid int) (err error)
|
||||||
|
//sys Setfsuid(uid int) (err error)
|
||||||
|
//sysnb Setregid(rgid int, egid int) (err error)
|
||||||
|
//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
|
||||||
|
//sysnb Setresuid(ruid int, euid int, suid int) (err error)
|
||||||
|
//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
|
||||||
|
//sysnb Setreuid(ruid int, euid 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 Statfs(path string, buf *Statfs_t) (err error)
|
||||||
|
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
|
||||||
|
//sys Truncate(path string, length int64) (err error)
|
||||||
|
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||||
|
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
|
||||||
|
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
|
||||||
|
//sysnb setgroups(n int, list *_Gid_t) (err error)
|
||||||
|
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
|
||||||
|
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
|
||||||
|
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
||||||
|
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||||
|
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||||
|
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
|
||||||
|
|
||||||
|
func Getpagesize() int { return 65536 }
|
||||||
|
|
||||||
|
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||||
|
|
||||||
|
func Time(t *Time_t) (tt Time_t, err error) {
|
||||||
|
var tv Timeval
|
||||||
|
err = Gettimeofday(&tv)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if t != nil {
|
||||||
|
*t = Time_t(tv.Sec)
|
||||||
|
}
|
||||||
|
return Time_t(tv.Sec), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys Utime(path string, buf *Utimbuf) (err error)
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = nsec / 1e9
|
||||||
|
ts.Nsec = nsec % 1e9
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Sec = nsec / 1e9
|
||||||
|
tv.Usec = nsec % 1e9 / 1e3
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Pipe(p []int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe2(&pp, 0)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
||||||
|
|
||||||
|
func Pipe2(p []int, flags int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe2(&pp, flags)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Ioperm(from int, num int, on int) (err error) {
|
||||||
|
return ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
func Iopl(level int) (err error) {
|
||||||
|
return ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
type stat_t struct {
|
||||||
|
Dev uint32
|
||||||
|
Pad0 [3]int32
|
||||||
|
Ino uint64
|
||||||
|
Mode uint32
|
||||||
|
Nlink uint32
|
||||||
|
Uid uint32
|
||||||
|
Gid uint32
|
||||||
|
Rdev uint32
|
||||||
|
Pad1 [3]uint32
|
||||||
|
Size int64
|
||||||
|
Atime uint32
|
||||||
|
Atime_nsec uint32
|
||||||
|
Mtime uint32
|
||||||
|
Mtime_nsec uint32
|
||||||
|
Ctime uint32
|
||||||
|
Ctime_nsec uint32
|
||||||
|
Blksize uint32
|
||||||
|
Pad2 uint32
|
||||||
|
Blocks int64
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys fstat(fd int, st *stat_t) (err error)
|
||||||
|
//sys lstat(path string, st *stat_t) (err error)
|
||||||
|
//sys stat(path string, st *stat_t) (err error)
|
||||||
|
|
||||||
|
func Fstat(fd int, s *Stat_t) (err error) {
|
||||||
|
st := &stat_t{}
|
||||||
|
err = fstat(fd, st)
|
||||||
|
fillStat_t(s, st)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Lstat(path string, s *Stat_t) (err error) {
|
||||||
|
st := &stat_t{}
|
||||||
|
err = lstat(path, st)
|
||||||
|
fillStat_t(s, st)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Stat(path string, s *Stat_t) (err error) {
|
||||||
|
st := &stat_t{}
|
||||||
|
err = stat(path, st)
|
||||||
|
fillStat_t(s, st)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func fillStat_t(s *Stat_t, st *stat_t) {
|
||||||
|
s.Dev = st.Dev
|
||||||
|
s.Ino = st.Ino
|
||||||
|
s.Mode = st.Mode
|
||||||
|
s.Nlink = st.Nlink
|
||||||
|
s.Uid = st.Uid
|
||||||
|
s.Gid = st.Gid
|
||||||
|
s.Rdev = st.Rdev
|
||||||
|
s.Size = st.Size
|
||||||
|
s.Atim = Timespec{int64(st.Atime), int64(st.Atime_nsec)}
|
||||||
|
s.Mtim = Timespec{int64(st.Mtime), int64(st.Mtime_nsec)}
|
||||||
|
s.Ctim = Timespec{int64(st.Ctime), int64(st.Ctime_nsec)}
|
||||||
|
s.Blksize = st.Blksize
|
||||||
|
s.Blocks = st.Blocks
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *PtraceRegs) PC() uint64 { return r.Regs[64] }
|
||||||
|
|
||||||
|
func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = pc }
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint64(length)
|
||||||
|
}
|
99
vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go
generated
vendored
Normal file
99
vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go
generated
vendored
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build linux
|
||||||
|
// +build ppc64 ppc64le
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
|
||||||
|
//sys Dup2(oldfd int, newfd int) (err error)
|
||||||
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||||
|
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
|
||||||
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
|
//sysnb Getegid() (egid int)
|
||||||
|
//sysnb Geteuid() (euid int)
|
||||||
|
//sysnb Getgid() (gid int)
|
||||||
|
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT
|
||||||
|
//sysnb Getuid() (uid int)
|
||||||
|
//sys Ioperm(from int, num int, on int) (err error)
|
||||||
|
//sys Iopl(level int) (err error)
|
||||||
|
//sys Lchown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Listen(s int, n int) (err error)
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Pause() (err error)
|
||||||
|
//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 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 sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
|
||||||
|
//sys Setfsgid(gid int) (err error)
|
||||||
|
//sys Setfsuid(uid int) (err error)
|
||||||
|
//sysnb Setregid(rgid int, egid int) (err error)
|
||||||
|
//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
|
||||||
|
//sysnb Setresuid(ruid int, euid int, suid int) (err error)
|
||||||
|
//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
|
||||||
|
//sysnb Setreuid(ruid int, euid 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 Stat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Statfs(path string, buf *Statfs_t) (err error)
|
||||||
|
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2
|
||||||
|
//sys Truncate(path string, length int64) (err error)
|
||||||
|
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||||
|
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
|
||||||
|
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
|
||||||
|
//sysnb setgroups(n int, list *_Gid_t) (err error)
|
||||||
|
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
|
||||||
|
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
|
||||||
|
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
||||||
|
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||||
|
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||||
|
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
|
||||||
|
|
||||||
|
func Getpagesize() int { return 65536 }
|
||||||
|
|
||||||
|
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||||
|
//sysnb Time(t *Time_t) (tt Time_t, err error)
|
||||||
|
|
||||||
|
//sys Utime(path string, buf *Utimbuf) (err error)
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = nsec / 1e9
|
||||||
|
ts.Nsec = nsec % 1e9
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Sec = nsec / 1e9
|
||||||
|
tv.Usec = nsec % 1e9 / 1e3
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *PtraceRegs) PC() uint64 { return r.Nip }
|
||||||
|
|
||||||
|
func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc }
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint64(length)
|
||||||
|
}
|
492
vendor/golang.org/x/sys/unix/syscall_netbsd.go
generated
vendored
Normal file
492
vendor/golang.org/x/sys/unix/syscall_netbsd.go
generated
vendored
Normal file
|
@ -0,0 +1,492 @@
|
||||||
|
// Copyright 2009,2010 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.
|
||||||
|
|
||||||
|
// NetBSD system calls.
|
||||||
|
// This file is compiled as ordinary Go code,
|
||||||
|
// but it is also input to mksyscall,
|
||||||
|
// which parses the //sys lines and generates system call stubs.
|
||||||
|
// Note that sometimes we use a lowercase //sys name and wrap
|
||||||
|
// it in our own nicer implementation, either here or in
|
||||||
|
// syscall_bsd.go or syscall_unix.go.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SockaddrDatalink struct {
|
||||||
|
Len uint8
|
||||||
|
Family uint8
|
||||||
|
Index uint16
|
||||||
|
Type uint8
|
||||||
|
Nlen uint8
|
||||||
|
Alen uint8
|
||||||
|
Slen uint8
|
||||||
|
Data [12]int8
|
||||||
|
raw RawSockaddrDatalink
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
|
||||||
|
func sysctlNodes(mib []_C_int) (nodes []Sysctlnode, err error) {
|
||||||
|
var olen uintptr
|
||||||
|
|
||||||
|
// Get a list of all sysctl nodes below the given MIB by performing
|
||||||
|
// a sysctl for the given MIB with CTL_QUERY appended.
|
||||||
|
mib = append(mib, CTL_QUERY)
|
||||||
|
qnode := Sysctlnode{Flags: SYSCTL_VERS_1}
|
||||||
|
qp := (*byte)(unsafe.Pointer(&qnode))
|
||||||
|
sz := unsafe.Sizeof(qnode)
|
||||||
|
if err = sysctl(mib, nil, &olen, qp, sz); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now that we know the size, get the actual nodes.
|
||||||
|
nodes = make([]Sysctlnode, olen/sz)
|
||||||
|
np := (*byte)(unsafe.Pointer(&nodes[0]))
|
||||||
|
if err = sysctl(mib, np, &olen, qp, sz); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func nametomib(name string) (mib []_C_int, err error) {
|
||||||
|
|
||||||
|
// Split name into components.
|
||||||
|
var parts []string
|
||||||
|
last := 0
|
||||||
|
for i := 0; i < len(name); i++ {
|
||||||
|
if name[i] == '.' {
|
||||||
|
parts = append(parts, name[last:i])
|
||||||
|
last = i + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parts = append(parts, name[last:])
|
||||||
|
|
||||||
|
// Discover the nodes and construct the MIB OID.
|
||||||
|
for partno, part := range parts {
|
||||||
|
nodes, err := sysctlNodes(mib)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, node := range nodes {
|
||||||
|
n := make([]byte, 0)
|
||||||
|
for i := range node.Name {
|
||||||
|
if node.Name[i] != 0 {
|
||||||
|
n = append(n, byte(node.Name[i]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if string(n) == part {
|
||||||
|
mib = append(mib, _C_int(node.Num))
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(mib) != partno+1 {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mib, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseDirent parses up to max directory entries in buf,
|
||||||
|
// appending the names to names. It returns the number
|
||||||
|
// bytes consumed from buf, the number of entries added
|
||||||
|
// to names, and the new names slice.
|
||||||
|
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
||||||
|
origlen := len(buf)
|
||||||
|
for max != 0 && len(buf) > 0 {
|
||||||
|
dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
|
||||||
|
if dirent.Reclen == 0 {
|
||||||
|
buf = nil
|
||||||
|
break
|
||||||
|
}
|
||||||
|
buf = buf[dirent.Reclen:]
|
||||||
|
if dirent.Fileno == 0 { // File absent in directory.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
|
||||||
|
var name = string(bytes[0:dirent.Namlen])
|
||||||
|
if name == "." || name == ".." { // Useless names
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
max--
|
||||||
|
count++
|
||||||
|
names = append(names, name)
|
||||||
|
}
|
||||||
|
return origlen - len(buf), count, names
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe() (fd1 int, fd2 int, err error)
|
||||||
|
func Pipe(p []int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
p[0], p[1], err = pipe()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys getdents(fd int, buf []byte) (n int, err error)
|
||||||
|
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
||||||
|
return getdents(fd, buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
return -1, ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Exposed directly
|
||||||
|
*/
|
||||||
|
//sys Access(path string, mode uint32) (err error)
|
||||||
|
//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
|
||||||
|
//sys Chdir(path string) (err error)
|
||||||
|
//sys Chflags(path string, flags int) (err error)
|
||||||
|
//sys Chmod(path string, mode uint32) (err error)
|
||||||
|
//sys Chown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Chroot(path string) (err error)
|
||||||
|
//sys Close(fd int) (err error)
|
||||||
|
//sys Dup(fd int) (nfd int, err error)
|
||||||
|
//sys Dup2(from int, to int) (err error)
|
||||||
|
//sys Exit(code int)
|
||||||
|
//sys Fchdir(fd int) (err error)
|
||||||
|
//sys Fchflags(fd int, flags int) (err error)
|
||||||
|
//sys Fchmod(fd int, mode uint32) (err error)
|
||||||
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
|
//sys Flock(fd int, how int) (err error)
|
||||||
|
//sys Fpathconf(fd int, name int) (val int, err error)
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||||
|
//sys Fsync(fd int) (err error)
|
||||||
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
|
//sysnb Getegid() (egid int)
|
||||||
|
//sysnb Geteuid() (uid int)
|
||||||
|
//sysnb Getgid() (gid int)
|
||||||
|
//sysnb Getpgid(pid int) (pgid int, err error)
|
||||||
|
//sysnb Getpgrp() (pgrp int)
|
||||||
|
//sysnb Getpid() (pid int)
|
||||||
|
//sysnb Getppid() (ppid int)
|
||||||
|
//sys Getpriority(which int, who int) (prio int, err error)
|
||||||
|
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
|
||||||
|
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||||
|
//sysnb Getsid(pid int) (sid int, err error)
|
||||||
|
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||||
|
//sysnb Getuid() (uid int)
|
||||||
|
//sys Issetugid() (tainted bool)
|
||||||
|
//sys Kill(pid int, signum syscall.Signal) (err error)
|
||||||
|
//sys Kqueue() (fd int, err error)
|
||||||
|
//sys Lchown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Link(path string, link string) (err error)
|
||||||
|
//sys Listen(s int, backlog int) (err error)
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Mkdir(path string, mode uint32) (err error)
|
||||||
|
//sys Mkfifo(path string, mode uint32) (err error)
|
||||||
|
//sys Mknod(path string, mode uint32, dev int) (err error)
|
||||||
|
//sys Mlock(b []byte) (err error)
|
||||||
|
//sys Mlockall(flags int) (err error)
|
||||||
|
//sys Mprotect(b []byte, prot int) (err error)
|
||||||
|
//sys Munlock(b []byte) (err error)
|
||||||
|
//sys Munlockall() (err error)
|
||||||
|
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
||||||
|
//sys Open(path string, mode int, perm uint32) (fd int, err error)
|
||||||
|
//sys Pathconf(path string, name int) (val int, err error)
|
||||||
|
//sys Pread(fd int, p []byte, offset int64) (n int, err error)
|
||||||
|
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
|
||||||
|
//sys read(fd int, p []byte) (n int, err error)
|
||||||
|
//sys Readlink(path string, buf []byte) (n int, err error)
|
||||||
|
//sys Rename(from string, to string) (err error)
|
||||||
|
//sys Revoke(path string) (err error)
|
||||||
|
//sys Rmdir(path string) (err error)
|
||||||
|
//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
|
||||||
|
//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
|
||||||
|
//sysnb Setegid(egid int) (err error)
|
||||||
|
//sysnb Seteuid(euid int) (err error)
|
||||||
|
//sysnb Setgid(gid int) (err error)
|
||||||
|
//sysnb Setpgid(pid int, pgid int) (err error)
|
||||||
|
//sys Setpriority(which int, who int, prio int) (err error)
|
||||||
|
//sysnb Setregid(rgid int, egid int) (err error)
|
||||||
|
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||||
|
//sysnb Setrlimit(which int, lim *Rlimit) (err error)
|
||||||
|
//sysnb Setsid() (pid int, err error)
|
||||||
|
//sysnb Settimeofday(tp *Timeval) (err error)
|
||||||
|
//sysnb Setuid(uid int) (err error)
|
||||||
|
//sys Stat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Symlink(path string, link string) (err error)
|
||||||
|
//sys Sync() (err error)
|
||||||
|
//sys Truncate(path string, length int64) (err error)
|
||||||
|
//sys Umask(newmask int) (oldmask int)
|
||||||
|
//sys Unlink(path string) (err error)
|
||||||
|
//sys Unmount(path string, flags int) (err error)
|
||||||
|
//sys write(fd int, p []byte) (n int, err error)
|
||||||
|
//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
|
||||||
|
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||||
|
//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
|
||||||
|
//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unimplemented
|
||||||
|
*/
|
||||||
|
// ____semctl13
|
||||||
|
// __clone
|
||||||
|
// __fhopen40
|
||||||
|
// __fhstat40
|
||||||
|
// __fhstatvfs140
|
||||||
|
// __fstat30
|
||||||
|
// __getcwd
|
||||||
|
// __getfh30
|
||||||
|
// __getlogin
|
||||||
|
// __lstat30
|
||||||
|
// __mount50
|
||||||
|
// __msgctl13
|
||||||
|
// __msync13
|
||||||
|
// __ntp_gettime30
|
||||||
|
// __posix_chown
|
||||||
|
// __posix_fadvise50
|
||||||
|
// __posix_fchown
|
||||||
|
// __posix_lchown
|
||||||
|
// __posix_rename
|
||||||
|
// __setlogin
|
||||||
|
// __shmctl13
|
||||||
|
// __sigaction_sigtramp
|
||||||
|
// __sigaltstack14
|
||||||
|
// __sigpending14
|
||||||
|
// __sigprocmask14
|
||||||
|
// __sigsuspend14
|
||||||
|
// __sigtimedwait
|
||||||
|
// __stat30
|
||||||
|
// __syscall
|
||||||
|
// __vfork14
|
||||||
|
// _ksem_close
|
||||||
|
// _ksem_destroy
|
||||||
|
// _ksem_getvalue
|
||||||
|
// _ksem_init
|
||||||
|
// _ksem_open
|
||||||
|
// _ksem_post
|
||||||
|
// _ksem_trywait
|
||||||
|
// _ksem_unlink
|
||||||
|
// _ksem_wait
|
||||||
|
// _lwp_continue
|
||||||
|
// _lwp_create
|
||||||
|
// _lwp_ctl
|
||||||
|
// _lwp_detach
|
||||||
|
// _lwp_exit
|
||||||
|
// _lwp_getname
|
||||||
|
// _lwp_getprivate
|
||||||
|
// _lwp_kill
|
||||||
|
// _lwp_park
|
||||||
|
// _lwp_self
|
||||||
|
// _lwp_setname
|
||||||
|
// _lwp_setprivate
|
||||||
|
// _lwp_suspend
|
||||||
|
// _lwp_unpark
|
||||||
|
// _lwp_unpark_all
|
||||||
|
// _lwp_wait
|
||||||
|
// _lwp_wakeup
|
||||||
|
// _pset_bind
|
||||||
|
// _sched_getaffinity
|
||||||
|
// _sched_getparam
|
||||||
|
// _sched_setaffinity
|
||||||
|
// _sched_setparam
|
||||||
|
// acct
|
||||||
|
// aio_cancel
|
||||||
|
// aio_error
|
||||||
|
// aio_fsync
|
||||||
|
// aio_read
|
||||||
|
// aio_return
|
||||||
|
// aio_suspend
|
||||||
|
// aio_write
|
||||||
|
// break
|
||||||
|
// clock_getres
|
||||||
|
// clock_gettime
|
||||||
|
// clock_settime
|
||||||
|
// compat_09_ogetdomainname
|
||||||
|
// compat_09_osetdomainname
|
||||||
|
// compat_09_ouname
|
||||||
|
// compat_10_omsgsys
|
||||||
|
// compat_10_osemsys
|
||||||
|
// compat_10_oshmsys
|
||||||
|
// compat_12_fstat12
|
||||||
|
// compat_12_getdirentries
|
||||||
|
// compat_12_lstat12
|
||||||
|
// compat_12_msync
|
||||||
|
// compat_12_oreboot
|
||||||
|
// compat_12_oswapon
|
||||||
|
// compat_12_stat12
|
||||||
|
// compat_13_sigaction13
|
||||||
|
// compat_13_sigaltstack13
|
||||||
|
// compat_13_sigpending13
|
||||||
|
// compat_13_sigprocmask13
|
||||||
|
// compat_13_sigreturn13
|
||||||
|
// compat_13_sigsuspend13
|
||||||
|
// compat_14___semctl
|
||||||
|
// compat_14_msgctl
|
||||||
|
// compat_14_shmctl
|
||||||
|
// compat_16___sigaction14
|
||||||
|
// compat_16___sigreturn14
|
||||||
|
// compat_20_fhstatfs
|
||||||
|
// compat_20_fstatfs
|
||||||
|
// compat_20_getfsstat
|
||||||
|
// compat_20_statfs
|
||||||
|
// compat_30___fhstat30
|
||||||
|
// compat_30___fstat13
|
||||||
|
// compat_30___lstat13
|
||||||
|
// compat_30___stat13
|
||||||
|
// compat_30_fhopen
|
||||||
|
// compat_30_fhstat
|
||||||
|
// compat_30_fhstatvfs1
|
||||||
|
// compat_30_getdents
|
||||||
|
// compat_30_getfh
|
||||||
|
// compat_30_ntp_gettime
|
||||||
|
// compat_30_socket
|
||||||
|
// compat_40_mount
|
||||||
|
// compat_43_fstat43
|
||||||
|
// compat_43_lstat43
|
||||||
|
// compat_43_oaccept
|
||||||
|
// compat_43_ocreat
|
||||||
|
// compat_43_oftruncate
|
||||||
|
// compat_43_ogetdirentries
|
||||||
|
// compat_43_ogetdtablesize
|
||||||
|
// compat_43_ogethostid
|
||||||
|
// compat_43_ogethostname
|
||||||
|
// compat_43_ogetkerninfo
|
||||||
|
// compat_43_ogetpagesize
|
||||||
|
// compat_43_ogetpeername
|
||||||
|
// compat_43_ogetrlimit
|
||||||
|
// compat_43_ogetsockname
|
||||||
|
// compat_43_okillpg
|
||||||
|
// compat_43_olseek
|
||||||
|
// compat_43_ommap
|
||||||
|
// compat_43_oquota
|
||||||
|
// compat_43_orecv
|
||||||
|
// compat_43_orecvfrom
|
||||||
|
// compat_43_orecvmsg
|
||||||
|
// compat_43_osend
|
||||||
|
// compat_43_osendmsg
|
||||||
|
// compat_43_osethostid
|
||||||
|
// compat_43_osethostname
|
||||||
|
// compat_43_osetrlimit
|
||||||
|
// compat_43_osigblock
|
||||||
|
// compat_43_osigsetmask
|
||||||
|
// compat_43_osigstack
|
||||||
|
// compat_43_osigvec
|
||||||
|
// compat_43_otruncate
|
||||||
|
// compat_43_owait
|
||||||
|
// compat_43_stat43
|
||||||
|
// execve
|
||||||
|
// extattr_delete_fd
|
||||||
|
// extattr_delete_file
|
||||||
|
// extattr_delete_link
|
||||||
|
// extattr_get_fd
|
||||||
|
// extattr_get_file
|
||||||
|
// extattr_get_link
|
||||||
|
// extattr_list_fd
|
||||||
|
// extattr_list_file
|
||||||
|
// extattr_list_link
|
||||||
|
// extattr_set_fd
|
||||||
|
// extattr_set_file
|
||||||
|
// extattr_set_link
|
||||||
|
// extattrctl
|
||||||
|
// fchroot
|
||||||
|
// fdatasync
|
||||||
|
// fgetxattr
|
||||||
|
// fktrace
|
||||||
|
// flistxattr
|
||||||
|
// fork
|
||||||
|
// fremovexattr
|
||||||
|
// fsetxattr
|
||||||
|
// fstatvfs1
|
||||||
|
// fsync_range
|
||||||
|
// getcontext
|
||||||
|
// getitimer
|
||||||
|
// getvfsstat
|
||||||
|
// getxattr
|
||||||
|
// ioctl
|
||||||
|
// ktrace
|
||||||
|
// lchflags
|
||||||
|
// lchmod
|
||||||
|
// lfs_bmapv
|
||||||
|
// lfs_markv
|
||||||
|
// lfs_segclean
|
||||||
|
// lfs_segwait
|
||||||
|
// lgetxattr
|
||||||
|
// lio_listio
|
||||||
|
// listxattr
|
||||||
|
// llistxattr
|
||||||
|
// lremovexattr
|
||||||
|
// lseek
|
||||||
|
// lsetxattr
|
||||||
|
// lutimes
|
||||||
|
// madvise
|
||||||
|
// mincore
|
||||||
|
// minherit
|
||||||
|
// modctl
|
||||||
|
// mq_close
|
||||||
|
// mq_getattr
|
||||||
|
// mq_notify
|
||||||
|
// mq_open
|
||||||
|
// mq_receive
|
||||||
|
// mq_send
|
||||||
|
// mq_setattr
|
||||||
|
// mq_timedreceive
|
||||||
|
// mq_timedsend
|
||||||
|
// mq_unlink
|
||||||
|
// mremap
|
||||||
|
// msgget
|
||||||
|
// msgrcv
|
||||||
|
// msgsnd
|
||||||
|
// nfssvc
|
||||||
|
// ntp_adjtime
|
||||||
|
// pmc_control
|
||||||
|
// pmc_get_info
|
||||||
|
// poll
|
||||||
|
// pollts
|
||||||
|
// preadv
|
||||||
|
// profil
|
||||||
|
// pselect
|
||||||
|
// pset_assign
|
||||||
|
// pset_create
|
||||||
|
// pset_destroy
|
||||||
|
// ptrace
|
||||||
|
// pwritev
|
||||||
|
// quotactl
|
||||||
|
// rasctl
|
||||||
|
// readv
|
||||||
|
// reboot
|
||||||
|
// removexattr
|
||||||
|
// sa_enable
|
||||||
|
// sa_preempt
|
||||||
|
// sa_register
|
||||||
|
// sa_setconcurrency
|
||||||
|
// sa_stacks
|
||||||
|
// sa_yield
|
||||||
|
// sbrk
|
||||||
|
// sched_yield
|
||||||
|
// semconfig
|
||||||
|
// semget
|
||||||
|
// semop
|
||||||
|
// setcontext
|
||||||
|
// setitimer
|
||||||
|
// setxattr
|
||||||
|
// shmat
|
||||||
|
// shmdt
|
||||||
|
// shmget
|
||||||
|
// sstk
|
||||||
|
// statvfs1
|
||||||
|
// swapctl
|
||||||
|
// sysarch
|
||||||
|
// syscall
|
||||||
|
// timer_create
|
||||||
|
// timer_delete
|
||||||
|
// timer_getoverrun
|
||||||
|
// timer_gettime
|
||||||
|
// timer_settime
|
||||||
|
// undelete
|
||||||
|
// utrace
|
||||||
|
// uuidgen
|
||||||
|
// vadvise
|
||||||
|
// vfork
|
||||||
|
// writev
|
42
vendor/golang.org/x/sys/unix/syscall_netbsd_386.go
generated
vendored
Normal file
42
vendor/golang.org/x/sys/unix/syscall_netbsd_386.go
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build 386,netbsd
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = int64(nsec / 1e9)
|
||||||
|
ts.Nsec = int32(nsec % 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||||
|
tv.Sec = int64(nsec / 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint32(fd)
|
||||||
|
k.Filter = uint32(mode)
|
||||||
|
k.Flags = uint32(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
42
vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go
generated
vendored
Normal file
42
vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build amd64,netbsd
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = int64(nsec / 1e9)
|
||||||
|
ts.Nsec = int64(nsec % 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||||
|
tv.Sec = int64(nsec / 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint64(fd)
|
||||||
|
k.Filter = uint32(mode)
|
||||||
|
k.Flags = uint32(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
42
vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go
generated
vendored
Normal file
42
vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
// +build arm,netbsd
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = int64(nsec / 1e9)
|
||||||
|
ts.Nsec = int32(nsec % 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||||
|
tv.Sec = int64(nsec / 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint32(fd)
|
||||||
|
k.Filter = uint32(mode)
|
||||||
|
k.Flags = uint32(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
11
vendor/golang.org/x/sys/unix/syscall_no_getwd.go
generated
vendored
Normal file
11
vendor/golang.org/x/sys/unix/syscall_no_getwd.go
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
// +build dragonfly freebsd netbsd openbsd
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const ImplementsGetwd = false
|
||||||
|
|
||||||
|
func Getwd() (string, error) { return "", ENOTSUP }
|
303
vendor/golang.org/x/sys/unix/syscall_openbsd.go
generated
vendored
Normal file
303
vendor/golang.org/x/sys/unix/syscall_openbsd.go
generated
vendored
Normal file
|
@ -0,0 +1,303 @@
|
||||||
|
// Copyright 2009,2010 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.
|
||||||
|
|
||||||
|
// OpenBSD system calls.
|
||||||
|
// This file is compiled as ordinary Go code,
|
||||||
|
// but it is also input to mksyscall,
|
||||||
|
// which parses the //sys lines and generates system call stubs.
|
||||||
|
// Note that sometimes we use a lowercase //sys name and wrap
|
||||||
|
// it in our own nicer implementation, either here or in
|
||||||
|
// syscall_bsd.go or syscall_unix.go.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SockaddrDatalink struct {
|
||||||
|
Len uint8
|
||||||
|
Family uint8
|
||||||
|
Index uint16
|
||||||
|
Type uint8
|
||||||
|
Nlen uint8
|
||||||
|
Alen uint8
|
||||||
|
Slen uint8
|
||||||
|
Data [24]int8
|
||||||
|
raw RawSockaddrDatalink
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
|
||||||
|
func nametomib(name string) (mib []_C_int, err error) {
|
||||||
|
|
||||||
|
// Perform lookup via a binary search
|
||||||
|
left := 0
|
||||||
|
right := len(sysctlMib) - 1
|
||||||
|
for {
|
||||||
|
idx := left + (right-left)/2
|
||||||
|
switch {
|
||||||
|
case name == sysctlMib[idx].ctlname:
|
||||||
|
return sysctlMib[idx].ctloid, nil
|
||||||
|
case name > sysctlMib[idx].ctlname:
|
||||||
|
left = idx + 1
|
||||||
|
default:
|
||||||
|
right = idx - 1
|
||||||
|
}
|
||||||
|
if left > right {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseDirent parses up to max directory entries in buf,
|
||||||
|
// appending the names to names. It returns the number
|
||||||
|
// bytes consumed from buf, the number of entries added
|
||||||
|
// to names, and the new names slice.
|
||||||
|
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
||||||
|
origlen := len(buf)
|
||||||
|
for max != 0 && len(buf) > 0 {
|
||||||
|
dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
|
||||||
|
if dirent.Reclen == 0 {
|
||||||
|
buf = nil
|
||||||
|
break
|
||||||
|
}
|
||||||
|
buf = buf[dirent.Reclen:]
|
||||||
|
if dirent.Fileno == 0 { // File absent in directory.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
|
||||||
|
var name = string(bytes[0:dirent.Namlen])
|
||||||
|
if name == "." || name == ".." { // Useless names
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
max--
|
||||||
|
count++
|
||||||
|
names = append(names, name)
|
||||||
|
}
|
||||||
|
return origlen - len(buf), count, names
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe(p *[2]_C_int) (err error)
|
||||||
|
func Pipe(p []int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe(&pp)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys getdents(fd int, buf []byte) (n int, err error)
|
||||||
|
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
||||||
|
return getdents(fd, buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
return -1, ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
|
||||||
|
var _p0 unsafe.Pointer
|
||||||
|
var bufsize uintptr
|
||||||
|
if len(buf) > 0 {
|
||||||
|
_p0 = unsafe.Pointer(&buf[0])
|
||||||
|
bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
|
||||||
|
}
|
||||||
|
r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
|
||||||
|
n = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Exposed directly
|
||||||
|
*/
|
||||||
|
//sys Access(path string, mode uint32) (err error)
|
||||||
|
//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
|
||||||
|
//sys Chdir(path string) (err error)
|
||||||
|
//sys Chflags(path string, flags int) (err error)
|
||||||
|
//sys Chmod(path string, mode uint32) (err error)
|
||||||
|
//sys Chown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Chroot(path string) (err error)
|
||||||
|
//sys Close(fd int) (err error)
|
||||||
|
//sys Dup(fd int) (nfd int, err error)
|
||||||
|
//sys Dup2(from int, to int) (err error)
|
||||||
|
//sys Exit(code int)
|
||||||
|
//sys Fchdir(fd int) (err error)
|
||||||
|
//sys Fchflags(fd int, flags int) (err error)
|
||||||
|
//sys Fchmod(fd int, mode uint32) (err error)
|
||||||
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
|
//sys Flock(fd int, how int) (err error)
|
||||||
|
//sys Fpathconf(fd int, name int) (val int, err error)
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||||
|
//sys Fstatfs(fd int, stat *Statfs_t) (err error)
|
||||||
|
//sys Fsync(fd int) (err error)
|
||||||
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
|
//sysnb Getegid() (egid int)
|
||||||
|
//sysnb Geteuid() (uid int)
|
||||||
|
//sysnb Getgid() (gid int)
|
||||||
|
//sysnb Getpgid(pid int) (pgid int, err error)
|
||||||
|
//sysnb Getpgrp() (pgrp int)
|
||||||
|
//sysnb Getpid() (pid int)
|
||||||
|
//sysnb Getppid() (ppid int)
|
||||||
|
//sys Getpriority(which int, who int) (prio int, err error)
|
||||||
|
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
|
||||||
|
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||||
|
//sysnb Getsid(pid int) (sid int, err error)
|
||||||
|
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||||
|
//sysnb Getuid() (uid int)
|
||||||
|
//sys Issetugid() (tainted bool)
|
||||||
|
//sys Kill(pid int, signum syscall.Signal) (err error)
|
||||||
|
//sys Kqueue() (fd int, err error)
|
||||||
|
//sys Lchown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Link(path string, link string) (err error)
|
||||||
|
//sys Listen(s int, backlog int) (err error)
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Mkdir(path string, mode uint32) (err error)
|
||||||
|
//sys Mkfifo(path string, mode uint32) (err error)
|
||||||
|
//sys Mknod(path string, mode uint32, dev int) (err error)
|
||||||
|
//sys Mlock(b []byte) (err error)
|
||||||
|
//sys Mlockall(flags int) (err error)
|
||||||
|
//sys Mprotect(b []byte, prot int) (err error)
|
||||||
|
//sys Munlock(b []byte) (err error)
|
||||||
|
//sys Munlockall() (err error)
|
||||||
|
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
||||||
|
//sys Open(path string, mode int, perm uint32) (fd int, err error)
|
||||||
|
//sys Pathconf(path string, name int) (val int, err error)
|
||||||
|
//sys Pread(fd int, p []byte, offset int64) (n int, err error)
|
||||||
|
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
|
||||||
|
//sys read(fd int, p []byte) (n int, err error)
|
||||||
|
//sys Readlink(path string, buf []byte) (n int, err error)
|
||||||
|
//sys Rename(from string, to string) (err error)
|
||||||
|
//sys Revoke(path string) (err error)
|
||||||
|
//sys Rmdir(path string) (err error)
|
||||||
|
//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
|
||||||
|
//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
|
||||||
|
//sysnb Setegid(egid int) (err error)
|
||||||
|
//sysnb Seteuid(euid int) (err error)
|
||||||
|
//sysnb Setgid(gid int) (err error)
|
||||||
|
//sys Setlogin(name string) (err error)
|
||||||
|
//sysnb Setpgid(pid int, pgid int) (err error)
|
||||||
|
//sys Setpriority(which int, who int, prio int) (err error)
|
||||||
|
//sysnb Setregid(rgid int, egid int) (err error)
|
||||||
|
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||||
|
//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
|
||||||
|
//sysnb Setresuid(ruid int, euid int, suid int) (err error)
|
||||||
|
//sysnb Setrlimit(which int, lim *Rlimit) (err error)
|
||||||
|
//sysnb Setsid() (pid int, err error)
|
||||||
|
//sysnb Settimeofday(tp *Timeval) (err error)
|
||||||
|
//sysnb Setuid(uid int) (err error)
|
||||||
|
//sys Stat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Statfs(path string, stat *Statfs_t) (err error)
|
||||||
|
//sys Symlink(path string, link string) (err error)
|
||||||
|
//sys Sync() (err error)
|
||||||
|
//sys Truncate(path string, length int64) (err error)
|
||||||
|
//sys Umask(newmask int) (oldmask int)
|
||||||
|
//sys Unlink(path string) (err error)
|
||||||
|
//sys Unmount(path string, flags int) (err error)
|
||||||
|
//sys write(fd int, p []byte) (n int, err error)
|
||||||
|
//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
|
||||||
|
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||||
|
//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
|
||||||
|
//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unimplemented
|
||||||
|
*/
|
||||||
|
// __getcwd
|
||||||
|
// __semctl
|
||||||
|
// __syscall
|
||||||
|
// __sysctl
|
||||||
|
// adjfreq
|
||||||
|
// break
|
||||||
|
// clock_getres
|
||||||
|
// clock_gettime
|
||||||
|
// clock_settime
|
||||||
|
// closefrom
|
||||||
|
// execve
|
||||||
|
// faccessat
|
||||||
|
// fchmodat
|
||||||
|
// fchownat
|
||||||
|
// fcntl
|
||||||
|
// fhopen
|
||||||
|
// fhstat
|
||||||
|
// fhstatfs
|
||||||
|
// fork
|
||||||
|
// fstatat
|
||||||
|
// futimens
|
||||||
|
// getfh
|
||||||
|
// getgid
|
||||||
|
// getitimer
|
||||||
|
// getlogin
|
||||||
|
// getresgid
|
||||||
|
// getresuid
|
||||||
|
// getrtable
|
||||||
|
// getthrid
|
||||||
|
// ioctl
|
||||||
|
// ktrace
|
||||||
|
// lfs_bmapv
|
||||||
|
// lfs_markv
|
||||||
|
// lfs_segclean
|
||||||
|
// lfs_segwait
|
||||||
|
// linkat
|
||||||
|
// mincore
|
||||||
|
// minherit
|
||||||
|
// mkdirat
|
||||||
|
// mkfifoat
|
||||||
|
// mknodat
|
||||||
|
// mount
|
||||||
|
// mquery
|
||||||
|
// msgctl
|
||||||
|
// msgget
|
||||||
|
// msgrcv
|
||||||
|
// msgsnd
|
||||||
|
// nfssvc
|
||||||
|
// nnpfspioctl
|
||||||
|
// openat
|
||||||
|
// poll
|
||||||
|
// preadv
|
||||||
|
// profil
|
||||||
|
// pwritev
|
||||||
|
// quotactl
|
||||||
|
// readlinkat
|
||||||
|
// readv
|
||||||
|
// reboot
|
||||||
|
// renameat
|
||||||
|
// rfork
|
||||||
|
// sched_yield
|
||||||
|
// semget
|
||||||
|
// semop
|
||||||
|
// setgroups
|
||||||
|
// setitimer
|
||||||
|
// setrtable
|
||||||
|
// setsockopt
|
||||||
|
// shmat
|
||||||
|
// shmctl
|
||||||
|
// shmdt
|
||||||
|
// shmget
|
||||||
|
// sigaction
|
||||||
|
// sigaltstack
|
||||||
|
// sigpending
|
||||||
|
// sigprocmask
|
||||||
|
// sigreturn
|
||||||
|
// sigsuspend
|
||||||
|
// symlinkat
|
||||||
|
// sysarch
|
||||||
|
// syscall
|
||||||
|
// threxit
|
||||||
|
// thrsigdivert
|
||||||
|
// thrsleep
|
||||||
|
// thrwakeup
|
||||||
|
// unlinkat
|
||||||
|
// utimensat
|
||||||
|
// vfork
|
||||||
|
// writev
|
42
vendor/golang.org/x/sys/unix/syscall_openbsd_386.go
generated
vendored
Normal file
42
vendor/golang.org/x/sys/unix/syscall_openbsd_386.go
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build 386,openbsd
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = int64(nsec / 1e9)
|
||||||
|
ts.Nsec = int32(nsec % 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Usec = int32(nsec % 1e9 / 1e3)
|
||||||
|
tv.Sec = int64(nsec / 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint32(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
42
vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go
generated
vendored
Normal file
42
vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build amd64,openbsd
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
func Getpagesize() int { return 4096 }
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = nsec / 1e9
|
||||||
|
ts.Nsec = nsec % 1e9
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Usec = nsec % 1e9 / 1e3
|
||||||
|
tv.Sec = nsec / 1e9
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint64(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
713
vendor/golang.org/x/sys/unix/syscall_solaris.go
generated
vendored
Normal file
713
vendor/golang.org/x/sys/unix/syscall_solaris.go
generated
vendored
Normal file
|
@ -0,0 +1,713 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// Solaris system calls.
|
||||||
|
// This file is compiled as ordinary Go code,
|
||||||
|
// but it is also input to mksyscall,
|
||||||
|
// which parses the //sys lines and generates system call stubs.
|
||||||
|
// Note that sometimes we use a lowercase //sys name and wrap
|
||||||
|
// it in our own nicer implementation, either here or in
|
||||||
|
// syscall_solaris.go or syscall_unix.go.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync/atomic"
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Implemented in runtime/syscall_solaris.go.
|
||||||
|
type syscallFunc uintptr
|
||||||
|
|
||||||
|
func rawSysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
|
||||||
|
type SockaddrDatalink struct {
|
||||||
|
Family uint16
|
||||||
|
Index uint16
|
||||||
|
Type uint8
|
||||||
|
Nlen uint8
|
||||||
|
Alen uint8
|
||||||
|
Slen uint8
|
||||||
|
Data [244]int8
|
||||||
|
raw RawSockaddrDatalink
|
||||||
|
}
|
||||||
|
|
||||||
|
func clen(n []byte) int {
|
||||||
|
for i := 0; i < len(n); i++ {
|
||||||
|
if n[i] == 0 {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len(n)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseDirent parses up to max directory entries in buf,
|
||||||
|
// appending the names to names. It returns the number
|
||||||
|
// bytes consumed from buf, the number of entries added
|
||||||
|
// to names, and the new names slice.
|
||||||
|
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
||||||
|
origlen := len(buf)
|
||||||
|
for max != 0 && len(buf) > 0 {
|
||||||
|
dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
|
||||||
|
if dirent.Reclen == 0 {
|
||||||
|
buf = nil
|
||||||
|
break
|
||||||
|
}
|
||||||
|
buf = buf[dirent.Reclen:]
|
||||||
|
if dirent.Ino == 0 { // File absent in directory.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
|
||||||
|
var name = string(bytes[0:clen(bytes[:])])
|
||||||
|
if name == "." || name == ".." { // Useless names
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
max--
|
||||||
|
count++
|
||||||
|
names = append(names, name)
|
||||||
|
}
|
||||||
|
return origlen - len(buf), count, names
|
||||||
|
}
|
||||||
|
|
||||||
|
func pipe() (r uintptr, w uintptr, err uintptr)
|
||||||
|
|
||||||
|
func Pipe(p []int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
r0, w0, e1 := pipe()
|
||||||
|
if e1 != 0 {
|
||||||
|
err = syscall.Errno(e1)
|
||||||
|
}
|
||||||
|
p[0], p[1] = int(r0), int(w0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
if sa.Port < 0 || sa.Port > 0xFFFF {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
sa.raw.Family = AF_INET
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
|
||||||
|
p[0] = byte(sa.Port >> 8)
|
||||||
|
p[1] = byte(sa.Port)
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.raw.Addr[i] = sa.Addr[i]
|
||||||
|
}
|
||||||
|
return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
if sa.Port < 0 || sa.Port > 0xFFFF {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
sa.raw.Family = AF_INET6
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
|
||||||
|
p[0] = byte(sa.Port >> 8)
|
||||||
|
p[1] = byte(sa.Port)
|
||||||
|
sa.raw.Scope_id = sa.ZoneId
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.raw.Addr[i] = sa.Addr[i]
|
||||||
|
}
|
||||||
|
return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
name := sa.Name
|
||||||
|
n := len(name)
|
||||||
|
if n >= len(sa.raw.Path) {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
sa.raw.Family = AF_UNIX
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
sa.raw.Path[i] = int8(name[i])
|
||||||
|
}
|
||||||
|
// length is family (uint16), name, NUL.
|
||||||
|
sl := _Socklen(2)
|
||||||
|
if n > 0 {
|
||||||
|
sl += _Socklen(n) + 1
|
||||||
|
}
|
||||||
|
if sa.raw.Path[0] == '@' {
|
||||||
|
sa.raw.Path[0] = 0
|
||||||
|
// Don't count trailing NUL for abstract address.
|
||||||
|
sl--
|
||||||
|
}
|
||||||
|
|
||||||
|
return unsafe.Pointer(&sa.raw), sl, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getsockname
|
||||||
|
|
||||||
|
func Getsockname(fd int) (sa Sockaddr, err error) {
|
||||||
|
var rsa RawSockaddrAny
|
||||||
|
var len _Socklen = SizeofSockaddrAny
|
||||||
|
if err = getsockname(fd, &rsa, &len); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return anyToSockaddr(&rsa)
|
||||||
|
}
|
||||||
|
|
||||||
|
const ImplementsGetwd = true
|
||||||
|
|
||||||
|
//sys Getcwd(buf []byte) (n int, err error)
|
||||||
|
|
||||||
|
func Getwd() (wd string, err error) {
|
||||||
|
var buf [PathMax]byte
|
||||||
|
// Getcwd will return an error if it failed for any reason.
|
||||||
|
_, err = Getcwd(buf[0:])
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
n := clen(buf[:])
|
||||||
|
if n < 1 {
|
||||||
|
return "", EINVAL
|
||||||
|
}
|
||||||
|
return string(buf[:n]), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wrapped
|
||||||
|
*/
|
||||||
|
|
||||||
|
//sysnb getgroups(ngid int, gid *_Gid_t) (n int, err error)
|
||||||
|
//sysnb setgroups(ngid int, gid *_Gid_t) (err error)
|
||||||
|
|
||||||
|
func Getgroups() (gids []int, err error) {
|
||||||
|
n, err := getgroups(0, nil)
|
||||||
|
// Check for error and sanity check group count. Newer versions of
|
||||||
|
// Solaris allow up to 1024 (NGROUPS_MAX).
|
||||||
|
if n < 0 || n > 1024 {
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return nil, EINVAL
|
||||||
|
} else if n == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
a := make([]_Gid_t, n)
|
||||||
|
n, err = getgroups(n, &a[0])
|
||||||
|
if n == -1 {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
gids = make([]int, n)
|
||||||
|
for i, v := range a[0:n] {
|
||||||
|
gids[i] = int(v)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Setgroups(gids []int) (err error) {
|
||||||
|
if len(gids) == 0 {
|
||||||
|
return setgroups(0, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
a := make([]_Gid_t, len(gids))
|
||||||
|
for i, v := range gids {
|
||||||
|
a[i] = _Gid_t(v)
|
||||||
|
}
|
||||||
|
return setgroups(len(a), &a[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
func ReadDirent(fd int, buf []byte) (n int, err error) {
|
||||||
|
// Final argument is (basep *uintptr) and the syscall doesn't take nil.
|
||||||
|
// TODO(rsc): Can we use a single global basep for all calls?
|
||||||
|
return Getdents(fd, buf, new(uintptr))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait status is 7 bits at bottom, either 0 (exited),
|
||||||
|
// 0x7F (stopped), or a signal number that caused an exit.
|
||||||
|
// The 0x80 bit is whether there was a core dump.
|
||||||
|
// An extra number (exit code, signal causing a stop)
|
||||||
|
// is in the high bits.
|
||||||
|
|
||||||
|
type WaitStatus uint32
|
||||||
|
|
||||||
|
const (
|
||||||
|
mask = 0x7F
|
||||||
|
core = 0x80
|
||||||
|
shift = 8
|
||||||
|
|
||||||
|
exited = 0
|
||||||
|
stopped = 0x7F
|
||||||
|
)
|
||||||
|
|
||||||
|
func (w WaitStatus) Exited() bool { return w&mask == exited }
|
||||||
|
|
||||||
|
func (w WaitStatus) ExitStatus() int {
|
||||||
|
if w&mask != exited {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return int(w >> shift)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != 0 }
|
||||||
|
|
||||||
|
func (w WaitStatus) Signal() syscall.Signal {
|
||||||
|
sig := syscall.Signal(w & mask)
|
||||||
|
if sig == stopped || sig == 0 {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return sig
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 }
|
||||||
|
|
||||||
|
func (w WaitStatus) Stopped() bool { return w&mask == stopped && syscall.Signal(w>>shift) != SIGSTOP }
|
||||||
|
|
||||||
|
func (w WaitStatus) Continued() bool { return w&mask == stopped && syscall.Signal(w>>shift) == SIGSTOP }
|
||||||
|
|
||||||
|
func (w WaitStatus) StopSignal() syscall.Signal {
|
||||||
|
if !w.Stopped() {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return syscall.Signal(w>>shift) & 0xFF
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WaitStatus) TrapCause() int { return -1 }
|
||||||
|
|
||||||
|
func wait4(pid uintptr, wstatus *WaitStatus, options uintptr, rusage *Rusage) (wpid uintptr, err uintptr)
|
||||||
|
|
||||||
|
func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
|
||||||
|
r0, e1 := wait4(uintptr(pid), wstatus, uintptr(options), rusage)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = syscall.Errno(e1)
|
||||||
|
}
|
||||||
|
return int(r0), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func gethostname() (name string, err uintptr)
|
||||||
|
|
||||||
|
func Gethostname() (name string, err error) {
|
||||||
|
name, e1 := gethostname()
|
||||||
|
if e1 != 0 {
|
||||||
|
err = syscall.Errno(e1)
|
||||||
|
}
|
||||||
|
return name, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys utimes(path string, times *[2]Timeval) (err error)
|
||||||
|
|
||||||
|
func Utimes(path string, tv []Timeval) (err error) {
|
||||||
|
if tv == nil {
|
||||||
|
return utimes(path, nil)
|
||||||
|
}
|
||||||
|
if len(tv) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys utimensat(fd int, path string, times *[2]Timespec, flag int) (err error)
|
||||||
|
|
||||||
|
func UtimesNano(path string, ts []Timespec) error {
|
||||||
|
if ts == nil {
|
||||||
|
return utimensat(AT_FDCWD, path, nil, 0)
|
||||||
|
}
|
||||||
|
if len(ts) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error {
|
||||||
|
if ts == nil {
|
||||||
|
return utimensat(dirfd, path, nil, flags)
|
||||||
|
}
|
||||||
|
if len(ts) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys fcntl(fd int, cmd int, arg int) (val int, err error)
|
||||||
|
|
||||||
|
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
||||||
|
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
||||||
|
_, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(unsafe.Pointer(lk)), 0, 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
return e1
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys futimesat(fildes int, path *byte, times *[2]Timeval) (err error)
|
||||||
|
|
||||||
|
func Futimesat(dirfd int, path string, tv []Timeval) error {
|
||||||
|
pathp, err := BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if tv == nil {
|
||||||
|
return futimesat(dirfd, pathp, nil)
|
||||||
|
}
|
||||||
|
if len(tv) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
return futimesat(dirfd, pathp, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Solaris doesn't have an futimes function because it allows NULL to be
|
||||||
|
// specified as the path for futimesat. However, Go doesn't like
|
||||||
|
// NULL-style string interfaces, so this simple wrapper is provided.
|
||||||
|
func Futimes(fd int, tv []Timeval) error {
|
||||||
|
if tv == nil {
|
||||||
|
return futimesat(fd, nil, nil)
|
||||||
|
}
|
||||||
|
if len(tv) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
return futimesat(fd, nil, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||||
|
}
|
||||||
|
|
||||||
|
func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||||
|
switch rsa.Addr.Family {
|
||||||
|
case AF_UNIX:
|
||||||
|
pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
|
||||||
|
sa := new(SockaddrUnix)
|
||||||
|
// Assume path ends at NUL.
|
||||||
|
// This is not technically the Solaris semantics for
|
||||||
|
// abstract Unix domain sockets -- they are supposed
|
||||||
|
// to be uninterpreted fixed-size binary blobs -- but
|
||||||
|
// everyone uses this convention.
|
||||||
|
n := 0
|
||||||
|
for n < len(pp.Path) && pp.Path[n] != 0 {
|
||||||
|
n++
|
||||||
|
}
|
||||||
|
bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
|
||||||
|
sa.Name = string(bytes)
|
||||||
|
return sa, nil
|
||||||
|
|
||||||
|
case AF_INET:
|
||||||
|
pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
|
||||||
|
sa := new(SockaddrInet4)
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&pp.Port))
|
||||||
|
sa.Port = int(p[0])<<8 + int(p[1])
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.Addr[i] = pp.Addr[i]
|
||||||
|
}
|
||||||
|
return sa, nil
|
||||||
|
|
||||||
|
case AF_INET6:
|
||||||
|
pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
|
||||||
|
sa := new(SockaddrInet6)
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&pp.Port))
|
||||||
|
sa.Port = int(p[0])<<8 + int(p[1])
|
||||||
|
sa.ZoneId = pp.Scope_id
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.Addr[i] = pp.Addr[i]
|
||||||
|
}
|
||||||
|
return sa, nil
|
||||||
|
}
|
||||||
|
return nil, EAFNOSUPPORT
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) = libsocket.accept
|
||||||
|
|
||||||
|
func Accept(fd int) (nfd int, sa Sockaddr, err error) {
|
||||||
|
var rsa RawSockaddrAny
|
||||||
|
var len _Socklen = SizeofSockaddrAny
|
||||||
|
nfd, err = accept(fd, &rsa, &len)
|
||||||
|
if nfd == -1 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
sa, err = anyToSockaddr(&rsa)
|
||||||
|
if err != nil {
|
||||||
|
Close(nfd)
|
||||||
|
nfd = 0
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.recvmsg
|
||||||
|
|
||||||
|
func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
|
||||||
|
var msg Msghdr
|
||||||
|
var rsa RawSockaddrAny
|
||||||
|
msg.Name = (*byte)(unsafe.Pointer(&rsa))
|
||||||
|
msg.Namelen = uint32(SizeofSockaddrAny)
|
||||||
|
var iov Iovec
|
||||||
|
if len(p) > 0 {
|
||||||
|
iov.Base = (*int8)(unsafe.Pointer(&p[0]))
|
||||||
|
iov.SetLen(len(p))
|
||||||
|
}
|
||||||
|
var dummy int8
|
||||||
|
if len(oob) > 0 {
|
||||||
|
// receive at least one normal byte
|
||||||
|
if len(p) == 0 {
|
||||||
|
iov.Base = &dummy
|
||||||
|
iov.SetLen(1)
|
||||||
|
}
|
||||||
|
msg.Accrights = (*int8)(unsafe.Pointer(&oob[0]))
|
||||||
|
}
|
||||||
|
msg.Iov = &iov
|
||||||
|
msg.Iovlen = 1
|
||||||
|
if n, err = recvmsg(fd, &msg, flags); n == -1 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
oobn = int(msg.Accrightslen)
|
||||||
|
// source address is only specified if the socket is unconnected
|
||||||
|
if rsa.Addr.Family != AF_UNSPEC {
|
||||||
|
from, err = anyToSockaddr(&rsa)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
|
||||||
|
_, err = SendmsgN(fd, p, oob, to, flags)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.sendmsg
|
||||||
|
|
||||||
|
func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
|
||||||
|
var ptr unsafe.Pointer
|
||||||
|
var salen _Socklen
|
||||||
|
if to != nil {
|
||||||
|
ptr, salen, err = to.sockaddr()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var msg Msghdr
|
||||||
|
msg.Name = (*byte)(unsafe.Pointer(ptr))
|
||||||
|
msg.Namelen = uint32(salen)
|
||||||
|
var iov Iovec
|
||||||
|
if len(p) > 0 {
|
||||||
|
iov.Base = (*int8)(unsafe.Pointer(&p[0]))
|
||||||
|
iov.SetLen(len(p))
|
||||||
|
}
|
||||||
|
var dummy int8
|
||||||
|
if len(oob) > 0 {
|
||||||
|
// send at least one normal byte
|
||||||
|
if len(p) == 0 {
|
||||||
|
iov.Base = &dummy
|
||||||
|
iov.SetLen(1)
|
||||||
|
}
|
||||||
|
msg.Accrights = (*int8)(unsafe.Pointer(&oob[0]))
|
||||||
|
}
|
||||||
|
msg.Iov = &iov
|
||||||
|
msg.Iovlen = 1
|
||||||
|
if n, err = sendmsg(fd, &msg, flags); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if len(oob) > 0 && len(p) == 0 {
|
||||||
|
n = 0
|
||||||
|
}
|
||||||
|
return n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys acct(path *byte) (err error)
|
||||||
|
|
||||||
|
func Acct(path string) (err error) {
|
||||||
|
if len(path) == 0 {
|
||||||
|
// Assume caller wants to disable accounting.
|
||||||
|
return acct(nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
pathp, err := BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return acct(pathp)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Expose the ioctl function
|
||||||
|
*/
|
||||||
|
|
||||||
|
//sys ioctl(fd int, req int, arg uintptr) (err error)
|
||||||
|
|
||||||
|
func IoctlSetInt(fd int, req int, value int) (err error) {
|
||||||
|
return ioctl(fd, req, uintptr(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlSetWinsize(fd int, req int, value *Winsize) (err error) {
|
||||||
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlSetTermios(fd int, req int, value *Termios) (err error) {
|
||||||
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlSetTermio(fd int, req int, value *Termio) (err error) {
|
||||||
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetInt(fd int, req int) (int, error) {
|
||||||
|
var value int
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetWinsize(fd int, req int) (*Winsize, error) {
|
||||||
|
var value Winsize
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetTermios(fd int, req int) (*Termios, error) {
|
||||||
|
var value Termios
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetTermio(fd int, req int) (*Termio, error) {
|
||||||
|
var value Termio
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Exposed directly
|
||||||
|
*/
|
||||||
|
//sys Access(path string, mode uint32) (err error)
|
||||||
|
//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
|
||||||
|
//sys Chdir(path string) (err error)
|
||||||
|
//sys Chmod(path string, mode uint32) (err error)
|
||||||
|
//sys Chown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Chroot(path string) (err error)
|
||||||
|
//sys Close(fd int) (err error)
|
||||||
|
//sys Creat(path string, mode uint32) (fd int, err error)
|
||||||
|
//sys Dup(fd int) (nfd int, err error)
|
||||||
|
//sys Dup2(oldfd int, newfd int) (err error)
|
||||||
|
//sys Exit(code int)
|
||||||
|
//sys Fchdir(fd int) (err error)
|
||||||
|
//sys Fchmod(fd int, mode uint32) (err error)
|
||||||
|
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
|
||||||
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
|
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
|
||||||
|
//sys Fdatasync(fd int) (err error)
|
||||||
|
//sys Fpathconf(fd int, name int) (val int, err error)
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||||
|
//sys Getdents(fd int, buf []byte, basep *uintptr) (n int, err error)
|
||||||
|
//sysnb Getgid() (gid int)
|
||||||
|
//sysnb Getpid() (pid int)
|
||||||
|
//sysnb Getpgid(pid int) (pgid int, err error)
|
||||||
|
//sysnb Getpgrp() (pgid int, err error)
|
||||||
|
//sys Geteuid() (euid int)
|
||||||
|
//sys Getegid() (egid int)
|
||||||
|
//sys Getppid() (ppid int)
|
||||||
|
//sys Getpriority(which int, who int) (n int, err error)
|
||||||
|
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
|
||||||
|
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||||
|
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||||
|
//sysnb Getuid() (uid int)
|
||||||
|
//sys Kill(pid int, signum syscall.Signal) (err error)
|
||||||
|
//sys Lchown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Link(path string, link string) (err error)
|
||||||
|
//sys Listen(s int, backlog int) (err error) = libsocket.listen
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Madvise(b []byte, advice int) (err error)
|
||||||
|
//sys Mkdir(path string, mode uint32) (err error)
|
||||||
|
//sys Mkdirat(dirfd int, path string, mode uint32) (err error)
|
||||||
|
//sys Mkfifo(path string, mode uint32) (err error)
|
||||||
|
//sys Mkfifoat(dirfd int, path string, mode uint32) (err error)
|
||||||
|
//sys Mknod(path string, mode uint32, dev int) (err error)
|
||||||
|
//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
|
||||||
|
//sys Mlock(b []byte) (err error)
|
||||||
|
//sys Mlockall(flags int) (err error)
|
||||||
|
//sys Mprotect(b []byte, prot int) (err error)
|
||||||
|
//sys Munlock(b []byte) (err error)
|
||||||
|
//sys Munlockall() (err error)
|
||||||
|
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
||||||
|
//sys Open(path string, mode int, perm uint32) (fd int, err error)
|
||||||
|
//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
|
||||||
|
//sys Pathconf(path string, name int) (val int, err error)
|
||||||
|
//sys Pause() (err error)
|
||||||
|
//sys Pread(fd int, p []byte, offset int64) (n int, err error)
|
||||||
|
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
|
||||||
|
//sys read(fd int, p []byte) (n int, err error)
|
||||||
|
//sys Readlink(path string, buf []byte) (n int, err error)
|
||||||
|
//sys Rename(from string, to string) (err error)
|
||||||
|
//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
|
||||||
|
//sys Rmdir(path string) (err error)
|
||||||
|
//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = lseek
|
||||||
|
//sysnb Setegid(egid int) (err error)
|
||||||
|
//sysnb Seteuid(euid int) (err error)
|
||||||
|
//sysnb Setgid(gid int) (err error)
|
||||||
|
//sys Sethostname(p []byte) (err error)
|
||||||
|
//sysnb Setpgid(pid int, pgid int) (err error)
|
||||||
|
//sys Setpriority(which int, who int, prio int) (err error)
|
||||||
|
//sysnb Setregid(rgid int, egid int) (err error)
|
||||||
|
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||||
|
//sysnb Setrlimit(which int, lim *Rlimit) (err error)
|
||||||
|
//sysnb Setsid() (pid int, err error)
|
||||||
|
//sysnb Setuid(uid int) (err error)
|
||||||
|
//sys Shutdown(s int, how int) (err error) = libsocket.shutdown
|
||||||
|
//sys Stat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Symlink(path string, link string) (err error)
|
||||||
|
//sys Sync() (err error)
|
||||||
|
//sysnb Times(tms *Tms) (ticks uintptr, err error)
|
||||||
|
//sys Truncate(path string, length int64) (err error)
|
||||||
|
//sys Fsync(fd int) (err error)
|
||||||
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
|
//sys Umask(mask int) (oldmask int)
|
||||||
|
//sysnb Uname(buf *Utsname) (err error)
|
||||||
|
//sys Unmount(target string, flags int) (err error) = libc.umount
|
||||||
|
//sys Unlink(path string) (err error)
|
||||||
|
//sys Unlinkat(dirfd int, path string, flags int) (err error)
|
||||||
|
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
|
||||||
|
//sys Utime(path string, buf *Utimbuf) (err error)
|
||||||
|
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.bind
|
||||||
|
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.connect
|
||||||
|
//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
|
||||||
|
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||||
|
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.sendto
|
||||||
|
//sys socket(domain int, typ int, proto int) (fd int, err error) = libsocket.socket
|
||||||
|
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) = libsocket.socketpair
|
||||||
|
//sys write(fd int, p []byte) (n int, err error)
|
||||||
|
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) = libsocket.getsockopt
|
||||||
|
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getpeername
|
||||||
|
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) = libsocket.setsockopt
|
||||||
|
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) = libsocket.recvfrom
|
||||||
|
|
||||||
|
func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
|
||||||
|
r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procread)), 3, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf), 0, 0, 0)
|
||||||
|
n = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
|
||||||
|
r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procwrite)), 3, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf), 0, 0, 0)
|
||||||
|
n = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var mapper = &mmapper{
|
||||||
|
active: make(map[*byte][]byte),
|
||||||
|
mmap: mmap,
|
||||||
|
munmap: munmap,
|
||||||
|
}
|
||||||
|
|
||||||
|
func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
|
||||||
|
return mapper.Mmap(fd, offset, length, prot, flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Munmap(b []byte) (err error) {
|
||||||
|
return mapper.Munmap(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys sysconf(name int) (n int64, err error)
|
||||||
|
|
||||||
|
// pageSize caches the value of Getpagesize, since it can't change
|
||||||
|
// once the system is booted.
|
||||||
|
var pageSize int64 // accessed atomically
|
||||||
|
|
||||||
|
func Getpagesize() int {
|
||||||
|
n := atomic.LoadInt64(&pageSize)
|
||||||
|
if n == 0 {
|
||||||
|
n, _ = sysconf(_SC_PAGESIZE)
|
||||||
|
atomic.StoreInt64(&pageSize, n)
|
||||||
|
}
|
||||||
|
return int(n)
|
||||||
|
}
|
35
vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go
generated
vendored
Normal file
35
vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build amd64,solaris
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||||
|
|
||||||
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
||||||
|
ts.Sec = nsec / 1e9
|
||||||
|
ts.Nsec = nsec % 1e9
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
||||||
|
nsec += 999 // round up to microsecond
|
||||||
|
tv.Usec = nsec % 1e9 / 1e3
|
||||||
|
tv.Sec = int64(nsec / 1e9)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
// TODO(aram): implement this, see issue 5847.
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
297
vendor/golang.org/x/sys/unix/syscall_unix.go
generated
vendored
Normal file
297
vendor/golang.org/x/sys/unix/syscall_unix.go
generated
vendored
Normal file
|
@ -0,0 +1,297 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
"sync"
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
Stdin = 0
|
||||||
|
Stdout = 1
|
||||||
|
Stderr = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
darwin64Bit = runtime.GOOS == "darwin" && sizeofPtr == 8
|
||||||
|
dragonfly64Bit = runtime.GOOS == "dragonfly" && sizeofPtr == 8
|
||||||
|
netbsd32Bit = runtime.GOOS == "netbsd" && sizeofPtr == 4
|
||||||
|
)
|
||||||
|
|
||||||
|
// Do the interface allocations only once for common
|
||||||
|
// Errno values.
|
||||||
|
var (
|
||||||
|
errEAGAIN error = syscall.EAGAIN
|
||||||
|
errEINVAL error = syscall.EINVAL
|
||||||
|
errENOENT error = syscall.ENOENT
|
||||||
|
)
|
||||||
|
|
||||||
|
// errnoErr returns common boxed Errno values, to prevent
|
||||||
|
// allocations at runtime.
|
||||||
|
func errnoErr(e syscall.Errno) error {
|
||||||
|
switch e {
|
||||||
|
case 0:
|
||||||
|
return nil
|
||||||
|
case EAGAIN:
|
||||||
|
return errEAGAIN
|
||||||
|
case EINVAL:
|
||||||
|
return errEINVAL
|
||||||
|
case ENOENT:
|
||||||
|
return errENOENT
|
||||||
|
}
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
|
||||||
|
// Mmap manager, for use by operating system-specific implementations.
|
||||||
|
|
||||||
|
type mmapper struct {
|
||||||
|
sync.Mutex
|
||||||
|
active map[*byte][]byte // active mappings; key is last byte in mapping
|
||||||
|
mmap func(addr, length uintptr, prot, flags, fd int, offset int64) (uintptr, error)
|
||||||
|
munmap func(addr uintptr, length uintptr) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *mmapper) Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
|
||||||
|
if length <= 0 {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Map the requested memory.
|
||||||
|
addr, errno := m.mmap(0, uintptr(length), prot, flags, fd, offset)
|
||||||
|
if errno != nil {
|
||||||
|
return nil, errno
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slice memory layout
|
||||||
|
var sl = struct {
|
||||||
|
addr uintptr
|
||||||
|
len int
|
||||||
|
cap int
|
||||||
|
}{addr, length, length}
|
||||||
|
|
||||||
|
// Use unsafe to turn sl into a []byte.
|
||||||
|
b := *(*[]byte)(unsafe.Pointer(&sl))
|
||||||
|
|
||||||
|
// Register mapping in m and return it.
|
||||||
|
p := &b[cap(b)-1]
|
||||||
|
m.Lock()
|
||||||
|
defer m.Unlock()
|
||||||
|
m.active[p] = b
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *mmapper) Munmap(data []byte) (err error) {
|
||||||
|
if len(data) == 0 || len(data) != cap(data) {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the base of the mapping.
|
||||||
|
p := &data[cap(data)-1]
|
||||||
|
m.Lock()
|
||||||
|
defer m.Unlock()
|
||||||
|
b := m.active[p]
|
||||||
|
if b == nil || &b[0] != &data[0] {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unmap the memory and update m.
|
||||||
|
if errno := m.munmap(uintptr(unsafe.Pointer(&b[0])), uintptr(len(b))); errno != nil {
|
||||||
|
return errno
|
||||||
|
}
|
||||||
|
delete(m.active, p)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Read(fd int, p []byte) (n int, err error) {
|
||||||
|
n, err = read(fd, p)
|
||||||
|
if raceenabled {
|
||||||
|
if n > 0 {
|
||||||
|
raceWriteRange(unsafe.Pointer(&p[0]), n)
|
||||||
|
}
|
||||||
|
if err == nil {
|
||||||
|
raceAcquire(unsafe.Pointer(&ioSync))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Write(fd int, p []byte) (n int, err error) {
|
||||||
|
if raceenabled {
|
||||||
|
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
||||||
|
}
|
||||||
|
n, err = write(fd, p)
|
||||||
|
if raceenabled && n > 0 {
|
||||||
|
raceReadRange(unsafe.Pointer(&p[0]), n)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// For testing: clients can set this flag to force
|
||||||
|
// creation of IPv6 sockets to return EAFNOSUPPORT.
|
||||||
|
var SocketDisableIPv6 bool
|
||||||
|
|
||||||
|
type Sockaddr interface {
|
||||||
|
sockaddr() (ptr unsafe.Pointer, len _Socklen, err error) // lowercase; only we can define Sockaddrs
|
||||||
|
}
|
||||||
|
|
||||||
|
type SockaddrInet4 struct {
|
||||||
|
Port int
|
||||||
|
Addr [4]byte
|
||||||
|
raw RawSockaddrInet4
|
||||||
|
}
|
||||||
|
|
||||||
|
type SockaddrInet6 struct {
|
||||||
|
Port int
|
||||||
|
ZoneId uint32
|
||||||
|
Addr [16]byte
|
||||||
|
raw RawSockaddrInet6
|
||||||
|
}
|
||||||
|
|
||||||
|
type SockaddrUnix struct {
|
||||||
|
Name string
|
||||||
|
raw RawSockaddrUnix
|
||||||
|
}
|
||||||
|
|
||||||
|
func Bind(fd int, sa Sockaddr) (err error) {
|
||||||
|
ptr, n, err := sa.sockaddr()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return bind(fd, ptr, n)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Connect(fd int, sa Sockaddr) (err error) {
|
||||||
|
ptr, n, err := sa.sockaddr()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return connect(fd, ptr, n)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Getpeername(fd int) (sa Sockaddr, err error) {
|
||||||
|
var rsa RawSockaddrAny
|
||||||
|
var len _Socklen = SizeofSockaddrAny
|
||||||
|
if err = getpeername(fd, &rsa, &len); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return anyToSockaddr(&rsa)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetsockoptInt(fd, level, opt int) (value int, err error) {
|
||||||
|
var n int32
|
||||||
|
vallen := _Socklen(4)
|
||||||
|
err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen)
|
||||||
|
return int(n), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) {
|
||||||
|
var rsa RawSockaddrAny
|
||||||
|
var len _Socklen = SizeofSockaddrAny
|
||||||
|
if n, err = recvfrom(fd, p, flags, &rsa, &len); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if rsa.Addr.Family != AF_UNSPEC {
|
||||||
|
from, err = anyToSockaddr(&rsa)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Sendto(fd int, p []byte, flags int, to Sockaddr) (err error) {
|
||||||
|
ptr, n, err := to.sockaddr()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return sendto(fd, p, flags, ptr, n)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetsockoptByte(fd, level, opt int, value byte) (err error) {
|
||||||
|
return setsockopt(fd, level, opt, unsafe.Pointer(&value), 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetsockoptInt(fd, level, opt int, value int) (err error) {
|
||||||
|
var n = int32(value)
|
||||||
|
return setsockopt(fd, level, opt, unsafe.Pointer(&n), 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetsockoptInet4Addr(fd, level, opt int, value [4]byte) (err error) {
|
||||||
|
return setsockopt(fd, level, opt, unsafe.Pointer(&value[0]), 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetsockoptIPMreq(fd, level, opt int, mreq *IPMreq) (err error) {
|
||||||
|
return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPMreq)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetsockoptIPv6Mreq(fd, level, opt int, mreq *IPv6Mreq) (err error) {
|
||||||
|
return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPv6Mreq)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetsockoptICMPv6Filter(fd, level, opt int, filter *ICMPv6Filter) error {
|
||||||
|
return setsockopt(fd, level, opt, unsafe.Pointer(filter), SizeofICMPv6Filter)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetsockoptLinger(fd, level, opt int, l *Linger) (err error) {
|
||||||
|
return setsockopt(fd, level, opt, unsafe.Pointer(l), SizeofLinger)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetsockoptString(fd, level, opt int, s string) (err error) {
|
||||||
|
return setsockopt(fd, level, opt, unsafe.Pointer(&[]byte(s)[0]), uintptr(len(s)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (err error) {
|
||||||
|
return setsockopt(fd, level, opt, unsafe.Pointer(tv), unsafe.Sizeof(*tv))
|
||||||
|
}
|
||||||
|
|
||||||
|
func Socket(domain, typ, proto int) (fd int, err error) {
|
||||||
|
if domain == AF_INET6 && SocketDisableIPv6 {
|
||||||
|
return -1, EAFNOSUPPORT
|
||||||
|
}
|
||||||
|
fd, err = socket(domain, typ, proto)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Socketpair(domain, typ, proto int) (fd [2]int, err error) {
|
||||||
|
var fdx [2]int32
|
||||||
|
err = socketpair(domain, typ, proto, &fdx)
|
||||||
|
if err == nil {
|
||||||
|
fd[0] = int(fdx[0])
|
||||||
|
fd[1] = int(fdx[1])
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
if raceenabled {
|
||||||
|
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
||||||
|
}
|
||||||
|
return sendfile(outfd, infd, offset, count)
|
||||||
|
}
|
||||||
|
|
||||||
|
var ioSync int64
|
||||||
|
|
||||||
|
func CloseOnExec(fd int) { fcntl(fd, F_SETFD, FD_CLOEXEC) }
|
||||||
|
|
||||||
|
func SetNonblock(fd int, nonblocking bool) (err error) {
|
||||||
|
flag, err := fcntl(fd, F_GETFL, 0)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if nonblocking {
|
||||||
|
flag |= O_NONBLOCK
|
||||||
|
} else {
|
||||||
|
flag &= ^O_NONBLOCK
|
||||||
|
}
|
||||||
|
_, err = fcntl(fd, F_SETFL, flag)
|
||||||
|
return err
|
||||||
|
}
|
250
vendor/golang.org/x/sys/unix/types_darwin.go
generated
vendored
Normal file
250
vendor/golang.org/x/sys/unix/types_darwin.go
generated
vendored
Normal file
|
@ -0,0 +1,250 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
/*
|
||||||
|
Input to cgo -godefs. See also mkerrors.sh and mkall.sh
|
||||||
|
*/
|
||||||
|
|
||||||
|
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||||
|
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define __DARWIN_UNIX03 0
|
||||||
|
#define KERNEL
|
||||||
|
#define _DARWIN_USE_64_BIT_INODE
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <mach/mach.h>
|
||||||
|
#include <mach/message.h>
|
||||||
|
#include <sys/event.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/ptrace.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <sys/select.h>
|
||||||
|
#include <sys/signal.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <net/bpf.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <net/if_dl.h>
|
||||||
|
#include <net/if_var.h>
|
||||||
|
#include <net/route.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/icmp6.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
|
|
||||||
|
enum {
|
||||||
|
sizeofPtr = sizeof(void*),
|
||||||
|
};
|
||||||
|
|
||||||
|
union sockaddr_all {
|
||||||
|
struct sockaddr s1; // this one gets used for fields
|
||||||
|
struct sockaddr_in s2; // these pad it out
|
||||||
|
struct sockaddr_in6 s3;
|
||||||
|
struct sockaddr_un s4;
|
||||||
|
struct sockaddr_dl s5;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sockaddr_any {
|
||||||
|
struct sockaddr addr;
|
||||||
|
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
|
||||||
|
};
|
||||||
|
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
// Machine characteristics; for internal use.
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeofPtr = C.sizeofPtr
|
||||||
|
sizeofShort = C.sizeof_short
|
||||||
|
sizeofInt = C.sizeof_int
|
||||||
|
sizeofLong = C.sizeof_long
|
||||||
|
sizeofLongLong = C.sizeof_longlong
|
||||||
|
)
|
||||||
|
|
||||||
|
// Basic types
|
||||||
|
|
||||||
|
type (
|
||||||
|
_C_short C.short
|
||||||
|
_C_int C.int
|
||||||
|
_C_long C.long
|
||||||
|
_C_long_long C.longlong
|
||||||
|
)
|
||||||
|
|
||||||
|
// Time
|
||||||
|
|
||||||
|
type Timespec C.struct_timespec
|
||||||
|
|
||||||
|
type Timeval C.struct_timeval
|
||||||
|
|
||||||
|
type Timeval32 C.struct_timeval32
|
||||||
|
|
||||||
|
// Processes
|
||||||
|
|
||||||
|
type Rusage C.struct_rusage
|
||||||
|
|
||||||
|
type Rlimit C.struct_rlimit
|
||||||
|
|
||||||
|
type _Gid_t C.gid_t
|
||||||
|
|
||||||
|
// Files
|
||||||
|
|
||||||
|
type Stat_t C.struct_stat64
|
||||||
|
|
||||||
|
type Statfs_t C.struct_statfs64
|
||||||
|
|
||||||
|
type Flock_t C.struct_flock
|
||||||
|
|
||||||
|
type Fstore_t C.struct_fstore
|
||||||
|
|
||||||
|
type Radvisory_t C.struct_radvisory
|
||||||
|
|
||||||
|
type Fbootstraptransfer_t C.struct_fbootstraptransfer
|
||||||
|
|
||||||
|
type Log2phys_t C.struct_log2phys
|
||||||
|
|
||||||
|
type Fsid C.struct_fsid
|
||||||
|
|
||||||
|
type Dirent C.struct_dirent
|
||||||
|
|
||||||
|
// Sockets
|
||||||
|
|
||||||
|
type RawSockaddrInet4 C.struct_sockaddr_in
|
||||||
|
|
||||||
|
type RawSockaddrInet6 C.struct_sockaddr_in6
|
||||||
|
|
||||||
|
type RawSockaddrUnix C.struct_sockaddr_un
|
||||||
|
|
||||||
|
type RawSockaddrDatalink C.struct_sockaddr_dl
|
||||||
|
|
||||||
|
type RawSockaddr C.struct_sockaddr
|
||||||
|
|
||||||
|
type RawSockaddrAny C.struct_sockaddr_any
|
||||||
|
|
||||||
|
type _Socklen C.socklen_t
|
||||||
|
|
||||||
|
type Linger C.struct_linger
|
||||||
|
|
||||||
|
type Iovec C.struct_iovec
|
||||||
|
|
||||||
|
type IPMreq C.struct_ip_mreq
|
||||||
|
|
||||||
|
type IPv6Mreq C.struct_ipv6_mreq
|
||||||
|
|
||||||
|
type Msghdr C.struct_msghdr
|
||||||
|
|
||||||
|
type Cmsghdr C.struct_cmsghdr
|
||||||
|
|
||||||
|
type Inet4Pktinfo C.struct_in_pktinfo
|
||||||
|
|
||||||
|
type Inet6Pktinfo C.struct_in6_pktinfo
|
||||||
|
|
||||||
|
type IPv6MTUInfo C.struct_ip6_mtuinfo
|
||||||
|
|
||||||
|
type ICMPv6Filter C.struct_icmp6_filter
|
||||||
|
|
||||||
|
const (
|
||||||
|
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
|
||||||
|
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||||
|
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
|
||||||
|
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
|
||||||
|
SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
|
||||||
|
SizeofLinger = C.sizeof_struct_linger
|
||||||
|
SizeofIPMreq = C.sizeof_struct_ip_mreq
|
||||||
|
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
|
||||||
|
SizeofMsghdr = C.sizeof_struct_msghdr
|
||||||
|
SizeofCmsghdr = C.sizeof_struct_cmsghdr
|
||||||
|
SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo
|
||||||
|
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
|
||||||
|
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
|
||||||
|
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
|
||||||
|
)
|
||||||
|
|
||||||
|
// Ptrace requests
|
||||||
|
|
||||||
|
const (
|
||||||
|
PTRACE_TRACEME = C.PT_TRACE_ME
|
||||||
|
PTRACE_CONT = C.PT_CONTINUE
|
||||||
|
PTRACE_KILL = C.PT_KILL
|
||||||
|
)
|
||||||
|
|
||||||
|
// Events (kqueue, kevent)
|
||||||
|
|
||||||
|
type Kevent_t C.struct_kevent
|
||||||
|
|
||||||
|
// Select
|
||||||
|
|
||||||
|
type FdSet C.fd_set
|
||||||
|
|
||||||
|
// Routing and interface messages
|
||||||
|
|
||||||
|
const (
|
||||||
|
SizeofIfMsghdr = C.sizeof_struct_if_msghdr
|
||||||
|
SizeofIfData = C.sizeof_struct_if_data
|
||||||
|
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
|
||||||
|
SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
|
||||||
|
SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2
|
||||||
|
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
|
||||||
|
SizeofRtMetrics = C.sizeof_struct_rt_metrics
|
||||||
|
)
|
||||||
|
|
||||||
|
type IfMsghdr C.struct_if_msghdr
|
||||||
|
|
||||||
|
type IfData C.struct_if_data
|
||||||
|
|
||||||
|
type IfaMsghdr C.struct_ifa_msghdr
|
||||||
|
|
||||||
|
type IfmaMsghdr C.struct_ifma_msghdr
|
||||||
|
|
||||||
|
type IfmaMsghdr2 C.struct_ifma_msghdr2
|
||||||
|
|
||||||
|
type RtMsghdr C.struct_rt_msghdr
|
||||||
|
|
||||||
|
type RtMetrics C.struct_rt_metrics
|
||||||
|
|
||||||
|
// Berkeley packet filter
|
||||||
|
|
||||||
|
const (
|
||||||
|
SizeofBpfVersion = C.sizeof_struct_bpf_version
|
||||||
|
SizeofBpfStat = C.sizeof_struct_bpf_stat
|
||||||
|
SizeofBpfProgram = C.sizeof_struct_bpf_program
|
||||||
|
SizeofBpfInsn = C.sizeof_struct_bpf_insn
|
||||||
|
SizeofBpfHdr = C.sizeof_struct_bpf_hdr
|
||||||
|
)
|
||||||
|
|
||||||
|
type BpfVersion C.struct_bpf_version
|
||||||
|
|
||||||
|
type BpfStat C.struct_bpf_stat
|
||||||
|
|
||||||
|
type BpfProgram C.struct_bpf_program
|
||||||
|
|
||||||
|
type BpfInsn C.struct_bpf_insn
|
||||||
|
|
||||||
|
type BpfHdr C.struct_bpf_hdr
|
||||||
|
|
||||||
|
// Terminal handling
|
||||||
|
|
||||||
|
type Termios C.struct_termios
|
||||||
|
|
||||||
|
// fchmodat-like syscalls.
|
||||||
|
|
||||||
|
const (
|
||||||
|
AT_FDCWD = C.AT_FDCWD
|
||||||
|
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
|
||||||
|
)
|
242
vendor/golang.org/x/sys/unix/types_dragonfly.go
generated
vendored
Normal file
242
vendor/golang.org/x/sys/unix/types_dragonfly.go
generated
vendored
Normal file
|
@ -0,0 +1,242 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
/*
|
||||||
|
Input to cgo -godefs. See also mkerrors.sh and mkall.sh
|
||||||
|
*/
|
||||||
|
|
||||||
|
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||||
|
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define KERNEL
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/event.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/ptrace.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <sys/select.h>
|
||||||
|
#include <sys/signal.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <net/bpf.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <net/if_dl.h>
|
||||||
|
#include <net/route.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/icmp6.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
|
|
||||||
|
enum {
|
||||||
|
sizeofPtr = sizeof(void*),
|
||||||
|
};
|
||||||
|
|
||||||
|
union sockaddr_all {
|
||||||
|
struct sockaddr s1; // this one gets used for fields
|
||||||
|
struct sockaddr_in s2; // these pad it out
|
||||||
|
struct sockaddr_in6 s3;
|
||||||
|
struct sockaddr_un s4;
|
||||||
|
struct sockaddr_dl s5;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sockaddr_any {
|
||||||
|
struct sockaddr addr;
|
||||||
|
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
|
||||||
|
};
|
||||||
|
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
// Machine characteristics; for internal use.
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeofPtr = C.sizeofPtr
|
||||||
|
sizeofShort = C.sizeof_short
|
||||||
|
sizeofInt = C.sizeof_int
|
||||||
|
sizeofLong = C.sizeof_long
|
||||||
|
sizeofLongLong = C.sizeof_longlong
|
||||||
|
)
|
||||||
|
|
||||||
|
// Basic types
|
||||||
|
|
||||||
|
type (
|
||||||
|
_C_short C.short
|
||||||
|
_C_int C.int
|
||||||
|
_C_long C.long
|
||||||
|
_C_long_long C.longlong
|
||||||
|
)
|
||||||
|
|
||||||
|
// Time
|
||||||
|
|
||||||
|
type Timespec C.struct_timespec
|
||||||
|
|
||||||
|
type Timeval C.struct_timeval
|
||||||
|
|
||||||
|
// Processes
|
||||||
|
|
||||||
|
type Rusage C.struct_rusage
|
||||||
|
|
||||||
|
type Rlimit C.struct_rlimit
|
||||||
|
|
||||||
|
type _Gid_t C.gid_t
|
||||||
|
|
||||||
|
// Files
|
||||||
|
|
||||||
|
const ( // Directory mode bits
|
||||||
|
S_IFMT = C.S_IFMT
|
||||||
|
S_IFIFO = C.S_IFIFO
|
||||||
|
S_IFCHR = C.S_IFCHR
|
||||||
|
S_IFDIR = C.S_IFDIR
|
||||||
|
S_IFBLK = C.S_IFBLK
|
||||||
|
S_IFREG = C.S_IFREG
|
||||||
|
S_IFLNK = C.S_IFLNK
|
||||||
|
S_IFSOCK = C.S_IFSOCK
|
||||||
|
S_ISUID = C.S_ISUID
|
||||||
|
S_ISGID = C.S_ISGID
|
||||||
|
S_ISVTX = C.S_ISVTX
|
||||||
|
S_IRUSR = C.S_IRUSR
|
||||||
|
S_IWUSR = C.S_IWUSR
|
||||||
|
S_IXUSR = C.S_IXUSR
|
||||||
|
)
|
||||||
|
|
||||||
|
type Stat_t C.struct_stat
|
||||||
|
|
||||||
|
type Statfs_t C.struct_statfs
|
||||||
|
|
||||||
|
type Flock_t C.struct_flock
|
||||||
|
|
||||||
|
type Dirent C.struct_dirent
|
||||||
|
|
||||||
|
type Fsid C.struct_fsid
|
||||||
|
|
||||||
|
// Sockets
|
||||||
|
|
||||||
|
type RawSockaddrInet4 C.struct_sockaddr_in
|
||||||
|
|
||||||
|
type RawSockaddrInet6 C.struct_sockaddr_in6
|
||||||
|
|
||||||
|
type RawSockaddrUnix C.struct_sockaddr_un
|
||||||
|
|
||||||
|
type RawSockaddrDatalink C.struct_sockaddr_dl
|
||||||
|
|
||||||
|
type RawSockaddr C.struct_sockaddr
|
||||||
|
|
||||||
|
type RawSockaddrAny C.struct_sockaddr_any
|
||||||
|
|
||||||
|
type _Socklen C.socklen_t
|
||||||
|
|
||||||
|
type Linger C.struct_linger
|
||||||
|
|
||||||
|
type Iovec C.struct_iovec
|
||||||
|
|
||||||
|
type IPMreq C.struct_ip_mreq
|
||||||
|
|
||||||
|
type IPv6Mreq C.struct_ipv6_mreq
|
||||||
|
|
||||||
|
type Msghdr C.struct_msghdr
|
||||||
|
|
||||||
|
type Cmsghdr C.struct_cmsghdr
|
||||||
|
|
||||||
|
type Inet6Pktinfo C.struct_in6_pktinfo
|
||||||
|
|
||||||
|
type IPv6MTUInfo C.struct_ip6_mtuinfo
|
||||||
|
|
||||||
|
type ICMPv6Filter C.struct_icmp6_filter
|
||||||
|
|
||||||
|
const (
|
||||||
|
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
|
||||||
|
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||||
|
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
|
||||||
|
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
|
||||||
|
SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
|
||||||
|
SizeofLinger = C.sizeof_struct_linger
|
||||||
|
SizeofIPMreq = C.sizeof_struct_ip_mreq
|
||||||
|
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
|
||||||
|
SizeofMsghdr = C.sizeof_struct_msghdr
|
||||||
|
SizeofCmsghdr = C.sizeof_struct_cmsghdr
|
||||||
|
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
|
||||||
|
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
|
||||||
|
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
|
||||||
|
)
|
||||||
|
|
||||||
|
// Ptrace requests
|
||||||
|
|
||||||
|
const (
|
||||||
|
PTRACE_TRACEME = C.PT_TRACE_ME
|
||||||
|
PTRACE_CONT = C.PT_CONTINUE
|
||||||
|
PTRACE_KILL = C.PT_KILL
|
||||||
|
)
|
||||||
|
|
||||||
|
// Events (kqueue, kevent)
|
||||||
|
|
||||||
|
type Kevent_t C.struct_kevent
|
||||||
|
|
||||||
|
// Select
|
||||||
|
|
||||||
|
type FdSet C.fd_set
|
||||||
|
|
||||||
|
// Routing and interface messages
|
||||||
|
|
||||||
|
const (
|
||||||
|
SizeofIfMsghdr = C.sizeof_struct_if_msghdr
|
||||||
|
SizeofIfData = C.sizeof_struct_if_data
|
||||||
|
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
|
||||||
|
SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
|
||||||
|
SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
|
||||||
|
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
|
||||||
|
SizeofRtMetrics = C.sizeof_struct_rt_metrics
|
||||||
|
)
|
||||||
|
|
||||||
|
type IfMsghdr C.struct_if_msghdr
|
||||||
|
|
||||||
|
type IfData C.struct_if_data
|
||||||
|
|
||||||
|
type IfaMsghdr C.struct_ifa_msghdr
|
||||||
|
|
||||||
|
type IfmaMsghdr C.struct_ifma_msghdr
|
||||||
|
|
||||||
|
type IfAnnounceMsghdr C.struct_if_announcemsghdr
|
||||||
|
|
||||||
|
type RtMsghdr C.struct_rt_msghdr
|
||||||
|
|
||||||
|
type RtMetrics C.struct_rt_metrics
|
||||||
|
|
||||||
|
// Berkeley packet filter
|
||||||
|
|
||||||
|
const (
|
||||||
|
SizeofBpfVersion = C.sizeof_struct_bpf_version
|
||||||
|
SizeofBpfStat = C.sizeof_struct_bpf_stat
|
||||||
|
SizeofBpfProgram = C.sizeof_struct_bpf_program
|
||||||
|
SizeofBpfInsn = C.sizeof_struct_bpf_insn
|
||||||
|
SizeofBpfHdr = C.sizeof_struct_bpf_hdr
|
||||||
|
)
|
||||||
|
|
||||||
|
type BpfVersion C.struct_bpf_version
|
||||||
|
|
||||||
|
type BpfStat C.struct_bpf_stat
|
||||||
|
|
||||||
|
type BpfProgram C.struct_bpf_program
|
||||||
|
|
||||||
|
type BpfInsn C.struct_bpf_insn
|
||||||
|
|
||||||
|
type BpfHdr C.struct_bpf_hdr
|
||||||
|
|
||||||
|
// Terminal handling
|
||||||
|
|
||||||
|
type Termios C.struct_termios
|
353
vendor/golang.org/x/sys/unix/types_freebsd.go
generated
vendored
Normal file
353
vendor/golang.org/x/sys/unix/types_freebsd.go
generated
vendored
Normal file
|
@ -0,0 +1,353 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
/*
|
||||||
|
Input to cgo -godefs. See also mkerrors.sh and mkall.sh
|
||||||
|
*/
|
||||||
|
|
||||||
|
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||||
|
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define KERNEL
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/event.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/ptrace.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <sys/select.h>
|
||||||
|
#include <sys/signal.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <net/bpf.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <net/if_dl.h>
|
||||||
|
#include <net/route.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/icmp6.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
|
|
||||||
|
enum {
|
||||||
|
sizeofPtr = sizeof(void*),
|
||||||
|
};
|
||||||
|
|
||||||
|
union sockaddr_all {
|
||||||
|
struct sockaddr s1; // this one gets used for fields
|
||||||
|
struct sockaddr_in s2; // these pad it out
|
||||||
|
struct sockaddr_in6 s3;
|
||||||
|
struct sockaddr_un s4;
|
||||||
|
struct sockaddr_dl s5;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sockaddr_any {
|
||||||
|
struct sockaddr addr;
|
||||||
|
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
|
||||||
|
};
|
||||||
|
|
||||||
|
// This structure is a duplicate of stat on FreeBSD 8-STABLE.
|
||||||
|
// See /usr/include/sys/stat.h.
|
||||||
|
struct stat8 {
|
||||||
|
#undef st_atimespec st_atim
|
||||||
|
#undef st_mtimespec st_mtim
|
||||||
|
#undef st_ctimespec st_ctim
|
||||||
|
#undef st_birthtimespec st_birthtim
|
||||||
|
__dev_t st_dev;
|
||||||
|
ino_t st_ino;
|
||||||
|
mode_t st_mode;
|
||||||
|
nlink_t st_nlink;
|
||||||
|
uid_t st_uid;
|
||||||
|
gid_t st_gid;
|
||||||
|
__dev_t st_rdev;
|
||||||
|
#if __BSD_VISIBLE
|
||||||
|
struct timespec st_atimespec;
|
||||||
|
struct timespec st_mtimespec;
|
||||||
|
struct timespec st_ctimespec;
|
||||||
|
#else
|
||||||
|
time_t st_atime;
|
||||||
|
long __st_atimensec;
|
||||||
|
time_t st_mtime;
|
||||||
|
long __st_mtimensec;
|
||||||
|
time_t st_ctime;
|
||||||
|
long __st_ctimensec;
|
||||||
|
#endif
|
||||||
|
off_t st_size;
|
||||||
|
blkcnt_t st_blocks;
|
||||||
|
blksize_t st_blksize;
|
||||||
|
fflags_t st_flags;
|
||||||
|
__uint32_t st_gen;
|
||||||
|
__int32_t st_lspare;
|
||||||
|
#if __BSD_VISIBLE
|
||||||
|
struct timespec st_birthtimespec;
|
||||||
|
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
|
||||||
|
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
|
||||||
|
#else
|
||||||
|
time_t st_birthtime;
|
||||||
|
long st_birthtimensec;
|
||||||
|
unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
|
||||||
|
unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
// This structure is a duplicate of if_data on FreeBSD 8-STABLE.
|
||||||
|
// See /usr/include/net/if.h.
|
||||||
|
struct if_data8 {
|
||||||
|
u_char ifi_type;
|
||||||
|
u_char ifi_physical;
|
||||||
|
u_char ifi_addrlen;
|
||||||
|
u_char ifi_hdrlen;
|
||||||
|
u_char ifi_link_state;
|
||||||
|
u_char ifi_spare_char1;
|
||||||
|
u_char ifi_spare_char2;
|
||||||
|
u_char ifi_datalen;
|
||||||
|
u_long ifi_mtu;
|
||||||
|
u_long ifi_metric;
|
||||||
|
u_long ifi_baudrate;
|
||||||
|
u_long ifi_ipackets;
|
||||||
|
u_long ifi_ierrors;
|
||||||
|
u_long ifi_opackets;
|
||||||
|
u_long ifi_oerrors;
|
||||||
|
u_long ifi_collisions;
|
||||||
|
u_long ifi_ibytes;
|
||||||
|
u_long ifi_obytes;
|
||||||
|
u_long ifi_imcasts;
|
||||||
|
u_long ifi_omcasts;
|
||||||
|
u_long ifi_iqdrops;
|
||||||
|
u_long ifi_noproto;
|
||||||
|
u_long ifi_hwassist;
|
||||||
|
time_t ifi_epoch;
|
||||||
|
struct timeval ifi_lastchange;
|
||||||
|
};
|
||||||
|
|
||||||
|
// This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE.
|
||||||
|
// See /usr/include/net/if.h.
|
||||||
|
struct if_msghdr8 {
|
||||||
|
u_short ifm_msglen;
|
||||||
|
u_char ifm_version;
|
||||||
|
u_char ifm_type;
|
||||||
|
int ifm_addrs;
|
||||||
|
int ifm_flags;
|
||||||
|
u_short ifm_index;
|
||||||
|
struct if_data8 ifm_data;
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
// Machine characteristics; for internal use.
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeofPtr = C.sizeofPtr
|
||||||
|
sizeofShort = C.sizeof_short
|
||||||
|
sizeofInt = C.sizeof_int
|
||||||
|
sizeofLong = C.sizeof_long
|
||||||
|
sizeofLongLong = C.sizeof_longlong
|
||||||
|
)
|
||||||
|
|
||||||
|
// Basic types
|
||||||
|
|
||||||
|
type (
|
||||||
|
_C_short C.short
|
||||||
|
_C_int C.int
|
||||||
|
_C_long C.long
|
||||||
|
_C_long_long C.longlong
|
||||||
|
)
|
||||||
|
|
||||||
|
// Time
|
||||||
|
|
||||||
|
type Timespec C.struct_timespec
|
||||||
|
|
||||||
|
type Timeval C.struct_timeval
|
||||||
|
|
||||||
|
// Processes
|
||||||
|
|
||||||
|
type Rusage C.struct_rusage
|
||||||
|
|
||||||
|
type Rlimit C.struct_rlimit
|
||||||
|
|
||||||
|
type _Gid_t C.gid_t
|
||||||
|
|
||||||
|
// Files
|
||||||
|
|
||||||
|
const ( // Directory mode bits
|
||||||
|
S_IFMT = C.S_IFMT
|
||||||
|
S_IFIFO = C.S_IFIFO
|
||||||
|
S_IFCHR = C.S_IFCHR
|
||||||
|
S_IFDIR = C.S_IFDIR
|
||||||
|
S_IFBLK = C.S_IFBLK
|
||||||
|
S_IFREG = C.S_IFREG
|
||||||
|
S_IFLNK = C.S_IFLNK
|
||||||
|
S_IFSOCK = C.S_IFSOCK
|
||||||
|
S_ISUID = C.S_ISUID
|
||||||
|
S_ISGID = C.S_ISGID
|
||||||
|
S_ISVTX = C.S_ISVTX
|
||||||
|
S_IRUSR = C.S_IRUSR
|
||||||
|
S_IWUSR = C.S_IWUSR
|
||||||
|
S_IXUSR = C.S_IXUSR
|
||||||
|
)
|
||||||
|
|
||||||
|
type Stat_t C.struct_stat8
|
||||||
|
|
||||||
|
type Statfs_t C.struct_statfs
|
||||||
|
|
||||||
|
type Flock_t C.struct_flock
|
||||||
|
|
||||||
|
type Dirent C.struct_dirent
|
||||||
|
|
||||||
|
type Fsid C.struct_fsid
|
||||||
|
|
||||||
|
// Advice to Fadvise
|
||||||
|
|
||||||
|
const (
|
||||||
|
FADV_NORMAL = C.POSIX_FADV_NORMAL
|
||||||
|
FADV_RANDOM = C.POSIX_FADV_RANDOM
|
||||||
|
FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL
|
||||||
|
FADV_WILLNEED = C.POSIX_FADV_WILLNEED
|
||||||
|
FADV_DONTNEED = C.POSIX_FADV_DONTNEED
|
||||||
|
FADV_NOREUSE = C.POSIX_FADV_NOREUSE
|
||||||
|
)
|
||||||
|
|
||||||
|
// Sockets
|
||||||
|
|
||||||
|
type RawSockaddrInet4 C.struct_sockaddr_in
|
||||||
|
|
||||||
|
type RawSockaddrInet6 C.struct_sockaddr_in6
|
||||||
|
|
||||||
|
type RawSockaddrUnix C.struct_sockaddr_un
|
||||||
|
|
||||||
|
type RawSockaddrDatalink C.struct_sockaddr_dl
|
||||||
|
|
||||||
|
type RawSockaddr C.struct_sockaddr
|
||||||
|
|
||||||
|
type RawSockaddrAny C.struct_sockaddr_any
|
||||||
|
|
||||||
|
type _Socklen C.socklen_t
|
||||||
|
|
||||||
|
type Linger C.struct_linger
|
||||||
|
|
||||||
|
type Iovec C.struct_iovec
|
||||||
|
|
||||||
|
type IPMreq C.struct_ip_mreq
|
||||||
|
|
||||||
|
type IPMreqn C.struct_ip_mreqn
|
||||||
|
|
||||||
|
type IPv6Mreq C.struct_ipv6_mreq
|
||||||
|
|
||||||
|
type Msghdr C.struct_msghdr
|
||||||
|
|
||||||
|
type Cmsghdr C.struct_cmsghdr
|
||||||
|
|
||||||
|
type Inet6Pktinfo C.struct_in6_pktinfo
|
||||||
|
|
||||||
|
type IPv6MTUInfo C.struct_ip6_mtuinfo
|
||||||
|
|
||||||
|
type ICMPv6Filter C.struct_icmp6_filter
|
||||||
|
|
||||||
|
const (
|
||||||
|
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
|
||||||
|
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||||
|
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
|
||||||
|
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
|
||||||
|
SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
|
||||||
|
SizeofLinger = C.sizeof_struct_linger
|
||||||
|
SizeofIPMreq = C.sizeof_struct_ip_mreq
|
||||||
|
SizeofIPMreqn = C.sizeof_struct_ip_mreqn
|
||||||
|
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
|
||||||
|
SizeofMsghdr = C.sizeof_struct_msghdr
|
||||||
|
SizeofCmsghdr = C.sizeof_struct_cmsghdr
|
||||||
|
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
|
||||||
|
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
|
||||||
|
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
|
||||||
|
)
|
||||||
|
|
||||||
|
// Ptrace requests
|
||||||
|
|
||||||
|
const (
|
||||||
|
PTRACE_TRACEME = C.PT_TRACE_ME
|
||||||
|
PTRACE_CONT = C.PT_CONTINUE
|
||||||
|
PTRACE_KILL = C.PT_KILL
|
||||||
|
)
|
||||||
|
|
||||||
|
// Events (kqueue, kevent)
|
||||||
|
|
||||||
|
type Kevent_t C.struct_kevent
|
||||||
|
|
||||||
|
// Select
|
||||||
|
|
||||||
|
type FdSet C.fd_set
|
||||||
|
|
||||||
|
// Routing and interface messages
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeofIfMsghdr = C.sizeof_struct_if_msghdr
|
||||||
|
SizeofIfMsghdr = C.sizeof_struct_if_msghdr8
|
||||||
|
sizeofIfData = C.sizeof_struct_if_data
|
||||||
|
SizeofIfData = C.sizeof_struct_if_data8
|
||||||
|
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
|
||||||
|
SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
|
||||||
|
SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
|
||||||
|
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
|
||||||
|
SizeofRtMetrics = C.sizeof_struct_rt_metrics
|
||||||
|
)
|
||||||
|
|
||||||
|
type ifMsghdr C.struct_if_msghdr
|
||||||
|
|
||||||
|
type IfMsghdr C.struct_if_msghdr8
|
||||||
|
|
||||||
|
type ifData C.struct_if_data
|
||||||
|
|
||||||
|
type IfData C.struct_if_data8
|
||||||
|
|
||||||
|
type IfaMsghdr C.struct_ifa_msghdr
|
||||||
|
|
||||||
|
type IfmaMsghdr C.struct_ifma_msghdr
|
||||||
|
|
||||||
|
type IfAnnounceMsghdr C.struct_if_announcemsghdr
|
||||||
|
|
||||||
|
type RtMsghdr C.struct_rt_msghdr
|
||||||
|
|
||||||
|
type RtMetrics C.struct_rt_metrics
|
||||||
|
|
||||||
|
// Berkeley packet filter
|
||||||
|
|
||||||
|
const (
|
||||||
|
SizeofBpfVersion = C.sizeof_struct_bpf_version
|
||||||
|
SizeofBpfStat = C.sizeof_struct_bpf_stat
|
||||||
|
SizeofBpfZbuf = C.sizeof_struct_bpf_zbuf
|
||||||
|
SizeofBpfProgram = C.sizeof_struct_bpf_program
|
||||||
|
SizeofBpfInsn = C.sizeof_struct_bpf_insn
|
||||||
|
SizeofBpfHdr = C.sizeof_struct_bpf_hdr
|
||||||
|
SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header
|
||||||
|
)
|
||||||
|
|
||||||
|
type BpfVersion C.struct_bpf_version
|
||||||
|
|
||||||
|
type BpfStat C.struct_bpf_stat
|
||||||
|
|
||||||
|
type BpfZbuf C.struct_bpf_zbuf
|
||||||
|
|
||||||
|
type BpfProgram C.struct_bpf_program
|
||||||
|
|
||||||
|
type BpfInsn C.struct_bpf_insn
|
||||||
|
|
||||||
|
type BpfHdr C.struct_bpf_hdr
|
||||||
|
|
||||||
|
type BpfZbufHeader C.struct_bpf_zbuf_header
|
||||||
|
|
||||||
|
// Terminal handling
|
||||||
|
|
||||||
|
type Termios C.struct_termios
|
414
vendor/golang.org/x/sys/unix/types_linux.go
generated
vendored
Normal file
414
vendor/golang.org/x/sys/unix/types_linux.go
generated
vendored
Normal file
|
@ -0,0 +1,414 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
/*
|
||||||
|
Input to cgo -godefs. See also mkerrors.sh and mkall.sh
|
||||||
|
*/
|
||||||
|
|
||||||
|
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||||
|
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define _LARGEFILE_SOURCE
|
||||||
|
#define _LARGEFILE64_SOURCE
|
||||||
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
|
#include <netpacket/packet.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/epoll.h>
|
||||||
|
#include <sys/inotify.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/ptrace.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <sys/select.h>
|
||||||
|
#include <sys/signal.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/statfs.h>
|
||||||
|
#include <sys/sysinfo.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/times.h>
|
||||||
|
#include <sys/timex.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <sys/user.h>
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <linux/filter.h>
|
||||||
|
#include <linux/netlink.h>
|
||||||
|
#include <linux/rtnetlink.h>
|
||||||
|
#include <linux/icmpv6.h>
|
||||||
|
#include <asm/termbits.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <ustat.h>
|
||||||
|
#include <utime.h>
|
||||||
|
#include <bluetooth/bluetooth.h>
|
||||||
|
#include <bluetooth/hci.h>
|
||||||
|
|
||||||
|
#ifdef TCSETS2
|
||||||
|
// On systems that have "struct termios2" use this as type Termios.
|
||||||
|
typedef struct termios2 termios_t;
|
||||||
|
#else
|
||||||
|
typedef struct termios termios_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
enum {
|
||||||
|
sizeofPtr = sizeof(void*),
|
||||||
|
};
|
||||||
|
|
||||||
|
union sockaddr_all {
|
||||||
|
struct sockaddr s1; // this one gets used for fields
|
||||||
|
struct sockaddr_in s2; // these pad it out
|
||||||
|
struct sockaddr_in6 s3;
|
||||||
|
struct sockaddr_un s4;
|
||||||
|
struct sockaddr_ll s5;
|
||||||
|
struct sockaddr_nl s6;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sockaddr_any {
|
||||||
|
struct sockaddr addr;
|
||||||
|
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
|
||||||
|
};
|
||||||
|
|
||||||
|
// copied from /usr/include/linux/un.h
|
||||||
|
struct my_sockaddr_un {
|
||||||
|
sa_family_t sun_family;
|
||||||
|
#if defined(__ARM_EABI__) || defined(__powerpc64__)
|
||||||
|
// on ARM char is by default unsigned
|
||||||
|
signed char sun_path[108];
|
||||||
|
#else
|
||||||
|
char sun_path[108];
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __ARM_EABI__
|
||||||
|
typedef struct user_regs PtraceRegs;
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
typedef struct user_pt_regs PtraceRegs;
|
||||||
|
#elif defined(__powerpc64__)
|
||||||
|
typedef struct pt_regs PtraceRegs;
|
||||||
|
#elif defined(__mips__)
|
||||||
|
typedef struct user PtraceRegs;
|
||||||
|
#else
|
||||||
|
typedef struct user_regs_struct PtraceRegs;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// The real epoll_event is a union, and godefs doesn't handle it well.
|
||||||
|
struct my_epoll_event {
|
||||||
|
uint32_t events;
|
||||||
|
#if defined(__ARM_EABI__) || defined(__aarch64__)
|
||||||
|
// padding is not specified in linux/eventpoll.h but added to conform to the
|
||||||
|
// alignment requirements of EABI
|
||||||
|
int32_t padFd;
|
||||||
|
#endif
|
||||||
|
int32_t fd;
|
||||||
|
int32_t pad;
|
||||||
|
};
|
||||||
|
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
// Machine characteristics; for internal use.
|
||||||
|
|
||||||
|
const (
|
||||||
|
sizeofPtr = C.sizeofPtr
|
||||||
|
sizeofShort = C.sizeof_short
|
||||||
|
sizeofInt = C.sizeof_int
|
||||||
|
sizeofLong = C.sizeof_long
|
||||||
|
sizeofLongLong = C.sizeof_longlong
|
||||||
|
PathMax = C.PATH_MAX
|
||||||
|
)
|
||||||
|
|
||||||
|
// Basic types
|
||||||
|
|
||||||
|
type (
|
||||||
|
_C_short C.short
|
||||||
|
_C_int C.int
|
||||||
|
_C_long C.long
|
||||||
|
_C_long_long C.longlong
|
||||||
|
)
|
||||||
|
|
||||||
|
// Time
|
||||||
|
|
||||||
|
type Timespec C.struct_timespec
|
||||||
|
|
||||||
|
type Timeval C.struct_timeval
|
||||||
|
|
||||||
|
type Timex C.struct_timex
|
||||||
|
|
||||||
|
type Time_t C.time_t
|
||||||
|
|
||||||
|
type Tms C.struct_tms
|
||||||
|
|
||||||
|
type Utimbuf C.struct_utimbuf
|
||||||
|
|
||||||
|
// Processes
|
||||||
|
|
||||||
|
type Rusage C.struct_rusage
|
||||||
|
|
||||||
|
type Rlimit C.struct_rlimit
|
||||||
|
|
||||||
|
type _Gid_t C.gid_t
|
||||||
|
|
||||||
|
// Files
|
||||||
|
|
||||||
|
type Stat_t C.struct_stat
|
||||||
|
|
||||||
|
type Statfs_t C.struct_statfs
|
||||||
|
|
||||||
|
type Dirent C.struct_dirent
|
||||||
|
|
||||||
|
type Fsid C.fsid_t
|
||||||
|
|
||||||
|
type Flock_t C.struct_flock
|
||||||
|
|
||||||
|
// Advice to Fadvise
|
||||||
|
|
||||||
|
const (
|
||||||
|
FADV_NORMAL = C.POSIX_FADV_NORMAL
|
||||||
|
FADV_RANDOM = C.POSIX_FADV_RANDOM
|
||||||
|
FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL
|
||||||
|
FADV_WILLNEED = C.POSIX_FADV_WILLNEED
|
||||||
|
FADV_DONTNEED = C.POSIX_FADV_DONTNEED
|
||||||
|
FADV_NOREUSE = C.POSIX_FADV_NOREUSE
|
||||||
|
)
|
||||||
|
|
||||||
|
// Sockets
|
||||||
|
|
||||||
|
type RawSockaddrInet4 C.struct_sockaddr_in
|
||||||
|
|
||||||
|
type RawSockaddrInet6 C.struct_sockaddr_in6
|
||||||
|
|
||||||
|
type RawSockaddrUnix C.struct_my_sockaddr_un
|
||||||
|
|
||||||
|
type RawSockaddrLinklayer C.struct_sockaddr_ll
|
||||||
|
|
||||||
|
type RawSockaddrNetlink C.struct_sockaddr_nl
|
||||||
|
|
||||||
|
type RawSockaddrHCI C.struct_sockaddr_hci
|
||||||
|
|
||||||
|
type RawSockaddr C.struct_sockaddr
|
||||||
|
|
||||||
|
type RawSockaddrAny C.struct_sockaddr_any
|
||||||
|
|
||||||
|
type _Socklen C.socklen_t
|
||||||
|
|
||||||
|
type Linger C.struct_linger
|
||||||
|
|
||||||
|
type Iovec C.struct_iovec
|
||||||
|
|
||||||
|
type IPMreq C.struct_ip_mreq
|
||||||
|
|
||||||
|
type IPMreqn C.struct_ip_mreqn
|
||||||
|
|
||||||
|
type IPv6Mreq C.struct_ipv6_mreq
|
||||||
|
|
||||||
|
type Msghdr C.struct_msghdr
|
||||||
|
|
||||||
|
type Cmsghdr C.struct_cmsghdr
|
||||||
|
|
||||||
|
type Inet4Pktinfo C.struct_in_pktinfo
|
||||||
|
|
||||||
|
type Inet6Pktinfo C.struct_in6_pktinfo
|
||||||
|
|
||||||
|
type IPv6MTUInfo C.struct_ip6_mtuinfo
|
||||||
|
|
||||||
|
type ICMPv6Filter C.struct_icmp6_filter
|
||||||
|
|
||||||
|
type Ucred C.struct_ucred
|
||||||
|
|
||||||
|
type TCPInfo C.struct_tcp_info
|
||||||
|
|
||||||
|
const (
|
||||||
|
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
|
||||||
|
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||||
|
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
|
||||||
|
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
|
||||||
|
SizeofSockaddrLinklayer = C.sizeof_struct_sockaddr_ll
|
||||||
|
SizeofSockaddrNetlink = C.sizeof_struct_sockaddr_nl
|
||||||
|
SizeofSockaddrHCI = C.sizeof_struct_sockaddr_hci
|
||||||
|
SizeofLinger = C.sizeof_struct_linger
|
||||||
|
SizeofIPMreq = C.sizeof_struct_ip_mreq
|
||||||
|
SizeofIPMreqn = C.sizeof_struct_ip_mreqn
|
||||||
|
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
|
||||||
|
SizeofMsghdr = C.sizeof_struct_msghdr
|
||||||
|
SizeofCmsghdr = C.sizeof_struct_cmsghdr
|
||||||
|
SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo
|
||||||
|
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
|
||||||
|
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
|
||||||
|
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
|
||||||
|
SizeofUcred = C.sizeof_struct_ucred
|
||||||
|
SizeofTCPInfo = C.sizeof_struct_tcp_info
|
||||||
|
)
|
||||||
|
|
||||||
|
// Netlink routing and interface messages
|
||||||
|
|
||||||
|
const (
|
||||||
|
IFA_UNSPEC = C.IFA_UNSPEC
|
||||||
|
IFA_ADDRESS = C.IFA_ADDRESS
|
||||||
|
IFA_LOCAL = C.IFA_LOCAL
|
||||||
|
IFA_LABEL = C.IFA_LABEL
|
||||||
|
IFA_BROADCAST = C.IFA_BROADCAST
|
||||||
|
IFA_ANYCAST = C.IFA_ANYCAST
|
||||||
|
IFA_CACHEINFO = C.IFA_CACHEINFO
|
||||||
|
IFA_MULTICAST = C.IFA_MULTICAST
|
||||||
|
IFLA_UNSPEC = C.IFLA_UNSPEC
|
||||||
|
IFLA_ADDRESS = C.IFLA_ADDRESS
|
||||||
|
IFLA_BROADCAST = C.IFLA_BROADCAST
|
||||||
|
IFLA_IFNAME = C.IFLA_IFNAME
|
||||||
|
IFLA_MTU = C.IFLA_MTU
|
||||||
|
IFLA_LINK = C.IFLA_LINK
|
||||||
|
IFLA_QDISC = C.IFLA_QDISC
|
||||||
|
IFLA_STATS = C.IFLA_STATS
|
||||||
|
IFLA_COST = C.IFLA_COST
|
||||||
|
IFLA_PRIORITY = C.IFLA_PRIORITY
|
||||||
|
IFLA_MASTER = C.IFLA_MASTER
|
||||||
|
IFLA_WIRELESS = C.IFLA_WIRELESS
|
||||||
|
IFLA_PROTINFO = C.IFLA_PROTINFO
|
||||||
|
IFLA_TXQLEN = C.IFLA_TXQLEN
|
||||||
|
IFLA_MAP = C.IFLA_MAP
|
||||||
|
IFLA_WEIGHT = C.IFLA_WEIGHT
|
||||||
|
IFLA_OPERSTATE = C.IFLA_OPERSTATE
|
||||||
|
IFLA_LINKMODE = C.IFLA_LINKMODE
|
||||||
|
IFLA_LINKINFO = C.IFLA_LINKINFO
|
||||||
|
IFLA_NET_NS_PID = C.IFLA_NET_NS_PID
|
||||||
|
IFLA_IFALIAS = C.IFLA_IFALIAS
|
||||||
|
IFLA_MAX = C.IFLA_MAX
|
||||||
|
RT_SCOPE_UNIVERSE = C.RT_SCOPE_UNIVERSE
|
||||||
|
RT_SCOPE_SITE = C.RT_SCOPE_SITE
|
||||||
|
RT_SCOPE_LINK = C.RT_SCOPE_LINK
|
||||||
|
RT_SCOPE_HOST = C.RT_SCOPE_HOST
|
||||||
|
RT_SCOPE_NOWHERE = C.RT_SCOPE_NOWHERE
|
||||||
|
RT_TABLE_UNSPEC = C.RT_TABLE_UNSPEC
|
||||||
|
RT_TABLE_COMPAT = C.RT_TABLE_COMPAT
|
||||||
|
RT_TABLE_DEFAULT = C.RT_TABLE_DEFAULT
|
||||||
|
RT_TABLE_MAIN = C.RT_TABLE_MAIN
|
||||||
|
RT_TABLE_LOCAL = C.RT_TABLE_LOCAL
|
||||||
|
RT_TABLE_MAX = C.RT_TABLE_MAX
|
||||||
|
RTA_UNSPEC = C.RTA_UNSPEC
|
||||||
|
RTA_DST = C.RTA_DST
|
||||||
|
RTA_SRC = C.RTA_SRC
|
||||||
|
RTA_IIF = C.RTA_IIF
|
||||||
|
RTA_OIF = C.RTA_OIF
|
||||||
|
RTA_GATEWAY = C.RTA_GATEWAY
|
||||||
|
RTA_PRIORITY = C.RTA_PRIORITY
|
||||||
|
RTA_PREFSRC = C.RTA_PREFSRC
|
||||||
|
RTA_METRICS = C.RTA_METRICS
|
||||||
|
RTA_MULTIPATH = C.RTA_MULTIPATH
|
||||||
|
RTA_FLOW = C.RTA_FLOW
|
||||||
|
RTA_CACHEINFO = C.RTA_CACHEINFO
|
||||||
|
RTA_TABLE = C.RTA_TABLE
|
||||||
|
RTN_UNSPEC = C.RTN_UNSPEC
|
||||||
|
RTN_UNICAST = C.RTN_UNICAST
|
||||||
|
RTN_LOCAL = C.RTN_LOCAL
|
||||||
|
RTN_BROADCAST = C.RTN_BROADCAST
|
||||||
|
RTN_ANYCAST = C.RTN_ANYCAST
|
||||||
|
RTN_MULTICAST = C.RTN_MULTICAST
|
||||||
|
RTN_BLACKHOLE = C.RTN_BLACKHOLE
|
||||||
|
RTN_UNREACHABLE = C.RTN_UNREACHABLE
|
||||||
|
RTN_PROHIBIT = C.RTN_PROHIBIT
|
||||||
|
RTN_THROW = C.RTN_THROW
|
||||||
|
RTN_NAT = C.RTN_NAT
|
||||||
|
RTN_XRESOLVE = C.RTN_XRESOLVE
|
||||||
|
RTNLGRP_NONE = C.RTNLGRP_NONE
|
||||||
|
RTNLGRP_LINK = C.RTNLGRP_LINK
|
||||||
|
RTNLGRP_NOTIFY = C.RTNLGRP_NOTIFY
|
||||||
|
RTNLGRP_NEIGH = C.RTNLGRP_NEIGH
|
||||||
|
RTNLGRP_TC = C.RTNLGRP_TC
|
||||||
|
RTNLGRP_IPV4_IFADDR = C.RTNLGRP_IPV4_IFADDR
|
||||||
|
RTNLGRP_IPV4_MROUTE = C.RTNLGRP_IPV4_MROUTE
|
||||||
|
RTNLGRP_IPV4_ROUTE = C.RTNLGRP_IPV4_ROUTE
|
||||||
|
RTNLGRP_IPV4_RULE = C.RTNLGRP_IPV4_RULE
|
||||||
|
RTNLGRP_IPV6_IFADDR = C.RTNLGRP_IPV6_IFADDR
|
||||||
|
RTNLGRP_IPV6_MROUTE = C.RTNLGRP_IPV6_MROUTE
|
||||||
|
RTNLGRP_IPV6_ROUTE = C.RTNLGRP_IPV6_ROUTE
|
||||||
|
RTNLGRP_IPV6_IFINFO = C.RTNLGRP_IPV6_IFINFO
|
||||||
|
RTNLGRP_IPV6_PREFIX = C.RTNLGRP_IPV6_PREFIX
|
||||||
|
RTNLGRP_IPV6_RULE = C.RTNLGRP_IPV6_RULE
|
||||||
|
RTNLGRP_ND_USEROPT = C.RTNLGRP_ND_USEROPT
|
||||||
|
SizeofNlMsghdr = C.sizeof_struct_nlmsghdr
|
||||||
|
SizeofNlMsgerr = C.sizeof_struct_nlmsgerr
|
||||||
|
SizeofRtGenmsg = C.sizeof_struct_rtgenmsg
|
||||||
|
SizeofNlAttr = C.sizeof_struct_nlattr
|
||||||
|
SizeofRtAttr = C.sizeof_struct_rtattr
|
||||||
|
SizeofIfInfomsg = C.sizeof_struct_ifinfomsg
|
||||||
|
SizeofIfAddrmsg = C.sizeof_struct_ifaddrmsg
|
||||||
|
SizeofRtMsg = C.sizeof_struct_rtmsg
|
||||||
|
SizeofRtNexthop = C.sizeof_struct_rtnexthop
|
||||||
|
)
|
||||||
|
|
||||||
|
type NlMsghdr C.struct_nlmsghdr
|
||||||
|
|
||||||
|
type NlMsgerr C.struct_nlmsgerr
|
||||||
|
|
||||||
|
type RtGenmsg C.struct_rtgenmsg
|
||||||
|
|
||||||
|
type NlAttr C.struct_nlattr
|
||||||
|
|
||||||
|
type RtAttr C.struct_rtattr
|
||||||
|
|
||||||
|
type IfInfomsg C.struct_ifinfomsg
|
||||||
|
|
||||||
|
type IfAddrmsg C.struct_ifaddrmsg
|
||||||
|
|
||||||
|
type RtMsg C.struct_rtmsg
|
||||||
|
|
||||||
|
type RtNexthop C.struct_rtnexthop
|
||||||
|
|
||||||
|
// Linux socket filter
|
||||||
|
|
||||||
|
const (
|
||||||
|
SizeofSockFilter = C.sizeof_struct_sock_filter
|
||||||
|
SizeofSockFprog = C.sizeof_struct_sock_fprog
|
||||||
|
)
|
||||||
|
|
||||||
|
type SockFilter C.struct_sock_filter
|
||||||
|
|
||||||
|
type SockFprog C.struct_sock_fprog
|
||||||
|
|
||||||
|
// Inotify
|
||||||
|
|
||||||
|
type InotifyEvent C.struct_inotify_event
|
||||||
|
|
||||||
|
const SizeofInotifyEvent = C.sizeof_struct_inotify_event
|
||||||
|
|
||||||
|
// Ptrace
|
||||||
|
|
||||||
|
// Register structures
|
||||||
|
type PtraceRegs C.PtraceRegs
|
||||||
|
|
||||||
|
// Misc
|
||||||
|
|
||||||
|
type FdSet C.fd_set
|
||||||
|
|
||||||
|
type Sysinfo_t C.struct_sysinfo
|
||||||
|
|
||||||
|
type Utsname C.struct_utsname
|
||||||
|
|
||||||
|
type Ustat_t C.struct_ustat
|
||||||
|
|
||||||
|
type EpollEvent C.struct_my_epoll_event
|
||||||
|
|
||||||
|
const (
|
||||||
|
AT_FDCWD = C.AT_FDCWD
|
||||||
|
AT_REMOVEDIR = C.AT_REMOVEDIR
|
||||||
|
AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW
|
||||||
|
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
|
||||||
|
)
|
||||||
|
|
||||||
|
// Terminal handling
|
||||||
|
|
||||||
|
type Termios C.termios_t
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue