Messages in this thread | | | Date | Tue, 12 Aug 2008 13:02:59 -0700 (PDT) | From | Linus Torvalds <> | Subject | Re: [RFC] readdir mess |
| |
On Tue, 12 Aug 2008, Al Viro wrote: > > Doesn't work well for readdir(2)...
Sure it does.
> > error = vfs_readdir(file, filldir, &buf); > > lastdirent = buf.previous; > > if (lastdirent) { > > error = count - buf.count; > > if (put_user(file->f_pos, &lastdirent->d_off)) > > error = -EFAULT; > > } > > fput(file); > > return error; > > > > and we wouldn't need any other logic at all. > > you've just lost e.g. -EIO for getdents().
No I've not.
If we returned a partial result, we _should_ return a partial result.
And if we got EIO on the first entry, we should return EIO.
The _current_ code is crap. It sometimes returns the error (if the ->readdir() function returned error), and sometimes returns the partial result (if the "buf.error" was set).
> Frankly, I'd rather keep ->readdir() instances simpler. There are far > more of those, for one thing. As it is, we only have "stop"/"continue" > ->readdir() has to care about...
Keeping them simple (and not changing them - always returning zero is what the _original_ readdir() thing did!) is why the current situation exists.
So if we keep it that way, then we really *KEEP* it that way. Don't go around changing any of the existing rules. Just make sure that the callbacks keep on always returning negative or zero (and never positive).
Linus
| |