From patchwork Mon Oct 21 15:46:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 35200 Received: (qmail 90188 invoked by alias); 21 Oct 2019 15:51:29 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 90180 invoked by uid 89); 21 Oct 2019 15:51:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT autolearn=ham version=3.3.1 spammy=brackets, HContent-Transfer-Encoding:8bit X-HELO: esa4.hgst.iphmx.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1571673087; x=1603209087; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=3cRUakfHLPgBVB1Ux70ozgOpEwMdUrTSEqklXFkZk5o=; b=EkuY1lMrvfP8SzbGBU+f2GfOocfb6ENsFMjjezXCyeqtL2a/ifcSwU2i lhQNRZby7PBQMzE1UEoxj7/b20BsFUmql8HazdNz0VxDpxoN6gXk2mZOA UJkCx0vD7/Z5KztdsPubq7iCoZti66iUNaJ35MdysnSi97gXrzBpZULdo kE55dkndt8hTz1EisasRnpFqlVAz3tEaAYlxuc/PUwacg8jyXjW0Nuns2 qXoRywdGIRlJ0BtftYBvhSkPa8e17zhufUDwxBG8AsLjqVBEE5JaC9QEb qTsXC7bkrT63XhCN0L+MCNAm31XLc7NnVkFGFHNmzTmkp9bs25qy2kwx6 A==; IronPort-SDR: Rdtwe+j4CXRL7JLF1qkb5H9u6jRAmGllnPwh1Jb14IAG+pdgZZSzn2Y5AYMbkNNA1SS9qceIXO 2EHE8lyTKafYrUjmnY7R08pF8lxlPiK+DMVzeHS8ciJAagflcrA02eK08UJk7P5WhjszpfTpyk J/sS8PS+rpweofujcBWtoEjEReG28RmSGFTIaADDBAGtdPfQBiOo7im31lm3l7IhS8KEJrwlns 27nJnLkSs8fMY4h/D49gj5x1ZkIT3Vg2WuoPNta/mH7u2B/VxfXybPaZ4zgEjW7XfUkMAYgR5G QzM= IronPort-SDR: QbplbW0H0znVTde6t6LRJyX1bHFKPFzeo+kxqGSV2/2iTKAlnfTAzS7h1ffj260KLtu/g8/IO6 VUTw1hkoFyEg5POt1w7mt9hTHDBrZkvYpf9UD6axN32wy6bvnf218yyYDW2NQclu/Xldg100Jw lhHmtPkRhes+0zZKBddDJN3FimogBQfPyBplqPIDyQCbkAuyOFqMZtFfTUNCiBaCZ25nLm8Xw9 JaVZ7C6I8kKEG50AVgl2uH40yxXCFxpR9AMqAVzvnoCQ0HFT7yVpUTgEns//IMC6LYQMM6U2Pf OiRMxHV2qNef8jfmXjI2Ueqy IronPort-SDR: JTDvLKRmWth5yvVk+6zfbN+iVbVEcIyjawdZwPlHXT/EZfDGn3/E68HJ3iEl+PNjGwzdZlShxs +m4MimXYbHDdcjB3hF90r/dLpO/XXCiv4gb+SoD9zYA7U3gtZ9vOh085xszZdWUDyOU6WeRXYf EX2XvPx89ZWMMLCBacE8n4oprsMi4R+W22XzGT6y7/FgfE9OvC9vZQg3+U3QZZ0DTLfIIf7Cvp BLufX20qh3dzQSMldTt5IRSDUi55OdlUT0IfmRZRebqlmyPw+V2yyzYbzw/zd/uZvJg/OCdVP0 irA= WDCIronportException: Internal From: Alistair Francis To: libc-alpha@sourceware.org Cc: alistair23@gmail.com, Alistair Francis Subject: [PATCH v5 1/2] sysdeps/stat: Handle 64-bit ino_t types on 32-bit hosts Date: Mon, 21 Oct 2019 08:46:26 -0700 Message-Id: <20191021154627.23713-1-alistair.francis@wdc.com> MIME-Version: 1.0 On a 32-bit platform with a 64-bit ino_t type (__INO_T_MATCHES_INO64_T defined) we want to update the stat struct to remove the padding as it isn't required. As we don't have the padding we also need to update the overflow checker to not access the undefined members. --- This change was tested by running user space tests for RV32 and RV64. v4: - Move the assert to: sysdeps/unix/sysv/linux/generic/stat-check.c - Add a comment around the assert v3: - Don't use brackets around the defined v2: - Change to if defined instead of if == 1 sysdeps/unix/sysv/linux/generic/bits/stat.h | 5 +++- sysdeps/unix/sysv/linux/generic/stat-check.c | 29 +++++++++++++++++++ .../sysv/linux/generic/wordsize-32/overflow.h | 4 +++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 sysdeps/unix/sysv/linux/generic/stat-check.c diff --git a/sysdeps/unix/sysv/linux/generic/bits/stat.h b/sysdeps/unix/sysv/linux/generic/bits/stat.h index 1565f3f8248..34c455ed786 100644 --- a/sysdeps/unix/sysv/linux/generic/bits/stat.h +++ b/sysdeps/unix/sysv/linux/generic/bits/stat.h @@ -42,7 +42,10 @@ #if defined __USE_FILE_OFFSET64 # define __field64(type, type64, name) type64 name -#elif __WORDSIZE == 64 +#elif __WORDSIZE == 64 || defined __INO_T_MATCHES_INO64_T +# if defined __INO_T_MATCHES_INO64_T && !defined __OFF_T_MATCHES_OFF64_T +# error "ino_t and off_t must both be the same type" +# endif # define __field64(type, type64, name) type name #elif __BYTE_ORDER == __LITTLE_ENDIAN # define __field64(type, type64, name) \ diff --git a/sysdeps/unix/sysv/linux/generic/stat-check.c b/sysdeps/unix/sysv/linux/generic/stat-check.c new file mode 100644 index 00000000000..5bc80c7fc6f --- /dev/null +++ b/sysdeps/unix/sysv/linux/generic/stat-check.c @@ -0,0 +1,29 @@ +/* Copyright (C) 2011-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Alistair Francis 2019 + + 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 + . */ + +#include +#include + +/* This is due to the layout code in bits/stat.h and the overflow handling in + wordsize-32/overflow.h, requiring either all or none of the three types + concerned to have padding. */ + +#if __INO_T_MATCHES_INO64_T +_Static_assert (sizeof (__blkcnt_t) == sizeof (__blkcnt64_t), + "__blkcnt_t and __blkcnt64_t must match"); +#endif diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h index 45efcd8fd34..66546b07ccd 100644 --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h @@ -36,12 +36,16 @@ static inline off_t lseek_overflow (loff_t res) static inline int stat_overflow (struct stat *buf) { +#if defined __INO_T_MATCHES_INO64_T + return 0; +#else if (buf->__st_ino_pad == 0 && buf->__st_size_pad == 0 && buf->__st_blocks_pad == 0) return 0; __set_errno (EOVERFLOW); return -1; +#endif } /* Note that f_files and f_ffree may validly be a sign-extended -1. */