1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/patches/uClibc/0.9.30.2/200-clean-up-O_CLOEXEC-handling.patch Sun Feb 28 11:50:15 2010 +0100
1.3 @@ -0,0 +1,297 @@
1.4 +From 74ca5695cd9913691192e075449b8be5794d50f0 Mon Sep 17 00:00:00 2001
1.5 +From: Mike Frysinger <vapier@gentoo.org>
1.6 +Date: Thu, 8 Oct 2009 02:51:55 +0000
1.7 +Subject: [PATCH 12/15] clean up O_CLOEXEC handling
1.8 +
1.9 +Drop the "#ifndef O_CLOEXEC" cruft, enable O_CLOEXEC in most fcntl.h
1.10 +headers, and import __ASSUME_O_CLOEXEC from glibc.
1.11 +
1.12 +Signed-off-by: Mike Frysinger <vapier@gentoo.org>
1.13 +Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
1.14 +---
1.15 + libc/pwd_grp/lckpwdf.c | 8 +++++++-
1.16 + libc/sysdeps/linux/alpha/bits/fcntl.h | 2 --
1.17 + libc/sysdeps/linux/arm/bits/fcntl.h | 2 --
1.18 + libc/sysdeps/linux/avr32/bits/fcntl.h | 1 +
1.19 + libc/sysdeps/linux/bfin/bits/fcntl.h | 2 ++
1.20 + libc/sysdeps/linux/cris/bits/fcntl.h | 1 +
1.21 + libc/sysdeps/linux/frv/bits/fcntl.h | 2 ++
1.22 + libc/sysdeps/linux/hppa/bits/fcntl.h | 1 +
1.23 + libc/sysdeps/linux/i386/bits/fcntl.h | 2 --
1.24 + libc/sysdeps/linux/ia64/bits/fcntl.h | 2 --
1.25 + libc/sysdeps/linux/m68k/bits/fcntl.h | 1 +
1.26 + libc/sysdeps/linux/microblaze/bits/fcntl.h | 2 ++
1.27 + libc/sysdeps/linux/mips/bits/fcntl.h | 1 +
1.28 + libc/sysdeps/linux/powerpc/bits/fcntl.h | 2 --
1.29 + libc/sysdeps/linux/sh/bits/fcntl.h | 2 --
1.30 + libc/sysdeps/linux/sh64/bits/fcntl.h | 2 ++
1.31 + libc/sysdeps/linux/sparc/bits/fcntl.h | 2 --
1.32 + libc/sysdeps/linux/x86_64/bits/fcntl.h | 2 --
1.33 + libc/sysdeps/linux/xtensa/bits/fcntl.h | 1 +
1.34 + 19 files changed, 21 insertions(+), 17 deletions(-)
1.35 +
1.36 +diff --git a/libc/pwd_grp/lckpwdf.c b/libc/pwd_grp/lckpwdf.c
1.37 +index 0b0fb47..aec6283 100644
1.38 +--- a/libc/pwd_grp/lckpwdf.c
1.39 ++++ b/libc/pwd_grp/lckpwdf.c
1.40 +@@ -75,7 +75,7 @@ lckpwdf (void)
1.41 + /* Prevent problems caused by multiple threads. */
1.42 + __UCLIBC_MUTEX_LOCK(mylock);
1.43 +
1.44 +- lock_fd = open (_PATH_PASSWD, O_WRONLY);
1.45 ++ lock_fd = open (_PATH_PASSWD, O_WRONLY | O_CLOEXEC);
1.46 + if (lock_fd == -1) {
1.47 + /* Cannot create lock file. */
1.48 + goto DONE;
1.49 +@@ -97,6 +97,12 @@ lckpwdf (void)
1.50 + goto DONE;
1.51 + }
1.52 +
1.53 ++#ifndef __ASSUME_O_CLOEXEC
1.54 ++ /* Make sure file gets correctly closed when process finished. */
1.55 ++ fcntl (lock_fd, F_SETFD, FD_CLOEXEC);
1.56 ++#endif
1.57 ++
1.58 ++
1.59 + /* Now we have to get exclusive write access. Since multiple
1.60 + process could try this we won't stop when it first fails.
1.61 + Instead we set a timeout for the system call. Once the timer
1.62 +diff --git a/libc/sysdeps/linux/alpha/bits/fcntl.h b/libc/sysdeps/linux/alpha/bits/fcntl.h
1.63 +index 2a6b9ea..649c563 100644
1.64 +--- a/libc/sysdeps/linux/alpha/bits/fcntl.h
1.65 ++++ b/libc/sysdeps/linux/alpha/bits/fcntl.h
1.66 +@@ -50,9 +50,7 @@
1.67 + # define O_NOFOLLOW 0200000 /* Do not follow links. */
1.68 + # define O_DIRECT 02000000 /* Direct disk access. */
1.69 + # define O_NOATIME 04000000 /* Do not set atime. */
1.70 +-# if 0
1.71 + # define O_CLOEXEC 010000000 /* Set close_on_exec. */
1.72 +-# endif
1.73 + #endif
1.74 +
1.75 + #ifdef __USE_LARGEFILE64
1.76 +diff --git a/libc/sysdeps/linux/arm/bits/fcntl.h b/libc/sysdeps/linux/arm/bits/fcntl.h
1.77 +index 86cea4b..7cc5a9d 100644
1.78 +--- a/libc/sysdeps/linux/arm/bits/fcntl.h
1.79 ++++ b/libc/sysdeps/linux/arm/bits/fcntl.h
1.80 +@@ -50,9 +50,7 @@
1.81 + # define O_NOFOLLOW 0100000 /* Do not follow links. */
1.82 + # define O_DIRECT 0200000 /* Direct disk access. */
1.83 + # define O_NOATIME 01000000 /* Do not set atime. */
1.84 +-# if 0
1.85 + # define O_CLOEXEC 02000000 /* Set close_on_exec. */
1.86 +-# endif
1.87 + #endif
1.88 +
1.89 + /* For now Linux has synchronisity options for data and read operations.
1.90 +diff --git a/libc/sysdeps/linux/avr32/bits/fcntl.h b/libc/sysdeps/linux/avr32/bits/fcntl.h
1.91 +index 2301e22..767243e 100644
1.92 +--- a/libc/sysdeps/linux/avr32/bits/fcntl.h
1.93 ++++ b/libc/sysdeps/linux/avr32/bits/fcntl.h
1.94 +@@ -30,6 +30,7 @@
1.95 + # define O_DIRECTORY 00200000 /* direct disk access */
1.96 + # define O_NOFOLLOW 00400000 /* don't follow links */
1.97 + # define O_NOATIME 01000000 /* don't set atime */
1.98 ++# define O_CLOEXEC 02000000 /* set close_on_exec */
1.99 + #endif
1.100 +
1.101 + #ifdef __USE_LARGEFILE64
1.102 +diff --git a/libc/sysdeps/linux/bfin/bits/fcntl.h b/libc/sysdeps/linux/bfin/bits/fcntl.h
1.103 +index 7d0bcf9..aabf94d 100644
1.104 +--- a/libc/sysdeps/linux/bfin/bits/fcntl.h
1.105 ++++ b/libc/sysdeps/linux/bfin/bits/fcntl.h
1.106 +@@ -48,6 +48,8 @@
1.107 + # define O_DIRECTORY 040000 /* Must be a directory. */
1.108 + # define O_NOFOLLOW 0100000 /* Do not follow links. */
1.109 + # define O_DIRECT 0200000 /* Direct disk access. */
1.110 ++# define O_NOATIME 01000000 /* don't set atime */
1.111 ++# define O_CLOEXEC 02000000 /* set close_on_exec *
1.112 + #endif
1.113 +
1.114 + /* For now Linux has synchronisity options for data and read operations.
1.115 +diff --git a/libc/sysdeps/linux/cris/bits/fcntl.h b/libc/sysdeps/linux/cris/bits/fcntl.h
1.116 +index a2106ef..29443ba 100644
1.117 +--- a/libc/sysdeps/linux/cris/bits/fcntl.h
1.118 ++++ b/libc/sysdeps/linux/cris/bits/fcntl.h
1.119 +@@ -50,6 +50,7 @@
1.120 + # define O_DIRECTORY 0200000 /* Must be a directory. */
1.121 + # define O_NOFOLLOW 0400000 /* Do not follow links. */
1.122 + # define O_NOATIME 01000000 /* Do not set atime. */
1.123 ++# define O_CLOEXEC 02000000 /* set close_on_exec */
1.124 + #endif
1.125 +
1.126 + /* For now Linux has synchronisity options for data and read operations.
1.127 +diff --git a/libc/sysdeps/linux/frv/bits/fcntl.h b/libc/sysdeps/linux/frv/bits/fcntl.h
1.128 +index 06e8860..5bff4d3 100644
1.129 +--- a/libc/sysdeps/linux/frv/bits/fcntl.h
1.130 ++++ b/libc/sysdeps/linux/frv/bits/fcntl.h
1.131 +@@ -45,6 +45,8 @@
1.132 + # define O_DIRECT 040000 /* Direct disk access. */
1.133 + # define O_DIRECTORY 0200000 /* Must be a directory. */
1.134 + # define O_NOFOLLOW 0400000 /* Do not follow links. */
1.135 ++# define O_NOATIME 01000000 /* don't set atime */
1.136 ++# define O_CLOEXEC 02000000 /* set close_on_exec */
1.137 + #endif
1.138 +
1.139 + /* For now Linux has synchronisity options for data and read operations.
1.140 +diff --git a/libc/sysdeps/linux/hppa/bits/fcntl.h b/libc/sysdeps/linux/hppa/bits/fcntl.h
1.141 +index cc23bf8..86e3b6f 100644
1.142 +--- a/libc/sysdeps/linux/hppa/bits/fcntl.h
1.143 ++++ b/libc/sysdeps/linux/hppa/bits/fcntl.h
1.144 +@@ -50,6 +50,7 @@
1.145 + # define O_DIRECTORY 00010000 /* Must be a directory. */
1.146 + # define O_NOFOLLOW 00000200 /* Do not follow links. */
1.147 + # define O_NOATIME 04000000 /* Do not set atime. */
1.148 ++# define O_CLOEXEC 010000000 /* set close_on_exec */
1.149 + #endif
1.150 +
1.151 + #ifdef __USE_LARGEFILE64
1.152 +diff --git a/libc/sysdeps/linux/i386/bits/fcntl.h b/libc/sysdeps/linux/i386/bits/fcntl.h
1.153 +index 7f0b552..22e073b 100644
1.154 +--- a/libc/sysdeps/linux/i386/bits/fcntl.h
1.155 ++++ b/libc/sysdeps/linux/i386/bits/fcntl.h
1.156 +@@ -50,9 +50,7 @@
1.157 + # define O_DIRECTORY 0200000 /* Must be a directory. */
1.158 + # define O_NOFOLLOW 0400000 /* Do not follow links. */
1.159 + # define O_NOATIME 01000000 /* Do not set atime. */
1.160 +-# if 0
1.161 + # define O_CLOEXEC 02000000 /* Set close_on_exec. */
1.162 +-# endif
1.163 + #endif
1.164 +
1.165 + /* For now Linux has synchronisity options for data and read operations.
1.166 +diff --git a/libc/sysdeps/linux/ia64/bits/fcntl.h b/libc/sysdeps/linux/ia64/bits/fcntl.h
1.167 +index d134c4b..85a55f6 100644
1.168 +--- a/libc/sysdeps/linux/ia64/bits/fcntl.h
1.169 ++++ b/libc/sysdeps/linux/ia64/bits/fcntl.h
1.170 +@@ -49,9 +49,7 @@
1.171 + # define O_DIRECTORY 0200000 /* must be a directory */
1.172 + # define O_NOFOLLOW 0400000 /* don't follow links */
1.173 + # define O_NOATIME 01000000 /* Do not set atime. */
1.174 +-# if 0
1.175 + # define O_CLOEXEC 02000000 /* Set close_on_exec. */
1.176 +-# endif
1.177 + #endif
1.178 +
1.179 + #ifdef __USE_LARGEFILE64
1.180 +diff --git a/libc/sysdeps/linux/m68k/bits/fcntl.h b/libc/sysdeps/linux/m68k/bits/fcntl.h
1.181 +index d36198d..e564b42 100644
1.182 +--- a/libc/sysdeps/linux/m68k/bits/fcntl.h
1.183 ++++ b/libc/sysdeps/linux/m68k/bits/fcntl.h
1.184 +@@ -49,6 +49,7 @@
1.185 + # define O_NOFOLLOW 0100000 /* Do not follow links. */
1.186 + # define O_DIRECT 0200000 /* Direct disk access. */
1.187 + # define O_NOATIME 01000000 /* Do not set atime. */
1.188 ++# define O_CLOEXEC 02000000 /* set close_on_exec */
1.189 + #endif
1.190 +
1.191 + /* For now Linux has synchronisity options for data and read operations.
1.192 +diff --git a/libc/sysdeps/linux/microblaze/bits/fcntl.h b/libc/sysdeps/linux/microblaze/bits/fcntl.h
1.193 +index c8aeb91..da35209 100644
1.194 +--- a/libc/sysdeps/linux/microblaze/bits/fcntl.h
1.195 ++++ b/libc/sysdeps/linux/microblaze/bits/fcntl.h
1.196 +@@ -45,6 +45,8 @@
1.197 + # define O_DIRECTORY 040000 /* Must be a directory. */
1.198 + # define O_NOFOLLOW 0100000 /* Do not follow links. */
1.199 + # define O_DIRECT 0200000 /* Direct disk access. */
1.200 ++# define O_NOATIME 01000000 /* Do not set atime. */
1.201 ++# define O_CLOEXEC 02000000 /* set close_on_exec */
1.202 + #endif
1.203 +
1.204 + /* For now Linux has synchronisity options for data and read operations.
1.205 +diff --git a/libc/sysdeps/linux/mips/bits/fcntl.h b/libc/sysdeps/linux/mips/bits/fcntl.h
1.206 +index ef015a4..f0072fd 100644
1.207 +--- a/libc/sysdeps/linux/mips/bits/fcntl.h
1.208 ++++ b/libc/sysdeps/linux/mips/bits/fcntl.h
1.209 +@@ -51,6 +51,7 @@
1.210 + # define O_DIRECT 0x8000 /* Direct disk access hint. */
1.211 + # define O_DIRECTORY 0x10000 /* Must be a directory. */
1.212 + # define O_NOATIME 0x40000 /* Do not set atime. */
1.213 ++# define O_CLOEXEC 02000000 /* set close_on_exec */
1.214 + #endif
1.215 +
1.216 + /* For now Linux has no synchronisity options for data and read operations.
1.217 +diff --git a/libc/sysdeps/linux/powerpc/bits/fcntl.h b/libc/sysdeps/linux/powerpc/bits/fcntl.h
1.218 +index ceb75b4..0759c6a 100644
1.219 +--- a/libc/sysdeps/linux/powerpc/bits/fcntl.h
1.220 ++++ b/libc/sysdeps/linux/powerpc/bits/fcntl.h
1.221 +@@ -50,9 +50,7 @@
1.222 + # define O_DIRECTORY 040000 /* Must be a directory. */
1.223 + # define O_NOFOLLOW 0100000 /* Do not follow links. */
1.224 + # define O_NOATIME 01000000 /* Do not set atime. */
1.225 +-# if 0
1.226 + # define O_CLOEXEC 02000000 /* Set close_on_exec. */
1.227 +-# endif
1.228 + #endif
1.229 +
1.230 + #ifdef __USE_LARGEFILE64
1.231 +diff --git a/libc/sysdeps/linux/sh/bits/fcntl.h b/libc/sysdeps/linux/sh/bits/fcntl.h
1.232 +index 570484c..adb7377 100644
1.233 +--- a/libc/sysdeps/linux/sh/bits/fcntl.h
1.234 ++++ b/libc/sysdeps/linux/sh/bits/fcntl.h
1.235 +@@ -50,9 +50,7 @@
1.236 + # define O_DIRECTORY 0200000 /* Must be a directory. */
1.237 + # define O_NOFOLLOW 0400000 /* Do not follow links. */
1.238 + # define O_NOATIME 01000000 /* Do not set atime. */
1.239 +-# if 0
1.240 + # define O_CLOEXEC 02000000 /* Set close_on_exec. */
1.241 +-# endif
1.242 + #endif
1.243 +
1.244 + /* For now Linux has synchronisity options for data and read operations.
1.245 +diff --git a/libc/sysdeps/linux/sh64/bits/fcntl.h b/libc/sysdeps/linux/sh64/bits/fcntl.h
1.246 +index 06e8860..245d35a 100644
1.247 +--- a/libc/sysdeps/linux/sh64/bits/fcntl.h
1.248 ++++ b/libc/sysdeps/linux/sh64/bits/fcntl.h
1.249 +@@ -45,6 +45,8 @@
1.250 + # define O_DIRECT 040000 /* Direct disk access. */
1.251 + # define O_DIRECTORY 0200000 /* Must be a directory. */
1.252 + # define O_NOFOLLOW 0400000 /* Do not follow links. */
1.253 ++# define O_NOATIME 01000000 /* Do not set atime. */
1.254 ++# define O_CLOEXEC 02000000 /* set close_on_exec */
1.255 + #endif
1.256 +
1.257 + /* For now Linux has synchronisity options for data and read operations.
1.258 +diff --git a/libc/sysdeps/linux/sparc/bits/fcntl.h b/libc/sysdeps/linux/sparc/bits/fcntl.h
1.259 +index 29c09a9..31a6d9b 100644
1.260 +--- a/libc/sysdeps/linux/sparc/bits/fcntl.h
1.261 ++++ b/libc/sysdeps/linux/sparc/bits/fcntl.h
1.262 +@@ -49,9 +49,7 @@
1.263 + # define O_NOFOLLOW 0x20000 /* don't follow links */
1.264 + # define O_DIRECT 0x100000 /* direct disk access hint */
1.265 + # define O_NOATIME 0x200000 /* Do not set atime. */
1.266 +-# if 0
1.267 + # define O_CLOEXEC 0x400000 /* Set close_on_exit. */
1.268 +-# endif
1.269 + #endif
1.270 +
1.271 + #ifdef __USE_LARGEFILE64
1.272 +diff --git a/libc/sysdeps/linux/x86_64/bits/fcntl.h b/libc/sysdeps/linux/x86_64/bits/fcntl.h
1.273 +index be00e4a..f1cf388 100644
1.274 +--- a/libc/sysdeps/linux/x86_64/bits/fcntl.h
1.275 ++++ b/libc/sysdeps/linux/x86_64/bits/fcntl.h
1.276 +@@ -50,9 +50,7 @@
1.277 + # define O_DIRECTORY 0200000 /* Must be a directory. */
1.278 + # define O_NOFOLLOW 0400000 /* Do not follow links. */
1.279 + # define O_NOATIME 01000000 /* Do not set atime. */
1.280 +-# if 0
1.281 + # define O_CLOEXEC 02000000 /* Set close_on_exec. */
1.282 +-# endif
1.283 + #endif
1.284 +
1.285 + /* For now Linux has synchronisity options for data and read operations.
1.286 +diff --git a/libc/sysdeps/linux/xtensa/bits/fcntl.h b/libc/sysdeps/linux/xtensa/bits/fcntl.h
1.287 +index a89362e..921a626 100644
1.288 +--- a/libc/sysdeps/linux/xtensa/bits/fcntl.h
1.289 ++++ b/libc/sysdeps/linux/xtensa/bits/fcntl.h
1.290 +@@ -50,6 +50,7 @@
1.291 + # define O_DIRECTORY 0200000 /* Must be a directory. */
1.292 + # define O_NOFOLLOW 0400000 /* Do not follow links. */
1.293 + # define O_NOATIME 01000000 /* Do not set atime. */
1.294 ++# define O_CLOEXEC 02000000 /* set close_on_exec */
1.295 + #endif
1.296 +
1.297 + /* For now Linux has synchronisity options for data and read operations.
1.298 +--
1.299 +1.6.6.1
1.300 +