diff --git a/file_system.go b/file_system.go index c9105b8..5cd73fd 100644 --- a/file_system.go +++ b/file_system.go @@ -109,14 +109,6 @@ type HandleID uint64 // ReadDirRequest.Offset for details. type DirOffset uint64 -// XXX: Comments for all -type Dirent struct { - Inode InodeID - Offset DirOffset - Name string - Type DirentType -} - //////////////////////////////////////////////////////////////////////// // Requests and responses //////////////////////////////////////////////////////////////////////// diff --git a/fuseutil/dirent.go b/fuseutil/dirent.go new file mode 100644 index 0000000..32e6eea --- /dev/null +++ b/fuseutil/dirent.go @@ -0,0 +1,31 @@ +// Copyright 2015 Google Inc. All Rights Reserved. +// Author: jacobsa@google.com (Aaron Jacobs) + +package fuseutil + +import ( + bazilfuse "bazil.org/fuse" + "github.com/jacobsa/fuse" +) + +type DirentType bazilfuse.DirentType + +// A struct representing an entry within a directory file, describing a child. +// See notes on fuse.ReadDirResponse and on AppendDirent for details. +type Dirent struct { + // The (opaque) offset within the directory file of this entry. See notes on + // fuse.ReadDirRequest.Offset for details. + Offset fuse.DirOffset + + // The inode of the child file or directory, and its name within the parent. + Inode fuse.InodeID + Name string + + // The type of the child. The zero value (DT_Unknown) is legal, but means + // that the kernel will need to call GetAttr when the type is needed. + Type DirentType +} + +// Append the supplied directory entry to the given buffer in the format +// expected in fuse.ReadResponse.Data, returning the resulting buffer. +func AppendDirent(buf []byte, d Dirent) []byte