Messages in this thread | | | Date | Fri, 11 Jul 2008 11:16:40 -0700 (PDT) | From | Linus Torvalds <> | Subject | Re: [PATCH] x86_64: fix delayed signals |
| |
On Fri, 11 Jul 2008, Roland McGrath wrote: > > > + /* Only check signals if we have filled at least one entry! */ > > + if (signal_pending(current)) > > + return -EINTR; > > Shouldn't it return the short count? > (And if not, then probably should be -ERESTARTSYS.)
readdir (getdents) is a complex system call, and the path is
sys_getdents64() -> vfs_readdir (with 'filldir64' as a callback) -> low-level filesystem 'readdir' function -> filldir64 callback
and what happens is that when that 'filldir64()' callback returns an error, the low-level filesystem just stops and returns with a success (because everything worked for _it_ - it was the callback that errored out).
The 'sys_getdents64()' then does:
.. lastdirent = buf.previous; if (lastdirent) { typeof(lastdirent->d_off) d_off = file->f_pos; error = -EFAULT; if (__put_user(d_off, &lastdirent->d_off)) goto out_putf; error = count - buf.count; } ..
ie we'll do that "return partial buffer size" at that level, not deep in the callback.
So making the callback just return an error is the right thing to do - because the callers will then fix up the file offset in the last directory entry and the final return value.
Linus
| |