From patchwork Wed Oct 31 11:09:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 991343 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=datacom.com.br Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42lQbf3BQHz9rxp for ; Wed, 31 Oct 2018 22:10:06 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 5ED0C23FD1; Wed, 31 Oct 2018 11:10:04 +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 nOo0ImKCBDw6; Wed, 31 Oct 2018 11:10:03 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 0A44F22839; Wed, 31 Oct 2018 11:10:03 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 078591BF2A3 for ; Wed, 31 Oct 2018 11:10:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 040CF23543 for ; Wed, 31 Oct 2018 11:10:02 +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 yvIZfs24KAsx for ; Wed, 31 Oct 2018 11:09:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.datacom.com.br (mx.datacom.ind.br [177.66.5.10]) by silver.osuosl.org (Postfix) with ESMTPS id 59FAF21563 for ; Wed, 31 Oct 2018 11:09:56 +0000 (UTC) Received: from mail.datacom.com.br (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTPS id C9C271BA0A14; Wed, 31 Oct 2018 08:10:18 -0300 (-03) Received: from localhost (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTP id B89C41BA09F9; Wed, 31 Oct 2018 08:10:18 -0300 (-03) Received: from mail.datacom.com.br ([127.0.0.1]) by localhost (mail.datacom.com.br [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 9kvjg0YXIPsU; Wed, 31 Oct 2018 08:10:18 -0300 (-03) Received: from pedeld202344.datacom.net (pedeld202344.datacom.net [10.0.120.87]) by mail.datacom.com.br (Postfix) with ESMTPSA id 9C1C41BA070A; Wed, 31 Oct 2018 08:10:18 -0300 (-03) From: Carlos Santos To: buildroot@buildroot.org Date: Wed, 31 Oct 2018 08:09:48 -0300 Message-Id: <20181031110948.6791-1-casantos@datacom.com.br> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20181031051918.6obvzpncii5dl3lx@sapphire.tkos.co.il> References: <20181031051918.6obvzpncii5dl3lx@sapphire.tkos.co.il> Subject: [Buildroot] [PATCH v2] uclibc: fix mkostemp X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 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" Pull a patch already submitted upstream[1] that fixes mkostemp when _LARGEFILE64_SOURCE is defined. This is required to prevent failures on eudev[2]: # udevadm hwdb --update Failure writing database //etc/udev/hwdb.bin: Invalid argument 1. https://patchwork.ozlabs.org/patch/990045/ 2. https://patchwork.ozlabs.org/patch/984848/ Signed-off-by: Carlos Santos --- Changes v1->v2: - Fix commit message error reported by Baruch Siach. - Improve example. --- Test: $ cat test.c #include #include #include #include #include #include #include void fatal(int n) { fprintf(stderr, "fatal[%d]: %s\n", n, strerror(errno)); exit(1); } int main(int argc, char *argv[]) { FILE *f; int cur_mode; char template[64]; strncpy(template, argc > 1 ? argv[1] : "testXXXXXX", 63); umask(077); printf("main[1]: %s, %07o\n", template, O_WRONLY|O_CLOEXEC); int fd = mkostemp(template, O_WRONLY|O_CLOEXEC); if (fd < 0) { fatal(1); } cur_mode = fcntl(fd, F_GETFL); printf("main[2]: %s, %07o\n", template, cur_mode); printf("main[3]: %d, %s\n", fd, "we"); f = fdopen(fd, "we"); if (!f) { fatal(2); } if (fclose(f) == EOF) { fatal(3); } return 0; } $ x86_64-buildroot-linux-uclibc-cc -Wall -Werror -D_GNU_SOURCE \ -o mkostemp-test test.c $ x86_64-buildroot-linux-uclibc-cc -Wall -Werror -D_GNU_SOURCE \ -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 \ -o mkostemp-test-large test.c [ copy executables to target device (qemu, in this case) ] Without patch: # mkostemp-test main[1]: testXXXXXX, 2000001 random: fast init done main[2]: testIPn9UR, 0100002 main[3]: 3, we # mkostemp-test-large main[1]: testXXXXXX, 2000001 main[2]: testiXRydb, 0100003 main[3]: 3, we fatal[2]: Invalid argument With patch: # mkostemp-test main[1]: testXXXXXX, 2000001 main[2]: testcVhbXs, 0100002 main[3]: 3, we # mkostemp-test-large main[1]: testXXXXXX, 2000001 main[2]: testDAulBF, 0100002 main[3]: 3, we --- Change-Id: Iaf8c39a6e3e28bd6ee881ed692e297bfc9d7cfdb --- ...4-mkostemp64-clear-flags-as-mkostemp-does.patch | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 package/uclibc/0004-mkostemp64-clear-flags-as-mkostemp-does.patch diff --git a/package/uclibc/0004-mkostemp64-clear-flags-as-mkostemp-does.patch b/package/uclibc/0004-mkostemp64-clear-flags-as-mkostemp-does.patch new file mode 100644 index 0000000000..f87abd8849 --- /dev/null +++ b/package/uclibc/0004-mkostemp64-clear-flags-as-mkostemp-does.patch @@ -0,0 +1,38 @@ +From 09a776103e4aa75f95c9ad44554a9c2b56de3535 Mon Sep 17 00:00:00 2001 +From: Carlos Santos +Date: Mon, 29 Oct 2018 01:17:38 -0300 +Subject: [PATCH] mkostemp64: clear flags, as mkostemp does + +This should have been made in commit 9649721950 but was forgotten. + +Signed-off-by: Carlos Santos +--- + libc/stdlib/mkostemp64.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/libc/stdlib/mkostemp64.c b/libc/stdlib/mkostemp64.c +index aa9736cd6..f4674bb0c 100644 +--- a/libc/stdlib/mkostemp64.c ++++ b/libc/stdlib/mkostemp64.c +@@ -15,9 +15,9 @@ + License along with the GNU C Library; if not, see + . */ + +-#include + #include + #include ++#include + #include "../misc/internals/tempname.h" + + /* Generate a unique temporary file name from TEMPLATE. +@@ -27,6 +27,7 @@ + int + mkostemp64 (char *template, int flags) + { ++ flags -= flags & O_ACCMODE; /* Remove O_RDONLY, O_WRONLY, and O_RDWR. */ + return __gen_tempname (template, __GT_BIGFILE, flags | O_LARGEFILE, 0, + S_IRUSR | S_IWUSR); + } +-- +2.14.5 +