Exemplo n.º 1
0
static int
snp_modevent(module_t mod, int type, void *data)
{
	int i;

	lwkt_gettoken(&tty_token);
	switch (type) {
	case MOD_LOAD:
		snooplinedisc = ldisc_register(LDISC_LOAD, &snpdisc);
		make_autoclone_dev(&snp_ops, &DEVFS_CLONE_BITMAP(snp),
			snpclone, UID_ROOT, GID_WHEEL, 0600, "snp");

		for (i = 0; i < SNP_PREALLOCATED_UNITS; i++) {
			make_dev(&snp_ops, i, UID_ROOT, GID_WHEEL, 0600, "snp%d", i);
			devfs_clone_bitmap_set(&DEVFS_CLONE_BITMAP(snp), i);
		}
		break;
	case MOD_UNLOAD:
		if (!LIST_EMPTY(&snp_sclist)) {
			lwkt_reltoken(&tty_token);
			return (EBUSY);
		}
		ldisc_deregister(snooplinedisc);
		devfs_clone_handler_del("snp");
		dev_ops_remove_all(&snp_ops);
		devfs_clone_bitmap_uninit(&DEVFS_CLONE_BITMAP(snp));
		break;
	default:
		break;
	}
	lwkt_reltoken(&tty_token);
	return (0);
}
Exemplo n.º 2
0
static void
ptc_drvinit(void *unused)
{
	int i;

#ifdef UNIX98_PTYS
	/*
	 * Unix98 pty stuff.
	 * Create the clonable base device.
	 */
	make_autoclone_dev(&ptc_ops, &DEVFS_CLONE_BITMAP(pty), ptyclone,
	    0, 0, 0666, "ptmx");
#endif

	for (i = 0; i < 256; i++) {
		ptyinit(i);
	}
}