From de4cbbf593ed1b3e905d95edb37661f3e9806086 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Thu, 25 Nov 2004 09:47:51 +0000 Subject: [PATCH] Integrate the relevant bits of vfs_rootmountalloc() where it matters. --- sys/kern/vfs_mount.c | 56 ++++++++++++++------------------------------ sys/sys/mount.h | 1 - 2 files changed, 18 insertions(+), 39 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 25fe5898e02a..917d4e27a20d 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -1165,37 +1165,6 @@ dounmount(mp, flags, td) return (0); } -/* - * Lookup a filesystem type, and if found allocate and initialize - * a mount structure for it. - * - * Devname is usually updated by mount(8) after booting. - */ -int -vfs_rootmountalloc(fstypename, devname, mpp) - char *fstypename; - char *devname; - struct mount **mpp; -{ - struct thread *td = curthread; /* XXX */ - struct vfsconf *vfsp; - struct mount *mp; - int error; - - if (fstypename == NULL) - return (ENODEV); - vfsp = vfs_byname(fstypename); - if (vfsp == NULL) - return (ENODEV); - error = vfs_mount_alloc(NULLVP, vfsp, "/", td, &mp); - if (error) - return (error); - mp->mnt_flag |= MNT_RDONLY | MNT_ROOTFS; - strlcpy(mp->mnt_stat.f_mntfromname, devname, MNAMELEN); - *mpp = mp; - return (0); -} - /* * Find and mount the root filesystem */ @@ -1289,6 +1258,8 @@ static int vfs_mountroot_try(const char *mountfrom) { struct mount *mp; + struct thread *td = curthread; + struct vfsconf *vfsp; char *vfsname, *path; int error; char patt[32]; @@ -1303,7 +1274,7 @@ vfs_mountroot_try(const char *mountfrom) return (error); /* don't complain */ s = splcam(); /* Overkill, but annoying without it */ - printf("Mounting root from %s\n", mountfrom); + printf("Trying to mount root from %s\n", mountfrom); splx(s); /* parse vfs name and path */ @@ -1314,14 +1285,23 @@ vfs_mountroot_try(const char *mountfrom) if (sscanf(mountfrom, patt, vfsname, path) < 1) goto done; - /* allocate a root mount */ - error = vfs_rootmountalloc(vfsname, path[0] != 0 ? path : ROOTNAME, - &mp); - if (error != 0) { - printf("Can't allocate root mount for filesystem '%s': %d\n", - vfsname, error); + if (path[0] == '\0') + strcpy(path, ROOTNAME); + + vfsp = vfs_byname(vfsname); + if (vfsp == NULL) { + printf("Can't find filesystem \"%s\"\n", vfsname); goto done; } + error = vfs_mount_alloc(NULLVP, vfsp, "/", td, &mp); + if (error) { + printf("Could not alloc mountpoint\n"); + goto done; + } + + mp->mnt_flag |= MNT_RDONLY | MNT_ROOTFS; + + strlcpy(mp->mnt_stat.f_mntfromname, path, MNAMELEN); /* * do our best to set rootdev diff --git a/sys/sys/mount.h b/sys/sys/mount.h index c60e30286676..13036edc21bc 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -584,7 +584,6 @@ struct cdev *vfs_getrootfsid(struct mount *); struct mount *vfs_getvfs(fsid_t *); /* return vfs given fsid */ int vfs_modevent(module_t, int, void *); void vfs_mountroot(void); /* mount our root filesystem */ -int vfs_rootmountalloc(char *, char *, struct mount **); void vfs_mount_destroy(struct mount *, struct thread *); int vfs_suser(struct mount *, struct thread *); void vfs_unbusy(struct mount *, struct thread *);