From nobody Fri Apr 28 08:57:07 2023 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 4Q761J1vrTz48C23; Fri, 28 Apr 2023 08:57:08 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q761J0tLjz4RMj; Fri, 28 Apr 2023 08:57:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682672228; 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=TzxR4F/4Tdtv7Eg75btU0zTpjHmpFg/OqRf83LP/yXg=; b=jXtbNqYjVw0MDO6xNI9xy4PK7ZaxqAJ2Vuxc6SF9dEw4P+T5eOCcTdQsGptkGF2MGKt7qD kc2hnxGmzMPAw5C6gACE/apiJyGcRnTAb09/4CVdLomRHDxqBoFB8VnKiGIFVEOZpOuJUJ PibXZs51hzPGyzwsf4VdV22i7DwLjohVVBRIdmzK2usC0j9W0CWgAqinWS3j7gC1zIUX9a qFfoiBh0k3A45ftuUz6o0pmTCI461l04yfqH+o1LHfQxQIlyuGo283XxQMJz6ZBryOlEZu SBNwBWPgPl8Zz2VBNDWYAGZu10SDk1lmIsXjH6sZ494zQg+9xRZLFAGyPRPs1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682672228; 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=TzxR4F/4Tdtv7Eg75btU0zTpjHmpFg/OqRf83LP/yXg=; b=ri9BgpKBfufrp7Xs3GNu7pjbAGxz817e/rO9nA/x0SBLsod5Bg0JIa09LIr9m/GCZE9jFg F5BjwVVaReMmmBpoQEN2YM+uhkkonkHZNobCFGMj7zVEcFPsS9dfm8tzruPGBGthtqPKUd YAbnexPdfL7GvEfOhFTkNl0SJFfbUWf0TF4k86aH9xcP+WcjJhTYR6H24zNzW4GTMALWnh K6izOgUXGkA1CKwJtea2zxA3nCcdMBV9WnSuz/QHl4ncFUMLz57KPVpEpjk1oC5c3bZidK z1tQ/UToG0d9xAA/Jg9em81GJUp4XWFoWlxhmPepoLVnISjHCN1bVE635znRoA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682672228; a=rsa-sha256; cv=none; b=olB0buKXBVeuDmGVJdROYkSVqZOmqXsOZKOebM7Kkpx66nKyNglCgY5ibGjxib2/rOYx78 mqGcVSwO9aIX397KnL6aK5TQQyXEQ3UYErIm8RQhAluk17dDQwB0YHzeN1PrWkTlRlvd+O 8JTuEwI4dZ0MDCLwCIxf//Kp+zYul75/p9Y1D7Z9PCEuOJksgU1hOjqoCa+T42RZ3zCTtz Qd8oHOzWmVue5ZT/+YpN4JMMjOtupwBBPjzFWOAk84c8PI03G1NmhkMAz/EqCgCe437NwI RVELLMNPzTujYG80yJQOUisZD/GMBQaS3lZtVgD3DoFYeoV3y9XQ/ZQ0zwSavw== 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 4Q761H72vyzt05; Fri, 28 Apr 2023 08:57:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33S8v79i017906; Fri, 28 Apr 2023 08:57:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33S8v7aP017905; Fri, 28 Apr 2023 08:57:07 GMT (envelope-from git) Date: Fri, 28 Apr 2023 08:57:07 GMT Message-Id: <202304280857.33S8v7aP017905@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 6072eea0c375 - main - linux(4): Move translate_vnhook_major_minor() into the Linux common module 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6072eea0c375fc3ab0cf5bb494c75d1beac7b8ba Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=6072eea0c375fc3ab0cf5bb494c75d1beac7b8ba commit 6072eea0c375fc3ab0cf5bb494c75d1beac7b8ba Author: Dmitry Chagin AuthorDate: 2023-04-28 08:54:58 +0000 Commit: Dmitry Chagin CommitDate: 2023-04-28 08:54:58 +0000 linux(4): Move translate_vnhook_major_minor() into the Linux common module --- sys/compat/linux/linux_stats.c | 24 ------------------------ sys/compat/linux/linux_util.c | 26 ++++++++++++++++++++++++++ sys/compat/linux/linux_util.h | 3 +++ 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c index 79937fd9fa86..219f4a602eb4 100644 --- a/sys/compat/linux/linux_stats.c +++ b/sys/compat/linux/linux_stats.c @@ -52,30 +52,6 @@ __FBSDID("$FreeBSD$"); #include #include -static void -translate_vnhook_major_minor(struct vnode *vp, struct stat *sb) -{ - int major, minor; - - if (vn_isdisk(vp)) { - sb->st_mode &= ~S_IFMT; - sb->st_mode |= S_IFBLK; - } - - /* - * Return the same st_dev for every devfs instance. The reason - * for this is to work around an idiosyncrasy of glibc getttynam() - * implementation: it checks whether st_dev returned for fd 0 - * is the same as st_dev returned for the target of /proc/self/fd/0 - * symlink, and with linux chroots having their own devfs instance, - * the check will fail if you chroot into it. - */ - if (rootdevmp != NULL && vp->v_mount->mnt_vfc == rootdevmp->mnt_vfc) - sb->st_dev = rootdevmp->mnt_stat.f_fsid.val[0]; - - if (linux_vn_get_major_minor(vp, &major, &minor) == 0) - sb->st_rdev = (major << 8 | minor); -} static int linux_kern_statat(struct thread *td, int flag, int fd, const char *path, diff --git a/sys/compat/linux/linux_util.c b/sys/compat/linux/linux_util.c index 6d82f87a3b31..dd739fde2551 100644 --- a/sys/compat/linux/linux_util.c +++ b/sys/compat/linux/linux_util.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -225,6 +226,31 @@ linux_vn_get_major_minor(const struct vnode *vp, int *major, int *minor) return (error); } +void +translate_vnhook_major_minor(struct vnode *vp, struct stat *sb) +{ + int major, minor; + + if (vn_isdisk(vp)) { + sb->st_mode &= ~S_IFMT; + sb->st_mode |= S_IFBLK; + } + + /* + * Return the same st_dev for every devfs instance. The reason + * for this is to work around an idiosyncrasy of glibc getttynam() + * implementation: it checks whether st_dev returned for fd 0 + * is the same as st_dev returned for the target of /proc/self/fd/0 + * symlink, and with linux chroots having their own devfs instance, + * the check will fail if you chroot into it. + */ + if (rootdevmp != NULL && vp->v_mount->mnt_vfc == rootdevmp->mnt_vfc) + sb->st_dev = rootdevmp->mnt_stat.f_fsid.val[0]; + + if (linux_vn_get_major_minor(vp, &major, &minor) == 0) + sb->st_rdev = (major << 8 | minor); +} + char * linux_get_char_devices(void) { diff --git a/sys/compat/linux/linux_util.h b/sys/compat/linux/linux_util.h index 37445ad0af27..f61aeea99136 100644 --- a/sys/compat/linux/linux_util.h +++ b/sys/compat/linux/linux_util.h @@ -105,6 +105,8 @@ struct linux_device_handler { int linux_char_device; }; +struct stat; + int linux_device_register_handler(struct linux_device_handler *h); int linux_device_unregister_handler(struct linux_device_handler *h); char *linux_driver_get_name_dev(device_t dev); @@ -112,6 +114,7 @@ int linux_driver_get_major_minor(const char *node, int *major, int *minor); int linux_vn_get_major_minor(const struct vnode *vn, int *major, int *minor); char *linux_get_char_devices(void); void linux_free_get_char_devices(char *string); +void translate_vnhook_major_minor(struct vnode *vp, struct stat *sb); #if defined(KTR)