From patchwork Sun Apr 6 12:37:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Naour X-Patchwork-Id: 337261 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id 895671400E3 for ; Sun, 6 Apr 2014 22:37:51 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id A9EAE31D7A; Sun, 6 Apr 2014 12:37:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DPTHo0cq5V1H; Sun, 6 Apr 2014 12:37:48 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 0766B30685; Sun, 6 Apr 2014 12:37:48 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 029531BF95D for ; Sun, 6 Apr 2014 12:37:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id F1BDA89100 for ; Sun, 6 Apr 2014 12:37:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zm9LLxZ-ZDXM for ; Sun, 6 Apr 2014 12:37:45 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from smtp3-g21.free.fr (smtp3-g21.free.fr [212.27.42.3]) by hemlock.osuosl.org (Postfix) with ESMTP id 55E59890F8 for ; Sun, 6 Apr 2014 12:37:43 +0000 (UTC) Received: from localhost.localdomain (unknown [81.57.22.125]) by smtp3-g21.free.fr (Postfix) with ESMTP id 75D06A60F5; Sun, 6 Apr 2014 14:37:38 +0200 (CEST) From: Romain Naour To: buildroot@buildroot.org Date: Sun, 6 Apr 2014 14:37:33 +0200 Message-Id: <1396787854-29725-1-git-send-email-romain.naour@openwide.fr> X-Mailer: git-send-email 1.9.0 Subject: [Buildroot] [PATCH v2 1/2] util-linux: add a check for mkostemp() X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net mkostemp() is missing with older version of uClibc (uClibc <= 0.9.33). So, we need to check if mkostemp() is available. If not, we use a wrapper function based on mkstemp() to implement it. Since util-linux v2.23, mkostemp() is called with O_CLOEXEC flag. If we use a define to mkstemp() to implement mkostemp(), flags will be discared. mkstemp() will pass O_RDWR|O_CREAT|O_EXCL, but not O_CLOEXEC, which means that the file descriptor will no longer be closed automatically upon exec(). To avoid to discard the flags, we add a call to fcntl() to set O_CLOEXEC flag just after mkstemp(). Signed-off-by: Romain Naour --- v2: add a check for mkostemp() instead of using a define for uClibc case. (ThomasP) ...fine-mkostemp-for-older-version-of-uClibc.patch | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 package/util-linux/util-linux-004-c.h-define-mkostemp-for-older-version-of-uClibc.patch diff --git a/package/util-linux/util-linux-004-c.h-define-mkostemp-for-older-version-of-uClibc.patch b/package/util-linux/util-linux-004-c.h-define-mkostemp-for-older-version-of-uClibc.patch new file mode 100644 index 0000000..0dfe7be --- /dev/null +++ b/package/util-linux/util-linux-004-c.h-define-mkostemp-for-older-version-of-uClibc.patch @@ -0,0 +1,50 @@ +From 42a84250fc78bae3e885ecd1379e713663fe6487 Mon Sep 17 00:00:00 2001 +From: Romain Naour +Date: Sun, 6 Apr 2014 12:12:41 +0200 +Subject: [PATCH 1/1] c.h: define mkostemp for older version of uClibc + +Signed-off-by: Romain Naour +--- + configure.ac | 2 ++ + include/c.h | 14 ++++++++++++++ + 2 files changed, 16 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 35a1f26..a9b8d34 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -321,6 +321,8 @@ AC_CHECK_FUNCS([ \ + ]) + AC_FUNC_FSEEKO + ++AC_CHECK_FUNCS([mkostemp]) ++ + AC_CHECK_FUNCS([openat fstatat unlinkat], [have_openat=yes], [have_openat=no]) + AC_CHECK_FUNCS([ioperm iopl], [have_io=yes]) + +diff --git a/include/c.h b/include/c.h +index 4a9bf3d..1b880ed 100644 +--- a/include/c.h ++++ b/include/c.h +@@ -300,4 +300,18 @@ static inline int usleep(useconds_t usec) + # define SEEK_HOLE 4 + #endif + ++/* ++ * mkostemp() may be missing with older version of uClibc ++ */ ++#ifndef HAVE_MKOSTEMP ++static inline int mkostemp(char *template, int flags) ++{ ++ int fd; ++ fd = mkstemp(template); ++ if (flags & O_CLOEXEC && fd >= 0) ++ fcntl(fd, F_SETFD, FD_CLOEXEC); ++ return fd; ++} ++#endif ++ + #endif /* UTIL_LINUX_C_H */ +-- +1.9.0 +