[klibc] [klibc:master] Remove open_cloexec()
klibc-bot for H. Peter Anvin
hpa at linux.intel.com
Fri Jan 15 11:33:04 PST 2016
Commit-ID: 26e26f48cf9255c44514b8d36e351ecf3c6260b2
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=26e26f48cf9255c44514b8d36e351ecf3c6260b2
Author: H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Fri, 15 Jan 2016 11:30:01 -0800
Committer: H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Fri, 15 Jan 2016 11:30:01 -0800
[klibc] Remove open_cloexec()
The kernel now (since 2.6.23) allows O_CLOEXEC to be passed directly
to open(), so there is no reason to have open_cloexec() anymore.
Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>
---
usr/include/unistd.h | 1 -
usr/kinit/initrd.c | 4 ++--
usr/klibc/Kbuild | 2 +-
usr/klibc/open_cloexec.c | 18 ------------------
usr/klibc/shm_open.c | 2 +-
5 files changed, 4 insertions(+), 23 deletions(-)
diff --git a/usr/include/unistd.h b/usr/include/unistd.h
index 6c08d4e..0e26f5e 100644
--- a/usr/include/unistd.h
+++ b/usr/include/unistd.h
@@ -90,7 +90,6 @@ __extern int open(const char *, int, ...);
__extern int openat(int, const char *, int, ...);
#endif
__extern int creat(const char *, mode_t);
-__extern int open_cloexec(const char *, int, mode_t);
__extern int close(int);
__extern off_t lseek(int, off_t, int);
/* off_t is 64 bits now even on 32-bit platforms; see llseek.c */
diff --git a/usr/kinit/initrd.c b/usr/kinit/initrd.c
index d2efc59..7eece2c 100644
--- a/usr/kinit/initrd.c
+++ b/usr/kinit/initrd.c
@@ -103,8 +103,8 @@ static int run_linuxrc(int argc, char *argv[], dev_t root_dev)
fclose(fp);
mkdir("/old", 0700);
- root_fd = open_cloexec("/", O_RDONLY | O_DIRECTORY, 0);
- old_fd = open_cloexec("/old", O_RDONLY | O_DIRECTORY, 0);
+ root_fd = open("/", O_RDONLY|O_DIRECTORY|O_CLOEXEC, 0);
+ old_fd = open("/old", O_RDONLY|O_DIRECTORY|O_CLOEXEC, 0);
if (root_fd < 0 || old_fd < 0)
return -errno;
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index f797166..a0e440d 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -27,7 +27,7 @@ klib-y += vsnprintf.o snprintf.o vsprintf.o sprintf.o \
setpgrp.o getpgrp.o daemon.o \
printf.o vprintf.o fprintf.o vfprintf.o perror.o \
statfs.o fstatfs.o umount.o \
- creat.o open.o openat.o open_cloexec.o \
+ creat.o open.o openat.o \
fread2.o fwrite2.o fgets.o fputc.o fputs.o puts.o putchar.o \
sleep.o usleep.o strtotimespec.o strtotimeval.o \
raise.o abort.o assert.o alarm.o pause.o \
diff --git a/usr/klibc/open_cloexec.c b/usr/klibc/open_cloexec.c
deleted file mode 100644
index e30b09d..0000000
--- a/usr/klibc/open_cloexec.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * open_cloexec.c
- *
- * A quick hack to do an open() and set the cloexec flag
- */
-
-#include <unistd.h>
-#include <fcntl.h>
-
-int open_cloexec(const char *path, int flags, mode_t mode)
-{
- int fd = open(path, flags, mode);
-
- if (fd >= 0)
- fcntl(fd, F_SETFD, FD_CLOEXEC);
-
- return fd;
-}
diff --git a/usr/klibc/shm_open.c b/usr/klibc/shm_open.c
index 8fe93aa..a54e246 100644
--- a/usr/klibc/shm_open.c
+++ b/usr/klibc/shm_open.c
@@ -19,5 +19,5 @@ int shm_open(const char *path, int oflag, mode_t mode)
memcpy(pathbuf, "/dev/shm/", 9);
memcpy(pathbuf+9, path, len+1);
- return open_cloexec(path, oflag, mode);
+ return open(path, oflag, mode|O_CLOEXEC);
}
More information about the klibc
mailing list