From: Goswin v. B. <gos...@we...> - 2008-12-11 18:02:48
|
Miklos Szeredi <mi...@sz...> writes: > On Thu, 11 Dec 2008, Goswin von Brederlow wrote: >> In my filesystem I collect a list of (name, type, inode) in opendir() >> and slowly feed that out in readdir(). As such readdir() will always >> reflect the state of the directory at the time of the opendir() call >> and not neccessarily the current situation. >> >> I'm wondering now if that is fundamentally flawed and violates normal >> filesystem semantics. Has anyone else experienced such a problem? > > That's OK, but rewinding a directory (setting the offset to zero) > should have the same effect as closing/opening it: > > The rewinddir() function shall reset the position of the directory > stream to which dirp refers to the beginning of the directory. It > shall also cause the directory stream to refer to the current state > of the corresponding directory, as a call to opendir() would have > done. If dirp does not refer to a directory stream, the effect is > undefined. > > Miklos And to the fuse filesystem that looks like what? The next readdir call will have offset == 0? I don't se a rewinddir callback. Currently I generate the list of entries in opendir and store it in the filehandle. In readdir() I check for offset==NULL and then copy the list from the filehandle to the offset. After that readdir just adds new entries till it hits a marker (name == NULL) or the buffer is full, each with offset pointing to the next list entry. I guess then I have to add an indirection struct dir_file_handle { struct file_list *first; } so I can modify fi->fh->first when readdir is called with offset == 0 or can I modify fi->fh during readdir calls? MfG Goswin |