git: acec1d6969de - stable/13 - mount: improve error message for invalid filesystem names
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 22 Mar 2022 18:53:58 UTC
The branch stable/13 has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=acec1d6969de36eb8f8d561deb0e887f5a832f5b commit acec1d6969de36eb8f8d561deb0e887f5a832f5b Author: Piotr Pawel Stefaniak <pstef@FreeBSD.org> AuthorDate: 2021-08-14 20:06:08 +0000 Commit: Piotr Pawel Stefaniak <pstef@FreeBSD.org> 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); + } } /*