From patchwork Fri Aug 16 12:34:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1973238 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EWqdPRBy; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WlhKK5H0hz20Bh for ; Fri, 16 Aug 2024 22:35:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8D7C9385E027 for ; Fri, 16 Aug 2024 12:35:15 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id E551E385DDC5 for ; Fri, 16 Aug 2024 12:34:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E551E385DDC5 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E551E385DDC5 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723811699; cv=none; b=xfzzKzOFHSqAmOn7oAvnGSwVVYRWWpoc90u0W8FWP0amflR3R4HNfRDKLxgndd8AnHakdwRIdRUlfdlJUtA5GoC4LKQPzOeodzqt5G4HH0T/70TMluQqcvJ0kc9Ubcqu6SeSY3WSY7mwC6gpbUWDNlyfwsh9bcpw5b09pTkc6xc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723811699; c=relaxed/simple; bh=vToyBUTQhSDWxAkRXyUIQVij5ZRQli0c5uSxWoDsGzc=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=T/93jovz8R+F7p+dKld30me4Jh46BNBt3culwexbruy5LgPHzCNb61unShGLCoPiGKNItJVCkVTJvYNklJV9A3Qm6FLBeOolxW3kxdPp4t/9fTELNpx5g1U9ldxuQuKlxgmeHAx3SvCBxBE4WxArISDgKS+slHCPzwrgglAP2e4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723811697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=D1A1u35HvV8pG/LxKBPoCLukAW22TbP+6cU2vciLe2Q=; b=EWqdPRByQZ9weRqw3YytFG3HwW4FNY00/zGVdvimU13i8KGxkGntjLYL1h7HEkoRkxiNGc Is+g2qUIWOJysl+WwVh3eP5PCBUeodPOPl8bhgsNFKmgi6ktQk4THwUCYEf4oWcfxWz2o6 ZD2b/hS/DUxIoofky9Y0zai6WimttMo= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-272-txwiVfWLOJOBFmBqZbmB0g-1; Fri, 16 Aug 2024 08:34:56 -0400 X-MC-Unique: txwiVfWLOJOBFmBqZbmB0g-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D1FF01955BE7 for ; Fri, 16 Aug 2024 12:34:54 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.19]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0018C19560A3 for ; Fri, 16 Aug 2024 12:34:53 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 1/5] support: Remove #include In-Reply-To: Message-ID: <0f90ca5e02a1ec4293a307ac691771c92f4cff0a.1723811552.git.fweimer@redhat.com> References: X-From-Line: 0f90ca5e02a1ec4293a307ac691771c92f4cff0a Mon Sep 17 00:00:00 2001 Date: Fri, 16 Aug 2024 14:34:51 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org This is not needed: include/intprops.h has its own detection logic. It makes building these files outside of glibc easer. Reviewed-by: Adhemerval Zanella --- support/timespec-add.c | 1 - support/timespec-sub.c | 1 - 2 files changed, 2 deletions(-) diff --git a/support/timespec-add.c b/support/timespec-add.c index 55fd812f31..57b968c316 100644 --- a/support/timespec-add.c +++ b/support/timespec-add.c @@ -20,7 +20,6 @@ /* Return the sum of two timespec values A and B. On overflow, return an extremal value. This assumes 0 <= tv_nsec < TIMESPEC_HZ. */ -#include #include "timespec.h" #include "intprops.h" diff --git a/support/timespec-sub.c b/support/timespec-sub.c index 7d89c1415a..2897343fce 100644 --- a/support/timespec-sub.c +++ b/support/timespec-sub.c @@ -21,7 +21,6 @@ overflow, return an extremal value. This assumes 0 <= tv_nsec < TIMESPEC_HZ. */ -#include #include "timespec.h" #include "intprops.h" From patchwork Fri Aug 16 12:34:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1973241 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LmOwK38w; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WlhLH4H36z20Bh for ; Fri, 16 Aug 2024 22:36:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 67F7E385EC56 for ; Fri, 16 Aug 2024 12:36:05 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 2690D385DDF3 for ; Fri, 16 Aug 2024 12:35:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2690D385DDF3 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2690D385DDF3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723811705; cv=none; b=yCsFW5TSG7NLHL8HBlKQjuQCKptDejU/XSuCkq3JmLrLoFZA0lP5dmTpZ5PnuuGE/p+e42a8eIP2m5Wi72T5bnTjkQNCURq7WPaopMymor3xCaUdeU9pMdkiy6o1UhIHvrLpJSApCkITDDaLz4+AqvQXMNp9Y8w36fblEFjOfnA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723811705; c=relaxed/simple; bh=gLgx4Zk92eSjQLaOvloaeHK51Bg+TF+/L34Sc+78/Ig=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=gNY2mKMK1biR2routCRWqFMSqwdrHV1b1n087mFjtn/BNk9yOfAFZrIe6YKX82Gpjo8cw4T1f8W/YsPJVwc3Un38lRYyMfR3kx47PGy3HW/ynweYz2QWQokwu9cCgNcJBEb7t9YdWI27APs/vQnDS8//58HsFMmJh6sS3vl/7tY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723811702; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QjSEq9SQOa2DENi5wMZPZQraNgXchZkbBM9gk25lZu4=; b=LmOwK38wetNXliisAgP3h2+0XOuv+rhGO9pgRUeC0AeU6ZXWJnxsyIrR77uW9s/cy4ahRu QPpljyVmekqvG64gkFvOw3qGIAQBI8lUJKMYbcqHbYKDDudA9VccKSGBT3MNz8OiKY5q/y BjVPer07XEbiBna4xOyMlHz9ZhdeqCA= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-473-4iEcc5lFPbiufj9ANZ949Q-1; Fri, 16 Aug 2024 08:35:01 -0400 X-MC-Unique: 4iEcc5lFPbiufj9ANZ949Q-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C69BC1955EA1 for ; Fri, 16 Aug 2024 12:35:00 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.19]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DF6DD300019A for ; Fri, 16 Aug 2024 12:34:59 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 2/5] support: Include for strcmp in support_format_addrinfo.c In-Reply-To: Message-ID: References: X-From-Line: c6289a18adee9a1d64a260b265dccb190d1707e6 Mon Sep 17 00:00:00 2001 Date: Fri, 16 Aug 2024 14:34:56 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org This is currently implied by the internal headers, but it makes sense not to rely on this. Reviewed-by: Adhemerval Zanella --- support/support_format_addrinfo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/support/support_format_addrinfo.c b/support/support_format_addrinfo.c index cbc72910a9..77f4db345c 100644 --- a/support/support_format_addrinfo.c +++ b/support/support_format_addrinfo.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include From patchwork Fri Aug 16 12:35:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1973239 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Qcf3ZqXj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WlhKc0NGhz20Bh for ; Fri, 16 Aug 2024 22:35:32 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 45F58385DDFA for ; Fri, 16 Aug 2024 12:35:30 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 1FA13385DDFE for ; Fri, 16 Aug 2024 12:35:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1FA13385DDFE Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1FA13385DDFE Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723811711; cv=none; b=u4Eg9m663AVjeHLV6TpviQ7S/c+Cn/giv/07tONpdYSaKQKh9zoGkClhKDShCuHCXyv7r33yl0S+YlauTN4Qd6E7zvQelZQjZ6ohjpTcbEKjySrCWkGCuiUI4FeGxyakeLD4mmrDHqQEWjZTZSNlgtO0+SW610CfShidN7TLOQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723811711; c=relaxed/simple; bh=Ed/RyHbN+Zz83zmQmQK6a8H7kMgCbahbH8kt0MshR2A=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=gPqZA7TSVeQPC3ijE2nZNpX8kiDfpXl/Ss6vVvq9l8wPr1/VqNITepvoJnZ/+xBwnKnumBSnvVYJA9RJ53a9fzxSMQYVyg+56V8mEKRM1ftasXheu1/FV2P3QT7JKZW7uG7dnARQYrpwp3gH9CUOawgohPQ5qWkTAyh7p1i9hx4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723811708; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Prtatdbpd4hEe69B4Q6P6oITFnhbO1IWqM3Ua8U6kdM=; b=Qcf3ZqXjC/dG2dEkrGzzx2M4imbN/7Ntly8+ZvXA+kJnj9tYwf9WusxSvPwQVVKVUZw3gE En9faPPGOOrd1TOaB7Kbkb6b8K1BTdxICkDBKN5wxYEu/so4fAWXlyEltZskS/XLMi1U6t 2IrVLsH8rRlNUOff0Vu68j/M99eOIp8= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-250-wOyKQxa7ND2vELEGj3BBwA-1; Fri, 16 Aug 2024 08:35:07 -0400 X-MC-Unique: wOyKQxa7ND2vELEGj3BBwA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B67691955BEF for ; Fri, 16 Aug 2024 12:35:06 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.19]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A5F3319560A3 for ; Fri, 16 Aug 2024 12:35:05 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 3/5] support: Add the xstatx function In-Reply-To: Message-ID: References: X-From-Line: ca50eee59f2be39e65bd0da1d03e915da3912225 Mon Sep 17 00:00:00 2001 Date: Fri, 16 Aug 2024 14:35:02 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org --- support/Makefile | 1 + support/xstatx.c | 32 ++++++++++++++++++++++++++++++++ support/xunistd.h | 2 ++ 3 files changed, 35 insertions(+) create mode 100644 support/xstatx.c Reviewed-by: Adhemerval Zanella diff --git a/support/Makefile b/support/Makefile index aa57207bdc..5b1c96a49e 100644 --- a/support/Makefile +++ b/support/Makefile @@ -210,6 +210,7 @@ libsupport-routines = \ xsignal \ xsigstack \ xsocket \ + xstatx \ xstrdup \ xstrndup \ xsymlink \ diff --git a/support/xstatx.c b/support/xstatx.c new file mode 100644 index 0000000000..621f2440f8 --- /dev/null +++ b/support/xstatx.c @@ -0,0 +1,32 @@ +/* Error-checking wrapper for statx. + Copyright (C) 2024 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 + . */ + +#include + +#include +#include +#include + +void +xstatx (int fd, const char *path, int flags, unsigned int mask, + struct statx *stx) +{ + if (statx (fd, path, flags, mask, stx) != 0) + FAIL_EXIT1 ("statx (AT_FDCWD, \"%s\", 0x%x, 0x%x): %m", + path, (unsigned int) flags, mask); +} diff --git a/support/xunistd.h b/support/xunistd.h index 13be9a46a3..cc74c4fad0 100644 --- a/support/xunistd.h +++ b/support/xunistd.h @@ -30,6 +30,7 @@ __BEGIN_DECLS struct stat64; +struct statx; pid_t xfork (void); pid_t xwaitpid (pid_t, int *status, int flags); @@ -51,6 +52,7 @@ 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 xstatx (int, const char *, int, unsigned int, struct statx *); void xmkdir (const char *path, mode_t); void xchroot (const char *path); void xunlink (const char *path); From patchwork Fri Aug 16 12:35:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1973240 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BSns55PM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WlhKp43j2z20Bh for ; Fri, 16 Aug 2024 22:35:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 69AB8385E45C for ; Fri, 16 Aug 2024 12:35:40 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 10CB2385DDD7 for ; Fri, 16 Aug 2024 12:35:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 10CB2385DDD7 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 10CB2385DDD7 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723811721; cv=none; b=W00pe15YkH6OsCWlIyHQwnVlERVzHX9861pRJcLhbkGPZLUMYDq5C9sMjAJqz2qjSmpUzDsO4m1+ELIHeduZJGxaIeW4jSN4TG3mcmBNGi0nzjUOIEpR4yDx3BeNQs9HJVCJQ8l8hwSphFhu6f0iI9i05Xu8RkcSkmgZOBh7IOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723811721; c=relaxed/simple; bh=MmQoN4XAnUbEnPud+FF8hUq5ppdiqhf6N79bPGWATQo=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=XaJUEacJV8GbHZzLP5LmXS0ybgXOPw0VWEON015+DLks1lzq8I3pz2fZ2H1jZIuaSCF+Ubfo3h5ivTjEpa8x7Ig0/OOMIb0s36XzdxRJlSSdNpWoUM/8dQKf5C8h0WQw6h06rrnGRhLoIag/QuN5yD6x2aSadlphgstS9g+axoM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723811714; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fCpTk6mzZqeMEEltA7uMkl6pm//1l5ZW0IRCDRiN3Vs=; b=BSns55PMA0yeXzGrPtka7ZNL/e41tIqgK3jFxJUO82On4Fb0Ovkkbamn61gpYxz44ZRK6B gEJtXq53H0PCxdw2BiTs4AGnyLTTCQ+ZcgwNnc2TpZq48D/wk29yfRsQIm1Odg8WOLIdhc JQSGeXibxvhYkq0Yagokkaoh//K2ILg= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-570-ovUtq4YvPuu8HPthgtbHvw-1; Fri, 16 Aug 2024 08:35:13 -0400 X-MC-Unique: ovUtq4YvPuu8HPthgtbHvw-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9C4DF1955D4C for ; Fri, 16 Aug 2024 12:35:12 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.19]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7F93C19560A3 for ; Fri, 16 Aug 2024 12:35:11 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 4/5] io: Use struct statx and xstatx in tests In-Reply-To: Message-ID: <1279ea9f57a65416b08a1c202a3220f5e0e24803.1723811552.git.fweimer@redhat.com> References: X-From-Line: 1279ea9f57a65416b08a1c202a3220f5e0e24803 Mon Sep 17 00:00:00 2001 Date: Fri, 16 Aug 2024 14:35:08 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org This avoids the need to define struct_statx to an appropriate struct stat type variant because struct statx does not change based on time/file offset flags. Reviewed-by: Adhemerval Zanella --- io/tst-futimens-time64.c | 1 - io/tst-futimens.c | 13 +++++-------- io/tst-futimes-time64.c | 1 - io/tst-futimes.c | 13 +++++-------- io/tst-futimesat-time64.c | 3 --- io/tst-futimesat.c | 30 ++++++++---------------------- io/tst-lutimes-time64.c | 1 - io/tst-lutimes.c | 26 ++++++++++++-------------- io/tst-utime-time64.c | 1 - io/tst-utime.c | 13 +++++-------- io/tst-utimensat-time64.c | 1 - io/tst-utimensat.c | 35 +++++++++++++++++------------------ io/tst-utimes-time64.c | 1 - io/tst-utimes.c | 13 +++++-------- 14 files changed, 57 insertions(+), 95 deletions(-) diff --git a/io/tst-futimens-time64.c b/io/tst-futimens-time64.c index 88fcb38489..71204a6166 100644 --- a/io/tst-futimens-time64.c +++ b/io/tst-futimens-time64.c @@ -1,2 +1 @@ -#define struct_stat struct stat #include "tst-futimens.c" diff --git a/io/tst-futimens.c b/io/tst-futimens.c index 6204befedd..075ca42b93 100644 --- a/io/tst-futimens.c +++ b/io/tst-futimens.c @@ -18,26 +18,23 @@ #include #include +#include #include -#ifndef struct_stat -# define struct_stat struct stat64 -#endif - static int test_futimens_helper (const char *file, int fd, const struct timespec *ts) { int result = futimens (fd, ts); TEST_VERIFY_EXIT (result == 0); - struct_stat st; - xfstat (fd, &st); + struct statx st; + xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st); /* Check if seconds for atime match */ - TEST_COMPARE (st.st_atime, ts[0].tv_sec); + TEST_COMPARE (st.stx_atime.tv_sec, ts[0].tv_sec); /* Check if seconds for mtime match */ - TEST_COMPARE (st.st_mtime, ts[1].tv_sec); + TEST_COMPARE (st.stx_mtime.tv_sec, ts[1].tv_sec); return 0; } diff --git a/io/tst-futimes-time64.c b/io/tst-futimes-time64.c index d489c265d1..eeb4bed7c4 100644 --- a/io/tst-futimes-time64.c +++ b/io/tst-futimes-time64.c @@ -1,2 +1 @@ -#define struct_stat struct stat #include "tst-futimes.c" diff --git a/io/tst-futimes.c b/io/tst-futimes.c index d21acf6a24..612fe460cf 100644 --- a/io/tst-futimes.c +++ b/io/tst-futimes.c @@ -18,27 +18,24 @@ #include #include +#include #include #include -#ifndef struct_stat -# define struct_stat struct stat64 -#endif - static int test_futimens_helper (const char *file, int fd, const struct timeval *tv) { int r = futimes (fd, tv); TEST_VERIFY_EXIT (r == 0); - struct_stat st; - xfstat (fd, &st); + struct statx st; + xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st); /* Check if seconds for atime match */ - TEST_COMPARE (st.st_atime, tv[0].tv_sec); + TEST_COMPARE (st.stx_atime.tv_sec, tv[0].tv_sec); /* Check if seconds for mtime match */ - TEST_COMPARE (st.st_mtime, tv[1].tv_sec); + TEST_COMPARE (st.stx_mtime.tv_sec, tv[1].tv_sec); return 0; } diff --git a/io/tst-futimesat-time64.c b/io/tst-futimesat-time64.c index f6c0500eef..1585317579 100644 --- a/io/tst-futimesat-time64.c +++ b/io/tst-futimesat-time64.c @@ -1,4 +1 @@ -#define struct_stat struct stat -#define fstat fstat -#define fstatat fstatat #include "io/tst-futimesat.c" diff --git a/io/tst-futimesat.c b/io/tst-futimesat.c index 67a8551beb..feae4e7aa7 100644 --- a/io/tst-futimesat.c +++ b/io/tst-futimesat.c @@ -30,12 +30,6 @@ #include #include -#ifndef struct_stat -# define struct_stat struct stat64 -# define fstat fstat64 -# define fstatat fstatat64 -#endif - static int dir_fd; static void @@ -118,19 +112,15 @@ do_test (void) xwrite (fd, "hello", 5); puts ("file created"); - struct_stat st1; - if (fstat (fd, &st1) != 0) - { - puts ("fstat64 failed"); - return 1; - } + struct statx st1; + xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st1); close (fd); struct timeval tv[2]; - tv[0].tv_sec = st1.st_atime + 1; + tv[0].tv_sec = st1.stx_atime.tv_sec + 1; tv[0].tv_usec = 0; - tv[1].tv_sec = st1.st_mtime + 1; + tv[1].tv_sec = st1.stx_mtime.tv_sec + 1; tv[1].tv_usec = 0; if (futimesat (dir_fd, "some-file", tv) != 0) { @@ -138,16 +128,12 @@ do_test (void) return 1; } - struct_stat st2; - if (fstatat (dir_fd, "some-file", &st2, 0) != 0) - { - puts ("fstatat64 failed"); - return 1; - } + struct statx st2; + xstatx (dir_fd, "some-file", 0, STATX_BASIC_STATS, &st2); - if (st2.st_mtime != tv[1].tv_sec + if (st2.stx_mtime.tv_sec != tv[1].tv_sec #ifdef _STATBUF_ST_NSEC - || st2.st_mtim.tv_nsec != 0 + || st2.stx_mtime.tv_nsec != 0 #endif ) { diff --git a/io/tst-lutimes-time64.c b/io/tst-lutimes-time64.c index 06caec0a91..c5bea965da 100644 --- a/io/tst-lutimes-time64.c +++ b/io/tst-lutimes-time64.c @@ -1,2 +1 @@ -#define struct_stat struct stat #include "tst-lutimes.c" diff --git a/io/tst-lutimes.c b/io/tst-lutimes.c index edef5ab90e..78bcc58291 100644 --- a/io/tst-lutimes.c +++ b/io/tst-lutimes.c @@ -18,34 +18,32 @@ #include #include +#include #include #include -#ifndef struct_stat -# define struct_stat struct stat64 -#endif - static int test_lutimes_helper (const char *testfile, int fd, const char *testlink, const struct timeval *tv) { - struct_stat stfile_orig; - xlstat (testfile, &stfile_orig); + struct statx stfile_orig; + xstatx (AT_FDCWD, testfile, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, + &stfile_orig); TEST_VERIFY_EXIT (lutimes (testlink, tv) == 0); - struct_stat stlink; - xlstat (testlink, &stlink); + struct statx stlink; + xstatx (AT_FDCWD, testlink, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, &stlink); - TEST_COMPARE (stlink.st_atime, tv[0].tv_sec); - TEST_COMPARE (stlink.st_mtime, tv[1].tv_sec); + TEST_COMPARE (stlink.stx_atime.tv_sec, tv[0].tv_sec); + TEST_COMPARE (stlink.stx_mtime.tv_sec, tv[1].tv_sec); /* Check if the timestamp from original file is not changed. */ - struct_stat stfile; - xlstat (testfile, &stfile); + struct statx stfile; + xstatx (AT_FDCWD, testfile, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, &stfile); - TEST_COMPARE (stfile_orig.st_atime, stfile.st_atime); - TEST_COMPARE (stfile_orig.st_mtime, stfile.st_mtime); + TEST_COMPARE (stfile_orig.stx_atime.tv_sec, stfile.stx_atime.tv_sec); + TEST_COMPARE (stfile_orig.stx_mtime.tv_sec, stfile.stx_mtime.tv_sec); return 0; } diff --git a/io/tst-utime-time64.c b/io/tst-utime-time64.c index eb62f59126..8894592a15 100644 --- a/io/tst-utime-time64.c +++ b/io/tst-utime-time64.c @@ -1,2 +1 @@ -#define struct_stat struct stat #include "tst-utime.c" diff --git a/io/tst-utime.c b/io/tst-utime.c index e2e6dcd04c..f329358289 100644 --- a/io/tst-utime.c +++ b/io/tst-utime.c @@ -19,26 +19,23 @@ #include #include #include +#include #include -#ifndef struct_stat -# define struct_stat struct stat64 -#endif - static int test_utime_helper (const char *file, int fd, const struct utimbuf *ut) { int result = utime (file, ut); TEST_VERIFY_EXIT (result == 0); - struct_stat st; - xfstat (fd, &st); + struct statx st; + xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st); /* Check if seconds for actime match */ - TEST_COMPARE (st.st_atime, ut->actime); + TEST_COMPARE (st.stx_atime.tv_sec, ut->actime); /* Check if seconds for modtime match */ - TEST_COMPARE (st.st_mtime, ut->modtime); + TEST_COMPARE (st.stx_mtime.tv_sec, ut->modtime); return 0; } diff --git a/io/tst-utimensat-time64.c b/io/tst-utimensat-time64.c index 7ac7d8df1d..5d60fce881 100644 --- a/io/tst-utimensat-time64.c +++ b/io/tst-utimensat-time64.c @@ -1,2 +1 @@ -#define struct_stat struct stat #include "tst-utimensat.c" diff --git a/io/tst-utimensat.c b/io/tst-utimensat.c index 3d9a72c471..2a756d7b07 100644 --- a/io/tst-utimensat.c +++ b/io/tst-utimensat.c @@ -22,10 +22,6 @@ #include #include -#ifndef struct_stat -# define struct_stat struct stat64 -#endif - static int test_utimesat_helper (const char *testfile, int fd, const char *testlink, const struct timespec *ts) @@ -33,35 +29,38 @@ test_utimesat_helper (const char *testfile, int fd, const char *testlink, { TEST_VERIFY_EXIT (utimensat (fd, testfile, ts, 0) == 0); - struct_stat st; - xfstat (fd, &st); + struct statx st; + xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st); /* Check if seconds for atime match */ - TEST_COMPARE (st.st_atime, ts[0].tv_sec); + TEST_COMPARE (st.stx_atime.tv_sec, ts[0].tv_sec); /* Check if seconds for mtime match */ - TEST_COMPARE (st.st_mtime, ts[1].tv_sec); + TEST_COMPARE (st.stx_mtime.tv_sec, ts[1].tv_sec); } { - struct_stat stfile_orig; - xlstat (testfile, &stfile_orig); + struct statx stfile_orig; + xstatx (AT_FDCWD, testfile, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, + &stfile_orig); TEST_VERIFY_EXIT (utimensat (0 /* ignored */, testlink, ts, AT_SYMLINK_NOFOLLOW) == 0); - struct_stat stlink; - xlstat (testlink, &stlink); + struct statx stlink; + xstatx (AT_FDCWD, testlink, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, + &stlink); - TEST_COMPARE (stlink.st_atime, ts[0].tv_sec); - TEST_COMPARE (stlink.st_mtime, ts[1].tv_sec); + TEST_COMPARE (stlink.stx_atime.tv_sec, ts[0].tv_sec); + TEST_COMPARE (stlink.stx_mtime.tv_sec, ts[1].tv_sec); /* Check if the timestamp from original file is not changed. */ - struct_stat stfile; - xlstat (testfile, &stfile); + struct statx stfile; + xstatx (AT_FDCWD, testfile, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, + &stfile); - TEST_COMPARE (stfile_orig.st_atime, stfile.st_atime); - TEST_COMPARE (stfile_orig.st_mtime, stfile.st_mtime); + TEST_COMPARE (stfile_orig.stx_atime.tv_sec, stfile.stx_atime.tv_sec); + TEST_COMPARE (stfile_orig.stx_mtime.tv_sec, stfile.stx_mtime.tv_sec); } return 0; diff --git a/io/tst-utimes-time64.c b/io/tst-utimes-time64.c index 234ec02541..026ef5f78d 100644 --- a/io/tst-utimes-time64.c +++ b/io/tst-utimes-time64.c @@ -1,2 +1 @@ -#define struct_stat struct stat #include "tst-utimes.c" diff --git a/io/tst-utimes.c b/io/tst-utimes.c index 8edcfabebf..6cd436c5a0 100644 --- a/io/tst-utimes.c +++ b/io/tst-utimes.c @@ -18,28 +18,25 @@ #include #include +#include #include #include #include -#ifndef struct_stat -# define struct_stat struct stat64 -#endif - static int test_utimes_helper (const char *file, int fd, const struct timeval *tv) { int result = utimes (file, tv); TEST_VERIFY_EXIT (result == 0); - struct_stat st; - xfstat (fd, &st); + struct statx st; + xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st); /* Check if seconds for atime match */ - TEST_COMPARE (st.st_atime, tv[0].tv_sec); + TEST_COMPARE (st.stx_atime.tv_sec, tv[0].tv_sec); /* Check if seconds for mtime match */ - TEST_COMPARE (st.st_mtime, tv[1].tv_sec); + TEST_COMPARE (st.stx_mtime.tv_sec, tv[1].tv_sec); return 0; } From patchwork Fri Aug 16 12:35:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1973242 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WYtrA6Bu; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WlhLl2yBMz20Bh for ; Fri, 16 Aug 2024 22:36:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 458B0385DDD9 for ; Fri, 16 Aug 2024 12:36:29 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 50C40385DDC5 for ; Fri, 16 Aug 2024 12:35:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 50C40385DDC5 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 50C40385DDC5 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723811723; cv=none; b=kCUqf4B9RWiHarQzANIcVnKs+Dr6V7xosLY0so/qiIYOwrt5BMLxttDQtp0IhUrhI7DAm0nN0SnBmz/VPPuANueNMh+gpZYR6APl7h3/hsg6tnaB8jOrj9F3Q2DZe4Ga9Xv+qoX/QPvmM6ajCfCgCiu5DDB+rv8yTjYzMReoCno= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723811723; c=relaxed/simple; bh=3iy8tPH8PSa4MjRpw9+ZTtPrbbqyHojjRJHKKbMnt2o=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=bWX4FAqKX/Yf8+dDzb/sjif0HLhlIjjThoQjZQk/ec02q32mPtvUp3l1RRR5qn5Au3K3yCz56yeGYMMtG3AIrJwfYt5BEPPNnWfy/+LYg8krGsckk9O2PD8q3knR+rr3ygHoxi64wa4H+6CHP0XiulbChwSRti9yMFVwv9qbFcU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723811720; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9sN73n4Tof4ohh+/m/QI+tCza9ahwjlRvvXP9+soCJQ=; b=WYtrA6BuM8XozibYCZCQ7EF0ePYSA50Focr1C1dGT68/dERzE4uoEORHv6KCQTC8Ke9M4R cr9IrDkOGR/RDUjW5YlCpdKaCs6qiOBBWVjA8TUvkFs+IUDv+PePu315Ap+P5ivUtAtqu9 QoL0psuZOToJd1jv3kxi8U1sJwWKpAo= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-319-_K5Slqa1PiejznBrOC_GFw-1; Fri, 16 Aug 2024 08:35:18 -0400 X-MC-Unique: _K5Slqa1PiejznBrOC_GFw-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2267319560B1 for ; Fri, 16 Aug 2024 12:35:18 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.19]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3C3581955BE1 for ; Fri, 16 Aug 2024 12:35:16 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 5/5] support: Use macros for *stat wrappers In-Reply-To: Message-ID: <6c0575946b135dce84f68578348894ae587488b4.1723811552.git.fweimer@redhat.com> References: X-From-Line: 6c0575946b135dce84f68578348894ae587488b4 Mon Sep 17 00:00:00 2001 Date: Fri, 16 Aug 2024 14:35:14 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org Macros will automatically use the correct types, without having to fiddle with internal glibc macros. It's also impossible to get the types wrong due to aliasing because support_check_stat_fd and support_check_stat_path do not depend on the struct stat* types. The changes reveal some inconsistencies in tests. Reviewed-by: Adhemerval Zanella --- elf/tst-ldconfig-bad-aux-cache.c | 2 +- io/tst-copy_file_range.c | 2 +- io/tst-statx.c | 4 +-- locale/tst-localedef-path-norm.c | 2 +- localedata/tst-localedef-hardlinks.c | 2 +- posix/tst-execveat.c | 2 +- stdio-common/tst-renameat2.c | 2 +- stdlib/tst-system.c | 2 +- support/Makefile | 8 ++--- support/support-xfstat-time64.c | 32 ------------------- support/support-xstat-time64.c | 32 ------------------- support/support-xstat.c | 30 ----------------- support/{xlstat.c => support_check_stat_fd.c} | 11 +++---- ...ort-xfstat.c => support_check_stat_path.c} | 9 +++--- support/xlstat-time64.c | 32 ------------------- support/xunistd.h | 30 ++++++++--------- 16 files changed, 34 insertions(+), 168 deletions(-) delete mode 100644 support/support-xfstat-time64.c delete mode 100644 support/support-xstat-time64.c delete mode 100644 support/support-xstat.c rename support/{xlstat.c => support_check_stat_fd.c} (76%) rename support/{support-xfstat.c => support_check_stat_path.c} (81%) delete mode 100644 support/xlstat-time64.c diff --git a/elf/tst-ldconfig-bad-aux-cache.c b/elf/tst-ldconfig-bad-aux-cache.c index 7f1fbb5252..8c2e62ecc2 100644 --- a/elf/tst-ldconfig-bad-aux-cache.c +++ b/elf/tst-ldconfig-bad-aux-cache.c @@ -85,7 +85,7 @@ do_test (void) support_capture_subprocess_check (&result, "execv", 0, sc_allow_none); support_capture_subprocess_free (&result); - xstat (path, &fs); + xstat64 (path, &fs); size = fs.st_size; /* Run 3 tests, each truncating aux-cache shorter and shorter. */ diff --git a/io/tst-copy_file_range.c b/io/tst-copy_file_range.c index 9837b7c339..3d7b0aa901 100644 --- a/io/tst-copy_file_range.c +++ b/io/tst-copy_file_range.c @@ -117,7 +117,7 @@ simple_file_copy (void) TEST_COMPARE (xlseek (outfd, 0, SEEK_CUR), 6 + length); struct stat64 st; - xfstat (outfd, &st); + xfstat64 (outfd, &st); if (length > 0) TEST_COMPARE (st.st_size, out_skipped + length); else diff --git a/io/tst-statx.c b/io/tst-statx.c index d84568859e..685924ae76 100644 --- a/io/tst-statx.c +++ b/io/tst-statx.c @@ -78,7 +78,7 @@ both_implementations_tests (statx_function impl, const char *path, int fd) struct statx stx = { 0, }; TEST_COMPARE (statx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &stx), 0); struct stat64 st; - xfstat (fd, &st); + xfstat64 (fd, &st); TEST_COMPARE (stx.stx_mode, st.st_mode); TEST_COMPARE (stx.stx_dev_major, major (st.st_dev)); TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev)); @@ -88,7 +88,7 @@ both_implementations_tests (statx_function impl, const char *path, int fd) TEST_COMPARE (statx (AT_FDCWD, "/dev/null", 0, STATX_BASIC_STATS, &stx), 0); struct stat64 st; - xstat ("/dev/null", &st); + xstat64 ("/dev/null", &st); TEST_COMPARE (stx.stx_mode, st.st_mode); TEST_COMPARE (stx.stx_dev_major, major (st.st_dev)); TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev)); diff --git a/locale/tst-localedef-path-norm.c b/locale/tst-localedef-path-norm.c index ffe8cbd467..f592b9a960 100644 --- a/locale/tst-localedef-path-norm.c +++ b/locale/tst-localedef-path-norm.c @@ -84,7 +84,7 @@ run_test (void *closure) support_capture_subprocess_free (&result); /* Verify path is present and is a directory. */ - xstat (path, &fs); + xstat64 (path, &fs); if (!S_ISDIR (fs.st_mode)) { support_record_failure (); diff --git a/localedata/tst-localedef-hardlinks.c b/localedata/tst-localedef-hardlinks.c index e88215a150..23927b462f 100644 --- a/localedata/tst-localedef-hardlinks.c +++ b/localedata/tst-localedef-hardlinks.c @@ -62,7 +62,7 @@ check_link (struct test_data step) char *output; output = xasprintf ("%s/%s", support_complocaledir_prefix, step.output); - xstat (output, &locale); + xstat64 (output, &locale); free (output); TEST_COMPARE (locale.st_nlink, step.st_nlink); } diff --git a/posix/tst-execveat.c b/posix/tst-execveat.c index 4565d6b19f..dde034a9f1 100644 --- a/posix/tst-execveat.c +++ b/posix/tst-execveat.c @@ -155,7 +155,7 @@ do_test (void) tmp_sh = xasprintf ("%s/tmp_sh", tmp_dir); add_temp_file (tmp_sh); fd_out = xopen (symlink_name, O_CREAT | O_WRONLY, 0); - xstat ("/bin/sh", &st); + xstat64 ("/bin/sh", &st); fd = xopen ("/bin/sh", O_RDONLY, 0); xcopy_file_range (fd, 0, fd_out, 0, st.st_size, 0); xfchmod (fd_out, 0700); diff --git a/stdio-common/tst-renameat2.c b/stdio-common/tst-renameat2.c index b65afed75e..7f4345f716 100644 --- a/stdio-common/tst-renameat2.c +++ b/stdio-common/tst-renameat2.c @@ -82,7 +82,7 @@ static void check_size (const char *path, off64_t expected_size) { struct stat64 st; - xstat (path, &st); + xstat64 (path, &st); if (st.st_size != expected_size) FAIL_EXIT1 ("file \"%s\": expected size %lld, actual size %lld", path, (unsigned long long int) expected_size, diff --git a/stdlib/tst-system.c b/stdlib/tst-system.c index 47c742f963..b5b630a41b 100644 --- a/stdlib/tst-system.c +++ b/stdlib/tst-system.c @@ -169,7 +169,7 @@ do_test (void) { struct stat64 st; - xstat (_PATH_BSHELL, &st); + xstat64 (_PATH_BSHELL, &st); mode_t mode = st.st_mode; xchmod (_PATH_BSHELL, mode & ~(S_IXUSR | S_IXGRP | S_IXOTH)); diff --git a/support/Makefile b/support/Makefile index 5b1c96a49e..6e3c55394f 100644 --- a/support/Makefile +++ b/support/Makefile @@ -42,14 +42,12 @@ libsupport-routines = \ resolv_test \ set_fortify_handler \ support-open-dev-null-range \ - support-xfstat \ - support-xfstat-time64 \ - support-xstat \ - support-xstat-time64 \ support_become_root \ support_can_chroot \ support_capture_subprocess \ support_capture_subprocess_check \ + support_check_stat_fd \ + support_check_stat_path \ support_chroot \ support_copy_file \ support_copy_file_range \ @@ -135,8 +133,6 @@ libsupport-routines = \ xgetsockname \ xlisten \ xlseek \ - xlstat \ - xlstat-time64 \ xmalloc \ xmemstream \ xmkdir \ diff --git a/support/support-xfstat-time64.c b/support/support-xfstat-time64.c deleted file mode 100644 index 589a69bb3e..0000000000 --- a/support/support-xfstat-time64.c +++ /dev/null @@ -1,32 +0,0 @@ -/* 64-bit time_t stat with error checking. - Copyright (C) 2021-2024 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 deleted file mode 100644 index 451948734a..0000000000 --- a/support/support-xstat-time64.c +++ /dev/null @@ -1,32 +0,0 @@ -/* 64-bit time_t stat with error checking. - Copyright (C) 2021-2024 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/support-xstat.c b/support/support-xstat.c deleted file mode 100644 index ce866f74d2..0000000000 --- a/support/support-xstat.c +++ /dev/null @@ -1,30 +0,0 @@ -/* stat64 with error checking. - Copyright (C) 2017-2024 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 - -void -xstat (const char *path, struct stat64 *result) -{ - if (stat64 (path, result) != 0) - FAIL_EXIT1 ("stat64 (\"%s\"): %m", path); -} diff --git a/support/xlstat.c b/support/support_check_stat_fd.c similarity index 76% rename from support/xlstat.c rename to support/support_check_stat_fd.c index 87df988879..4c12adf6b7 100644 --- a/support/xlstat.c +++ b/support/support_check_stat_fd.c @@ -1,5 +1,5 @@ -/* lstat64 with error checking. - Copyright (C) 2017-2024 Free Software Foundation, Inc. +/* Error checking for descriptor-based stat functions. + Copyright (C) 2024 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 @@ -18,11 +18,10 @@ #include #include -#include void -xlstat (const char *path, struct stat64 *result) +support_check_stat_fd (const char *name, int fd, int result) { - if (lstat64 (path, result) != 0) - FAIL_EXIT1 ("lstat64 (\"%s\"): %m", path); + if (result != 0) + FAIL_EXIT1 ("%s (%d): %m", name, fd); } diff --git a/support/support-xfstat.c b/support/support_check_stat_path.c similarity index 81% rename from support/support-xfstat.c rename to support/support_check_stat_path.c index ab4b01c97d..3cf72afe59 100644 --- a/support/support-xfstat.c +++ b/support/support_check_stat_path.c @@ -1,4 +1,4 @@ -/* fstat64 with error checking. +/* Error checking for path-based stat functions. Copyright (C) 2017-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -18,11 +18,10 @@ #include #include -#include void -xfstat (int fd, struct stat64 *result) +support_check_stat_path (const char *name, const char *path, int result) { - if (fstat64 (fd, result) != 0) - FAIL_EXIT1 ("fstat64 (%d): %m", fd); + if (result != 0) + FAIL_EXIT1 ("%s (\"%s\"): %m", name, path); } diff --git a/support/xlstat-time64.c b/support/xlstat-time64.c deleted file mode 100644 index 2bc3ca6593..0000000000 --- a/support/xlstat-time64.c +++ /dev/null @@ -1,32 +0,0 @@ -/* 64-bit time_t stat with error checking. - Copyright (C) 2021-2024 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 cc74c4fad0..204951bce7 100644 --- a/support/xunistd.h +++ b/support/xunistd.h @@ -29,7 +29,6 @@ __BEGIN_DECLS -struct stat64; struct statx; pid_t xfork (void); @@ -37,21 +36,20 @@ 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_TIME64_REDIRECTS -# 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 support_check_stat_fd (const char *name, int fd, int result); +void support_check_stat_path (const char *name, const char *path, int result); +#define xstat(path, st) \ + (support_check_stat_path ("stat", (path), stat ((path), (st)))) +#define xfstat(fd, st) \ + (support_check_stat_fd ("fstat", (fd), fstat ((fd), (st)))) +#define xlstat(path, st) \ + (support_check_stat_path ("lstat", (path), lstat ((path), (st)))) +#define xstat64(path, st) \ + (support_check_stat_path ("stat64", (path), stat64 ((path), (st)))) +#define xfstat64(fd, st) \ + (support_check_stat_fd ("fstat64", (fd), fstat64 ((fd), (st)))) +#define xlstat64(path, st) \ + (support_check_stat_path ("lstat64", (path), lstat64 ((path), (st)))) void xstatx (int, const char *, int, unsigned int, struct statx *); void xmkdir (const char *path, mode_t); void xchroot (const char *path);