The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3eed4803f943e2937325e81140b88e2e8eea8deb

commit 3eed4803f943e2937325e81140b88e2e8eea8deb
Author:     John Baldwin <[email protected]>
AuthorDate: 2023-11-18 19:08:34 +0000
Commit:     John Baldwin <[email protected]>
CommitDate: 2023-11-18 19:08:34 +0000

    vfs mount: Consistently use ENODEV internally for an invalid fstype
    
    Change vfs_byname_kld to always return an error value of ENODEV to
    indicate an unsupported fstype leaving ENOENT to indicate errors such
    as a missing mount point or invalid path.  This allows nmount(2) to
    better distinguish these cases and avoid treating a missing device
    node as an invalid fstype after commit 6e8272f317b8.
    
    While here, change mount(2) to return EINVAL instead of ENODEV for an
    invalid fstype to match nmount(2).
    
    PR:             274600
    Reviewed by:    pstef, markj
    Differential Revision:  https://reviews.freebsd.org/D42327
---
 sys/kern/vfs_init.c  | 4 +++-
 sys/kern/vfs_mount.c | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c
index c57e1471e356..64263caaef98 100644
--- a/sys/kern/vfs_init.c
+++ b/sys/kern/vfs_init.c
@@ -149,8 +149,10 @@ vfs_byname_kld(const char *fstype, struct thread *td, int 
*error)
        loaded = (*error == 0);
        if (*error == EEXIST)
                *error = 0;
-       if (*error)
+       if (*error) {
+               *error = ENODEV;
                return (NULL);
+       }
 
        /* Look up again to see if the VFS was loaded. */
        vfsp = vfs_byname(fstype);
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 1a559bfd998e..10b29b569cc5 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -996,7 +996,7 @@ vfs_donmount(struct thread *td, uint64_t fsflags, struct 
uio *fsoptions)
                jail_export = false;
 
        error = vfs_domount(td, fstype, fspath, fsflags, jail_export, &optlist);
-       if (error == ENOENT) {
+       if (error == ENODEV) {
                error = EINVAL;
                if (errmsg != NULL)
                        strncpy(errmsg, "Invalid fstype", errmsg_len);
@@ -1086,7 +1086,7 @@ sys_mount(struct thread *td, struct mount_args *uap)
        vfsp = vfs_byname_kld(fstype, td, &error);
        free(fstype, M_TEMP);
        if (vfsp == NULL)
-               return (ENOENT);
+               return (EINVAL);
        if (((vfsp->vfc_flags & VFCF_SBDRY) != 0 &&
            vfsp->vfc_vfsops_sd->vfs_cmount == NULL) ||
            ((vfsp->vfc_flags & VFCF_SBDRY) == 0 &&

Reply via email to