13 #include <linux/module.h>
16 #include <linux/sched.h>
18 #include <linux/slab.h>
20 #include <linux/tty.h>
22 #include <linux/magic.h>
29 #define DEVPTS_DEFAULT_MODE 0600
36 #define DEVPTS_DEFAULT_PTMX_MODE 0000
45 static int pty_limit_min;
46 static int pty_limit_max =
INT_MAX;
52 .maxlen =
sizeof(
int),
59 .procname =
"reserve",
60 .maxlen =
sizeof(
int),
68 .maxlen =
sizeof(
int),
76 static struct ctl_table pty_kern_table[] = {
85 static struct ctl_table pty_root_table[] = {
89 .child = pty_kern_table,
118 #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
139 #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
143 return devpts_mnt->
mnt_sb;
146 #define PARSE_MOUNT 0
147 #define PARSE_REMOUNT 1
209 #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
236 #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
277 d_add(dentry, inode);
286 static void update_ptmx_mode(
struct pts_fs_info *fsi)
295 static inline void update_ptmx_mode(
struct pts_fs_info *fsi)
315 update_ptmx_mode(fsi);
320 static int devpts_show_options(
struct seq_file *seq,
struct dentry *root)
330 #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
341 .remount_fs = devpts_remount,
342 .show_options = devpts_show_options,
345 static void *new_pts_fs_info(
void)
368 s->
s_op = &devpts_sops;
395 #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
396 static int compare_init_pts_sb(
struct super_block *s,
void *
p)
399 return devpts_mnt->
mnt_sb ==
s;
431 int flags,
const char *dev_name,
void *data)
437 error = parse_mount_options(data,
PARSE_MOUNT, &opts);
439 return ERR_PTR(error);
451 error = devpts_fill_super(s, data, flags &
MS_SILENT ? 1 : 0);
457 memcpy(&(DEVPTS_SB(s))->mount_opts, &opts,
sizeof(opts));
459 error = mknod_ptmx(s);
467 return ERR_PTR(error);
475 static struct dentry *devpts_mount(
struct file_system_type *fs_type,
int flags,
476 const char *dev_name,
void *data)
478 return mount_single(fs_type, flags, data, devpts_fill_super);
492 .mount = devpts_mount,
493 .kill_sb = devpts_kill_sb,
503 struct super_block *sb = pts_sb_from_inode(ptmx_inode);
513 if (pty_count >= pty_limit -
514 (fsi->
mount_opts.newinstance ? pty_reserve : 0)) {
539 struct super_block *sb = pts_sb_from_inode(ptmx_inode);
554 struct dentry *dentry;
555 struct super_block *sb = pts_sb_from_inode(ptmx_inode);
557 struct dentry *root = sb->
s_root;
570 inode->
i_ino = number + 3;
584 d_add(dentry, inode);
585 fsnotify_create(root->
d_inode, dentry);
598 struct dentry *dentry;
621 struct dentry *root = sb->
s_root;
622 struct dentry *dentry;
638 static int __init init_devpts_fs(
void)
646 if (IS_ERR(devpts_mnt)) {
647 err = PTR_ERR(devpts_mnt);