diff --git a/sys/amd64/amd64/autoconf.c b/sys/amd64/amd64/autoconf.c index 9fa03c306048..4f12924876cb 100644 --- a/sys/amd64/amd64/autoconf.c +++ b/sys/amd64/amd64/autoconf.c @@ -48,6 +48,7 @@ #include "opt_bootp.h" #include "opt_ffs.h" #include "opt_cd9660.h" +#include "opt_nfs.h" #include "opt_nfsroot.h" #include "opt_bus.h" #include "opt_rootdevname.h" @@ -213,12 +214,18 @@ configure_final(dummy) cold = 0; } +#ifdef BOOTP +extern void bootpc_init(void); +#endif /* * Do legacy root filesystem discovery. */ void cpu_rootconf() { +#ifdef BOOTP + bootpc_init(); +#endif #if defined(NFS) && defined(NFS_ROOT) #if !defined(BOOTP_NFSROOT) if (nfs_diskless_valid) @@ -226,7 +233,8 @@ cpu_rootconf() rootdevnames[0] = "nfs:"; #endif #if defined(FFS) && defined(FFS_ROOT) - setroot(); + if (!rootdevnames[0]) + setroot(); #endif } SYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL) diff --git a/sys/i386/i386/autoconf.c b/sys/i386/i386/autoconf.c index 9fa03c306048..4f12924876cb 100644 --- a/sys/i386/i386/autoconf.c +++ b/sys/i386/i386/autoconf.c @@ -48,6 +48,7 @@ #include "opt_bootp.h" #include "opt_ffs.h" #include "opt_cd9660.h" +#include "opt_nfs.h" #include "opt_nfsroot.h" #include "opt_bus.h" #include "opt_rootdevname.h" @@ -213,12 +214,18 @@ configure_final(dummy) cold = 0; } +#ifdef BOOTP +extern void bootpc_init(void); +#endif /* * Do legacy root filesystem discovery. */ void cpu_rootconf() { +#ifdef BOOTP + bootpc_init(); +#endif #if defined(NFS) && defined(NFS_ROOT) #if !defined(BOOTP_NFSROOT) if (nfs_diskless_valid) @@ -226,7 +233,8 @@ cpu_rootconf() rootdevnames[0] = "nfs:"; #endif #if defined(FFS) && defined(FFS_ROOT) - setroot(); + if (!rootdevnames[0]) + setroot(); #endif } SYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL) diff --git a/sys/kern/vfs_conf.c b/sys/kern/vfs_conf.c index afa6fa53e95a..f3d39f0fc7a1 100644 --- a/sys/kern/vfs_conf.c +++ b/sys/kern/vfs_conf.c @@ -200,7 +200,7 @@ vfs_mountroot_try(char *mountfrom) printf("setrootbyname failed\n"); /* If the root device is a type "memory disk", mount RW */ - if (devsw(rootdev) && (devsw(rootdev)->d_flags & D_MEMDISK)) + if (rootdev != NODEV && devsw(rootdev) && (devsw(rootdev)->d_flags & D_MEMDISK)) mp->mnt_flag &= ~MNT_RDONLY; error = VFS_MOUNT(mp, NULL, NULL, NULL, curproc); diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index afa6fa53e95a..f3d39f0fc7a1 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -200,7 +200,7 @@ vfs_mountroot_try(char *mountfrom) printf("setrootbyname failed\n"); /* If the root device is a type "memory disk", mount RW */ - if (devsw(rootdev) && (devsw(rootdev)->d_flags & D_MEMDISK)) + if (rootdev != NODEV && devsw(rootdev) && (devsw(rootdev)->d_flags & D_MEMDISK)) mp->mnt_flag &= ~MNT_RDONLY; error = VFS_MOUNT(mp, NULL, NULL, NULL, curproc);