#include <linux/module.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/fcntl.h>
#include <linux/sched/signal.h>
#include <linux/string.h>
#include <linux/major.h>
#include <linux/mm.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/uaccess.h>
#include <linux/bitops.h>
#include <linux/devpts_fs.h>
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/poll.h>
#include <linux/mount.h>
#include <linux/file.h>
#include <linux/ioctl.h>
#include <linux/compat.h>
#include "tty.h"
#undef TTY_DEBUG_HANGUP
#ifdef TTY_DEBUG_HANGUP
#define tty_debug_hangup …
#else
#define tty_debug_hangup(tty, f, args...) …
#endif
#ifdef CONFIG_UNIX98_PTYS
static struct tty_driver *ptm_driver;
static struct tty_driver *pts_driver;
static DEFINE_MUTEX(devpts_mutex);
#endif
static void pty_close(struct tty_struct *tty, struct file *filp)
{ … }
static void pty_unthrottle(struct tty_struct *tty)
{ … }
static ssize_t pty_write(struct tty_struct *tty, const u8 *buf, size_t c)
{ … }
static unsigned int pty_write_room(struct tty_struct *tty)
{ … }
static int pty_set_lock(struct tty_struct *tty, int __user *arg)
{ … }
static int pty_get_lock(struct tty_struct *tty, int __user *arg)
{ … }
static int pty_set_pktmode(struct tty_struct *tty, int __user *arg)
{ … }
static int pty_get_pktmode(struct tty_struct *tty, int __user *arg)
{ … }
static int pty_signal(struct tty_struct *tty, int sig)
{ … }
static void pty_flush_buffer(struct tty_struct *tty)
{ … }
static int pty_open(struct tty_struct *tty, struct file *filp)
{ … }
static void pty_set_termios(struct tty_struct *tty,
const struct ktermios *old_termios)
{ … }
static int pty_resize(struct tty_struct *tty, struct winsize *ws)
{ … }
static void pty_start(struct tty_struct *tty)
{ … }
static void pty_stop(struct tty_struct *tty)
{ … }
static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty,
bool legacy)
{ … }
static void pty_cleanup(struct tty_struct *tty)
{ … }
#ifdef CONFIG_LEGACY_PTYS
static int pty_install(struct tty_driver *driver, struct tty_struct *tty)
{ … }
static void pty_remove(struct tty_driver *driver, struct tty_struct *tty)
{ … }
static int pty_bsd_ioctl(struct tty_struct *tty,
unsigned int cmd, unsigned long arg)
{ … }
#ifdef CONFIG_COMPAT
static long pty_bsd_compat_ioctl(struct tty_struct *tty,
unsigned int cmd, unsigned long arg)
{ … }
#else
#define pty_bsd_compat_ioctl …
#endif
static int legacy_count = …;
module_param(legacy_count, int, 0);
static const struct tty_operations master_pty_ops_bsd = …;
static const struct tty_operations slave_pty_ops_bsd = …;
static void __init legacy_pty_init(void)
{ … }
#else
static inline void legacy_pty_init(void) { }
#endif
#ifdef CONFIG_UNIX98_PTYS
static struct cdev ptmx_cdev;
int ptm_open_peer(struct file *master, struct tty_struct *tty, int flags)
{ … }
static int pty_unix98_ioctl(struct tty_struct *tty,
unsigned int cmd, unsigned long arg)
{ … }
#ifdef CONFIG_COMPAT
static long pty_unix98_compat_ioctl(struct tty_struct *tty,
unsigned int cmd, unsigned long arg)
{ … }
#else
#define pty_unix98_compat_ioctl …
#endif
static struct tty_struct *ptm_unix98_lookup(struct tty_driver *driver,
struct file *file, int idx)
{ … }
static struct tty_struct *pts_unix98_lookup(struct tty_driver *driver,
struct file *file, int idx)
{ … }
static int pty_unix98_install(struct tty_driver *driver, struct tty_struct *tty)
{ … }
static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty)
{ … }
static void pty_show_fdinfo(struct tty_struct *tty, struct seq_file *m)
{ … }
static const struct tty_operations ptm_unix98_ops = …;
static const struct tty_operations pty_unix98_ops = …;
static int ptmx_open(struct inode *inode, struct file *filp)
{ … }
static struct file_operations ptmx_fops __ro_after_init;
static void __init unix98_pty_init(void)
{ … }
#else
static inline void unix98_pty_init(void) { }
#endif
static int __init pty_init(void)
{ … }
device_initcall(pty_init);