From patchwork Fri Mar 5 20:15:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 42324 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C9FC839A5C07; Fri, 5 Mar 2021 20:16:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C9FC839A5C07 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614975379; bh=VwkbMVjbD+11R3Lj7wG4B0tP48R4jfT9Y32wDGEc6vE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=jUQ6DCBfD3hKaZwZIXRyqyl5+h9XIeC9yuhzoo430gGupi2z6+HwR+76LsdjVaWNU +49pE2yDGbRvkYA4Mo8+tjxso1ingafG6tpijEftyHC7GHdmauusaA00+olBq7OZca JGPgL3zGfFqQp0xMi2HlkVJKFwafAdJA8S+bcbrw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by sourceware.org (Postfix) with ESMTPS id ABA7E399F023 for ; Fri, 5 Mar 2021 20:16:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ABA7E399F023 Received: by mail-qk1-x72f.google.com with SMTP id a9so3245136qkn.13 for ; Fri, 05 Mar 2021 12:16:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VwkbMVjbD+11R3Lj7wG4B0tP48R4jfT9Y32wDGEc6vE=; b=DRi+fAHvab8rJl1K5zXpHq2s5dNLTZ0XC7seqWykOLnlPAc0vI0kua9X6wUq8I6OBX Chyhtz2gB9l6Jd8u3VyCk53ytSKkTGzL7Gl9PACrV6ZBwqHP/qar6K3kkswmh94KpluQ AouB8f2ZIzgnqK6Ud6330soiStR4Rmx4aA8U5P/kXthjEK6jzbj4Oj7Q3sSLbZ4nLkOD Gu8gAQBaKO7/RQxdX6LMeqT13H2davvPf1pogYd/VmU7nTVGdGCfY3n7r5KaGy9Qfviz tTB/MhaRUqyU9/L0vHnishSyOG1ok4OxMdwsK7TB8OT61C5VVBBdHHCes85Y34X55YxH jS5g== X-Gm-Message-State: AOAM530dlwthpHm6Yweu7VEuiYDser7xAEhZshSvZUaIJ7PT0kx+gAAP vcsqUrpqQoLR3hRI+EmJ19gM7Ufjh9sQJg== X-Google-Smtp-Source: ABdhPJwL8ZWL2xy537jHVbOpXhotM1vw+O9oZY253rx6/K+R5Gd4d5pEJRnRH49uR6nGGdNGUn2EkA== X-Received: by 2002:a05:620a:4504:: with SMTP id t4mr10709662qkp.369.1614975375019; Fri, 05 Mar 2021 12:16:15 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id c5sm2526145qkl.21.2021.03.05.12.16.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Mar 2021 12:16:14 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 43/52] libsupport: Add 64 bit time_t support for stat functions Date: Fri, 5 Mar 2021 17:15:09 -0300 Message-Id: <20210305201518.798584-44-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210305201518.798584-1-adhemerval.zanella@linaro.org> References: <20210305201518.798584-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" 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 846e0dbb26..6f696c70be 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 \ @@ -111,6 +113,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);