From patchwork Thu Oct 3 17:41:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1171301 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-105607-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="tMm6ZMir"; dkim=pass (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="XL7rHsBc"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kgR83vsyz9sP7 for ; Fri, 4 Oct 2019 03:46:12 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; q=dns; s=default; b=C6O fipwX9is5+JbjBa1q1jXzMdcW9+bYPe3TophfFwnf/cOH5AeygzrmBfyDwmZCWFq E2/7TOD7gesLgSKYCwoDHXMx4cK5CK5vN0NN6KuJnwV+krpkukJkcTGe3MyO+Kwl XbRjljzDJvb6Xk8yTMbRS5NjIf5bbwxj66slMOs4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; s=default; bh=P1pka5JDM pQdiCz3awAnClJqikg=; b=tMm6ZMir1nE9BgMJbpQjtu8Qa0ySGzPLqJ9T9wMGt XRbCcS44VMvImlUpXsT0ie6R9hRKhkLuOz4H+c2GWqYO0h8YHMb7jt8p8d3JukkD WEgVLNE2MVlVYMIrjKnZxaJkDHq7tga9BpX9jwQa6QC5gR6/QJICwEsOBnGrcs1b Ds= Received: (qmail 97522 invoked by alias); 3 Oct 2019 17:46:06 -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 97512 invoked by uid 89); 3 Oct 2019 17:46:05 -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=HContent-Transfer-Encoding:8bit X-HELO: esa1.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=1570124764; x=1601660764; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=wDBjW442KGn0/jQ1gIHl/RzjOnISEs8NsBZjld/Wue0=; b=XL7rHsBc33XH/Y7aWJAh0vnEWTzjTPaIXFecYZJZ88SjFA8yhas8CMxg ktVM57L0ZVhO0SCyp2QWwDg9S9UgvsFh+Er/izcfNlJcyQpv/XP/T2ZLp /Tx3dCx2CeYNEXXhjcil2b3MoDbmmlLiJSslmj6JaCLuVlzhFRkOh/q74 GUT7YIwHGM8QhMOjPXIyuRFC+ZvUXyfF+HqIPTsbj1UrrjW0Sl/q8ilZT NvtsOAif0Tn094AKbhe0UieZoF/8b2YfKmknYRrU5gIKsWf1de70XXry8 5u6oxAVoGPqCVzRWyhAjLX1eH5ucY/KKT/9m3UEjK2DtuLtSSumE8DJF7 w==; IronPort-SDR: Xo6AjCXrqXoRlM1ZNnD0jtt3a//uRbwi1Ob57esZj3TE2uqEVYqe8d5gfJNl/klxAs8s5p2mgU IlL3+glWdJFv+oC08CqHzOig2OQ217BfsXihxK+P2MvIuIOoiaa2kA+4KjWuw0KGdDQZEtm3+j gne1LJ5H8kM0NbtN2BMD7SONk+hKqBlKAfg7bYE3fIo6Kq3uMwmqwVPsWePKcS9DgP4mA/dHFP 2IFPdITXSzZ88Dt5O1nyIuwlrCsmquSLy9sFjzSNGDflb2/vFfN1Wnlh53CENKpPwXm/3o67gt L5U= IronPort-SDR: sJrd/DpoYk3Evnm0ckllSyb9Uo1qdQoG5QSjYBFHqlHWxGnQB+E7pdTtIwe2IpxatdYdCuKVNg ti6lpIHVP/xw2O6pmU0DMic8rbl9kfYIh9qmQgm+0q/VWqtfessMAltm3ycDBEKycS2Rt+THq7 2ngUK1Ddy3FnKx4ZoGzKALtKbT/FaszN/ikBujKXzHXgxxQOL+ObLwKtsNIwm27MG1+hEuMsT3 RTatf9dqdU2+xSzkYhahmN0RlrOrePWT1lEcr56jetKagT1N7dMMXM1NKppzHRZzFTExEMAp7/ NAz00GM2vhdO7oYjOjJQcZBo IronPort-SDR: WAKlHkKrlpANQGWcSqflMxpIQDsa4m8WmT7jfOYaVTpL4dAT8JKBF5xVG/gxI0uS3XvSgx8/kZ Mx48a4OqDaBU0+7X0gXArAUxJq4oeNL6yxfQUfyifAAkF1ryK54FOfcDfs7kKQIkhUVGygCD9Z zWCKIWfwdwg6f1p/BIsqq2/eYLfMnhgVa5ThGqst0w4aguWmIBY5zGtpr4lBme3UapOR1DGxki DVNoyFbwV2HGNWVjaYQwXqv76AqQG+tktdLax1oZdqWNY+Z8RRLZZ53KUUi7voiSNMbqoZgqGd CSI= WDCIronportException: Internal From: Alistair Francis To: libc-alpha@sourceware.org Cc: alistair23@gmail.com, Alistair Francis Subject: [PATCH v3 1/2] sysdeps/stat: Handle 64-bit ino_t types on 32-bit hosts Date: Thu, 3 Oct 2019 10:41:30 -0700 Message-Id: <20191003174131.18673-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. --- 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/wordsize-32/overflow.h | 4 ++++ 2 files changed, 8 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..0c1850322be 100644 --- a/sysdeps/unix/sysv/linux/generic/bits/stat.h +++ b/sysdeps/unix/sysv/linux/generic/bits/stat.h @@ -40,7 +40,10 @@ /* Versions of the `xmknod' interface. */ #define _MKNOD_VER_LINUX 0 -#if defined __USE_FILE_OFFSET64 +#if defined __USE_FILE_OFFSET64 || 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) type64 name #elif __WORDSIZE == 64 # define __field64(type, type64, name) type 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. */ From patchwork Thu Oct 3 17:41:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1171302 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-105608-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="pemiGg33"; dkim=pass (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="anpNHJeV"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kgRH2HKrz9sP7 for ; Fri, 4 Oct 2019 03:46:19 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=L3/PyLLgF88DTbbaMXJwDT6HTXlyfNJNhgD3nXFJliDDPmYq2wfDb YGwNuDI0eU7FMoK2I+7dAFb4xiM5PfwkLyDmNvSpTdupEk96+rhMT65Ph2FPRvVz eaomNiHgxeiHZKx4cj4eEiN0tdzfcf5h8SWKFJLSNYux6sF0N1yz1U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=jMBJJ56K8i8jg2oUB4LdNGoKRxM=; b=pemiGg33+yQWssBIXUFWPHgp4hWv l0G9QG8Qh6eB4i8miUeghGUePMaR845pprLXtVBQn6qhi0tGWbsAYjrsTvHokrq0 0HfCOHN02TzRaQkvA4GP/HMFJjnAIsSMltdaKMF0a45Nr7VUU5omqEYQL91HHG4X 0cYLvAf41xD3R3c= Received: (qmail 97808 invoked by alias); 3 Oct 2019 17:46:08 -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 97744 invoked by uid 89); 3 Oct 2019 17:46:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT autolearn=ham version=3.3.1 spammy= X-HELO: esa1.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=1570124766; x=1601660766; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nuAcFK9VA+VeEcZx8WMlBB074sLCt9iG8VLtblVLKVo=; b=anpNHJeVFtH5gNjvXSmJ3TFNoPR4YUkOCYUF8K0zrwIeAtD1QCv8PCV2 lqpszVxp99FbphsfS59srrRa4Jn7Y+9R6JDSs0V3HYSe06K0+4AmhILXw mp8oeW+qFvOcP/s/XZr2QiW2oub8EPvHFDsJd+hgEm50Ho+19Hm1Eq7G0 amzk5wFI70Tvfwv7tW7GDIH0s0w9opk+Txwbg6Yo7vv5Vx9BYpwfxVB0q yY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0MlSIfisF +Oc= WDCIronportException: Internal From: Alistair Francis To: libc-alpha@sourceware.org Cc: alistair23@gmail.com, Alistair Francis Subject: [PATCH v3 2/2] Define __STATFS_MATCHES_STATFS64 Date: Thu, 3 Oct 2019 10:41:31 -0700 Message-Id: <20191003174131.18673-2-alistair.francis@wdc.com> In-Reply-To: <20191003174131.18673-1-alistair.francis@wdc.com> References: <20191003174131.18673-1-alistair.francis@wdc.com> MIME-Version: 1.0 Add a new macro __STATFS_MATCHES_STATFS64 that specifies if fsblkcnt_t matches fsblkcnt64_t and if fsfilcnt_t matches fsfilcnt64_t. On a 32-bit platform with a 64-bit ino_t type (__STATFS_MATCHES_STATFS64 defined) we want to update the statfs 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/statfs.h: Define __STATFS_MATCHES_STATFS64 to handle 64-bit __fsblkcnt_t and t__fsfilcnt_t types on 32-bit hosts. * sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h: Likewise. --- This change was tested by running user space tests for RV32 and RV64. This patch doesn't use the new macro. The RV32 port uses the macro, this is a preperation patch. v2: - Change to if defined instead of if == 1 - Introduce __STATFS_MATCHES_STATFS64 sysdeps/unix/sysv/linux/generic/bits/statfs.h | 2 +- sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sysdeps/unix/sysv/linux/generic/bits/statfs.h b/sysdeps/unix/sysv/linux/generic/bits/statfs.h index c4069aba620..8c92e5d934e 100644 --- a/sysdeps/unix/sysv/linux/generic/bits/statfs.h +++ b/sysdeps/unix/sysv/linux/generic/bits/statfs.h @@ -32,7 +32,7 @@ using __USE_FILE_OFFSET64 only see the low 32 bits of some of the fields (the __fsblkcnt_t and __fsfilcnt_t fields). */ -#if defined __USE_FILE_OFFSET64 +#if defined __USE_FILE_OFFSET64 || defined __STATFS_MATCHES_STATFS64 # define __field64(type, type64, name) type64 name #elif __WORDSIZE == 64 # define __field64(type, type64, name) type name diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h index 66546b07ccd..b68244c94de 100644 --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h @@ -51,6 +51,9 @@ static inline int stat_overflow (struct stat *buf) /* Note that f_files and f_ffree may validly be a sign-extended -1. */ static inline int statfs_overflow (struct statfs *buf) { +#if defined __STATFS_MATCHES_STATFS64 + return 0; +#else if (buf->__f_blocks_pad == 0 && buf->__f_bfree_pad == 0 && buf->__f_bavail_pad == 0 && (buf->__f_files_pad == 0 @@ -61,4 +64,5 @@ static inline int statfs_overflow (struct statfs *buf) __set_errno (EOVERFLOW); return -1; +#endif }