diff options
Diffstat (limited to 'drivers/tty/tty_io.c')
| -rw-r--r-- | drivers/tty/tty_io.c | 28 | 
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 3a1a01af9a8..34110719fe0 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -878,9 +878,8 @@ void disassociate_ctty(int on_exit)  	spin_lock_irq(¤t->sighand->siglock);  	put_pid(current->signal->tty_old_pgrp);  	current->signal->tty_old_pgrp = NULL; -	spin_unlock_irq(¤t->sighand->siglock); -	tty = get_current_tty(); +	tty = tty_kref_get(current->signal->tty);  	if (tty) {  		unsigned long flags;  		spin_lock_irqsave(&tty->ctrl_lock, flags); @@ -897,6 +896,7 @@ void disassociate_ctty(int on_exit)  #endif  	} +	spin_unlock_irq(¤t->sighand->siglock);  	/* Now clear signal->tty under the lock */  	read_lock(&tasklist_lock);  	session_clear_tty(task_session(current)); @@ -1271,12 +1271,13 @@ static void pty_line_name(struct tty_driver *driver, int index, char *p)   *   *	Locking: None   */ -static void tty_line_name(struct tty_driver *driver, int index, char *p) +static ssize_t tty_line_name(struct tty_driver *driver, int index, char *p)  {  	if (driver->flags & TTY_DRIVER_UNNUMBERED_NODE) -		strcpy(p, driver->name); +		return sprintf(p, "%s", driver->name);  	else -		sprintf(p, "%s%d", driver->name, index + driver->name_base); +		return sprintf(p, "%s%d", driver->name, +			       index + driver->name_base);  }  /** @@ -2086,6 +2087,7 @@ retry_open:  			filp->f_op = &tty_fops;  		goto retry_open;  	} +	clear_bit(TTY_HUPPED, &tty->flags);  	tty_unlock(tty); @@ -3544,9 +3546,19 @@ static ssize_t show_cons_active(struct device *dev,  		if (i >= ARRAY_SIZE(cs))  			break;  	} -	while (i--) -		count += sprintf(buf + count, "%s%d%c", -				 cs[i]->name, cs[i]->index, i ? ' ':'\n'); +	while (i--) { +		int index = cs[i]->index; +		struct tty_driver *drv = cs[i]->device(cs[i], &index); + +		/* don't resolve tty0 as some programs depend on it */ +		if (drv && (cs[i]->index > 0 || drv->major != TTY_MAJOR)) +			count += tty_line_name(drv, index, buf + count); +		else +			count += sprintf(buf + count, "%s%d", +					 cs[i]->name, cs[i]->index); + +		count += sprintf(buf + count, "%c", i ? ' ':'\n'); +	}  	console_unlock();  	return count;  | 
