From nobody Sat Nov 13 15:16:39 2021 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 1E931185A620; Sat, 13 Nov 2021 15:16:40 +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 4HrzZJ0DsHz4SGc; Sat, 13 Nov 2021 15:16:40 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 DBED3159A3; Sat, 13 Nov 2021 15:16:39 +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 1ADFGdVx063363; Sat, 13 Nov 2021 15:16:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1ADFGdTi063362; Sat, 13 Nov 2021 15:16:39 GMT (envelope-from git) Date: Sat, 13 Nov 2021 15:16:39 GMT Message-Id: <202111131516.1ADFGdTi063362@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: 5690261858b6 - main - rc.d/linux: Attempt to mount only if necessary 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: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5690261858b6bd8f7d09eda2ae74f3def2d69a01 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=5690261858b6bd8f7d09eda2ae74f3def2d69a01 commit 5690261858b6bd8f7d09eda2ae74f3def2d69a01 Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-10-12 08:40:36 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-11-13 15:15:14 +0000 rc.d/linux: Attempt to mount only if necessary Currently, if the linux service is run twice, mount(8) fails with: mount: linprocfs: Device busy mount: linsysfs: Device busy mount: devfs: Device busy mount: fdescfs: Device busy mount: tmpfs: Device busy It is a bit more user-friendly if before running mount(8) the service checks if there are any file systems left to be mounted. This patch implements this behavior. Also, while here, create mount points directories (as suggested by otis). Reviewed by: trasz Approved by: trasz (src) Differential Revision: https://reviews.freebsd.org/D32463 --- libexec/rc/rc.d/linux | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/libexec/rc/rc.d/linux b/libexec/rc/rc.d/linux index fd3e3d902709..caf9c2b39737 100755 --- a/libexec/rc/rc.d/linux +++ b/libexec/rc/rc.d/linux @@ -15,6 +15,17 @@ rcvar="linux_enable" start_cmd="${name}_start" stop_cmd=":" +linux_mount() { + local _fs _mount_point + _fs="$1" + _mount_point="$2" + shift 2 + if ! mount | grep -q "^$_fs on $_mount_point ("; then + mkdir -p "$_mount_point" + mount "$@" -t "$_fs" "$_fs" "$_mount_point" + fi +} + linux_start() { local _emul_path _tmpdir @@ -61,12 +72,12 @@ linux_start() sysctl kern.elf32.fallback_brand=3 > /dev/null fi - if checkyesno linux_mounts_enable; then - mount -o nocover -t linprocfs linprocfs "${_emul_path}/proc" - mount -o nocover -t linsysfs linsysfs "${_emul_path}/sys" - mount -o nocover -t devfs devfs "${_emul_path}/dev" - mount -o nocover,linrdlnk -t fdescfs fdescfs "${_emul_path}/dev/fd" - mount -o nocover,mode=1777 -t tmpfs tmpfs "${_emul_path}/dev/shm" + if checkyesno linux_mounts_enable; then + linux_mount linprocfs "${_emul_path}/proc" -o nocover + linux_mount linsysfs "${_emul_path}/sys" -o nocover + linux_mount devfs "${_emul_path}/dev" -o nocover + linux_mount fdescfs "${_emul_path}/dev/fd" -o nocover,linrdlnk + linux_mount tmpfs "${_emul_path}/dev/shm" -o nocover,mode=1777 fi }