lib9p

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

commit e0ee55e93ae9965b98855096295edb021993dee2
parent 2782b7242823bca25d920bf451a1f33b16ad8773
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Fri, 29 Dec 2023 09:34:08 +0900

unexport Fid

Diffstat:
Mexport_test.go | 1+
Mfid.go | 22+++++++++++-----------
Mreq.go | 4++--
Mserver.go | 2+-
4 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/export_test.go b/export_test.go @@ -67,6 +67,7 @@ func (r *Req) Afid() *Fid { return r.afid } type ReqPool = reqPool func (rp *ReqPool) Add(tag uint16) (*Req, error) { return rp.add(tag) } +type Fid = fid func (fid *Fid) SetPath(path string) { fid.path = path } func (fid *Fid) SetUid(uid string) { fid.uid = uid } func (fid *Fid) File() File { return fid.file } diff --git a/fid.go b/fid.go @@ -18,8 +18,8 @@ const ( ORCLOSE = 64 ) -// Fid represents the fid defined by 9P -type Fid struct { +// fid represents the fid defined by 9P +type fid struct { fid uint32 omode OpenMode /* -1 = not open */ path string // The path from the root of the FS. @@ -31,14 +31,14 @@ type Fid struct { const NOFID = ^uint32(0) -func newFid(fid uint32) *Fid { - return &Fid{ - fid: fid, +func newFid(id uint32) *fid { + return &fid{ + fid: id, omode: -1, } } -func (f *Fid) String() string { +func (f *fid) String() string { fid := int64(f.fid) if uint32(fid) == NOFID { fid = -1 @@ -46,29 +46,29 @@ func (f *Fid) String() string { return fmt.Sprintf("%d", fid) } -// FidPool is a pool of Fid. +// FidPool is a pool of fid. // It is used to track the fid in the file system the server is exporting. type FidPool struct { - m map[uint32]*Fid + m map[uint32]*fid lock *sync.Mutex } // newFidPool allocates an FidPool. func newFidPool() *FidPool { return &FidPool{ - m: make(map[uint32]*Fid), + m: make(map[uint32]*fid), lock: new(sync.Mutex), } } -func (pool *FidPool) lookup(fid uint32) (*Fid, bool) { +func (pool *FidPool) lookup(fid uint32) (*fid, bool) { pool.lock.Lock() defer pool.lock.Unlock() f, ok := pool.m[fid] return f, ok } -func (pool *FidPool) add(fid uint32) (*Fid, error) { +func (pool *FidPool) add(fid uint32) (*fid, error) { pool.lock.Lock() defer pool.lock.Unlock() if _, ok := pool.m[fid]; ok { diff --git a/req.go b/req.go @@ -11,8 +11,8 @@ type request struct { ifcall Msg // Ofcall is response message to Ifcall. ofcall Msg - fid *Fid - afid *Fid + fid *fid + afid *fid // Oldreq is set with Tflush message. oldreq *request // Pool is the pool this request belongs to. diff --git a/server.go b/server.go @@ -383,7 +383,7 @@ func sWalk(ctx context.Context, s *Server, c <-chan *request) { var ( err error oldst fs.FileInfo - newFid *Fid + newFid *fid wqids []Qid cwdp string n int