From patchwork Wed Oct 16 23:44:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 35075 Received: (qmail 4818 invoked by alias); 16 Oct 2019 23:48:55 -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 4804 invoked by uid 89); 16 Oct 2019 23:48:54 -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 autolearn=ham version=3.3.1 spammy=vers, 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=1571269733; x=1602805733; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=kdGPlkHpBBAWnZn4qDE0urpFR9v0U0XjBDQFyVxCryk=; b=hoFjMsqK7TX3nEH/HYcZEOagLIM+m2Wz5HqtwWHpIG+6s3U82hKgVLAy yhT2RtOyQ3qlpAS2Ozg4d4ptWuATHIgSfxTj1yWlsCrvxD04aQL/INqL/ HhhNgWVKVyP84FTbvtadyFLuYPSW30Mw9xxH7PzhzMlgTK1rdt3Fwdezl euhr2Qv8FWvtxwy3yzssvLsV2sDJEQ7UlyGlI7bz+ZtXmUsEmT2ccECxN wEIom1YtebxY5h1Px52rJ0HuDk0tKzYG6eIqQ4eEIMmcxbl2DX5ZMk/Wu fniETMIpRIpP+QlCsIQgyok8WFugENXdwlsiOY/HyPG2XU9H7gOAeN9R3 g==; IronPort-SDR: Ncb16topTn4Vb1E2bJlPRJgYfkQYMhVY0GbbBDE4jPvu8hs4txGv/0+Aa/oQ9/h/U+QARdXJW4 Xjyiw+wwzkmljjYzJIvrHPOqLDXAFkuNiThwPSiBwEgaW6aywqsOx2lQ4mI+pNwgqq6Uo7IRPg UDU4Y3BeOfYlWj+GnFCzP4S+zr86GDt4hS4Svdrlj+dD1qH2OZx5yVm3teuVmgq7zHs7Y0fwdE ZcncXQPPI4LpV7SBzGCxRqKTyaTYRasBakXYwjBuA9AjU0kkbY76eKxUzas/PyuYnSECz4Pgi5 2to= IronPort-SDR: qSlDkX/8iWAZ8o1D0i9+Bs4sSWUQG03Zjlb/cHhmf2PLcccv+6GpWQX1QXXViI0hZ/yr+yoyl7 xpb08cNNrmZKvM89cyIxZUMPbyap7Nc085VA6TKyhy5atL+n9nGFVyNU0R6gJMGM7b3hjF03g+ O+uI10rJxI2FdRpHA1SMjHoPFgjlmAcvMHDfVSFDvsmBRfO1R4S187YtUdN/yOYhJVLU9ydxU3 UFEFbcvJpc+aHNEo3gdyrvBPPnp+07BTNoOPn78T954A6bn5InZzVgTVEJ//vxEDOJty5rk1Oq 0AAdSm0sLoAahzSwku4z/TU2 IronPort-SDR: qp8qpxqeiJrRuh2rfeYHWZuaEU3rpy485/JH6TAju/mbQw8Ey2DZgL0cAvtHzQd6rvQRE0T8BX 7DiRQRWKRVpamPifFRDxoVjQpMmGDNLHbVP4UXydjieMuFjKNaf+eNmxsDRrwIprBXyIK58C4Z QUWE7jCGj6bpGRYVInT8eJbVFjH5ubMSvG1Pcxl71QzXGMfTkzTpQ4GmCXtXzJlxjo8iWCtUyh Fga5mv3Imqld9cBfCNGgs9SV1JW6jLnyoS1vFwBgjRB8pYde7gtqw1E6a8cIN421m7NGtXnF8s qdQ= WDCIronportException: Internal From: Alistair Francis To: libc-alpha@sourceware.org Cc: alistair23@gmaill.com, Alistair Francis Subject: [PATCH v4 1/2] sysdeps/stat: Handle 64-bit ino_t types on 32-bit hosts Date: Wed, 16 Oct 2019 16:44:06 -0700 Message-Id: <20191016234407.4306-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. * sysdeps/unix/sysv/linux/generic/bits/stat.h: Handle 64-bit ino_t types on 32-bit hosts. * sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h: Likewise. * sysdeps/unix/sysv/linux/generic/xstat.c: Ensure __blkcnt_t == __blkcnt64_t if __INO_T_MATCHES_INO64_T is defined. --- sysdeps/unix/sysv/linux/generic/bits/stat.h | 5 ++++- sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h | 4 ++++ sysdeps/unix/sysv/linux/generic/xstat.c | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) 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/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. */ diff --git a/sysdeps/unix/sysv/linux/generic/xstat.c b/sysdeps/unix/sysv/linux/generic/xstat.c index 75ceb9bc74b..ece14fc5838 100644 --- a/sysdeps/unix/sysv/linux/generic/xstat.c +++ b/sysdeps/unix/sysv/linux/generic/xstat.c @@ -28,6 +28,11 @@ #include #include +#if __INO_T_MATCHES_INO64_T +_Static_assert (sizeof (__blkcnt_t) == sizeof (__blkcnt64_t), + "__blkcnt_t and __blkcnt64_t must match"); +#endif + /* Get information about the file NAME in BUF. */ int __xstat (int vers, const char *name, struct stat *buf)