コード例 #1
0
ファイル: vfs_synth.c プロジェクト: wan721/DragonFlyBSD
struct vnode *
getsynthvnode(const char *devname)
{
	struct vnode *vp;
	struct nchandle nch;
	struct nlookupdata nd;
	struct ucred *cred = proc0.p_ucred;
	int error;

	KKASSERT(synth_inited != 0);
	KKASSERT(synth_mp != NULL);
	KKASSERT(synth_mp->mnt_ncmountpt.mount != NULL);

	/* Sync devfs/disks twice to make sure all devices are around */
	if (synth_synced < 2) {
		sync_devs();
		++synth_synced;
	}

	error = nlookup_init_root(&nd,
	     devname, UIO_SYSSPACE, NLC_FOLLOW,
	     cred, &synth_mp->mnt_ncmountpt,
	     &synth_mp->mnt_ncmountpt);

	if (error) {
		panic("synth: nlookup_init_root failed with %d", error);
		/* NOTREACHED */
	}

	error = nlookup(&nd);
	if (error == 0) {
		if (nd.nl_nch.ncp->nc_vp == NULL) {
			kprintf("synth: nc_vp == NULL\n");
			return (NULL);
		}
		nch = nd.nl_nch;
		cache_zero(&nd.nl_nch);
	}

	nlookup_done(&nd);
	if (error) {
		if (error != ENOENT) { /* Don't bother warning about ENOENT */
			kprintf("synth: nlookup of %s failed with %d\n",
			    devname, error);
		}
		return (NULL);
	}

	vp = nch.ncp->nc_vp;
	/* A VX locked & refd vnode must be returned. */
	error = vget(vp, LK_EXCLUSIVE);
	cache_unlock(&nch);

	if (error) {
		kprintf("synth: could not vget vnode\n");
		return (NULL);
	}

	return (vp);
}
コード例 #2
0
static void
dump_conf(void *dummy)
{
	char *path;
	cdev_t dev;

	path = kmalloc(MNAMELEN, M_TEMP, M_WAITOK);
	if (TUNABLE_STR_FETCH("dumpdev", path, MNAMELEN) != 0) {
		sync_devs();
		dev = kgetdiskbyname(path);
		if (dev != NULL)
			dumpdev = dev;
	}
	kfree(path, M_TEMP);
	if (setdumpdev(dumpdev) != 0)
		dumpdev = NULL;
}
コード例 #3
0
/*
 * Find and mount the root filesystem
 */
static void
vfs_mountroot(void *junk)
{
	cdev_t	save_rootdev = rootdev;
	int	i;
	int	dummy;
	
	/*
	 * Make sure all disk devices created so far have also been probed,
	 * and also make sure that the newly created device nodes for
	 * probed disks are ready, too.
	 *
	 * Messages can fly around here so get good synchronization
	 * coverage.
	 *
	 * XXX - Delay an additional 2 seconds to help drivers which pickup
	 *       devices asynchronously and are not caught by CAM's initial
	 *	 probe.
	 */
	sync_devs();
	tsleep(&dummy, 0, "syncer", hz*2);


	/* 
	 * The root filesystem information is compiled in, and we are
	 * booted with instructions to use it.
	 */
#ifdef ROOTDEVNAME
	if ((boothowto & RB_DFLTROOT) && 
	    !vfs_mountroot_try(ROOTDEVNAME))
		return;
#endif
	/* 
	 * We are booted with instructions to prompt for the root filesystem,
	 * or to use the compiled-in default when it doesn't exist.
	 */
	if (boothowto & (RB_DFLTROOT | RB_ASKNAME)) {
		if (!vfs_mountroot_ask())
			return;
	}

	/*
	 * We've been given the generic "use CDROM as root" flag.  This is
	 * necessary because one media may be used in many different
	 * devices, so we need to search for them.
	 */
	if (boothowto & RB_CDROM) {
		for (i = 0; cdrom_rootdevnames[i] != NULL; i++) {
			if (!vfs_mountroot_try(cdrom_rootdevnames[i]))
				return;
		}
	}

	/*
	 * Try to use the value read by the loader from /etc/fstab, or
	 * supplied via some other means.  This is the preferred 
	 * mechanism.
	 */
	if (!vfs_mountroot_try(kgetenv("vfs.root.mountfrom")))
		return;

	/*
	 * If a vfs set rootdev, try it (XXX VINUM HACK!)
	 */
	if (save_rootdev != NULL) {
		rootdev = save_rootdev;
		if (!vfs_mountroot_try(""))
			return;
	}

	/* 
	 * Try values that may have been computed by the machine-dependant
	 * legacy code.
	 */
	if (rootdevnames[0] && !vfs_mountroot_try(rootdevnames[0]))
		return;
	if (rootdevnames[1] && !vfs_mountroot_try(rootdevnames[1]))
		return;

	/*
	 * If we have a compiled-in default, and haven't already tried it, try
	 * it now.
	 */
#ifdef ROOTDEVNAME
	if (!(boothowto & RB_DFLTROOT))
		if (!vfs_mountroot_try(ROOTDEVNAME))
			return;
#endif

	/* 
	 * Everything so far has failed, prompt on the console if we haven't
	 * already tried that.
	 */
	if (!(boothowto & (RB_DFLTROOT | RB_ASKNAME)) && !vfs_mountroot_ask())
		return;
	panic("Root mount failed, startup aborted.");
}