The branch main has been updated by pstef:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6e8272f317b899438165108a72fa04a4995611bd

commit 6e8272f317b899438165108a72fa04a4995611bd
Author:     Piotr Pawel Stefaniak <ps...@freebsd.org>
AuthorDate: 2021-08-14 20:06:08 +0000
Commit:     Piotr Pawel Stefaniak <ps...@freebsd.org>
CommitDate: 2021-09-15 14:25:31 +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
---
 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 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);
+               }
        }
 
        /*
_______________________________________________
dev-commits-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"

Reply via email to