From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by sourceware.org (Postfix) with ESMTPS id C0726396C812 for ; Tue, 18 May 2021 20:56:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C0726396C812 Received: by mail-qk1-x72a.google.com with SMTP id i67so10725552qkc.4 for ; Tue, 18 May 2021 13:56:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EAl0AkPemUIfjeUbuGK2doHk6d4vuVlalwW24JYW8+M=; b=PUiKl2a1B4brHijnQXZuXyrmIfZZ9ZzRzjQbhHR+MnGffw9uyAjt/SnAfKzTHuHJVt JWO0Cg2sn4CbI070WjF1g+6Ige89zH3stbMPxaA91ZAaagJloq+tsNJ/ZMH59N++Puu9 StUw0ki44myAg7M2j+qvRAdfPzD2NA+c9eC0VtAH8UN8sYX27mPYGil6d/yJ6mrKYSqc Ts1xX1o4AonLdVVRdpn+XpUkMTewaoy3vpLNzru0z0YYMWG5m9TBojMCdBnBpB4+acLe mH9SE4tGOJmx4RvWan7AddS+wS6kjxAt0WVqhgHzryKgwqJXQyYUxV5SFSC83LZijXYo oSFA== X-Gm-Message-State: AOAM5327zo4vcbqztc5BHuuRopUKHCDmuqC64QH/+vmuF7d1HXovPZQ0 f3sGQbaJ1jBiZaC9IqnEK1NVR4GBOn9kWQ== X-Google-Smtp-Source: ABdhPJwgtoAdh8vX1tW1uaHKRJvLrrYq1+CAbYjY0/aoRRzvNtiM0nH/JMjH0PZ5ehxFK4BVRGLOkQ== X-Received: by 2002:a05:620a:13a8:: with SMTP id m8mr7351949qki.213.1621371415103; Tue, 18 May 2021 13:56:55 -0700 (PDT) Received: from birita.. ([177.194.37.86]) by smtp.googlemail.com with ESMTPSA id o26sm13649937qkm.4.2021.05.18.13.56.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 13:56:54 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 24/25] libsupport: Add 64 bit time_t support for stat functions Date: Tue, 18 May 2021 17:56:12 -0300 Message-Id: <20210518205613.1487824-25-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210518205613.1487824-1-adhemerval.zanella@linaro.org> References: <20210518205613.1487824-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 20:56:57 -0000 The patch adds redirections for xstat, xlstat, and xfstat when _TIME_BITS=64 is defined. --- support/Makefile | 3 +++ support/support-xfstat-time64.c | 32 ++++++++++++++++++++++++++++++++ support/support-xstat-time64.c | 32 ++++++++++++++++++++++++++++++++ support/xlstat-time64.c | 32 ++++++++++++++++++++++++++++++++ support/xunistd.h | 13 +++++++++++++ 5 files changed, 112 insertions(+) create mode 100644 support/support-xfstat-time64.c create mode 100644 support/support-xstat-time64.c create mode 100644 support/xlstat-time64.c diff --git a/support/Makefile b/support/Makefile index 1ee73f81bc..8b8534a3c6 100644 --- a/support/Makefile +++ b/support/Makefile @@ -40,7 +40,9 @@ libsupport-routines = \ resolv_test \ set_fortify_handler \ support-xfstat \ + support-xfstat-time64 \ support-xstat \ + support-xstat-time64 \ support_become_root \ support_can_chroot \ support_capture_subprocess \ @@ -117,6 +119,7 @@ libsupport-routines = \ xlisten \ xlseek \ xlstat \ + xlstat-time64 \ xmalloc \ xmemstream \ xmkdir \ diff --git a/support/support-xfstat-time64.c b/support/support-xfstat-time64.c new file mode 100644 index 0000000000..324c5d20d2 --- /dev/null +++ b/support/support-xfstat-time64.c @@ -0,0 +1,32 @@ +/* 64-bit time_t stat with error checking. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* NB: Non-standard file name to avoid sysdeps override for xstat. */ + +#include +#include +#include + +#if __TIMESIZE != 64 +void +xfstat_time64 (int fd, struct __stat64_t64 *result) +{ + if (__fstat64_time64 (fd, result) != 0) + FAIL_EXIT1 ("__fstat64_time64 (%d): %m", fd); +} +#endif diff --git a/support/support-xstat-time64.c b/support/support-xstat-time64.c new file mode 100644 index 0000000000..7d0194b98a --- /dev/null +++ b/support/support-xstat-time64.c @@ -0,0 +1,32 @@ +/* 64-bit time_t stat with error checking. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* NB: Non-standard file name to avoid sysdeps override for xstat. */ + +#include +#include +#include + +#if __TIMESIZE != 64 +void +xstat_time64 (const char *path, struct __stat64_t64 *result) +{ + if (__stat64_time64 (path, result) != 0) + FAIL_EXIT1 ("__stat64_time64 (\"%s\"): %m", path); +} +#endif diff --git a/support/xlstat-time64.c b/support/xlstat-time64.c new file mode 100644 index 0000000000..ef4d922635 --- /dev/null +++ b/support/xlstat-time64.c @@ -0,0 +1,32 @@ +/* 64-bit time_t stat with error checking. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* NB: Non-standard file name to avoid sysdeps override for xstat. */ + +#include +#include +#include + +#if __TIMESIZE != 64 +void +xlstat_time64 (const char *path, struct __stat64_t64 *result) +{ + if (__lstat64_time64 (path, result) != 0) + FAIL_EXIT1 ("__lstat64_time64 (\"%s\"): %m", path); +} +#endif diff --git a/support/xunistd.h b/support/xunistd.h index c642588c29..e4ade65c85 100644 --- a/support/xunistd.h +++ b/support/xunistd.h @@ -24,6 +24,7 @@ #include #include +#include #include __BEGIN_DECLS @@ -35,9 +36,21 @@ pid_t xwaitpid (pid_t, int *status, int flags); void xpipe (int[2]); void xdup2 (int, int); int xopen (const char *path, int flags, mode_t); +#ifndef __USE_TIME_BITS64 +# ifdef __USE_FILE_OFFSET64 +void xstat (const char *path, struct stat *); +void xlstat (const char *path, struct stat *); +void xfstat (int fd, struct stat *); +# else void xstat (const char *path, struct stat64 *); void xlstat (const char *path, struct stat64 *); void xfstat (int fd, struct stat64 *); +# endif +#else +void __REDIRECT (xstat, (const char *path, struct stat *), xstat_time64); +void __REDIRECT (xlstat, (const char *path, struct stat *), xlstat_time64); +void __REDIRECT (xfstat, (int fd, struct stat *), xfstat_time64); +#endif void xmkdir (const char *path, mode_t); void xchroot (const char *path); void xunlink (const char *path); -- 2.30.2