Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1290476

[PATCH 3/6] tty: Add fasync() hung up file operation

From Peter Hurley <peter@hurleysoftware.com>
Newsgroups linux.kernel
Subject [PATCH 3/6] tty: Add fasync() hung up file operation
Date 2015-12-12 23:20 +0100
Message-ID <qF0Gd-8bC-9@gated-at.bofh.it> (permalink)
References <qF0Gd-8bC-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


VFS uses a two-stage check-and-call method for invoking file_operations
methods, without explicitly snapshotting either the file_operations ptr
or the function ptr. Since the tty core is one of the few VFS users that
changes the f_op file_operations ptr of the file descriptor (when the
tty has been hung up), and since the likelihood of the compiler generating
a reload of either f_op or the function ptr is basically nil, just define
a hung up fasync() file operation that returns an error.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/tty_io.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index df7a3a9..e9b7591 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -468,6 +468,11 @@ static long hung_up_tty_compat_ioctl(struct file *file,
 	return cmd == TIOCSPGRP ? -ENOTTY : -EIO;
 }
 
+static int hung_up_tty_fasync(int fd, struct file *file, int on)
+{
+	return -ENOTTY;
+}
+
 static const struct file_operations tty_fops = {
 	.llseek		= no_llseek,
 	.read		= tty_read,
@@ -500,6 +505,7 @@ static const struct file_operations hung_up_tty_fops = {
 	.unlocked_ioctl	= hung_up_tty_ioctl,
 	.compat_ioctl	= hung_up_tty_compat_ioctl,
 	.release	= tty_release,
+	.fasync		= hung_up_tty_fasync,
 };
 
 static DEFINE_SPINLOCK(redirect_lock);
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/6] More n_tty fixes Peter Hurley <peter@hurleysoftware.com> - 2015-12-12 23:20 +0100
  [PATCH 6/6] n_tty: Remove tty count checks from unthrottle Peter Hurley <peter@hurleysoftware.com> - 2015-12-12 23:20 +0100
  [PATCH 4/6] tty: Fix ioctl(FIOASYNC) on hungup file Peter Hurley <peter@hurleysoftware.com> - 2015-12-12 23:20 +0100
  [PATCH 3/6] tty: Add fasync() hung up file operation Peter Hurley <peter@hurleysoftware.com> - 2015-12-12 23:20 +0100
  [PATCH 1/6] n_tty: Always wake up read()/poll() if new input Peter Hurley <peter@hurleysoftware.com> - 2015-12-12 23:20 +0100
    Re: [PATCH 1/6] n_tty: Always wake up read()/poll() if new input Johannes Stezenbach <js@sig21.net> - 2015-12-13 15:50 +0100
      Re: [PATCH 1/6] n_tty: Always wake up read()/poll() if new input Peter Hurley <peter@hurleysoftware.com> - 2015-12-13 21:00 +0100
  [PATCH 2/6] tty, n_tty: Remove fasync() ldisc notification Peter Hurley <peter@hurleysoftware.com> - 2015-12-12 23:20 +0100

csiph-web