summaryrefslogtreecommitdiffhomepage
path: root/test/uds/uds.go
diff options
context:
space:
mode:
authorAyush Ranjan <ayushranjan@google.com>2021-03-06 09:52:23 -0800
committergVisor bot <gvisor-bot@google.com>2021-03-06 09:54:09 -0800
commit0a909ba75a556db6acbb2a30d2e741b365217c83 (patch)
treeef8cb5bcc1a6fcdb638c1d1687d530e7d4cc0908 /test/uds/uds.go
parentfb733cdb8f4050fbc8ad083ea05c3e98b99b9acc (diff)
[op] Replace syscall package usage with golang.org/x/sys/unix in test/.
The syscall package has been deprecated in favor of golang.org/x/sys. Note that syscall is still used in some places because the following don't seem to have an equivalent in unix package: - syscall.SysProcIDMap - syscall.Credential Updates #214 PiperOrigin-RevId: 361332034
Diffstat (limited to 'test/uds/uds.go')
-rw-r--r--test/uds/uds.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/test/uds/uds.go b/test/uds/uds.go
index b714c61b0..02a4a7dee 100644
--- a/test/uds/uds.go
+++ b/test/uds/uds.go
@@ -21,8 +21,8 @@ import (
"io/ioutil"
"os"
"path/filepath"
- "syscall"
+ "golang.org/x/sys/unix"
"gvisor.dev/gvisor/pkg/log"
"gvisor.dev/gvisor/pkg/unet"
)
@@ -31,16 +31,16 @@ import (
//
// Only works for stream, seqpacket sockets.
func createEchoSocket(path string, protocol int) (cleanup func(), err error) {
- fd, err := syscall.Socket(syscall.AF_UNIX, protocol, 0)
+ fd, err := unix.Socket(unix.AF_UNIX, protocol, 0)
if err != nil {
return nil, fmt.Errorf("error creating echo(%d) socket: %v", protocol, err)
}
- if err := syscall.Bind(fd, &syscall.SockaddrUnix{Name: path}); err != nil {
+ if err := unix.Bind(fd, &unix.SockaddrUnix{Name: path}); err != nil {
return nil, fmt.Errorf("error binding echo(%d) socket: %v", protocol, err)
}
- if err := syscall.Listen(fd, 0); err != nil {
+ if err := unix.Listen(fd, 0); err != nil {
return nil, fmt.Errorf("error listening echo(%d) socket: %v", protocol, err)
}
@@ -97,17 +97,17 @@ func createEchoSocket(path string, protocol int) (cleanup func(), err error) {
//
// Only relevant for stream, seqpacket sockets.
func createNonListeningSocket(path string, protocol int) (cleanup func(), err error) {
- fd, err := syscall.Socket(syscall.AF_UNIX, protocol, 0)
+ fd, err := unix.Socket(unix.AF_UNIX, protocol, 0)
if err != nil {
return nil, fmt.Errorf("error creating nonlistening(%d) socket: %v", protocol, err)
}
- if err := syscall.Bind(fd, &syscall.SockaddrUnix{Name: path}); err != nil {
+ if err := unix.Bind(fd, &unix.SockaddrUnix{Name: path}); err != nil {
return nil, fmt.Errorf("error binding nonlistening(%d) socket: %v", protocol, err)
}
cleanup = func() {
- if err := syscall.Close(fd); err != nil {
+ if err := unix.Close(fd); err != nil {
log.Warningf("Failed to close nonlistening(%d) socket: %v", protocol, err)
}
}
@@ -119,12 +119,12 @@ func createNonListeningSocket(path string, protocol int) (cleanup func(), err er
//
// Only works for dgram sockets.
func createNullSocket(path string, protocol int) (cleanup func(), err error) {
- fd, err := syscall.Socket(syscall.AF_UNIX, protocol, 0)
+ fd, err := unix.Socket(unix.AF_UNIX, protocol, 0)
if err != nil {
return nil, fmt.Errorf("error creating null(%d) socket: %v", protocol, err)
}
- if err := syscall.Bind(fd, &syscall.SockaddrUnix{Name: path}); err != nil {
+ if err := unix.Bind(fd, &unix.SockaddrUnix{Name: path}); err != nil {
return nil, fmt.Errorf("error binding null(%d) socket: %v", protocol, err)
}
@@ -174,7 +174,7 @@ func CreateSocketTree(baseDir string) (dir string, cleanup func(), err error) {
sockets map[string]socketCreator
}{
{
- protocol: syscall.SOCK_STREAM,
+ protocol: unix.SOCK_STREAM,
name: "stream",
sockets: map[string]socketCreator{
"echo": createEchoSocket,
@@ -182,7 +182,7 @@ func CreateSocketTree(baseDir string) (dir string, cleanup func(), err error) {
},
},
{
- protocol: syscall.SOCK_SEQPACKET,
+ protocol: unix.SOCK_SEQPACKET,
name: "seqpacket",
sockets: map[string]socketCreator{
"echo": createEchoSocket,
@@ -190,7 +190,7 @@ func CreateSocketTree(baseDir string) (dir string, cleanup func(), err error) {
},
},
{
- protocol: syscall.SOCK_DGRAM,
+ protocol: unix.SOCK_DGRAM,
name: "dgram",
sockets: map[string]socketCreator{
"null": createNullSocket,