Refactored LookUpInodeResponse to share with MkDirResponse.

geesefs-0-30-9
Aaron Jacobs 2015-03-02 16:16:20 +11:00
parent c3298a7a6b
commit d88873bcd4
3 changed files with 47 additions and 39 deletions

View File

@ -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 {

View File

@ -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
}

View File

@ -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)