]> www.infradead.org Git - users/jedix/linux-maple.git/commit
vfs: show O_CLOEXE bit properly in /proc/<pid>/fdinfo/<fd> files
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 6 Aug 2011 18:51:33 +0000 (11:51 -0700)
committerMaxim Uvarov <maxim.uvarov@oracle.com>
Thu, 8 Dec 2011 19:18:03 +0000 (11:18 -0800)
commiteabf3fe97c612f3a5c8d46faf307ba004c9d8c32
treece316a1e4a8dd890908aed918784cf852fd26b54
parent091338b8e046d9d6bf2ff3498b314c6d186f8397
vfs: show O_CLOEXE bit properly in /proc/<pid>/fdinfo/<fd> files

commit 1117f72ea0217ba0cc19f05adbbd8b9a397f5ab7 upstream.

The CLOEXE bit is magical, and for performance (and semantic) reasons we
don't actually maintain it in the file descriptor itself, but in a
separate bit array.  Which means that when we show f_flags, the CLOEXE
status is shown incorrectly: we show the status not as it is now, but as
it was when the file was opened.

Fix that by looking up the bit properly in the 'fdt->close_on_exec' bit
array.

Uli needs this in order to re-implement the pfiles program:

  "For normal file descriptors (not sockets) this was the last piece of
   information which wasn't available.  This is all part of my 'give
   Solaris users no reason to not switch' effort.  I intend to offer the
   code to the util-linux-ng maintainers."

Requested-by: Ulrich Drepper <drepper@akkadia.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/proc/base.c