diff options
author | cognet <cognet@FreeBSD.org> | 2006-01-27 00:21:48 +0000 |
---|---|---|
committer | cognet <cognet@FreeBSD.org> | 2006-01-27 00:21:48 +0000 |
commit | 3299c77864b359b88db45b3a7f1b8e8ff8b48d70 (patch) | |
tree | 2269255294e64504112fa6f99da93419c7e68b1b /sys/kern/tty_pts.c | |
parent | c9e74adc5ee67d7f9d4d179d15dcda8abec5455c (diff) | |
download | FreeBSD-src-3299c77864b359b88db45b3a7f1b8e8ff8b48d70.zip FreeBSD-src-3299c77864b359b88db45b3a7f1b8e8ff8b48d70.tar.gz |
Take into account that bits 0x0000ff00 can't be used for minor.
Diffstat (limited to 'sys/kern/tty_pts.c')
-rw-r--r-- | sys/kern/tty_pts.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c index 19a12c0..e903b99 100644 --- a/sys/kern/tty_pts.c +++ b/sys/kern/tty_pts.c @@ -119,6 +119,7 @@ static struct cdevsw ptc_cdevsw = { #define TSA_PTC_WRITE(tp) ((void *)&(tp)->t_rawq.c_cl) #define TSA_PTS_READ(tp) ((void *)&(tp)->t_canq) +#define NUM_TO_MINOR(c) ((c & 0xff) | ((c & ~0xff) << 16)) /*- * Once a tty is allocated, it cannot (currently) be freed. As such, * we keep a global list of ptys that have been used so we can recycle @@ -188,7 +189,7 @@ pty_new(void) int nb; mtx_lock(&pt_mtx); - if (nb_allocated >= max_pts) { + if (nb_allocated >= max_pts || nb_allocated == 0xffffff) { mtx_unlock(&pt_mtx); return (NULL); } @@ -447,7 +448,8 @@ ptcopen(struct cdev *dev, int flag, int devtype, struct thread *td) if (pt->pt_devs) devs = pt->pt_devs; else - pt->pt_devs = devs = make_dev_cred(&pts_cdevsw, pt->pt_num, + pt->pt_devs = devs = make_dev_cred(&pts_cdevsw, + NUM_TO_MINOR(pt->pt_num), td->td_ucred, UID_ROOT, GID_WHEEL, 0666, "pts/%d", pt->pt_num); devs->si_drv1 = pt; @@ -946,8 +948,9 @@ pty_clone(void *arg, struct ucred *cred, char *name, int namelen, * opened, or some way to tell devfs that "this had better be for * an open() or we won't create a device". */ - pt->pt_devc = devc = make_dev_cred(&ptc_cdevsw, pt->pt_num, cred, - UID_ROOT, GID_WHEEL, 0666, "pty%d", pt->pt_num); + pt->pt_devc = devc = make_dev_cred(&ptc_cdevsw, + NUM_TO_MINOR(pt->pt_num), cred, UID_ROOT, GID_WHEEL, 0666, "pty%d", + pt->pt_num); dev_ref(devc); devc->si_drv1 = pt; |