From nobody Tue Mar 22 18:53:58 2022 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 44B8F1A2B8C4; Tue, 22 Mar 2022 18:54:00 +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 4KNLHW2wmBz3tKd; Tue, 22 Mar 2022 18:53:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647975240; 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=K1xU0FqGMx6va7stVoxVR+RA5IrCKRf5BptW6Ahsjgo=; b=Sg3riwAButQb/96VTp5eChO1x0bn36o86WtRQ1snQvwTlceuD0Pb1xprURlJlPtXibvFFN 4hJYB2YynHuVyvYP9owgezEyAwJ3bI+ipwrcaPVxOAvummQ2UgL3dF9e5ROZYkfW07jBkr 7KLX8J9Kp/JdeAtTlNtVdLDkospJcb5J57Xu78tnfpHRa/iSUiYGWZ5iPibA8x40J5p5Ao ATtar7a/G6clt5Bgml8ATRc6GlwxZY1Tav8X6orDo2792GPUplLv9jg76udoUfIJkem7KV pxOGdWCJJHWWUF53+qa6EtH19cCik/zOqQrCL9KVS6fzJGhJ/EVy3MPfyTCfNw== 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 C456914EB5; Tue, 22 Mar 2022 18:53:58 +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 22MIrwE4099858; Tue, 22 Mar 2022 18:53:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22MIrwXL099857; Tue, 22 Mar 2022 18:53:58 GMT (envelope-from git) Date: Tue, 22 Mar 2022 18:53:58 GMT Message-Id: <202203221853.22MIrwXL099857@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: acec1d6969de - stable/13 - mount: improve error message for invalid filesystem names 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: pstef X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: acec1d6969de36eb8f8d561deb0e887f5a832f5b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647975240; 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=K1xU0FqGMx6va7stVoxVR+RA5IrCKRf5BptW6Ahsjgo=; b=aZPK/YY2lCor82OyopJj7NptBS+eSKjrw3Z0crSnKKEMO6DOOsBGppl3MyV7XZfU+CHUvD kqYL5SnYCo3B6HIx+NLJuqxBWut3iIDBCukukGeytDXTsX2XmySZJeWovOMEBGwVR8orgV gBne82Bpjas4tGOttrI2mzbPPbe78MhKJZmHhO1IZpv5e8/vN3CeEumZx02XmwaVeHHaRl vOaKr+NgimXOMiqen6Htbi6/9N/ke+pNw5Yw3U+VxSzBSSVliJ/T099uzaP0iesjd33qgA JvHzUbBl2iJSePkDWu8aS8qwJ1T8P/5YGAiBxAwtt2xoqOv3iSUvfTo80peNLw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647975240; a=rsa-sha256; cv=none; b=uwUE33apzT+siKS9GDx+3e3QQ2ajpixF5dn3QbrU2swE676MP781DuOA2JdBg2BCJIqouK 5OquwsRxWMXAeQZkJrt3tsKzQcCzv2qwbFsGIr/Tsw0V+3/npN7NRNnZt2jIV+pv3qughH 9wwaf5pZsgzAH6d7Y15ZiFewEYxj0fawaCa5J3Tko4sRBtBp0EzFXdnt2aa08zL5kf5QbF KIcDHueGNQ5Es+cZBOUAISfMPZTTZ6xjfGouWulEh3kwGdxyer6oodRQSiH6tfdBaHw4RE 5zRWdm1mfhNgOgnAKRiMPK3UG+OkNROROpiObBpsKzPXhh5+TwiIV641QTdwAA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=acec1d6969de36eb8f8d561deb0e887f5a832f5b commit acec1d6969de36eb8f8d561deb0e887f5a832f5b Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-14 20:06:08 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2022-03-22 18:47:13 +0000 mount: improve error message for invalid filesystem names For an invalid filesystem name used like this: mount -t asdfs /dev/ada1p5 /usr/obj emit an error message like this: mount: /dev/ada1p5: Invalid fstype: Invalid argument instead of: mount: /dev/ada1p5: Operation not supported by device Differential Revision: https://reviews.freebsd.org/D31540 (cherry picked from commit 6e8272f317b899438165108a72fa04a4995611bd) --- sys/kern/vfs_mount.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 1ecb2b5939d5..44c9800ac493 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -823,6 +823,12 @@ vfs_donmount(struct thread *td, uint64_t fsflags, struct uio *fsoptions) } error = vfs_domount(td, fstype, fspath, fsflags, &optlist); + if (error == ENOENT) { + error = EINVAL; + if (errmsg != NULL) + strncpy(errmsg, "Invalid fstype", errmsg_len); + goto bail; + } /* * See if we can mount in the read-only mode if the error code suggests @@ -1367,12 +1373,13 @@ vfs_domount( vfsp = NULL; if ((fsflags & MNT_UPDATE) == 0) { /* Don't try to load KLDs if we're mounting the root. */ - if (fsflags & MNT_ROOTFS) - vfsp = vfs_byname(fstype); - else - vfsp = vfs_byname_kld(fstype, td, &error); - if (vfsp == NULL) - return (ENODEV); + if (fsflags & MNT_ROOTFS) { + if ((vfsp = vfs_byname(fstype)) == NULL) + return (ENODEV); + } else { + if ((vfsp = vfs_byname_kld(fstype, td, &error)) == NULL) + return (error); + } } /*