mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-03 18:20:25 +02:00 
			
		
		
		
	tty: Export redirect release
This will be required by the pty code when it removes tty_vhangup() on master close. Signed-off-by: Corey Minyard <cminyard@mvista.com> Link: https://lore.kernel.org/r/20201124004902.1398477-2-minyard@acm.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
		
							parent
							
								
									c31c3ea02e
								
							
						
					
					
						commit
						f446776ebf
					
				
					 2 changed files with 25 additions and 8 deletions
				
			
		| 
						 | 
					@ -540,6 +540,28 @@ void tty_wakeup(struct tty_struct *tty)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EXPORT_SYMBOL_GPL(tty_wakeup);
 | 
					EXPORT_SYMBOL_GPL(tty_wakeup);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *	tty_release_redirect	-	Release a redirect on a pty if present
 | 
				
			||||||
 | 
					 *	@tty: tty device
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *	This is available to the pty code so if the master closes, if the
 | 
				
			||||||
 | 
					 *	slave is a redirect it can release the redirect.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					struct file *tty_release_redirect(struct tty_struct *tty)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct file *f = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spin_lock(&redirect_lock);
 | 
				
			||||||
 | 
						if (redirect && file_tty(redirect) == tty) {
 | 
				
			||||||
 | 
							f = redirect;
 | 
				
			||||||
 | 
							redirect = NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						spin_unlock(&redirect_lock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return f;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					EXPORT_SYMBOL_GPL(tty_release_redirect);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 *	__tty_hangup		-	actual handler for hangup events
 | 
					 *	__tty_hangup		-	actual handler for hangup events
 | 
				
			||||||
 *	@tty: tty device
 | 
					 *	@tty: tty device
 | 
				
			||||||
| 
						 | 
					@ -566,7 +588,7 @@ EXPORT_SYMBOL_GPL(tty_wakeup);
 | 
				
			||||||
static void __tty_hangup(struct tty_struct *tty, int exit_session)
 | 
					static void __tty_hangup(struct tty_struct *tty, int exit_session)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct file *cons_filp = NULL;
 | 
						struct file *cons_filp = NULL;
 | 
				
			||||||
	struct file *filp, *f = NULL;
 | 
						struct file *filp, *f;
 | 
				
			||||||
	struct tty_file_private *priv;
 | 
						struct tty_file_private *priv;
 | 
				
			||||||
	int    closecount = 0, n;
 | 
						int    closecount = 0, n;
 | 
				
			||||||
	int refs;
 | 
						int refs;
 | 
				
			||||||
| 
						 | 
					@ -574,13 +596,7 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session)
 | 
				
			||||||
	if (!tty)
 | 
						if (!tty)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						f = tty_release_redirect(tty);
 | 
				
			||||||
	spin_lock(&redirect_lock);
 | 
					 | 
				
			||||||
	if (redirect && file_tty(redirect) == tty) {
 | 
					 | 
				
			||||||
		f = redirect;
 | 
					 | 
				
			||||||
		redirect = NULL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	spin_unlock(&redirect_lock);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tty_lock(tty);
 | 
						tty_lock(tty);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -421,6 +421,7 @@ extern void tty_kclose(struct tty_struct *tty);
 | 
				
			||||||
extern int tty_dev_name_to_number(const char *name, dev_t *number);
 | 
					extern int tty_dev_name_to_number(const char *name, dev_t *number);
 | 
				
			||||||
extern int tty_ldisc_lock(struct tty_struct *tty, unsigned long timeout);
 | 
					extern int tty_ldisc_lock(struct tty_struct *tty, unsigned long timeout);
 | 
				
			||||||
extern void tty_ldisc_unlock(struct tty_struct *tty);
 | 
					extern void tty_ldisc_unlock(struct tty_struct *tty);
 | 
				
			||||||
 | 
					extern struct file *tty_release_redirect(struct tty_struct *tty);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
static inline void tty_kref_put(struct tty_struct *tty)
 | 
					static inline void tty_kref_put(struct tty_struct *tty)
 | 
				
			||||||
{ }
 | 
					{ }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue