> 1. I'm trying to implement readdir - option 2 - using offsets.
> My "problem" is that i can't stop system for requesting next directories
> when i finished listing them. There's always an additional request:
> - readdir nr 1, off. 0
> - - read off. 0, filler(...., 1);
> - - read off. 1, filler(...., 2); last entry
> - - return 0;
> - readdir nr 2, off. 2
> - - return 0;
> How to pass "end of listing" to fuse?
The empty readdir will signal the end of listing.
> I tried returning 1 and 0 as in man readdir(2): "On success, 1 is
> returned. On end of directory, 0 is returned.", but returning !0 from
> readdir is an error signaled by fuse app.
> How can I solve it?
> It bothers me, as i need to mysql_query each time I do readdir.
It's not possible without the extra request.
You can cache the "end of listing" in the private directory data
> 2. Scenario: I "have X files" in my fs. I get readdir(offset=0), and
> list Y (Y<X) entries. Condition changes and I've "got 1+X files" (new at
> the begging). Readdir comes for rest of my files (offset=Y+1) and I list
> them, but 1 gets duplicated and the new one is lost. How do I avoid it /
> How do I get fuse to avoid it?
Fuse can't avoid it, it has to be done by the filesystem.
If you control the structure into which the new entry is inserted, you
can keep track of where each directory listing currently stands, and
continue from there (if the offset hasn't changed). For example
linux's generic readdir function, dcache_readdir() in fs/libfs.c does
But it sounds like you get the listing from an external source, in
which case it is much more difficult.
In fact the easiest way is to use "option 1". That would solve both
the above problems.
> 3. Fuse enumerates inodes by itself... should I take care of it, or
> leave it as it is?
As it suits you. If you specify the 'use_ino' mount option, libfuse
will honor the st_ino field in getattr() and fuse_fill_dir_t().