int
ptmx_init( __unused int config_count)
{
/*
* We start looking at slot 10, since there are inits that will
* stomp explicit slots (e.g. vndevice stomps 1) below that.
*/
/* Get a major number
for
/dev/ptmx
*/
if
((ptmx_major = cdevsw_add(-15, &ptmx_cdev)) == -1) {
printf
(
"ptmx_init: failed to obtain /dev/ptmx major number\n"
);
return
(ENOENT);
}
if
(cdevsw_setkqueueok(ptmx_major, &ptmx_cdev, 0) == -1) {
panic(
"Failed to set flags on ptmx cdevsw entry."
);
}
/* Get a major number
for
/dev/pts/nnn
*/
if
((ptsd_major = cdevsw_add(-15, &ptsd_cdev)) == -1) {
(void)cdevsw_remove(ptmx_major, &ptmx_cdev);
printf
(
"ptmx_init: failed to obtain /dev/ptmx major number\n"
);
return
(ENOENT);
}
if
(cdevsw_setkqueueok(ptsd_major, &ptsd_cdev, 0) == -1) {
panic(
"Failed to set flags on ptmx cdevsw entry."
);
}
/*
* Locks to guard against races between revoke and kevents
*/
ptsd_kevent_lock_init();
/* Create the
/dev/ptmx
device {<major>,0} */
(void)devfs_make_node_clone(makedev(ptmx_major, 0),
DEVFS_CHAR, UID_ROOT, GID_TTY, 0666,
ptmx_clone, PTMX_TEMPLATE);
return
(0);
}