diff --git a/file_system.go b/file_system.go index fc1cd49..083902c 100644 --- a/file_system.go +++ b/file_system.go @@ -197,36 +197,10 @@ type HandleID uint64 // ReadDirRequest.Offset for details. type DirOffset uint64 -//////////////////////////////////////////////////////////////////////// -// Requests and responses -//////////////////////////////////////////////////////////////////////// - -type InitRequest struct { - // User and group IDs for the process that is mounting the file system. - Uid uint32 - Gid uint32 -} - -type InitResponse struct { -} - -type LookUpInodeRequest struct { - // The ID of the directory inode to which the child belongs. - Parent InodeID - - // The name of the child of interest, relative to the parent. For example, in - // this directory structure: - // - // foo/ - // bar/ - // baz - // - // the file system may receive a request to look up the child named "bar" for - // the parent foo/. - Name string -} - -type LookUpInodeResponse struct { +// Information about a child inode within its parent directory. Shared by the +// responses for LookUpInode, MkDir, etc. Consumed by the kernel in order to +// set up a dcache entry. +type ChildInodeEntry struct { // The ID of the child inode. The file system must ensure that the returned // inode ID remains valid until a later call to ForgetInode. Child InodeID @@ -294,6 +268,39 @@ type LookUpInodeResponse struct { EntryExpiration time.Time } +//////////////////////////////////////////////////////////////////////// +// Requests and responses +//////////////////////////////////////////////////////////////////////// + +type InitRequest struct { + // User and group IDs for the process that is mounting the file system. + Uid uint32 + Gid uint32 +} + +type InitResponse struct { +} + +type LookUpInodeRequest struct { + // The ID of the directory inode to which the child belongs. + Parent InodeID + + // The name of the child of interest, relative to the parent. For example, in + // this directory structure: + // + // foo/ + // bar/ + // baz + // + // the file system may receive a request to look up the child named "bar" for + // the parent foo/. + Name string +} + +type LookUpInodeResponse struct { + Entry ChildInodeEntry +} + type GetInodeAttributesRequest struct { // The inode of interest. Inode InodeID @@ -326,7 +333,7 @@ type MkDirRequest struct { } type MkDirResponse struct { - // TODO(jacobsa): Create a structure and share it with LookUpInodeResponse. + Entry ChildInodeEntry } type OpenDirRequest struct { diff --git a/samples/memfs/fs.go b/samples/memfs/fs.go index f78d5c9..df164ca 100644 --- a/samples/memfs/fs.go +++ b/samples/memfs/fs.go @@ -151,12 +151,12 @@ func (fs *memFS) LookUpInode( defer child.mu.RUnlock() // Fill in the response. - resp.Attributes = child.attributes + resp.Entry.Attributes = child.attributes // We don't spontaneously mutate, so the kernel can cache as long as it wants // (since it also handles invalidation). - resp.AttributesExpiration = fs.clock.Now().Add(365 * 24 * time.Hour) - resp.EntryExpiration = resp.EntryExpiration + resp.Entry.AttributesExpiration = fs.clock.Now().Add(365 * 24 * time.Hour) + resp.Entry.EntryExpiration = resp.Entry.EntryExpiration return } diff --git a/server.go b/server.go index 5b321f1..4690a95 100644 --- a/server.go +++ b/server.go @@ -112,12 +112,13 @@ func (s *server) handleFuseRequest(fuseReq bazilfuse.Request) { } // Convert the response. + e := &resp.Entry fuseResp := &bazilfuse.LookupResponse{ - Node: bazilfuse.NodeID(resp.Child), - Generation: uint64(resp.Generation), - Attr: convertAttributes(resp.Child, resp.Attributes), - AttrValid: resp.AttributesExpiration.Sub(s.clock.Now()), - EntryValid: resp.EntryExpiration.Sub(s.clock.Now()), + Node: bazilfuse.NodeID(e.Child), + Generation: uint64(e.Generation), + Attr: convertAttributes(e.Child, e.Attributes), + AttrValid: e.AttributesExpiration.Sub(s.clock.Now()), + EntryValid: e.EntryExpiration.Sub(s.clock.Now()), } s.logger.Print("Responding:", fuseResp)