From nobody Tue Sep 24 17:58:50 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XCnff3BFzz5Y6Rm; Tue, 24 Sep 2024 17:58:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XCnff2b0jz4dQn; Tue, 24 Sep 2024 17:58:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727200730; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=USSEQyyJmi6e9ZCEuozN1AMAcin7u5GX6pqpQ9Ig+tg=; b=rhnFuDRWLjG35Zo1sQRsLN19Eede1fAZ6oSoHYpMOJvgAL4Uqz21oRBX1UPrmZBJBI9mRs UHlQpGKpMFKoy/6naQQtBXrJqC7qadz2xHqumNs2Krl9vpR9Ws1YDucA3Zy5ns/NuuLNea 4AZoy/oGuV0Kb+xcgX7HG2aBBP6W9Xire7rg0o+RRjmO8Hh+QISeO5Gd73EoXFXHnB6L2l xfveKgPGO1uBDhEhuV/4xqYeaybKKiDYRRzioQ9f9v2LFQuP0s8wU+GOv+xAJSjd3huJoV K0MhmjN0Ole9F9rwpchRzGfHR1JeP4xXXIta7MgtZkEEM93r26qWe5lAFPE/6A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727200730; a=rsa-sha256; cv=none; b=ZBJBRFlx9f2p5AIjs3NnBlFpPC6D7V+bNsZQx8e1bUvKH17AEnMyh0ChRB7wQlsDMfdDmO jLHECQPTaW8siRJPipf1nX9vSD6g3J/WGTyulxdWVEfkgtl5/IPCG9cA1hcVb5qClI0StC dISH0c4wrzHb4TiBPemIViQaQ6S+nO1b4v397rsSdSm56dNJI2pV5dDvMttL99qdqdUaAq 8Tc1vmrPOHGmlypIvHGyUYGgdWSkuF9zRd8eIEXuwRCXKDQYiaXjnqm8opnCxtNmwB4nBW 37AWGPzNomySHY6pFl8t2S9B7ReZ5S0iK5YQZjn5nTDVvJCX8fSIfwmDS0i2ww== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727200730; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=USSEQyyJmi6e9ZCEuozN1AMAcin7u5GX6pqpQ9Ig+tg=; b=Li6N91ViI6PBfAytYf0dYegoMNmbZQklNwAiDbMplZj5lDgwrKb0rZ4YOZT0OHb+bU/4OA 4Xnk3PnzpaJWKOjlQp5Hq1GMe+AncGfLcycJ3p4Ae1qwPTbm+g0fqNraHHXL+MGbhglxT3 5hylynCsGq+OvDGez/EOtpEHZV1UdSqGy2y0unzt9PtZKlNLab/kfxm9e0KUsZrm9QTbw3 Yj5x9Famt7U+cR/GalUkhaMUK63UzBasEjNiGgx59Hl450cN/29pJtBtu9UCcZ6jCa1j05 FSbAp6PO5OxlmV5e7keNZHlYu6FWcojHjAj9gVXWUoG7FgLarnx2nKSkEs77yw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XCnff25QXzdsn; Tue, 24 Sep 2024 17:58:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48OHwoBJ061658; Tue, 24 Sep 2024 17:58:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48OHwoYQ061655; Tue, 24 Sep 2024 17:58:50 GMT (envelope-from git) Date: Tue, 24 Sep 2024 17:58:50 GMT Message-Id: <202409241758.48OHwoYQ061655@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 3cf834d069d1 - main - linuxulator: ignore AT_NO_AUTOMOUNT for all stat variants List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3cf834d069d1dcdbe464ea74624930eaf916715d Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=3cf834d069d1dcdbe464ea74624930eaf916715d commit 3cf834d069d1dcdbe464ea74624930eaf916715d Author: Ed Maste AuthorDate: 2024-09-19 21:11:19 +0000 Commit: Ed Maste CommitDate: 2024-09-24 17:58:42 +0000 linuxulator: ignore AT_NO_AUTOMOUNT for all stat variants Commit ff39d74aa99a ignored AT_NO_AUTOMOUNT for statx(), but did not change fstat64() or newfstatat(), which also take an equivalent flags argument. Add a linux_to_bsd_stat_flags() helper and use it in all three places. PR: 281526 Reviewed by: trasz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46711 --- sys/compat/linux/linux_stats.c | 65 +++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c index 6c032cc569f8..03783d466211 100644 --- a/sys/compat/linux/linux_stats.c +++ b/sys/compat/linux/linux_stats.c @@ -485,6 +485,31 @@ linux_ustat(struct thread *td, struct linux_ustat_args *args) } #endif +/* + * Convert Linux stat flags to BSD flags. Return value indicates successful + * conversion (no unknown flags). + */ +static bool +linux_to_bsd_stat_flags(int linux_flags, int *out_flags) +{ + int flags, unsupported; + + unsupported = linux_flags & ~(LINUX_AT_SYMLINK_NOFOLLOW | + LINUX_AT_EMPTY_PATH | LINUX_AT_NO_AUTOMOUNT); + if (unsupported != 0) { + *out_flags = unsupported; + return (false); + } + + flags = 0; + if (linux_flags & LINUX_AT_SYMLINK_NOFOLLOW) + flags |= AT_SYMLINK_NOFOLLOW; + if (linux_flags & LINUX_AT_EMPTY_PATH) + flags |= AT_EMPTY_PATH; + *out_flags = flags; + return (true); +} + #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) static int @@ -561,21 +586,16 @@ linux_fstat64(struct thread *td, struct linux_fstat64_args *args) int linux_fstatat64(struct thread *td, struct linux_fstatat64_args *args) { - int error, dfd, flag, unsupported; + int error, dfd, flags; struct stat buf; - unsupported = args->flag & ~(LINUX_AT_SYMLINK_NOFOLLOW | LINUX_AT_EMPTY_PATH); - if (unsupported != 0) { - linux_msg(td, "fstatat64 unsupported flag 0x%x", unsupported); + if (!linux_to_bsd_stat_flags(args->flag, &flags)) { + linux_msg(td, "fstatat64 unsupported flags 0x%x", flags); return (EINVAL); } - flag = (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) ? - AT_SYMLINK_NOFOLLOW : 0; - flag |= (args->flag & LINUX_AT_EMPTY_PATH) ? - AT_EMPTY_PATH : 0; dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; - error = linux_kern_statat(td, flag, dfd, args->pathname, + error = linux_kern_statat(td, flags, dfd, args->pathname, UIO_USERSPACE, &buf); if (error == 0) error = stat64_copyout(&buf, args->statbuf); @@ -588,22 +608,16 @@ linux_fstatat64(struct thread *td, struct linux_fstatat64_args *args) int linux_newfstatat(struct thread *td, struct linux_newfstatat_args *args) { - int error, dfd, flag, unsupported; + int error, dfd, flags; struct stat buf; - unsupported = args->flag & ~(LINUX_AT_SYMLINK_NOFOLLOW | LINUX_AT_EMPTY_PATH); - if (unsupported != 0) { - linux_msg(td, "fstatat unsupported flag 0x%x", unsupported); + if (!linux_to_bsd_stat_flags(args->flag, &flags)) { + linux_msg(td, "fstatat unsupported flags 0x%x", flags); return (EINVAL); } - flag = (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) ? - AT_SYMLINK_NOFOLLOW : 0; - flag |= (args->flag & LINUX_AT_EMPTY_PATH) ? - AT_EMPTY_PATH : 0; - dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; - error = linux_kern_statat(td, flag, dfd, args->pathname, + error = linux_kern_statat(td, flags, dfd, args->pathname, UIO_USERSPACE, &buf); if (error == 0) error = newstat_copyout(&buf, args->statbuf); @@ -688,21 +702,14 @@ statx_copyout(struct stat *buf, void *ubuf) int linux_statx(struct thread *td, struct linux_statx_args *args) { - int error, dirfd, flags, unsupported; + int error, dirfd, flags; struct stat buf; - unsupported = args->flags & ~(LINUX_AT_SYMLINK_NOFOLLOW | - LINUX_AT_EMPTY_PATH | LINUX_AT_NO_AUTOMOUNT); - if (unsupported != 0) { - linux_msg(td, "statx unsupported flags 0x%x", unsupported); + if (!linux_to_bsd_stat_flags(args->flags, &flags)) { + linux_msg(td, "statx unsupported flags 0x%x", flags); return (EINVAL); } - flags = (args->flags & LINUX_AT_SYMLINK_NOFOLLOW) ? - AT_SYMLINK_NOFOLLOW : 0; - flags |= (args->flags & LINUX_AT_EMPTY_PATH) ? - AT_EMPTY_PATH : 0; - dirfd = (args->dirfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dirfd; error = linux_kern_statat(td, flags, dirfd, args->pathname, UIO_USERSPACE, &buf);