From nobody Tue Feb 22 13:24:41 2022 X-Original-To: dev-commits-src-branches@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 1D91919DE574; Tue, 22 Feb 2022 13:24:42 +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 4K30JV09jcz4sL4; Tue, 22 Feb 2022 13:24:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645536282; 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=jY8l13z5DcN3cPDw/oZWnXmAIxjNtEQ/BRNgF0u23BY=; b=JIxkfr3QlX/fn3u5anAoJ67z1L5ZfZk/ryuuVhFh4npz/bTfmRmVzGVnzm739i6LcGkobL 9mDaCkZCdPZFinqgl6iWRoevEdLq3c/oGyf027EtqS9ZTrk1+kOxCACmEEJZsvCMQFqdIG 9IAwMXK8V7zOiFV4m3gHTH/wvOKOFbEiAN71+6e1xQNl6MB9wQp/SlvFvgyCRd7BHSV9SU sv5vjZsBzqmLjY0gRks0LIY8Caz8pniI9S/pf6thj7JxQvPrOlHJl24trB/50+f6KFwtAU bWMiSoc6yLsxXgbYbCVDhJBQX+3VQqF9PMDGgQ2MVXz48wseYY3Du9gDGq48Vw== 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 D638B25052; Tue, 22 Feb 2022 13:24:41 +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 21MDOf2r000172; Tue, 22 Feb 2022 13:24:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21MDOfFw000171; Tue, 22 Feb 2022 13:24:41 GMT (envelope-from git) Date: Tue, 22 Feb 2022 13:24:41 GMT Message-Id: <202202221324.21MDOfFw000171@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Edward Tomasz Napierala Subject: git: 0bf6e572bd44 - stable/13 - rc.d/linux: Attempt to mount only if necessary List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0bf6e572bd446c6a6cbbafc8861616080d31cdb1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645536282; 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=jY8l13z5DcN3cPDw/oZWnXmAIxjNtEQ/BRNgF0u23BY=; b=xuk4M9BJ4egmdQzNFMA4yIDR5AHGx/b6pSeW4jX1r3EomnEJHRORdpJW5ZknBNDmGCaYdf EuL2UvQ1kPMFfExLcYEtG37tF5s4A1AxON04L3xRy08tYK+wfsMZ3MR25kYSMtkTSXo/W0 fTWI122jud0kIjQbsmyXpUipYfsR95GSp/WPdkN71ApgeeULYFSLvpjwC6m9LUR5IwULy6 K862Ic3KmT7V1qa6e+P9sXwi+Nn7AiINSFIsybZBTHZ1wahkpCfVfx8gscVLYFALPtU1Id 4QMUGTEVlPwJB4Hl24b9eArCK8wnHEvTacABK7EFeXqBIQMPPySAEa7Y1agLxw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645536282; a=rsa-sha256; cv=none; b=Bb509lESaXZA/vxJYsHIWBP0SJbyJa0hR56hT20sey7lrERzigpX67bFTuOADE8ZzQ71gC vM6gP0wkkCklIuXcNaK5xo0Q429o/68iC/MV0VX9XzyCo3TXpgmjrOOF5Lyzi6aLqdcOJY KL+aQGDqmlzQucWApb1CWlXpRgX+2OiXd/SSPwLXPT3meFL5C9cwQ3E5qIKjOZ2LfTYZlE YzPmq09mF4rhAGZ9LvBP+nmZQrbQRedRLji7SNUiIvCtgh4PyTLNFk7L5nDVWyjz4oRh28 Hep2rLE1ktGmG34JFnTfqL4CGP5uYSa6j5/wWOO0LlhAJt8kiH0t1CPdrsqPSQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=0bf6e572bd446c6a6cbbafc8861616080d31cdb1 commit 0bf6e572bd446c6a6cbbafc8861616080d31cdb1 Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-10-12 08:40:36 +0000 Commit: Edward Tomasz Napierala CommitDate: 2022-02-16 23:54:44 +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 (cherry picked from commit 5690261858b6bd8f7d09eda2ae74f3def2d69a01) --- 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 2cf32a1ecec3..adb9f4c64bad 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 }