aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPiotr Pawel Stefaniak <pstef@FreeBSD.org>2021-08-14 20:06:08 +0000
committerPiotr Pawel Stefaniak <pstef@FreeBSD.org>2021-09-15 14:25:31 +0000
commit6e8272f317b899438165108a72fa04a4995611bd (patch)
treeaea32b2557efe1974ed371b0ad8b59e422e25909 /sys
parent2de4c7f6d08798fb6269582907155703d1ab5ef4 (diff)
downloadsrc-6e8272f317b899438165108a72fa04a4995611bd.tar.gz
src-6e8272f317b899438165108a72fa04a4995611bd.zip
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
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_mount.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 73fd8321c9da..55c62b7fe491 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -966,6 +966,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
@@ -1525,12 +1531,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);
+ }
}
/*