Commit 2eb340ae authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Support rewinddir. Untested.

parent 9dd4fe7f
...@@ -105,8 +105,6 @@ Grep source code for TODO. Major topics: ...@@ -105,8 +105,6 @@ Grep source code for TODO. Major topics:
* Use splice for transporting data, use io.Reader in API. * Use splice for transporting data, use io.Reader in API.
* Opendir/Readdir does not support seeking
* Missing support for network FS file locking: FUSE_GETLK, FUSE_SETLK, * Missing support for network FS file locking: FUSE_GETLK, FUSE_SETLK,
FUSE_SETLKW FUSE_SETLKW
......
...@@ -79,16 +79,26 @@ type rawDir interface { ...@@ -79,16 +79,26 @@ type rawDir interface {
} }
type connectorDir struct { type connectorDir struct {
node FsNode
stream []DirEntry stream []DirEntry
lastOffset uint64
} }
func (d *connectorDir) ReadDir(input *ReadIn) (*DirEntryList, Status) { func (d *connectorDir) ReadDir(input *ReadIn) (list *DirEntryList, code Status) {
if d.stream == nil { if d.stream == nil {
return nil, OK return nil, OK
} }
// rewinddir() should be as if reopening directory.
// TODO - test this.
if d.lastOffset > 0 && input.Offset == 0 {
d.stream, code = d.node.OpenDir(nil)
if !code.Ok() {
return nil, code
}
}
off := input.Offset off := input.Offset
list := NewDirEntryList(int(input.Size), off) list = NewDirEntryList(int(input.Size), off)
todo := d.stream[off:] todo := d.stream[off:]
for _, e := range todo { for _, e := range todo {
...@@ -96,6 +106,7 @@ func (d *connectorDir) ReadDir(input *ReadIn) (*DirEntryList, Status) { ...@@ -96,6 +106,7 @@ func (d *connectorDir) ReadDir(input *ReadIn) (*DirEntryList, Status) {
break break
} }
} }
d.lastOffset = list.offset
return list, OK return list, OK
} }
......
...@@ -114,6 +114,7 @@ func (c *FileSystemConnector) OpenDir(header *raw.InHeader, input *raw.OpenIn) ( ...@@ -114,6 +114,7 @@ func (c *FileSystemConnector) OpenDir(header *raw.InHeader, input *raw.OpenIn) (
} }
stream = append(stream, node.getMountDirEntries()...) stream = append(stream, node.getMountDirEntries()...)
de := &connectorDir{ de := &connectorDir{
node: node.FsNode(),
stream: append(stream, DirEntry{S_IFDIR, "."}, DirEntry{S_IFDIR, ".."}), stream: append(stream, DirEntry{S_IFDIR, "."}, DirEntry{S_IFDIR, ".."}),
} }
h, opened := node.mount.registerFileHandle(node, de, nil, input.Flags) h, opened := node.mount.registerFileHandle(node, de, nil, input.Flags)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment