Refactored LookUpInodeResponse to share with MkDirResponse.
parent
c3298a7a6b
commit
d88873bcd4
|
@ -197,36 +197,10 @@ type HandleID uint64
|
||||||
// ReadDirRequest.Offset for details.
|
// ReadDirRequest.Offset for details.
|
||||||
type DirOffset uint64
|
type DirOffset uint64
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
// Information about a child inode within its parent directory. Shared by the
|
||||||
// Requests and responses
|
// responses for LookUpInode, MkDir, etc. Consumed by the kernel in order to
|
||||||
////////////////////////////////////////////////////////////////////////
|
// set up a dcache entry.
|
||||||
|
type ChildInodeEntry struct {
|
||||||
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 {
|
|
||||||
// The ID of the child inode. The file system must ensure that the returned
|
// The ID of the child inode. The file system must ensure that the returned
|
||||||
// inode ID remains valid until a later call to ForgetInode.
|
// inode ID remains valid until a later call to ForgetInode.
|
||||||
Child InodeID
|
Child InodeID
|
||||||
|
@ -294,6 +268,39 @@ type LookUpInodeResponse struct {
|
||||||
EntryExpiration time.Time
|
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 {
|
type GetInodeAttributesRequest struct {
|
||||||
// The inode of interest.
|
// The inode of interest.
|
||||||
Inode InodeID
|
Inode InodeID
|
||||||
|
@ -326,7 +333,7 @@ type MkDirRequest struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type MkDirResponse struct {
|
type MkDirResponse struct {
|
||||||
// TODO(jacobsa): Create a structure and share it with LookUpInodeResponse.
|
Entry ChildInodeEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
type OpenDirRequest struct {
|
type OpenDirRequest struct {
|
||||||
|
|
|
@ -151,12 +151,12 @@ func (fs *memFS) LookUpInode(
|
||||||
defer child.mu.RUnlock()
|
defer child.mu.RUnlock()
|
||||||
|
|
||||||
// Fill in the response.
|
// 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
|
// We don't spontaneously mutate, so the kernel can cache as long as it wants
|
||||||
// (since it also handles invalidation).
|
// (since it also handles invalidation).
|
||||||
resp.AttributesExpiration = fs.clock.Now().Add(365 * 24 * time.Hour)
|
resp.Entry.AttributesExpiration = fs.clock.Now().Add(365 * 24 * time.Hour)
|
||||||
resp.EntryExpiration = resp.EntryExpiration
|
resp.Entry.EntryExpiration = resp.Entry.EntryExpiration
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
11
server.go
11
server.go
|
@ -112,12 +112,13 @@ func (s *server) handleFuseRequest(fuseReq bazilfuse.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the response.
|
// Convert the response.
|
||||||
|
e := &resp.Entry
|
||||||
fuseResp := &bazilfuse.LookupResponse{
|
fuseResp := &bazilfuse.LookupResponse{
|
||||||
Node: bazilfuse.NodeID(resp.Child),
|
Node: bazilfuse.NodeID(e.Child),
|
||||||
Generation: uint64(resp.Generation),
|
Generation: uint64(e.Generation),
|
||||||
Attr: convertAttributes(resp.Child, resp.Attributes),
|
Attr: convertAttributes(e.Child, e.Attributes),
|
||||||
AttrValid: resp.AttributesExpiration.Sub(s.clock.Now()),
|
AttrValid: e.AttributesExpiration.Sub(s.clock.Now()),
|
||||||
EntryValid: resp.EntryExpiration.Sub(s.clock.Now()),
|
EntryValid: e.EntryExpiration.Sub(s.clock.Now()),
|
||||||
}
|
}
|
||||||
|
|
||||||
s.logger.Print("Responding:", fuseResp)
|
s.logger.Print("Responding:", fuseResp)
|
||||||
|
|
Loading…
Reference in New Issue