Skip to content

Commit 89dbb7b

Browse files
nlacassegvisor-bot
authored andcommitted
Delete most of pkg/p9.
The 9p protocol has been entirely replaced by LisaFS. All that remains are a few types that are used by LisaFS and some Gofers. Those should eventually move elsewhere. Updates #7911 PiperOrigin-RevId: 772515368
1 parent 59fdb02 commit 89dbb7b

29 files changed

+52
-12603
lines changed

WORKSPACE

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,13 +2663,6 @@ go_repository(
26632663
version = "v0.8.0",
26642664
)
26652665

2666-
go_repository(
2667-
name = "com_github_golang_mock",
2668-
importpath = "github.com/golang/mock",
2669-
sum = "h1:YojYx61/OLFsiv6Rw1Z96LpldJIy31o+UHmwAUMJ6/U=",
2670-
version = "v1.7.0-rc.1",
2671-
)
2672-
26732666
go_repository(
26742667
name = "com_github_google_subcommands",
26752668
importpath = "github.com/google/subcommands",

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ require (
5050
github.com/go-logr/logr v1.3.0 // indirect
5151
github.com/gogo/googleapis v1.4.0 // indirect
5252
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
53-
github.com/golang/mock v1.7.0-rc.1 // indirect
5453
github.com/golang/protobuf v1.5.4 // indirect
5554
github.com/google/go-cmp v0.6.0 // indirect
5655
github.com/google/go-github/v56 v56.0.0 // indirect

go.sum

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,6 @@ github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4er
366366
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
367367
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
368368
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
369-
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
370-
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
371-
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
372-
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
373-
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
374-
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
375-
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
376-
github.com/golang/mock v1.7.0-rc.1 h1:YojYx61/OLFsiv6Rw1Z96LpldJIy31o+UHmwAUMJ6/U=
377-
github.com/golang/mock v1.7.0-rc.1/go.mod h1:s42URUywIqd+OcERslBJvOjepvNymP31m3q8d/GkuRs=
378369
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
379370
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
380371
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=

pkg/lisafs/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ go_library(
104104
"//pkg/atomicbitops",
105105
"//pkg/cleanup",
106106
"//pkg/context",
107+
"//pkg/errors",
108+
"//pkg/errors/linuxerr",
107109
"//pkg/fdchannel",
108110
"//pkg/flipcall",
109111
"//pkg/fspath",

pkg/lisafs/connection.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"golang.org/x/sys/unix"
2323
"gvisor.dev/gvisor/pkg/flipcall"
2424
"gvisor.dev/gvisor/pkg/log"
25-
"gvisor.dev/gvisor/pkg/p9"
2625
"gvisor.dev/gvisor/pkg/sync"
2726
"gvisor.dev/gvisor/pkg/unet"
2827
)
@@ -205,7 +204,7 @@ func (c *Connection) handleMsg(comm Communicator, m MID, payloadLen uint32) (ret
205204
fds := comm.ReleaseFDs()
206205
if err != nil {
207206
closeFDs(fds)
208-
return c.respondError(comm, p9.ExtractErrno(err))
207+
return c.respondError(comm, ExtractErrno(err))
209208
}
210209
if respPayloadLen > c.maxMessageSize {
211210
log.Warningf("handler for message %d responded with payload which is too large: %d bytes", m, respPayloadLen)

pkg/lisafs/handlers.go

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@ package lisafs
1717
import (
1818
"fmt"
1919
"math"
20+
"os"
2021
"strings"
2122

2223
"golang.org/x/sys/unix"
2324
"gvisor.dev/gvisor/pkg/abi/linux"
2425
"gvisor.dev/gvisor/pkg/cleanup"
26+
"gvisor.dev/gvisor/pkg/errors"
27+
"gvisor.dev/gvisor/pkg/errors/linuxerr"
2528
"gvisor.dev/gvisor/pkg/flipcall"
2629
"gvisor.dev/gvisor/pkg/fspath"
2730
"gvisor.dev/gvisor/pkg/log"
2831
"gvisor.dev/gvisor/pkg/marshal/primitive"
29-
"gvisor.dev/gvisor/pkg/p9"
3032
)
3133

3234
const (
@@ -266,7 +268,7 @@ func SetStatHandler(c *Connection, comm Communicator, payloadLen uint32) (uint32
266268
failureMask, failureErr := fd.impl.SetStat(req)
267269
resp.FailureMask = failureMask
268270
if failureErr != nil {
269-
resp.FailureErrNo = uint32(p9.ExtractErrno(failureErr))
271+
resp.FailureErrNo = uint32(ExtractErrno(failureErr))
270272
}
271273
return nil
272274
}); err != nil {
@@ -1529,3 +1531,42 @@ func checkSafeName(name string) error {
15291531
}
15301532
return unix.EINVAL
15311533
}
1534+
1535+
// ExtractErrno extracts a unix.Errno from an error, best effort.
1536+
func ExtractErrno(err error) unix.Errno {
1537+
errno, _ := TryExtractErrno(err)
1538+
return errno
1539+
}
1540+
1541+
// TryExtractErrno extracts a unix.Errno from an error, and reports whether it
1542+
// was successful. If unsuccessful, the returned errno is EIO.
1543+
func TryExtractErrno(err error) (unix.Errno, bool) {
1544+
switch err {
1545+
case os.ErrNotExist:
1546+
return unix.ENOENT, true
1547+
case os.ErrExist:
1548+
return unix.EEXIST, true
1549+
case os.ErrPermission:
1550+
return unix.EACCES, true
1551+
case os.ErrInvalid:
1552+
return unix.EINVAL, true
1553+
}
1554+
1555+
// Attempt to unwrap.
1556+
switch e := err.(type) {
1557+
case *errors.Error:
1558+
return linuxerr.ToUnix(e), true
1559+
case unix.Errno:
1560+
return e, true
1561+
case *os.PathError:
1562+
return TryExtractErrno(e.Err)
1563+
case *os.SyscallError:
1564+
return TryExtractErrno(e.Err)
1565+
case *os.LinkError:
1566+
return TryExtractErrno(e.Err)
1567+
}
1568+
1569+
// Default case.
1570+
log.Warningf("unknown error: %v", err)
1571+
return unix.EIO, false
1572+
}

pkg/p9/BUILD

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,17 @@ package(
99
go_library(
1010
name = "p9",
1111
srcs = [
12-
"buffer.go",
13-
"client.go",
14-
"client_file.go",
15-
"file.go",
16-
"handlers.go",
17-
"messages.go",
1812
"p9.go",
19-
"path_tree.go",
20-
"server.go",
21-
"transport.go",
22-
"transport_flipcall.go",
23-
"version.go",
2413
],
2514
deps = [
2615
"//pkg/abi/linux",
27-
"//pkg/atomicbitops",
28-
"//pkg/errors",
29-
"//pkg/errors/linuxerr",
30-
"//pkg/fd",
31-
"//pkg/fdchannel",
32-
"//pkg/flipcall",
33-
"//pkg/log",
34-
"//pkg/pool",
35-
"//pkg/sync",
36-
"//pkg/unet",
3716
"@org_golang_x_sys//unix:go_default_library",
3817
],
3918
)
4019

4120
go_test(
4221
name = "p9_test",
4322
size = "small",
44-
srcs = [
45-
"buffer_test.go",
46-
"client_test.go",
47-
"messages_test.go",
48-
"p9_test.go",
49-
"transport_test.go",
50-
"version_test.go",
51-
],
23+
srcs = ["p9_test.go"],
5224
library = ":p9",
53-
deps = [
54-
"//pkg/fd",
55-
"//pkg/unet",
56-
"@org_golang_x_sys//unix:go_default_library",
57-
],
5825
)

0 commit comments

Comments
 (0)