static int snpclone(struct dev_clone_args *ap) { int unit; lwkt_gettoken(&tty_token); unit = devfs_clone_bitmap_get(&DEVFS_CLONE_BITMAP(snp), 0); ap->a_dev = make_only_dev(&snp_ops, unit, UID_ROOT, GID_WHEEL, 0600, "snp%d", unit); lwkt_reltoken(&tty_token); return 0; }
static int ptyclone(struct dev_clone_args *ap) { int unit; struct pt_ioctl *pt; /* * Limit the number of unix98 pty (slave) devices to 1000, as * the utmp(5) format only allows for 8 bytes for the tty, * "pts/XXX". * If this limit is reached, we don't clone and return error * to devfs. */ unit = devfs_clone_bitmap_get(&DEVFS_CLONE_BITMAP(pty), 1000); if (unit < 0) { ap->a_dev = NULL; return 1; } pt = kmalloc(sizeof(*pt), M_PTY, M_WAITOK | M_ZERO); pt->devc = make_only_dev(&ptc98_ops, unit, ap->a_cred->cr_ruid, 0, 0600, "ptm/%d", unit); pt->devs = make_dev(&pts98_ops, unit, ap->a_cred->cr_ruid, GID_TTY, 0620, "pts/%d", unit); ap->a_dev = pt->devc; pt->devs->si_flags |= SI_OVERRIDE; /* uid, gid, perms from dev */ pt->devc->si_flags |= SI_OVERRIDE; /* uid, gid, perms from dev */ pt->pt_tty.t_dev = pt->devs; pt->pt_flags |= PF_UNIX98; pt->pt_uminor = unit; pt->devs->si_drv1 = pt->devc->si_drv1 = pt; pt->devs->si_tty = pt->devc->si_tty = &pt->pt_tty; ttyregister(&pt->pt_tty); return 0; }