From nobody Sun Sep 29 22:37:26 2024 X-Original-To: dev-commits-src-all@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 4XGzbq11Y2z5XK6s; Sun, 29 Sep 2024 22:37:27 +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 4XGzbp74wyz4gWX; Sun, 29 Sep 2024 22:37:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727649447; 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=efmfeMs0krmne+JSXirEoI+y7jZ544ay+iTlf+h0A54=; b=WWSXG0dFtQnM/j0OEoXemwGdDBDh13XABtVLRoONppfFMS+0jBNbsy2Em7mFp2P02twLp4 yV3eePhibpG83Mv3zwflI1M2054Ci8hI7Xv2rWPXUnxuWdHepLMvBkLXdKwn/NipQDVr7H Q7CO2HhAF78cMYclruP3HalxDzsXLMCKm2kSYtUkk6qyARueLcfgbC1RU6vTvlJP00ngJU B5h1OxOZW0grpL53U8ZCOCx8LSr26L2SXbHtK1WXpKFSd65LiRb5W+yPJ6jXGfLRwTWtRb pxUvg+IBOerJHc6dupIzTn1ks+tkRid1BDgJ8948HSJves4p4ASGxTG44cSNQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727649447; 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=efmfeMs0krmne+JSXirEoI+y7jZ544ay+iTlf+h0A54=; b=X1Ab6P/kCOHOVVrHdSM+oEQWwdjznN9GR4/OlPlfi82AAenHZZmRXuM9BZu7MgytM8h7ji UzWYfZdLXfdwnApPx2h50uzREVUt9MVeEH6tZZ8NhoC+KWKHGrcK+g+nNAJPtSr/bh8EHS II0KOk9Qo4IPJnnHbN2JlQiBN5mFNLTMaiVpapCi2QT5R6pmMNge5bewbatj9nm7njkCGw 1aG05NKzC5ay/+dICqduSauom6zdFcqbKfnCiVkd+b28OuD68iZG5x4vTiVaAPj54YkxrT YOgMgVuOiQRcCJ+6K7P3G/YauhvmjOC+6vh37HPz90TWA3wD0k2OTogbAz1PRw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727649447; a=rsa-sha256; cv=none; b=HFBMx5YsufjRV1rslyrYV+pv9fLVugt3arpELLjSWlboq4kR0QsCT3DLf1P0++OTjzs90R nD8bXXJ6YVvD8My2KwsLnR/FVXETrQSDVe6KJnMHYvu3y2bVMjx3w0eOdElKKXLrHoaPXg w8DxrLN8m9K/aooKNzspkWV+rWKIg4noy8ty3ehMKqexs48w3NwFhqzujktafDR7WFBu5I iT6y7k9XdoqGwCTbezb4LAV+TY3q070fRuBS4ve26Sjh9Eh0QEavc1UEIoSTxfWtoiRD1U WqMgpIiE/SZAjWW/vUpB6QMsdtS0wpt3+/HCu+8d7mjTzZ7y0bSJLisk3bcDXw== 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 4XGzbp6gpXzRsD; Sun, 29 Sep 2024 22:37:26 +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 48TMbQ9b059112; Sun, 29 Sep 2024 22:37:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48TMbQ2x059109; Sun, 29 Sep 2024 22:37:26 GMT (envelope-from git) Date: Sun, 29 Sep 2024 22:37:26 GMT Message-Id: <202409292237.48TMbQ2x059109@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 99d3ce80ba07 - stable/14 - linuxulator: ignore AT_NO_AUTOMOUNT for all stat variants List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 99d3ce80ba07e751226a7ff07afc51ad2d79ccce Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=99d3ce80ba07e751226a7ff07afc51ad2d79ccce commit 99d3ce80ba07e751226a7ff07afc51ad2d79ccce Author: Ed Maste AuthorDate: 2024-09-19 21:11:19 +0000 Commit: Ed Maste CommitDate: 2024-09-29 22:37:02 +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 (cherry picked from commit 3cf834d069d1dcdbe464ea74624930eaf916715d) --- 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);