lib9p

Go 9P library.
Log | Files | Refs | LICENSE

commit ebcc8cd584bc946e400913e0d2a51640a66c697d
parent 41e9b36e077197a90ca39be7223ea5f43f2ef455
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Sun,  7 Jan 2024 13:03:17 +0900

gofmt

Diffstat:
Mclient/client.go | 3+++
Mclient/fid.go | 2+-
Mclient/file_test.go | 2+-
Mclient/fs2_test.go | 1-
Mclient/req.go | 22+++++++++++-----------
Mfid.go | 2+-
Mserver_test.go | 2+-
7 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/client/client.go b/client/client.go @@ -392,6 +392,9 @@ func (c *Client) Create(tag uint16, fid uint32, name string, perm lib9p.FileMode return lib9p.Qid{}, 0, fmt.Errorf("invalid reply: %v", rmsg) } } + +// Read doesn't return io.EOF at the end of file, +// but returns empty data and nil error. func (c *Client) Read(tag uint16, fid uint32, offset uint64, count uint32) (data []byte, err error) { tmsg := &lib9p.TRead{Tag: tag, Fid: fid, Offset: offset, Count: count} rmsg, err := c.transact(tmsg) diff --git a/client/fid.go b/client/fid.go @@ -24,7 +24,7 @@ func newClientFid(id uint32) *fid { } type fidPool struct { - m map[uint32]*fid + m map[uint32]*fid *sync.Mutex } diff --git a/client/file_test.go b/client/file_test.go @@ -127,7 +127,7 @@ func TestFileRead(t *testing.T) { return err } defer cf.Close() - cb := make([]byte, len(tf.content) * 2) + cb := make([]byte, len(tf.content)*2) n, err := cf.Read(cb) if err != nil { t.Error(err) diff --git a/client/fs2_test.go b/client/fs2_test.go @@ -58,4 +58,3 @@ func TestOpenFile(t *testing.T) { t.Error(err) } } - diff --git a/client/req.go b/client/req.go @@ -9,27 +9,27 @@ import ( // req represents each requests of the client. type req struct { - tag uint16 - tmsg lib9p.Msg - rmsg lib9p.Msg - err error - errc chan error // To report any client side error to transact(). - rxc chan *req + tag uint16 + tmsg lib9p.Msg + rmsg lib9p.Msg + err error + errc chan error // To report any client side error to transact(). + rxc chan *req } // newReq allocates a req with msg. func newReq(msg lib9p.Msg) *req { return &req{ - tag: msg.GetTag(), - tmsg: msg, - rxc: make(chan *req), - errc: make(chan error), + tag: msg.GetTag(), + tmsg: msg, + rxc: make(chan *req), + errc: make(chan error), } } // reqPool is the pool of Reqs the server is dealing with. type reqPool struct { - m map[uint16]*req + m map[uint16]*req *sync.Mutex } diff --git a/fid.go b/fid.go @@ -60,7 +60,7 @@ func (f *fid) String() string { // It is used to track the fids of each 9P connection (not of each session). // It is safe for concurrent use by multiple goroutines except the String method. type fidPool struct { - m map[uint32]*fid + m map[uint32]*fid *sync.Mutex } diff --git a/server_test.go b/server_test.go @@ -196,7 +196,7 @@ func TestSAuth(t *testing.T) { func() { c, rc := setupConn(nil) tc := make(chan *request) - c.s.Auth = test.authFunc + c.s.Auth = test.authFunc ctx, cancel := context.WithCancel(context.Background()) defer cancel() go sAuth(ctx, c, tc)