From a9441aea2780da8c93da1c73da860219f98438de Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Wed, 3 Mar 2021 10:23:55 -0800 Subject: [op] Replace syscall package usage with golang.org/x/sys/unix in pkg/. The syscall package has been deprecated in favor of golang.org/x/sys. Note that syscall is still used in the following places: - pkg/sentry/socket/hostinet/stack.go: some netlink related functionalities are not yet available in golang.org/x/sys. - syscall.Stat_t is still used in some places because os.FileInfo.Sys() still returns it and not unix.Stat_t. Updates #214 PiperOrigin-RevId: 360701387 --- pkg/tcpip/link/sharedmem/rx.go | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'pkg/tcpip/link/sharedmem/rx.go') diff --git a/pkg/tcpip/link/sharedmem/rx.go b/pkg/tcpip/link/sharedmem/rx.go index eec11e4cb..8e6f3e5e3 100644 --- a/pkg/tcpip/link/sharedmem/rx.go +++ b/pkg/tcpip/link/sharedmem/rx.go @@ -18,8 +18,8 @@ package sharedmem import ( "sync/atomic" - "syscall" + "golang.org/x/sys/unix" "gvisor.dev/gvisor/pkg/tcpip/link/rawfile" "gvisor.dev/gvisor/pkg/tcpip/link/sharedmem/queue" ) @@ -46,43 +46,43 @@ func (r *rx) init(mtu uint32, c *QueueConfig) error { rxPipe, err := getBuffer(c.RxPipeFD) if err != nil { - syscall.Munmap(txPipe) + unix.Munmap(txPipe) return err } data, err := getBuffer(c.DataFD) if err != nil { - syscall.Munmap(txPipe) - syscall.Munmap(rxPipe) + unix.Munmap(txPipe) + unix.Munmap(rxPipe) return err } sharedData, err := getBuffer(c.SharedDataFD) if err != nil { - syscall.Munmap(txPipe) - syscall.Munmap(rxPipe) - syscall.Munmap(data) + unix.Munmap(txPipe) + unix.Munmap(rxPipe) + unix.Munmap(data) return err } // Duplicate the eventFD so that caller can close it but we can still // use it. - efd, err := syscall.Dup(c.EventFD) + efd, err := unix.Dup(c.EventFD) if err != nil { - syscall.Munmap(txPipe) - syscall.Munmap(rxPipe) - syscall.Munmap(data) - syscall.Munmap(sharedData) + unix.Munmap(txPipe) + unix.Munmap(rxPipe) + unix.Munmap(data) + unix.Munmap(sharedData) return err } // Set the eventfd as non-blocking. - if err := syscall.SetNonblock(efd, true); err != nil { - syscall.Munmap(txPipe) - syscall.Munmap(rxPipe) - syscall.Munmap(data) - syscall.Munmap(sharedData) - syscall.Close(efd) + if err := unix.SetNonblock(efd, true); err != nil { + unix.Munmap(txPipe) + unix.Munmap(rxPipe) + unix.Munmap(data) + unix.Munmap(sharedData) + unix.Close(efd) return err } @@ -99,12 +99,12 @@ func (r *rx) init(mtu uint32, c *QueueConfig) error { // called if init() has previously succeeded. func (r *rx) cleanup() { a, b := r.q.Bytes() - syscall.Munmap(a) - syscall.Munmap(b) + unix.Munmap(a) + unix.Munmap(b) - syscall.Munmap(r.data) - syscall.Munmap(r.sharedData) - syscall.Close(r.eventFD) + unix.Munmap(r.data) + unix.Munmap(r.sharedData) + unix.Close(r.eventFD) } // postAndReceive posts the provided buffers (if any), and then tries to read -- cgit v1.2.3