This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] linux: use F_GETFL to validate futimes fd
On Sun, Jan 27, 2013 at 02:32:20PM +0100, Ben Noordhuis wrote:
> Use fcntl(F_GETFL) to validate the file descriptor in the futimes()
> fallback path.
>
> Before this commit, glibc used fctnl(F_GETFD) to check for EBADF but
> F_GETFD has to acquire a RCU read lock and do a fdtable lookup;
> F_GETFL just reads the f_flags field of the struct file.
Are you sure about this? In principle, F_GETFL is a more expensive
operation, not a less expensive one.
F_GETFD: integer -> process's fd table
F_GETFL: integer -> process's fd table -> shared open-file-descriptions
The latter should involve *more* locking.
None of this is based on any reading of kernel source, but if I'm
wrong, please cite the reasons, since it's contrary to intuition about
how the kernel should work.
Rich