aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/pty.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/pty.c')
-rw-r--r--drivers/char/pty.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 53761cefa915..62f282e67638 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -18,6 +18,7 @@
18#include <linux/tty.h> 18#include <linux/tty.h>
19#include <linux/tty_flip.h> 19#include <linux/tty_flip.h>
20#include <linux/fcntl.h> 20#include <linux/fcntl.h>
21#include <linux/sched.h>
21#include <linux/string.h> 22#include <linux/string.h>
22#include <linux/major.h> 23#include <linux/major.h>
23#include <linux/mm.h> 24#include <linux/mm.h>
@@ -261,6 +262,9 @@ done:
261 return 0; 262 return 0;
262} 263}
263 264
265/* Traditional BSD devices */
266#ifdef CONFIG_LEGACY_PTYS
267
264static int pty_install(struct tty_driver *driver, struct tty_struct *tty) 268static int pty_install(struct tty_driver *driver, struct tty_struct *tty)
265{ 269{
266 struct tty_struct *o_tty; 270 struct tty_struct *o_tty;
@@ -310,24 +314,6 @@ free_mem_out:
310 return -ENOMEM; 314 return -ENOMEM;
311} 315}
312 316
313
314static const struct tty_operations pty_ops = {
315 .install = pty_install,
316 .open = pty_open,
317 .close = pty_close,
318 .write = pty_write,
319 .write_room = pty_write_room,
320 .flush_buffer = pty_flush_buffer,
321 .chars_in_buffer = pty_chars_in_buffer,
322 .unthrottle = pty_unthrottle,
323 .set_termios = pty_set_termios,
324 .resize = pty_resize
325};
326
327/* Traditional BSD devices */
328#ifdef CONFIG_LEGACY_PTYS
329static struct tty_driver *pty_driver, *pty_slave_driver;
330
331static int pty_bsd_ioctl(struct tty_struct *tty, struct file *file, 317static int pty_bsd_ioctl(struct tty_struct *tty, struct file *file,
332 unsigned int cmd, unsigned long arg) 318 unsigned int cmd, unsigned long arg)
333{ 319{
@@ -341,7 +327,12 @@ static int pty_bsd_ioctl(struct tty_struct *tty, struct file *file,
341static int legacy_count = CONFIG_LEGACY_PTY_COUNT; 327static int legacy_count = CONFIG_LEGACY_PTY_COUNT;
342module_param(legacy_count, int, 0); 328module_param(legacy_count, int, 0);
343 329
344static const struct tty_operations pty_ops_bsd = { 330/*
331 * The master side of a pty can do TIOCSPTLCK and thus
332 * has pty_bsd_ioctl.
333 */
334static const struct tty_operations master_pty_ops_bsd = {
335 .install = pty_install,
345 .open = pty_open, 336 .open = pty_open,
346 .close = pty_close, 337 .close = pty_close,
347 .write = pty_write, 338 .write = pty_write,
@@ -354,8 +345,23 @@ static const struct tty_operations pty_ops_bsd = {
354 .resize = pty_resize 345 .resize = pty_resize
355}; 346};
356 347
348static const struct tty_operations slave_pty_ops_bsd = {
349 .install = pty_install,
350 .open = pty_open,
351 .close = pty_close,
352 .write = pty_write,
353 .write_room = pty_write_room,
354 .flush_buffer = pty_flush_buffer,
355 .chars_in_buffer = pty_chars_in_buffer,
356 .unthrottle = pty_unthrottle,
357 .set_termios = pty_set_termios,
358 .resize = pty_resize
359};
360
357static void __init legacy_pty_init(void) 361static void __init legacy_pty_init(void)
358{ 362{
363 struct tty_driver *pty_driver, *pty_slave_driver;
364
359 if (legacy_count <= 0) 365 if (legacy_count <= 0)
360 return; 366 return;
361 367
@@ -383,7 +389,7 @@ static void __init legacy_pty_init(void)
383 pty_driver->init_termios.c_ospeed = 38400; 389 pty_driver->init_termios.c_ospeed = 38400;
384 pty_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW; 390 pty_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW;
385 pty_driver->other = pty_slave_driver; 391 pty_driver->other = pty_slave_driver;
386 tty_set_operations(pty_driver, &pty_ops); 392 tty_set_operations(pty_driver, &master_pty_ops_bsd);
387 393
388 pty_slave_driver->owner = THIS_MODULE; 394 pty_slave_driver->owner = THIS_MODULE;
389 pty_slave_driver->driver_name = "pty_slave"; 395 pty_slave_driver->driver_name = "pty_slave";
@@ -399,7 +405,7 @@ static void __init legacy_pty_init(void)
399 pty_slave_driver->flags = TTY_DRIVER_RESET_TERMIOS | 405 pty_slave_driver->flags = TTY_DRIVER_RESET_TERMIOS |
400 TTY_DRIVER_REAL_RAW; 406 TTY_DRIVER_REAL_RAW;
401 pty_slave_driver->other = pty_driver; 407 pty_slave_driver->other = pty_driver;
402 tty_set_operations(pty_slave_driver, &pty_ops); 408 tty_set_operations(pty_slave_driver, &slave_pty_ops_bsd);
403 409
404 if (tty_register_driver(pty_driver)) 410 if (tty_register_driver(pty_driver))
405 panic("Couldn't register pty driver"); 411 panic("Couldn't register pty driver");