pty.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. /*
  2. * linux/drivers/char/pty.c
  3. *
  4. * Copyright (C) 1991, 1992 Linus Torvalds
  5. *
  6. * Added support for a Unix98-style ptmx device.
  7. * -- C. Scott Ananian <cananian@alumni.princeton.edu>, 14-Jan-1998
  8. * Added TTY_DO_WRITE_WAKEUP to enable n_tty to send POLL_OUT to
  9. * waiting writers -- Sapan Bhatia <sapan@corewars.org>
  10. *
  11. *
  12. */
  13. #include <linux/module.h> /* For EXPORT_SYMBOL */
  14. #include <linux/errno.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/tty.h>
  17. #include <linux/tty_flip.h>
  18. #include <linux/fcntl.h>
  19. #include <linux/string.h>
  20. #include <linux/major.h>
  21. #include <linux/mm.h>
  22. #include <linux/init.h>
  23. #include <linux/sysctl.h>
  24. #include <linux/device.h>
  25. #include <asm/uaccess.h>
  26. #include <asm/system.h>
  27. #include <linux/bitops.h>
  28. #include <linux/devpts_fs.h>
  29. /* These are global because they are accessed in tty_io.c */
  30. #ifdef CONFIG_UNIX98_PTYS
  31. struct tty_driver *ptm_driver;
  32. static struct tty_driver *pts_driver;
  33. #endif
  34. static void pty_close(struct tty_struct * tty, struct file * filp)
  35. {
  36. if (!tty)
  37. return;
  38. if (tty->driver->subtype == PTY_TYPE_MASTER) {
  39. if (tty->count > 1)
  40. printk("master pty_close: count = %d!!\n", tty->count);
  41. } else {
  42. if (tty->count > 2)
  43. return;
  44. }
  45. wake_up_interruptible(&tty->read_wait);
  46. wake_up_interruptible(&tty->write_wait);
  47. tty->packet = 0;
  48. if (!tty->link)
  49. return;
  50. tty->link->packet = 0;
  51. set_bit(TTY_OTHER_CLOSED, &tty->link->flags);
  52. wake_up_interruptible(&tty->link->read_wait);
  53. wake_up_interruptible(&tty->link->write_wait);
  54. if (tty->driver->subtype == PTY_TYPE_MASTER) {
  55. set_bit(TTY_OTHER_CLOSED, &tty->flags);
  56. #ifdef CONFIG_UNIX98_PTYS
  57. if (tty->driver == ptm_driver)
  58. devpts_pty_kill(tty->index);
  59. #endif
  60. tty_vhangup(tty->link);
  61. }
  62. }
  63. /*
  64. * The unthrottle routine is called by the line discipline to signal
  65. * that it can receive more characters. For PTY's, the TTY_THROTTLED
  66. * flag is always set, to force the line discipline to always call the
  67. * unthrottle routine when there are fewer than TTY_THRESHOLD_UNTHROTTLE
  68. * characters in the queue. This is necessary since each time this
  69. * happens, we need to wake up any sleeping processes that could be
  70. * (1) trying to send data to the pty, or (2) waiting in wait_until_sent()
  71. * for the pty buffer to be drained.
  72. */
  73. static void pty_unthrottle(struct tty_struct * tty)
  74. {
  75. struct tty_struct *o_tty = tty->link;
  76. if (!o_tty)
  77. return;
  78. tty_wakeup(o_tty);
  79. set_bit(TTY_THROTTLED, &tty->flags);
  80. }
  81. /*
  82. * WSH 05/24/97: modified to
  83. * (1) use space in tty->flip instead of a shared temp buffer
  84. * The flip buffers aren't being used for a pty, so there's lots
  85. * of space available. The buffer is protected by a per-pty
  86. * semaphore that should almost never come under contention.
  87. * (2) avoid redundant copying for cases where count >> receive_room
  88. * N.B. Calls from user space may now return an error code instead of
  89. * a count.
  90. *
  91. * FIXME: Our pty_write method is called with our ldisc lock held but
  92. * not our partners. We can't just take the other one blindly without
  93. * risking deadlocks.
  94. */
  95. static int pty_write(struct tty_struct * tty, const unsigned char *buf, int count)
  96. {
  97. struct tty_struct *to = tty->link;
  98. int c;
  99. if (!to || tty->stopped)
  100. return 0;
  101. c = to->receive_room;
  102. if (c > count)
  103. c = count;
  104. to->ldisc.ops->receive_buf(to, buf, NULL, c);
  105. return c;
  106. }
  107. static int pty_write_room(struct tty_struct *tty)
  108. {
  109. struct tty_struct *to = tty->link;
  110. if (!to || tty->stopped)
  111. return 0;
  112. return to->receive_room;
  113. }
  114. /*
  115. * WSH 05/24/97: Modified for asymmetric MASTER/SLAVE behavior
  116. * The chars_in_buffer() value is used by the ldisc select() function
  117. * to hold off writing when chars_in_buffer > WAKEUP_CHARS (== 256).
  118. * The pty driver chars_in_buffer() Master/Slave must behave differently:
  119. *
  120. * The Master side needs to allow typed-ahead commands to accumulate
  121. * while being canonicalized, so we report "our buffer" as empty until
  122. * some threshold is reached, and then report the count. (Any count >
  123. * WAKEUP_CHARS is regarded by select() as "full".) To avoid deadlock
  124. * the count returned must be 0 if no canonical data is available to be
  125. * read. (The N_TTY ldisc.chars_in_buffer now knows this.)
  126. *
  127. * The Slave side passes all characters in raw mode to the Master side's
  128. * buffer where they can be read immediately, so in this case we can
  129. * return the true count in the buffer.
  130. */
  131. static int pty_chars_in_buffer(struct tty_struct *tty)
  132. {
  133. struct tty_struct *to = tty->link;
  134. int count;
  135. /* We should get the line discipline lock for "tty->link" */
  136. if (!to || !to->ldisc.ops->chars_in_buffer)
  137. return 0;
  138. /* The ldisc must report 0 if no characters available to be read */
  139. count = to->ldisc.ops->chars_in_buffer(to);
  140. if (tty->driver->subtype == PTY_TYPE_SLAVE) return count;
  141. /* Master side driver ... if the other side's read buffer is less than
  142. * half full, return 0 to allow writers to proceed; otherwise return
  143. * the count. This leaves a comfortable margin to avoid overflow,
  144. * and still allows half a buffer's worth of typed-ahead commands.
  145. */
  146. return ((count < N_TTY_BUF_SIZE/2) ? 0 : count);
  147. }
  148. /* Set the lock flag on a pty */
  149. static int pty_set_lock(struct tty_struct *tty, int __user * arg)
  150. {
  151. int val;
  152. if (get_user(val,arg))
  153. return -EFAULT;
  154. if (val)
  155. set_bit(TTY_PTY_LOCK, &tty->flags);
  156. else
  157. clear_bit(TTY_PTY_LOCK, &tty->flags);
  158. return 0;
  159. }
  160. static void pty_flush_buffer(struct tty_struct *tty)
  161. {
  162. struct tty_struct *to = tty->link;
  163. unsigned long flags;
  164. if (!to)
  165. return;
  166. if (to->ldisc.ops->flush_buffer)
  167. to->ldisc.ops->flush_buffer(to);
  168. if (to->packet) {
  169. spin_lock_irqsave(&tty->ctrl_lock, flags);
  170. tty->ctrl_status |= TIOCPKT_FLUSHWRITE;
  171. wake_up_interruptible(&to->read_wait);
  172. spin_unlock_irqrestore(&tty->ctrl_lock, flags);
  173. }
  174. }
  175. static int pty_open(struct tty_struct *tty, struct file * filp)
  176. {
  177. int retval = -ENODEV;
  178. if (!tty || !tty->link)
  179. goto out;
  180. retval = -EIO;
  181. if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
  182. goto out;
  183. if (test_bit(TTY_PTY_LOCK, &tty->link->flags))
  184. goto out;
  185. if (tty->link->count != 1)
  186. goto out;
  187. clear_bit(TTY_OTHER_CLOSED, &tty->link->flags);
  188. set_bit(TTY_THROTTLED, &tty->flags);
  189. set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
  190. retval = 0;
  191. out:
  192. return retval;
  193. }
  194. static void pty_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
  195. {
  196. tty->termios->c_cflag &= ~(CSIZE | PARENB);
  197. tty->termios->c_cflag |= (CS8 | CREAD);
  198. }
  199. static const struct tty_operations pty_ops = {
  200. .open = pty_open,
  201. .close = pty_close,
  202. .write = pty_write,
  203. .write_room = pty_write_room,
  204. .flush_buffer = pty_flush_buffer,
  205. .chars_in_buffer = pty_chars_in_buffer,
  206. .unthrottle = pty_unthrottle,
  207. .set_termios = pty_set_termios,
  208. };
  209. /* Traditional BSD devices */
  210. #ifdef CONFIG_LEGACY_PTYS
  211. static struct tty_driver *pty_driver, *pty_slave_driver;
  212. static int pty_bsd_ioctl(struct tty_struct *tty, struct file *file,
  213. unsigned int cmd, unsigned long arg)
  214. {
  215. switch (cmd) {
  216. case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
  217. return pty_set_lock(tty, (int __user *) arg);
  218. }
  219. return -ENOIOCTLCMD;
  220. }
  221. static int legacy_count = CONFIG_LEGACY_PTY_COUNT;
  222. module_param(legacy_count, int, 0);
  223. static const struct tty_operations pty_ops_bsd = {
  224. .open = pty_open,
  225. .close = pty_close,
  226. .write = pty_write,
  227. .write_room = pty_write_room,
  228. .flush_buffer = pty_flush_buffer,
  229. .chars_in_buffer = pty_chars_in_buffer,
  230. .unthrottle = pty_unthrottle,
  231. .set_termios = pty_set_termios,
  232. .ioctl = pty_bsd_ioctl,
  233. };
  234. static void __init legacy_pty_init(void)
  235. {
  236. if (legacy_count <= 0)
  237. return;
  238. pty_driver = alloc_tty_driver(legacy_count);
  239. if (!pty_driver)
  240. panic("Couldn't allocate pty driver");
  241. pty_slave_driver = alloc_tty_driver(legacy_count);
  242. if (!pty_slave_driver)
  243. panic("Couldn't allocate pty slave driver");
  244. pty_driver->owner = THIS_MODULE;
  245. pty_driver->driver_name = "pty_master";
  246. pty_driver->name = "pty";
  247. pty_driver->major = PTY_MASTER_MAJOR;
  248. pty_driver->minor_start = 0;
  249. pty_driver->type = TTY_DRIVER_TYPE_PTY;
  250. pty_driver->subtype = PTY_TYPE_MASTER;
  251. pty_driver->init_termios = tty_std_termios;
  252. pty_driver->init_termios.c_iflag = 0;
  253. pty_driver->init_termios.c_oflag = 0;
  254. pty_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
  255. pty_driver->init_termios.c_lflag = 0;
  256. pty_driver->init_termios.c_ispeed = 38400;
  257. pty_driver->init_termios.c_ospeed = 38400;
  258. pty_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW;
  259. pty_driver->other = pty_slave_driver;
  260. tty_set_operations(pty_driver, &pty_ops);
  261. pty_slave_driver->owner = THIS_MODULE;
  262. pty_slave_driver->driver_name = "pty_slave";
  263. pty_slave_driver->name = "ttyp";
  264. pty_slave_driver->major = PTY_SLAVE_MAJOR;
  265. pty_slave_driver->minor_start = 0;
  266. pty_slave_driver->type = TTY_DRIVER_TYPE_PTY;
  267. pty_slave_driver->subtype = PTY_TYPE_SLAVE;
  268. pty_slave_driver->init_termios = tty_std_termios;
  269. pty_slave_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
  270. pty_slave_driver->init_termios.c_ispeed = 38400;
  271. pty_slave_driver->init_termios.c_ospeed = 38400;
  272. pty_slave_driver->flags = TTY_DRIVER_RESET_TERMIOS |
  273. TTY_DRIVER_REAL_RAW;
  274. pty_slave_driver->other = pty_driver;
  275. tty_set_operations(pty_slave_driver, &pty_ops);
  276. if (tty_register_driver(pty_driver))
  277. panic("Couldn't register pty driver");
  278. if (tty_register_driver(pty_slave_driver))
  279. panic("Couldn't register pty slave driver");
  280. }
  281. #else
  282. static inline void legacy_pty_init(void) { }
  283. #endif
  284. /* Unix98 devices */
  285. #ifdef CONFIG_UNIX98_PTYS
  286. /*
  287. * sysctl support for setting limits on the number of Unix98 ptys allocated.
  288. * Otherwise one can eat up all kernel memory by opening /dev/ptmx repeatedly.
  289. */
  290. int pty_limit = NR_UNIX98_PTY_DEFAULT;
  291. static int pty_limit_min = 0;
  292. static int pty_limit_max = NR_UNIX98_PTY_MAX;
  293. static struct cdev ptmx_cdev;
  294. static struct ctl_table pty_table[] = {
  295. {
  296. .ctl_name = PTY_MAX,
  297. .procname = "max",
  298. .maxlen = sizeof(int),
  299. .mode = 0644,
  300. .data = &pty_limit,
  301. .proc_handler = &proc_dointvec_minmax,
  302. .strategy = &sysctl_intvec,
  303. .extra1 = &pty_limit_min,
  304. .extra2 = &pty_limit_max,
  305. }, {
  306. .ctl_name = PTY_NR,
  307. .procname = "nr",
  308. .maxlen = sizeof(int),
  309. .mode = 0444,
  310. .proc_handler = &proc_dointvec,
  311. }, {
  312. .ctl_name = 0
  313. }
  314. };
  315. static struct ctl_table pty_kern_table[] = {
  316. {
  317. .ctl_name = KERN_PTY,
  318. .procname = "pty",
  319. .mode = 0555,
  320. .child = pty_table,
  321. },
  322. {}
  323. };
  324. static struct ctl_table pty_root_table[] = {
  325. {
  326. .ctl_name = CTL_KERN,
  327. .procname = "kernel",
  328. .mode = 0555,
  329. .child = pty_kern_table,
  330. },
  331. {}
  332. };
  333. static int pty_unix98_ioctl(struct tty_struct *tty, struct file *file,
  334. unsigned int cmd, unsigned long arg)
  335. {
  336. switch (cmd) {
  337. case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
  338. return pty_set_lock(tty, (int __user *)arg);
  339. case TIOCGPTN: /* Get PT Number */
  340. return put_user(tty->index, (unsigned int __user *)arg);
  341. }
  342. return -ENOIOCTLCMD;
  343. }
  344. /**
  345. * ptm_unix98_lookup - find a pty master
  346. * @driver: ptm driver
  347. * @idx: tty index
  348. *
  349. * Look up a pty master device. Called under the tty_mutex for now.
  350. * This provides our locking.
  351. */
  352. static struct tty_struct *ptm_unix98_lookup(struct tty_driver *driver, int idx)
  353. {
  354. struct tty_struct *tty = devpts_get_tty(idx);
  355. if (tty)
  356. tty = tty->link;
  357. return tty;
  358. }
  359. /**
  360. * pts_unix98_lookup - find a pty slave
  361. * @driver: pts driver
  362. * @idx: tty index
  363. *
  364. * Look up a pty master device. Called under the tty_mutex for now.
  365. * This provides our locking.
  366. */
  367. static struct tty_struct *pts_unix98_lookup(struct tty_driver *driver, int idx)
  368. {
  369. struct tty_struct *tty = devpts_get_tty(idx);
  370. /* Master must be open before slave */
  371. if (!tty)
  372. return ERR_PTR(-EIO);
  373. return tty;
  374. }
  375. static void pty_shutdown(struct tty_struct *tty)
  376. {
  377. /* We have our own method as we don't use the tty index */
  378. kfree(tty->termios);
  379. kfree(tty->termios_locked);
  380. }
  381. /* We have no need to install and remove our tty objects as devpts does all
  382. the work for us */
  383. static int pty_install(struct tty_driver *driver, struct tty_struct *tty)
  384. {
  385. return 0;
  386. }
  387. static void pty_remove(struct tty_driver *driver, struct tty_struct *tty)
  388. {
  389. }
  390. static const struct tty_operations ptm_unix98_ops = {
  391. .lookup = ptm_unix98_lookup,
  392. .install = pty_install,
  393. .remove = pty_remove,
  394. .open = pty_open,
  395. .close = pty_close,
  396. .write = pty_write,
  397. .write_room = pty_write_room,
  398. .flush_buffer = pty_flush_buffer,
  399. .chars_in_buffer = pty_chars_in_buffer,
  400. .unthrottle = pty_unthrottle,
  401. .set_termios = pty_set_termios,
  402. .ioctl = pty_unix98_ioctl,
  403. .shutdown = pty_shutdown
  404. };
  405. static const struct tty_operations pty_unix98_ops = {
  406. .lookup = pts_unix98_lookup,
  407. .install = pty_install,
  408. .remove = pty_remove,
  409. .open = pty_open,
  410. .close = pty_close,
  411. .write = pty_write,
  412. .write_room = pty_write_room,
  413. .flush_buffer = pty_flush_buffer,
  414. .chars_in_buffer = pty_chars_in_buffer,
  415. .unthrottle = pty_unthrottle,
  416. .set_termios = pty_set_termios,
  417. };
  418. /**
  419. * ptmx_open - open a unix 98 pty master
  420. * @inode: inode of device file
  421. * @filp: file pointer to tty
  422. *
  423. * Allocate a unix98 pty master device from the ptmx driver.
  424. *
  425. * Locking: tty_mutex protects the init_dev work. tty->count should
  426. * protect the rest.
  427. * allocated_ptys_lock handles the list of free pty numbers
  428. */
  429. static int __ptmx_open(struct inode *inode, struct file *filp)
  430. {
  431. struct tty_struct *tty;
  432. int retval;
  433. int index;
  434. nonseekable_open(inode, filp);
  435. /* find a device that is not in use. */
  436. index = devpts_new_index();
  437. if (index < 0)
  438. return index;
  439. mutex_lock(&tty_mutex);
  440. tty = tty_init_dev(ptm_driver, index, 1);
  441. mutex_unlock(&tty_mutex);
  442. if (IS_ERR(tty)) {
  443. retval = PTR_ERR(tty);
  444. goto out;
  445. }
  446. set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
  447. filp->private_data = tty;
  448. file_move(filp, &tty->tty_files);
  449. retval = devpts_pty_new(tty->link);
  450. if (retval)
  451. goto out1;
  452. retval = ptm_driver->ops->open(tty, filp);
  453. if (!retval)
  454. return 0;
  455. out1:
  456. tty_release_dev(filp);
  457. return retval;
  458. out:
  459. devpts_kill_index(index);
  460. return retval;
  461. }
  462. static int ptmx_open(struct inode *inode, struct file *filp)
  463. {
  464. int ret;
  465. lock_kernel();
  466. ret = __ptmx_open(inode, filp);
  467. unlock_kernel();
  468. return ret;
  469. }
  470. static struct file_operations ptmx_fops;
  471. static void __init unix98_pty_init(void)
  472. {
  473. ptm_driver = alloc_tty_driver(NR_UNIX98_PTY_MAX);
  474. if (!ptm_driver)
  475. panic("Couldn't allocate Unix98 ptm driver");
  476. pts_driver = alloc_tty_driver(NR_UNIX98_PTY_MAX);
  477. if (!pts_driver)
  478. panic("Couldn't allocate Unix98 pts driver");
  479. ptm_driver->owner = THIS_MODULE;
  480. ptm_driver->driver_name = "pty_master";
  481. ptm_driver->name = "ptm";
  482. ptm_driver->major = UNIX98_PTY_MASTER_MAJOR;
  483. ptm_driver->minor_start = 0;
  484. ptm_driver->type = TTY_DRIVER_TYPE_PTY;
  485. ptm_driver->subtype = PTY_TYPE_MASTER;
  486. ptm_driver->init_termios = tty_std_termios;
  487. ptm_driver->init_termios.c_iflag = 0;
  488. ptm_driver->init_termios.c_oflag = 0;
  489. ptm_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
  490. ptm_driver->init_termios.c_lflag = 0;
  491. ptm_driver->init_termios.c_ispeed = 38400;
  492. ptm_driver->init_termios.c_ospeed = 38400;
  493. ptm_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW |
  494. TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_DEVPTS_MEM;
  495. ptm_driver->other = pts_driver;
  496. tty_set_operations(ptm_driver, &ptm_unix98_ops);
  497. pts_driver->owner = THIS_MODULE;
  498. pts_driver->driver_name = "pty_slave";
  499. pts_driver->name = "pts";
  500. pts_driver->major = UNIX98_PTY_SLAVE_MAJOR;
  501. pts_driver->minor_start = 0;
  502. pts_driver->type = TTY_DRIVER_TYPE_PTY;
  503. pts_driver->subtype = PTY_TYPE_SLAVE;
  504. pts_driver->init_termios = tty_std_termios;
  505. pts_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
  506. pts_driver->init_termios.c_ispeed = 38400;
  507. pts_driver->init_termios.c_ospeed = 38400;
  508. pts_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW |
  509. TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_DEVPTS_MEM;
  510. pts_driver->other = ptm_driver;
  511. tty_set_operations(pts_driver, &pty_unix98_ops);
  512. if (tty_register_driver(ptm_driver))
  513. panic("Couldn't register Unix98 ptm driver");
  514. if (tty_register_driver(pts_driver))
  515. panic("Couldn't register Unix98 pts driver");
  516. /* FIXME: WTF */
  517. #if 0
  518. pty_table[1].data = &ptm_driver->refcount;
  519. #endif
  520. register_sysctl_table(pty_root_table);
  521. /* Now create the /dev/ptmx special device */
  522. tty_default_fops(&ptmx_fops);
  523. ptmx_fops.open = ptmx_open;
  524. cdev_init(&ptmx_cdev, &ptmx_fops);
  525. if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
  526. register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
  527. panic("Couldn't register /dev/ptmx driver\n");
  528. device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
  529. }
  530. #else
  531. static inline void unix98_pty_init(void) { }
  532. #endif
  533. static int __init pty_init(void)
  534. {
  535. legacy_pty_init();
  536. unix98_pty_init();
  537. return 0;
  538. }
  539. module_init(pty_init);