Re: [PATCH] Add cloexec information to fdinfo

From: Ulrich Drepper
Date: Tue Jun 28 2011 - 03:12:25 EST


On 06/20/2011 05:31 PM, Andrew Morton wrote:
> Does FD_ISSET return 0 or 1? Or 0 or non-zero?
>
> For x86 it's the former.
>
> <checks the architectures>
>
> arch/h8300/include/asm/posix_types.h: busted
> #define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d))
>
> arch/m68k/include/asm/posix_types.h: busted
> #define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d))
>
> arch/xtensa/include/asm/posix_types.h: busted
> #define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d))

I agree, this is an issue. Existing code works around this. We should
use the attached patch on top of the existing one.


This doesn't invalidate your patch to harmonize the architectures but
the above is what existing code does. I didn't use a tab in the output
since the initial string is long enough to force the subsequent text in
a new column. Using a single space seemed more visually pleasing.



Signed-off-by: Ulrich Drepper <drepper@xxxxxxxxx>

--- a/fs/proc/base.c 2011-06-28 02:54:01.888793757 -0400
+++ b/fs/proc/base.c 2011-06-28 02:54:30.668664335 -0400
@@ -1939,7 +1939,7 @@
"cloexec:\t%d\n",
(long long) file->f_pos,
file->f_flags,
- cloexec);
+ cloexec ? FD_CLOEXEC : 0);
}
spin_unlock(&files->file_lock);
put_files_struct(files);

Attachment: signature.asc
Description: OpenPGP digital signature