From patchwork Thu Sep 14 14:29:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Sionneau X-Patchwork-Id: 1834268 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=sionneau.net header.i=@sionneau.net header.a=rsa-sha256 header.s=selectormx4 header.b=Zbpy60XR; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=uclibc-ng.org (client-ip=2a00:1828:2000:679::23; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=patchwork.ozlabs.org) Received: from helium.openadk.org (helium.openadk.org [IPv6:2a00:1828:2000:679::23]) (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 4Rmfr548Pfz1yhd for ; Fri, 15 Sep 2023 00:30:45 +1000 (AEST) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id C53C5353A91B; Thu, 14 Sep 2023 16:30:39 +0200 (CEST) Authentication-Results: helium.openadk.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=sionneau.net header.i=@sionneau.net header.a=rsa-sha256 header.s=selectormx4 header.b=Zbpy60XR; dkim-atps=neutral Received: from mx4.sionneau.net (mx4.sionneau.net [51.15.250.1]) by helium.openadk.org (Postfix) with ESMTPS id 49530352BD97 for ; Thu, 14 Sep 2023 16:29:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sionneau.net; s=selectormx4; t=1694701785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VRtTafxDjPhzASvmxafo97uIahCys/NSTKjgPVjiSCc=; b=Zbpy60XRYywSgK7KTkJj2y5BwN1Zx+ve8kAGgsAn4jemiC8JV0d8j3LwBDQq50QKo9HQ/8 ld7tA6h7f8zJ5kYuRAQxQ4+gxjSUF2Y8buoQF19BnFSGoovrjXy9ea82Qh1j2CnXHjIsoW 91elOffEwzHEu8FZ9i/OQUhck6dzV5w= Received: from junon.lin.mbt.kalray.eu ( [217.181.231.53]) by mx4.sionneau.net (OpenSMTPD) with ESMTPSA id 71137fbe (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 14 Sep 2023 14:29:45 +0000 (UTC) From: yann@sionneau.net To: devel@uclibc-ng.org Date: Thu, 14 Sep 2023 16:29:41 +0200 Message-ID: <20230914142941.25389-4-yann@sionneau.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914142941.25389-1-yann@sionneau.net> References: <20230914142941.25389-1-yann@sionneau.net> MIME-Version: 1.0 Message-ID-Hash: GRL3ZLIUV3B3ICILZAIYI5XQ7EOLCUKN X-Message-ID-Hash: GRL3ZLIUV3B3ICILZAIYI5XQ7EOLCUKN X-MailFrom: yann@sionneau.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Julian Vetter , Jonathan Borne , Yann Sionneau X-Mailman-Version: 3.3.3 Precedence: list Subject: [uclibc-ng-devel] [PATCH 4/4] fstatat: add wrapper that uses statx for non-legacy arch List-Id: uClibc-ng Development Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Yann Sionneau Add fstatat wrapper that uses statx for non-legacy arch. This allows non-legacy arch to opt-out from defining the old stat* syscalls by not defining __ARCH_WANT_NEW_STAT in their arch/xxx/include/asm/unistd.h Signed-off-by: Yann Sionneau --- libc/sysdeps/linux/common/fstatat.c | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/libc/sysdeps/linux/common/fstatat.c b/libc/sysdeps/linux/common/fstatat.c index 13673d76c..db4a8327f 100644 --- a/libc/sysdeps/linux/common/fstatat.c +++ b/libc/sysdeps/linux/common/fstatat.c @@ -31,5 +31,44 @@ int fstatat(int fd, const char *file, struct stat *buf, int flag) } libc_hidden_def(fstatat) #else + +#if defined(__NR_statx) +#include // for makedev + +int fstatat(int fd, const char *file, struct stat *buf, int flag) +{ + int ret; + struct statx tmp; + + ret = INLINE_SYSCALL(statx, 5, fd, file, flag, + STATX_BASIC_STATS, &tmp); + if (ret != 0) + return ret; + + *buf = (struct stat) { + .st_dev = makedev(tmp.stx_dev_major, tmp.stx_dev_minor), + .st_ino = tmp.stx_ino, + .st_mode = tmp.stx_mode, + .st_nlink = tmp.stx_nlink, + .st_uid = tmp.stx_uid, + .st_gid = tmp.stx_gid, + .st_rdev = makedev(tmp.stx_rdev_major, tmp.stx_rdev_minor), + .st_size = tmp.stx_size, + .st_blksize = tmp.stx_blksize, + .st_blocks = tmp.stx_blocks, + .st_atim.tv_sec = tmp.stx_atime.tv_sec, + .st_atim.tv_nsec = tmp.stx_atime.tv_nsec, + .st_mtim.tv_sec = tmp.stx_mtime.tv_sec, + .st_mtim.tv_nsec = tmp.stx_mtime.tv_nsec, + .st_ctim.tv_sec = tmp.stx_ctime.tv_sec, + .st_ctim.tv_nsec = tmp.stx_ctime.tv_nsec, + }; + + return ret; +} +libc_hidden_def(fstatat) + +#endif + /* should add emulation with fstat() and /proc/self/fd/ ... */ #endif