1 From 74ca5695cd9913691192e075449b8be5794d50f0 Mon Sep 17 00:00:00 2001
2 From: Mike Frysinger <vapier@gentoo.org>
3 Date: Thu, 8 Oct 2009 02:51:55 +0000
4 Subject: [PATCH 12/15] clean up O_CLOEXEC handling
6 Drop the "#ifndef O_CLOEXEC" cruft, enable O_CLOEXEC in most fcntl.h
7 headers, and import __ASSUME_O_CLOEXEC from glibc.
9 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
10 Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
12 libc/pwd_grp/lckpwdf.c | 8 +++++++-
13 libc/sysdeps/linux/alpha/bits/fcntl.h | 2 --
14 libc/sysdeps/linux/arm/bits/fcntl.h | 2 --
15 libc/sysdeps/linux/avr32/bits/fcntl.h | 1 +
16 libc/sysdeps/linux/bfin/bits/fcntl.h | 2 ++
17 libc/sysdeps/linux/cris/bits/fcntl.h | 1 +
18 libc/sysdeps/linux/frv/bits/fcntl.h | 2 ++
19 libc/sysdeps/linux/hppa/bits/fcntl.h | 1 +
20 libc/sysdeps/linux/i386/bits/fcntl.h | 2 --
21 libc/sysdeps/linux/ia64/bits/fcntl.h | 2 --
22 libc/sysdeps/linux/m68k/bits/fcntl.h | 1 +
23 libc/sysdeps/linux/microblaze/bits/fcntl.h | 2 ++
24 libc/sysdeps/linux/mips/bits/fcntl.h | 1 +
25 libc/sysdeps/linux/powerpc/bits/fcntl.h | 2 --
26 libc/sysdeps/linux/sh/bits/fcntl.h | 2 --
27 libc/sysdeps/linux/sh64/bits/fcntl.h | 2 ++
28 libc/sysdeps/linux/sparc/bits/fcntl.h | 2 --
29 libc/sysdeps/linux/x86_64/bits/fcntl.h | 2 --
30 libc/sysdeps/linux/xtensa/bits/fcntl.h | 1 +
31 19 files changed, 21 insertions(+), 17 deletions(-)
33 diff --git a/libc/pwd_grp/lckpwdf.c b/libc/pwd_grp/lckpwdf.c
34 index 0b0fb47..aec6283 100644
35 --- a/libc/pwd_grp/lckpwdf.c
36 +++ b/libc/pwd_grp/lckpwdf.c
37 @@ -75,7 +75,7 @@ lckpwdf (void)
38 /* Prevent problems caused by multiple threads. */
39 __UCLIBC_MUTEX_LOCK(mylock);
41 - lock_fd = open (_PATH_PASSWD, O_WRONLY);
42 + lock_fd = open (_PATH_PASSWD, O_WRONLY | O_CLOEXEC);
44 /* Cannot create lock file. */
46 @@ -97,6 +97,12 @@ lckpwdf (void)
50 +#ifndef __ASSUME_O_CLOEXEC
51 + /* Make sure file gets correctly closed when process finished. */
52 + fcntl (lock_fd, F_SETFD, FD_CLOEXEC);
56 /* Now we have to get exclusive write access. Since multiple
57 process could try this we won't stop when it first fails.
58 Instead we set a timeout for the system call. Once the timer
59 diff --git a/libc/sysdeps/linux/alpha/bits/fcntl.h b/libc/sysdeps/linux/alpha/bits/fcntl.h
60 index 2a6b9ea..649c563 100644
61 --- a/libc/sysdeps/linux/alpha/bits/fcntl.h
62 +++ b/libc/sysdeps/linux/alpha/bits/fcntl.h
64 # define O_NOFOLLOW 0200000 /* Do not follow links. */
65 # define O_DIRECT 02000000 /* Direct disk access. */
66 # define O_NOATIME 04000000 /* Do not set atime. */
68 # define O_CLOEXEC 010000000 /* Set close_on_exec. */
72 #ifdef __USE_LARGEFILE64
73 diff --git a/libc/sysdeps/linux/arm/bits/fcntl.h b/libc/sysdeps/linux/arm/bits/fcntl.h
74 index 86cea4b..7cc5a9d 100644
75 --- a/libc/sysdeps/linux/arm/bits/fcntl.h
76 +++ b/libc/sysdeps/linux/arm/bits/fcntl.h
78 # define O_NOFOLLOW 0100000 /* Do not follow links. */
79 # define O_DIRECT 0200000 /* Direct disk access. */
80 # define O_NOATIME 01000000 /* Do not set atime. */
82 # define O_CLOEXEC 02000000 /* Set close_on_exec. */
86 /* For now Linux has synchronisity options for data and read operations.
87 diff --git a/libc/sysdeps/linux/avr32/bits/fcntl.h b/libc/sysdeps/linux/avr32/bits/fcntl.h
88 index 2301e22..767243e 100644
89 --- a/libc/sysdeps/linux/avr32/bits/fcntl.h
90 +++ b/libc/sysdeps/linux/avr32/bits/fcntl.h
92 # define O_DIRECTORY 00200000 /* direct disk access */
93 # define O_NOFOLLOW 00400000 /* don't follow links */
94 # define O_NOATIME 01000000 /* don't set atime */
95 +# define O_CLOEXEC 02000000 /* set close_on_exec */
98 #ifdef __USE_LARGEFILE64
99 diff --git a/libc/sysdeps/linux/bfin/bits/fcntl.h b/libc/sysdeps/linux/bfin/bits/fcntl.h
100 index 7d0bcf9..aabf94d 100644
101 --- a/libc/sysdeps/linux/bfin/bits/fcntl.h
102 +++ b/libc/sysdeps/linux/bfin/bits/fcntl.h
104 # define O_DIRECTORY 040000 /* Must be a directory. */
105 # define O_NOFOLLOW 0100000 /* Do not follow links. */
106 # define O_DIRECT 0200000 /* Direct disk access. */
107 +# define O_NOATIME 01000000 /* don't set atime */
108 +# define O_CLOEXEC 02000000 /* set close_on_exec */
111 /* For now Linux has synchronisity options for data and read operations.
112 diff --git a/libc/sysdeps/linux/cris/bits/fcntl.h b/libc/sysdeps/linux/cris/bits/fcntl.h
113 index a2106ef..29443ba 100644
114 --- a/libc/sysdeps/linux/cris/bits/fcntl.h
115 +++ b/libc/sysdeps/linux/cris/bits/fcntl.h
117 # define O_DIRECTORY 0200000 /* Must be a directory. */
118 # define O_NOFOLLOW 0400000 /* Do not follow links. */
119 # define O_NOATIME 01000000 /* Do not set atime. */
120 +# define O_CLOEXEC 02000000 /* set close_on_exec */
123 /* For now Linux has synchronisity options for data and read operations.
124 diff --git a/libc/sysdeps/linux/frv/bits/fcntl.h b/libc/sysdeps/linux/frv/bits/fcntl.h
125 index 06e8860..5bff4d3 100644
126 --- a/libc/sysdeps/linux/frv/bits/fcntl.h
127 +++ b/libc/sysdeps/linux/frv/bits/fcntl.h
129 # define O_DIRECT 040000 /* Direct disk access. */
130 # define O_DIRECTORY 0200000 /* Must be a directory. */
131 # define O_NOFOLLOW 0400000 /* Do not follow links. */
132 +# define O_NOATIME 01000000 /* don't set atime */
133 +# define O_CLOEXEC 02000000 /* set close_on_exec */
136 /* For now Linux has synchronisity options for data and read operations.
137 diff --git a/libc/sysdeps/linux/hppa/bits/fcntl.h b/libc/sysdeps/linux/hppa/bits/fcntl.h
138 index cc23bf8..86e3b6f 100644
139 --- a/libc/sysdeps/linux/hppa/bits/fcntl.h
140 +++ b/libc/sysdeps/linux/hppa/bits/fcntl.h
142 # define O_DIRECTORY 00010000 /* Must be a directory. */
143 # define O_NOFOLLOW 00000200 /* Do not follow links. */
144 # define O_NOATIME 04000000 /* Do not set atime. */
145 +# define O_CLOEXEC 010000000 /* set close_on_exec */
148 #ifdef __USE_LARGEFILE64
149 diff --git a/libc/sysdeps/linux/i386/bits/fcntl.h b/libc/sysdeps/linux/i386/bits/fcntl.h
150 index 7f0b552..22e073b 100644
151 --- a/libc/sysdeps/linux/i386/bits/fcntl.h
152 +++ b/libc/sysdeps/linux/i386/bits/fcntl.h
154 # define O_DIRECTORY 0200000 /* Must be a directory. */
155 # define O_NOFOLLOW 0400000 /* Do not follow links. */
156 # define O_NOATIME 01000000 /* Do not set atime. */
158 # define O_CLOEXEC 02000000 /* Set close_on_exec. */
162 /* For now Linux has synchronisity options for data and read operations.
163 diff --git a/libc/sysdeps/linux/ia64/bits/fcntl.h b/libc/sysdeps/linux/ia64/bits/fcntl.h
164 index d134c4b..85a55f6 100644
165 --- a/libc/sysdeps/linux/ia64/bits/fcntl.h
166 +++ b/libc/sysdeps/linux/ia64/bits/fcntl.h
168 # define O_DIRECTORY 0200000 /* must be a directory */
169 # define O_NOFOLLOW 0400000 /* don't follow links */
170 # define O_NOATIME 01000000 /* Do not set atime. */
172 # define O_CLOEXEC 02000000 /* Set close_on_exec. */
176 #ifdef __USE_LARGEFILE64
177 diff --git a/libc/sysdeps/linux/m68k/bits/fcntl.h b/libc/sysdeps/linux/m68k/bits/fcntl.h
178 index d36198d..e564b42 100644
179 --- a/libc/sysdeps/linux/m68k/bits/fcntl.h
180 +++ b/libc/sysdeps/linux/m68k/bits/fcntl.h
182 # define O_NOFOLLOW 0100000 /* Do not follow links. */
183 # define O_DIRECT 0200000 /* Direct disk access. */
184 # define O_NOATIME 01000000 /* Do not set atime. */
185 +# define O_CLOEXEC 02000000 /* set close_on_exec */
188 /* For now Linux has synchronisity options for data and read operations.
189 diff --git a/libc/sysdeps/linux/microblaze/bits/fcntl.h b/libc/sysdeps/linux/microblaze/bits/fcntl.h
190 index c8aeb91..da35209 100644
191 --- a/libc/sysdeps/linux/microblaze/bits/fcntl.h
192 +++ b/libc/sysdeps/linux/microblaze/bits/fcntl.h
194 # define O_DIRECTORY 040000 /* Must be a directory. */
195 # define O_NOFOLLOW 0100000 /* Do not follow links. */
196 # define O_DIRECT 0200000 /* Direct disk access. */
197 +# define O_NOATIME 01000000 /* Do not set atime. */
198 +# define O_CLOEXEC 02000000 /* set close_on_exec */
201 /* For now Linux has synchronisity options for data and read operations.
202 diff --git a/libc/sysdeps/linux/mips/bits/fcntl.h b/libc/sysdeps/linux/mips/bits/fcntl.h
203 index ef015a4..f0072fd 100644
204 --- a/libc/sysdeps/linux/mips/bits/fcntl.h
205 +++ b/libc/sysdeps/linux/mips/bits/fcntl.h
207 # define O_DIRECT 0x8000 /* Direct disk access hint. */
208 # define O_DIRECTORY 0x10000 /* Must be a directory. */
209 # define O_NOATIME 0x40000 /* Do not set atime. */
210 +# define O_CLOEXEC 02000000 /* set close_on_exec */
213 /* For now Linux has no synchronisity options for data and read operations.
214 diff --git a/libc/sysdeps/linux/powerpc/bits/fcntl.h b/libc/sysdeps/linux/powerpc/bits/fcntl.h
215 index ceb75b4..0759c6a 100644
216 --- a/libc/sysdeps/linux/powerpc/bits/fcntl.h
217 +++ b/libc/sysdeps/linux/powerpc/bits/fcntl.h
219 # define O_DIRECTORY 040000 /* Must be a directory. */
220 # define O_NOFOLLOW 0100000 /* Do not follow links. */
221 # define O_NOATIME 01000000 /* Do not set atime. */
223 # define O_CLOEXEC 02000000 /* Set close_on_exec. */
227 #ifdef __USE_LARGEFILE64
228 diff --git a/libc/sysdeps/linux/sh/bits/fcntl.h b/libc/sysdeps/linux/sh/bits/fcntl.h
229 index 570484c..adb7377 100644
230 --- a/libc/sysdeps/linux/sh/bits/fcntl.h
231 +++ b/libc/sysdeps/linux/sh/bits/fcntl.h
233 # define O_DIRECTORY 0200000 /* Must be a directory. */
234 # define O_NOFOLLOW 0400000 /* Do not follow links. */
235 # define O_NOATIME 01000000 /* Do not set atime. */
237 # define O_CLOEXEC 02000000 /* Set close_on_exec. */
241 /* For now Linux has synchronisity options for data and read operations.
242 diff --git a/libc/sysdeps/linux/sh64/bits/fcntl.h b/libc/sysdeps/linux/sh64/bits/fcntl.h
243 index 06e8860..245d35a 100644
244 --- a/libc/sysdeps/linux/sh64/bits/fcntl.h
245 +++ b/libc/sysdeps/linux/sh64/bits/fcntl.h
247 # define O_DIRECT 040000 /* Direct disk access. */
248 # define O_DIRECTORY 0200000 /* Must be a directory. */
249 # define O_NOFOLLOW 0400000 /* Do not follow links. */
250 +# define O_NOATIME 01000000 /* Do not set atime. */
251 +# define O_CLOEXEC 02000000 /* set close_on_exec */
254 /* For now Linux has synchronisity options for data and read operations.
255 diff --git a/libc/sysdeps/linux/sparc/bits/fcntl.h b/libc/sysdeps/linux/sparc/bits/fcntl.h
256 index 29c09a9..31a6d9b 100644
257 --- a/libc/sysdeps/linux/sparc/bits/fcntl.h
258 +++ b/libc/sysdeps/linux/sparc/bits/fcntl.h
260 # define O_NOFOLLOW 0x20000 /* don't follow links */
261 # define O_DIRECT 0x100000 /* direct disk access hint */
262 # define O_NOATIME 0x200000 /* Do not set atime. */
264 # define O_CLOEXEC 0x400000 /* Set close_on_exit. */
268 #ifdef __USE_LARGEFILE64
269 diff --git a/libc/sysdeps/linux/x86_64/bits/fcntl.h b/libc/sysdeps/linux/x86_64/bits/fcntl.h
270 index be00e4a..f1cf388 100644
271 --- a/libc/sysdeps/linux/x86_64/bits/fcntl.h
272 +++ b/libc/sysdeps/linux/x86_64/bits/fcntl.h
274 # define O_DIRECTORY 0200000 /* Must be a directory. */
275 # define O_NOFOLLOW 0400000 /* Do not follow links. */
276 # define O_NOATIME 01000000 /* Do not set atime. */
278 # define O_CLOEXEC 02000000 /* Set close_on_exec. */
282 /* For now Linux has synchronisity options for data and read operations.
283 diff --git a/libc/sysdeps/linux/xtensa/bits/fcntl.h b/libc/sysdeps/linux/xtensa/bits/fcntl.h
284 index a89362e..921a626 100644
285 --- a/libc/sysdeps/linux/xtensa/bits/fcntl.h
286 +++ b/libc/sysdeps/linux/xtensa/bits/fcntl.h
288 # define O_DIRECTORY 0200000 /* Must be a directory. */
289 # define O_NOFOLLOW 0400000 /* Do not follow links. */
290 # define O_NOATIME 01000000 /* Do not set atime. */
291 +# define O_CLOEXEC 02000000 /* set close_on_exec */
294 /* For now Linux has synchronisity options for data and read operations.