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