From patchwork Mon Jun 7 20:36:12 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: 43773 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 C36B93938C1F for ; Mon, 7 Jun 2021 20:53:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C36B93938C1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623099220; bh=7RoQsJx+qqwmHp0Zxere8hKpgWxHrb8SaqTvh7y4YWo=; 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=OuylMcV4S/WfYLegumPKtwUJkE78yRFgoT5oTB6w/EZThpWTMOYkfHUmlgI//Vdkj EkUhBPwjSk6Y3mSCeqGXonx5CyTbojiBBjZGdUn+ZauD6Q6dcFn7iGwMereUUMkWaT TraJz+TsyWreCEamJng/6KvzOzAS0O9GoaDemTvg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by sourceware.org (Postfix) with ESMTPS id F1E573939C01 for ; Mon, 7 Jun 2021 20:36:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F1E573939C01 Received: by mail-qk1-x735.google.com with SMTP id j189so18117690qkf.2 for ; Mon, 07 Jun 2021 13:36:57 -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=7RoQsJx+qqwmHp0Zxere8hKpgWxHrb8SaqTvh7y4YWo=; b=l5YNKHyW1NC8NAm+icPyq99rzJm9mQBtEMbtNLoC4opA6KpltwqcQKQGHB5uMi9fhb CdjWI9rhgnRCO35hIrET5Wv1xQNFG6T2x7MHDuY06rlAgu5QmcszIrTVQSej2nc8mZoL 07E/utBQWGfx4RgCPQcbs2AymIjnXpkb6ofSWPsRZj0SyclI7Fi1a/sAoLqwvo6y1KSw R+xFDZdoUKb1x2cW9+HvlBZgORs14pfuNLpBVEALYi8Bd1DYua4hl+aaBLHTaeWRNMsS g03GCMpmK/PksSks+CZt6tpOAnek+M+YUEfiivQpuNAzXSKkDzSuCoyqsHMtajXtdRmn +N5Q== X-Gm-Message-State: AOAM531qbOlVfCVJOWc2PbTRvZ5+iKwcAW4DCcYSuKqC97xwfa09jPDo m4BBOOgpIs2q3r7QSfmgdj1w43edt24I7Q== X-Google-Smtp-Source: ABdhPJynhCm9V0h8ornjC5R9d6m6Q5AhZ0R8FXKETfNUjHOSJ2/4VNWQgCarPA8O7EMm0Ot039L2Ig== X-Received: by 2002:a05:620a:2941:: with SMTP id n1mr18260240qkp.330.1623098217346; Mon, 07 Jun 2021 13:36:57 -0700 (PDT) Received: from birita.. ([177.194.59.218]) by smtp.googlemail.com with ESMTPSA id t196sm10422123qke.50.2021.06.07.13.36.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 13:36:57 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v3 23/24] libsupport: Add 64-bit time_t support for stat functions Date: Mon, 7 Jun 2021 17:36:12 -0300 Message-Id: <20210607203613.282543-24-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210607203613.282543-1-adhemerval.zanella@linaro.org> References: <20210607203613.282543-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" The patch adds redirections for xstat, xlstat, and xfstat when _TIME_BITS=64 is defined. Reviewed-by: Lukasz Majewski Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell --- 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 e27b9b164e..f3ebaa8d2e 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);