Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* -*- linux-c -*- --------------------------------------------------------- * |
| 2 | * |
| 3 | * linux/fs/devpts/inode.c |
| 4 | * |
| 5 | * Copyright 1998-2004 H. Peter Anvin -- All Rights Reserved |
| 6 | * |
| 7 | * This file is part of the Linux kernel and is made available under |
| 8 | * the terms of the GNU General Public License, version 2, or at your |
| 9 | * option, any later version, incorporated herein by reference. |
| 10 | * |
| 11 | * ------------------------------------------------------------------------- */ |
| 12 | |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/fs.h> |
| 16 | #include <linux/sched.h> |
| 17 | #include <linux/namei.h> |
| 18 | #include <linux/mount.h> |
| 19 | #include <linux/tty.h> |
Sukadev Bhattiprolu | 718a916 | 2008-04-30 00:54:21 -0700 | [diff] [blame] | 20 | #include <linux/mutex.h> |
Nick Black | 1fd7317 | 2009-09-22 16:43:33 -0700 | [diff] [blame] | 21 | #include <linux/magic.h> |
Sukadev Bhattiprolu | 718a916 | 2008-04-30 00:54:21 -0700 | [diff] [blame] | 22 | #include <linux/idr.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <linux/devpts_fs.h> |
Domen Puncer | 7a673c6 | 2006-03-23 03:00:59 -0800 | [diff] [blame] | 24 | #include <linux/parser.h> |
Florin Malita | 3972b7f | 2007-05-08 00:24:18 -0700 | [diff] [blame] | 25 | #include <linux/fsnotify.h> |
Miklos Szeredi | b87a267 | 2008-02-08 04:21:41 -0800 | [diff] [blame] | 26 | #include <linux/seq_file.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
Miklos Szeredi | b87a267 | 2008-02-08 04:21:41 -0800 | [diff] [blame] | 28 | #define DEVPTS_DEFAULT_MODE 0600 |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 29 | /* |
| 30 | * ptmx is a new node in /dev/pts and will be unused in legacy (single- |
| 31 | * instance) mode. To prevent surprises in user space, set permissions of |
| 32 | * ptmx to 0. Use 'chmod' or remount with '-o ptmxmode' to set meaningful |
| 33 | * permissions. |
| 34 | */ |
| 35 | #define DEVPTS_DEFAULT_PTMX_MODE 0000 |
Sukadev Bhattiprolu | 527b3e4 | 2008-10-13 10:43:08 +0100 | [diff] [blame] | 36 | #define PTMX_MINOR 2 |
Miklos Szeredi | b87a267 | 2008-02-08 04:21:41 -0800 | [diff] [blame] | 37 | |
Sukadev Bhattiprolu | 718a916 | 2008-04-30 00:54:21 -0700 | [diff] [blame] | 38 | extern int pty_limit; /* Config limit on Unix98 ptys */ |
Sukadev Bhattiprolu | 718a916 | 2008-04-30 00:54:21 -0700 | [diff] [blame] | 39 | static DEFINE_MUTEX(allocated_ptys_lock); |
| 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | static struct vfsmount *devpts_mnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
Sukadev Bhattiprolu | 31af0ab | 2009-01-02 13:41:33 +0000 | [diff] [blame] | 43 | struct pts_mount_opts { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | int setuid; |
| 45 | int setgid; |
| 46 | uid_t uid; |
| 47 | gid_t gid; |
| 48 | umode_t mode; |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 49 | umode_t ptmxmode; |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 50 | int newinstance; |
Sukadev Bhattiprolu | 31af0ab | 2009-01-02 13:41:33 +0000 | [diff] [blame] | 51 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Domen Puncer | 7a673c6 | 2006-03-23 03:00:59 -0800 | [diff] [blame] | 53 | enum { |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 54 | Opt_uid, Opt_gid, Opt_mode, Opt_ptmxmode, Opt_newinstance, |
Domen Puncer | 7a673c6 | 2006-03-23 03:00:59 -0800 | [diff] [blame] | 55 | Opt_err |
| 56 | }; |
| 57 | |
Steven Whitehouse | a447c09 | 2008-10-13 10:46:57 +0100 | [diff] [blame] | 58 | static const match_table_t tokens = { |
Domen Puncer | 7a673c6 | 2006-03-23 03:00:59 -0800 | [diff] [blame] | 59 | {Opt_uid, "uid=%u"}, |
| 60 | {Opt_gid, "gid=%u"}, |
| 61 | {Opt_mode, "mode=%o"}, |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 62 | #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES |
| 63 | {Opt_ptmxmode, "ptmxmode=%o"}, |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 64 | {Opt_newinstance, "newinstance"}, |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 65 | #endif |
Domen Puncer | 7a673c6 | 2006-03-23 03:00:59 -0800 | [diff] [blame] | 66 | {Opt_err, NULL} |
| 67 | }; |
| 68 | |
Sukadev Bhattiprolu | e76b7c0 | 2009-01-02 13:41:21 +0000 | [diff] [blame] | 69 | struct pts_fs_info { |
| 70 | struct ida allocated_ptys; |
Sukadev Bhattiprolu | 31af0ab | 2009-01-02 13:41:33 +0000 | [diff] [blame] | 71 | struct pts_mount_opts mount_opts; |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 72 | struct dentry *ptmx_dentry; |
Sukadev Bhattiprolu | e76b7c0 | 2009-01-02 13:41:21 +0000 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | static inline struct pts_fs_info *DEVPTS_SB(struct super_block *sb) |
| 76 | { |
| 77 | return sb->s_fs_info; |
| 78 | } |
| 79 | |
Sukadev Bhattiprolu | 59e55e6 | 2009-01-02 13:41:11 +0000 | [diff] [blame] | 80 | static inline struct super_block *pts_sb_from_inode(struct inode *inode) |
| 81 | { |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 82 | #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES |
Sukadev Bhattiprolu | 59e55e6 | 2009-01-02 13:41:11 +0000 | [diff] [blame] | 83 | if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) |
| 84 | return inode->i_sb; |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 85 | #endif |
Sukadev Bhattiprolu | 59e55e6 | 2009-01-02 13:41:11 +0000 | [diff] [blame] | 86 | return devpts_mnt->mnt_sb; |
| 87 | } |
| 88 | |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 89 | #define PARSE_MOUNT 0 |
| 90 | #define PARSE_REMOUNT 1 |
| 91 | |
Sukadev Bhattiprolu | 1f71ebe | 2009-05-14 19:38:24 -0700 | [diff] [blame] | 92 | /* |
| 93 | * parse_mount_options(): |
| 94 | * Set @opts to mount options specified in @data. If an option is not |
| 95 | * specified in @data, set it to its default value. The exception is |
| 96 | * 'newinstance' option which can only be set/cleared on a mount (i.e. |
| 97 | * cannot be changed during remount). |
| 98 | * |
| 99 | * Note: @data may be NULL (in which case all options are set to default). |
| 100 | */ |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 101 | static int parse_mount_options(char *data, int op, struct pts_mount_opts *opts) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | { |
Domen Puncer | 7a673c6 | 2006-03-23 03:00:59 -0800 | [diff] [blame] | 103 | char *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
Sukadev Bhattiprolu | 31af0ab | 2009-01-02 13:41:33 +0000 | [diff] [blame] | 105 | opts->setuid = 0; |
| 106 | opts->setgid = 0; |
| 107 | opts->uid = 0; |
| 108 | opts->gid = 0; |
| 109 | opts->mode = DEVPTS_DEFAULT_MODE; |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 110 | opts->ptmxmode = DEVPTS_DEFAULT_PTMX_MODE; |
Domen Puncer | 7a673c6 | 2006-03-23 03:00:59 -0800 | [diff] [blame] | 111 | |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 112 | /* newinstance makes sense only on initial mount */ |
| 113 | if (op == PARSE_MOUNT) |
| 114 | opts->newinstance = 0; |
| 115 | |
Domen Puncer | 7a673c6 | 2006-03-23 03:00:59 -0800 | [diff] [blame] | 116 | while ((p = strsep(&data, ",")) != NULL) { |
| 117 | substring_t args[MAX_OPT_ARGS]; |
| 118 | int token; |
| 119 | int option; |
| 120 | |
| 121 | if (!*p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | continue; |
Domen Puncer | 7a673c6 | 2006-03-23 03:00:59 -0800 | [diff] [blame] | 123 | |
| 124 | token = match_token(p, tokens, args); |
| 125 | switch (token) { |
| 126 | case Opt_uid: |
| 127 | if (match_int(&args[0], &option)) |
| 128 | return -EINVAL; |
Sukadev Bhattiprolu | 31af0ab | 2009-01-02 13:41:33 +0000 | [diff] [blame] | 129 | opts->uid = option; |
| 130 | opts->setuid = 1; |
Domen Puncer | 7a673c6 | 2006-03-23 03:00:59 -0800 | [diff] [blame] | 131 | break; |
| 132 | case Opt_gid: |
| 133 | if (match_int(&args[0], &option)) |
| 134 | return -EINVAL; |
Sukadev Bhattiprolu | 31af0ab | 2009-01-02 13:41:33 +0000 | [diff] [blame] | 135 | opts->gid = option; |
| 136 | opts->setgid = 1; |
Domen Puncer | 7a673c6 | 2006-03-23 03:00:59 -0800 | [diff] [blame] | 137 | break; |
| 138 | case Opt_mode: |
| 139 | if (match_octal(&args[0], &option)) |
| 140 | return -EINVAL; |
Sukadev Bhattiprolu | 31af0ab | 2009-01-02 13:41:33 +0000 | [diff] [blame] | 141 | opts->mode = option & S_IALLUGO; |
Domen Puncer | 7a673c6 | 2006-03-23 03:00:59 -0800 | [diff] [blame] | 142 | break; |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 143 | #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES |
| 144 | case Opt_ptmxmode: |
| 145 | if (match_octal(&args[0], &option)) |
| 146 | return -EINVAL; |
| 147 | opts->ptmxmode = option & S_IALLUGO; |
| 148 | break; |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 149 | case Opt_newinstance: |
| 150 | /* newinstance makes sense only on initial mount */ |
| 151 | if (op == PARSE_MOUNT) |
| 152 | opts->newinstance = 1; |
| 153 | break; |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 154 | #endif |
Domen Puncer | 7a673c6 | 2006-03-23 03:00:59 -0800 | [diff] [blame] | 155 | default: |
| 156 | printk(KERN_ERR "devpts: called with bogus options\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | return -EINVAL; |
| 158 | } |
| 159 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | |
| 161 | return 0; |
| 162 | } |
| 163 | |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 164 | #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES |
| 165 | static int mknod_ptmx(struct super_block *sb) |
Sukadev Bhattiprolu | 53af8ee | 2009-01-02 13:41:47 +0000 | [diff] [blame] | 166 | { |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 167 | int mode; |
| 168 | int rc = -ENOMEM; |
| 169 | struct dentry *dentry; |
| 170 | struct inode *inode; |
| 171 | struct dentry *root = sb->s_root; |
Sukadev Bhattiprolu | 53af8ee | 2009-01-02 13:41:47 +0000 | [diff] [blame] | 172 | struct pts_fs_info *fsi = DEVPTS_SB(sb); |
| 173 | struct pts_mount_opts *opts = &fsi->mount_opts; |
| 174 | |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 175 | mutex_lock(&root->d_inode->i_mutex); |
| 176 | |
| 177 | /* If we have already created ptmx node, return */ |
| 178 | if (fsi->ptmx_dentry) { |
| 179 | rc = 0; |
| 180 | goto out; |
| 181 | } |
| 182 | |
| 183 | dentry = d_alloc_name(root, "ptmx"); |
| 184 | if (!dentry) { |
| 185 | printk(KERN_NOTICE "Unable to alloc dentry for ptmx node\n"); |
| 186 | goto out; |
| 187 | } |
| 188 | |
| 189 | /* |
| 190 | * Create a new 'ptmx' node in this mount of devpts. |
| 191 | */ |
| 192 | inode = new_inode(sb); |
| 193 | if (!inode) { |
| 194 | printk(KERN_ERR "Unable to alloc inode for ptmx node\n"); |
| 195 | dput(dentry); |
| 196 | goto out; |
| 197 | } |
| 198 | |
| 199 | inode->i_ino = 2; |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 200 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; |
| 201 | |
| 202 | mode = S_IFCHR|opts->ptmxmode; |
| 203 | init_special_inode(inode, mode, MKDEV(TTYAUX_MAJOR, 2)); |
| 204 | |
| 205 | d_add(dentry, inode); |
| 206 | |
| 207 | fsi->ptmx_dentry = dentry; |
| 208 | rc = 0; |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 209 | out: |
| 210 | mutex_unlock(&root->d_inode->i_mutex); |
| 211 | return rc; |
| 212 | } |
| 213 | |
| 214 | static void update_ptmx_mode(struct pts_fs_info *fsi) |
| 215 | { |
| 216 | struct inode *inode; |
| 217 | if (fsi->ptmx_dentry) { |
| 218 | inode = fsi->ptmx_dentry->d_inode; |
| 219 | inode->i_mode = S_IFCHR|fsi->mount_opts.ptmxmode; |
| 220 | } |
| 221 | } |
| 222 | #else |
| 223 | static inline void update_ptmx_mode(struct pts_fs_info *fsi) |
| 224 | { |
| 225 | return; |
| 226 | } |
| 227 | #endif |
| 228 | |
| 229 | static int devpts_remount(struct super_block *sb, int *flags, char *data) |
| 230 | { |
| 231 | int err; |
| 232 | struct pts_fs_info *fsi = DEVPTS_SB(sb); |
| 233 | struct pts_mount_opts *opts = &fsi->mount_opts; |
| 234 | |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 235 | err = parse_mount_options(data, PARSE_REMOUNT, opts); |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 236 | |
| 237 | /* |
| 238 | * parse_mount_options() restores options to default values |
| 239 | * before parsing and may have changed ptmxmode. So, update the |
| 240 | * mode in the inode too. Bogus options don't fail the remount, |
| 241 | * so do this even on error return. |
| 242 | */ |
| 243 | update_ptmx_mode(fsi); |
| 244 | |
| 245 | return err; |
Sukadev Bhattiprolu | 53af8ee | 2009-01-02 13:41:47 +0000 | [diff] [blame] | 246 | } |
| 247 | |
Miklos Szeredi | b87a267 | 2008-02-08 04:21:41 -0800 | [diff] [blame] | 248 | static int devpts_show_options(struct seq_file *seq, struct vfsmount *vfs) |
| 249 | { |
Sukadev Bhattiprolu | 31af0ab | 2009-01-02 13:41:33 +0000 | [diff] [blame] | 250 | struct pts_fs_info *fsi = DEVPTS_SB(vfs->mnt_sb); |
| 251 | struct pts_mount_opts *opts = &fsi->mount_opts; |
| 252 | |
| 253 | if (opts->setuid) |
| 254 | seq_printf(seq, ",uid=%u", opts->uid); |
| 255 | if (opts->setgid) |
| 256 | seq_printf(seq, ",gid=%u", opts->gid); |
| 257 | seq_printf(seq, ",mode=%03o", opts->mode); |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 258 | #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES |
| 259 | seq_printf(seq, ",ptmxmode=%03o", opts->ptmxmode); |
| 260 | #endif |
Miklos Szeredi | b87a267 | 2008-02-08 04:21:41 -0800 | [diff] [blame] | 261 | |
| 262 | return 0; |
| 263 | } |
| 264 | |
Josef 'Jeff' Sipek | ee9b6d6 | 2007-02-12 00:55:41 -0800 | [diff] [blame] | 265 | static const struct super_operations devpts_sops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | .statfs = simple_statfs, |
| 267 | .remount_fs = devpts_remount, |
Miklos Szeredi | b87a267 | 2008-02-08 04:21:41 -0800 | [diff] [blame] | 268 | .show_options = devpts_show_options, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | }; |
| 270 | |
Sukadev Bhattiprolu | e76b7c0 | 2009-01-02 13:41:21 +0000 | [diff] [blame] | 271 | static void *new_pts_fs_info(void) |
| 272 | { |
| 273 | struct pts_fs_info *fsi; |
| 274 | |
| 275 | fsi = kzalloc(sizeof(struct pts_fs_info), GFP_KERNEL); |
| 276 | if (!fsi) |
| 277 | return NULL; |
| 278 | |
| 279 | ida_init(&fsi->allocated_ptys); |
Sukadev Bhattiprolu | 31af0ab | 2009-01-02 13:41:33 +0000 | [diff] [blame] | 280 | fsi->mount_opts.mode = DEVPTS_DEFAULT_MODE; |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 281 | fsi->mount_opts.ptmxmode = DEVPTS_DEFAULT_PTMX_MODE; |
Sukadev Bhattiprolu | e76b7c0 | 2009-01-02 13:41:21 +0000 | [diff] [blame] | 282 | |
| 283 | return fsi; |
| 284 | } |
| 285 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | static int |
| 287 | devpts_fill_super(struct super_block *s, void *data, int silent) |
| 288 | { |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 289 | struct inode *inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | |
| 291 | s->s_blocksize = 1024; |
| 292 | s->s_blocksize_bits = 10; |
| 293 | s->s_magic = DEVPTS_SUPER_MAGIC; |
| 294 | s->s_op = &devpts_sops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | s->s_time_gran = 1; |
| 296 | |
Sukadev Bhattiprolu | e76b7c0 | 2009-01-02 13:41:21 +0000 | [diff] [blame] | 297 | s->s_fs_info = new_pts_fs_info(); |
| 298 | if (!s->s_fs_info) |
| 299 | goto fail; |
| 300 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | inode = new_inode(s); |
| 302 | if (!inode) |
Sukadev Bhattiprolu | e76b7c0 | 2009-01-02 13:41:21 +0000 | [diff] [blame] | 303 | goto free_fsi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | inode->i_ino = 1; |
| 305 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; |
| 307 | inode->i_op = &simple_dir_inode_operations; |
| 308 | inode->i_fop = &simple_dir_operations; |
| 309 | inode->i_nlink = 2; |
| 310 | |
Sukadev Bhattiprolu | 59e55e6 | 2009-01-02 13:41:11 +0000 | [diff] [blame] | 311 | s->s_root = d_alloc_root(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | if (s->s_root) |
| 313 | return 0; |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 314 | |
Alan Cox | 835aa44 | 2009-01-02 13:42:48 +0000 | [diff] [blame] | 315 | printk(KERN_ERR "devpts: get root dentry failed\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | iput(inode); |
Sukadev Bhattiprolu | e76b7c0 | 2009-01-02 13:41:21 +0000 | [diff] [blame] | 317 | |
| 318 | free_fsi: |
| 319 | kfree(s->s_fs_info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | fail: |
| 321 | return -ENOMEM; |
| 322 | } |
| 323 | |
Andrew Morton | 8c056e5 | 2009-01-02 13:44:12 +0000 | [diff] [blame] | 324 | #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES |
Sukadev Bhattiprolu | d4076ac | 2009-01-02 13:42:19 +0000 | [diff] [blame] | 325 | static int compare_init_pts_sb(struct super_block *s, void *p) |
| 326 | { |
| 327 | if (devpts_mnt) |
| 328 | return devpts_mnt->mnt_sb == s; |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 329 | return 0; |
| 330 | } |
| 331 | |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 332 | /* |
Sukadev Bhattiprolu | 1bd7903 | 2009-03-07 10:12:32 -0800 | [diff] [blame] | 333 | * devpts_get_sb() |
Sukadev Bhattiprolu | 289f00e | 2009-03-07 10:12:06 -0800 | [diff] [blame] | 334 | * |
Sukadev Bhattiprolu | 1bd7903 | 2009-03-07 10:12:32 -0800 | [diff] [blame] | 335 | * If the '-o newinstance' mount option was specified, mount a new |
| 336 | * (private) instance of devpts. PTYs created in this instance are |
| 337 | * independent of the PTYs in other devpts instances. |
Sukadev Bhattiprolu | d4076ac | 2009-01-02 13:42:19 +0000 | [diff] [blame] | 338 | * |
Sukadev Bhattiprolu | 1bd7903 | 2009-03-07 10:12:32 -0800 | [diff] [blame] | 339 | * If the '-o newinstance' option was not specified, mount/remount the |
| 340 | * initial kernel mount of devpts. This type of mount gives the |
| 341 | * legacy, single-instance semantics. |
Sukadev Bhattiprolu | d4076ac | 2009-01-02 13:42:19 +0000 | [diff] [blame] | 342 | * |
Sukadev Bhattiprolu | 1bd7903 | 2009-03-07 10:12:32 -0800 | [diff] [blame] | 343 | * The 'newinstance' option is needed to support multiple namespace |
| 344 | * semantics in devpts while preserving backward compatibility of the |
| 345 | * current 'single-namespace' semantics. i.e all mounts of devpts |
| 346 | * without the 'newinstance' mount option should bind to the initial |
| 347 | * kernel mount, like get_sb_single(). |
Sukadev Bhattiprolu | d4076ac | 2009-01-02 13:42:19 +0000 | [diff] [blame] | 348 | * |
Sukadev Bhattiprolu | 1bd7903 | 2009-03-07 10:12:32 -0800 | [diff] [blame] | 349 | * Mounts with 'newinstance' option create a new, private namespace. |
| 350 | * |
| 351 | * NOTE: |
| 352 | * |
| 353 | * For single-mount semantics, devpts cannot use get_sb_single(), |
Sukadev Bhattiprolu | d4076ac | 2009-01-02 13:42:19 +0000 | [diff] [blame] | 354 | * because get_sb_single()/sget() find and use the super-block from |
| 355 | * the most recent mount of devpts. But that recent mount may be a |
| 356 | * 'newinstance' mount and get_sb_single() would pick the newinstance |
| 357 | * super-block instead of the initial super-block. |
Sukadev Bhattiprolu | d4076ac | 2009-01-02 13:42:19 +0000 | [diff] [blame] | 358 | */ |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 359 | static int devpts_get_sb(struct file_system_type *fs_type, |
| 360 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | { |
Sukadev Bhattiprolu | 482984f | 2009-03-07 10:14:41 -0800 | [diff] [blame] | 362 | int error; |
| 363 | struct pts_mount_opts opts; |
Sukadev Bhattiprolu | 1bd7903 | 2009-03-07 10:12:32 -0800 | [diff] [blame] | 364 | struct super_block *s; |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 365 | |
Sukadev Bhattiprolu | 1f71ebe | 2009-05-14 19:38:24 -0700 | [diff] [blame] | 366 | error = parse_mount_options(data, PARSE_MOUNT, &opts); |
| 367 | if (error) |
| 368 | return error; |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 369 | |
Sukadev Bhattiprolu | 482984f | 2009-03-07 10:14:41 -0800 | [diff] [blame] | 370 | if (opts.newinstance) |
Sukadev Bhattiprolu | 1bd7903 | 2009-03-07 10:12:32 -0800 | [diff] [blame] | 371 | s = sget(fs_type, NULL, set_anon_super, NULL); |
Sukadev Bhattiprolu | 482984f | 2009-03-07 10:14:41 -0800 | [diff] [blame] | 372 | else |
Sukadev Bhattiprolu | 1bd7903 | 2009-03-07 10:12:32 -0800 | [diff] [blame] | 373 | s = sget(fs_type, compare_init_pts_sb, set_anon_super, NULL); |
Sukadev Bhattiprolu | 945cf2c | 2009-03-07 10:11:41 -0800 | [diff] [blame] | 374 | |
Sukadev Bhattiprolu | 1bd7903 | 2009-03-07 10:12:32 -0800 | [diff] [blame] | 375 | if (IS_ERR(s)) |
| 376 | return PTR_ERR(s); |
Sukadev Bhattiprolu | 945cf2c | 2009-03-07 10:11:41 -0800 | [diff] [blame] | 377 | |
Sukadev Bhattiprolu | 1bd7903 | 2009-03-07 10:12:32 -0800 | [diff] [blame] | 378 | if (!s->s_root) { |
| 379 | s->s_flags = flags; |
| 380 | error = devpts_fill_super(s, data, flags & MS_SILENT ? 1 : 0); |
| 381 | if (error) |
| 382 | goto out_undo_sget; |
| 383 | s->s_flags |= MS_ACTIVE; |
| 384 | } |
| 385 | |
| 386 | simple_set_mnt(mnt, s); |
| 387 | |
| 388 | memcpy(&(DEVPTS_SB(s))->mount_opts, &opts, sizeof(opts)); |
| 389 | |
| 390 | error = mknod_ptmx(s); |
Sukadev Bhattiprolu | 945cf2c | 2009-03-07 10:11:41 -0800 | [diff] [blame] | 391 | if (error) |
| 392 | goto out_dput; |
| 393 | |
| 394 | return 0; |
| 395 | |
| 396 | out_dput: |
Al Viro | 6f5bbff | 2009-05-06 01:34:22 -0400 | [diff] [blame] | 397 | dput(s->s_root); /* undo dget() in simple_set_mnt() */ |
Sukadev Bhattiprolu | 1bd7903 | 2009-03-07 10:12:32 -0800 | [diff] [blame] | 398 | |
| 399 | out_undo_sget: |
Al Viro | 6f5bbff | 2009-05-06 01:34:22 -0400 | [diff] [blame] | 400 | deactivate_locked_super(s); |
Sukadev Bhattiprolu | 945cf2c | 2009-03-07 10:11:41 -0800 | [diff] [blame] | 401 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | } |
Sukadev Bhattiprolu | 482984f | 2009-03-07 10:14:41 -0800 | [diff] [blame] | 403 | |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 404 | #else |
| 405 | /* |
| 406 | * This supports only the legacy single-instance semantics (no |
| 407 | * multiple-instance semantics) |
| 408 | */ |
| 409 | static int devpts_get_sb(struct file_system_type *fs_type, int flags, |
| 410 | const char *dev_name, void *data, struct vfsmount *mnt) |
| 411 | { |
| 412 | return get_sb_single(fs_type, flags, data, devpts_fill_super, mnt); |
| 413 | } |
| 414 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | |
Sukadev Bhattiprolu | e76b7c0 | 2009-01-02 13:41:21 +0000 | [diff] [blame] | 416 | static void devpts_kill_sb(struct super_block *sb) |
| 417 | { |
| 418 | struct pts_fs_info *fsi = DEVPTS_SB(sb); |
| 419 | |
| 420 | kfree(fsi); |
Sukadev Bhattiprolu | 1f8f1e2 | 2009-01-02 13:42:02 +0000 | [diff] [blame] | 421 | kill_litter_super(sb); |
Sukadev Bhattiprolu | e76b7c0 | 2009-01-02 13:41:21 +0000 | [diff] [blame] | 422 | } |
| 423 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | static struct file_system_type devpts_fs_type = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | .name = "devpts", |
| 426 | .get_sb = devpts_get_sb, |
Sukadev Bhattiprolu | e76b7c0 | 2009-01-02 13:41:21 +0000 | [diff] [blame] | 427 | .kill_sb = devpts_kill_sb, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | }; |
| 429 | |
| 430 | /* |
| 431 | * The normal naming convention is simply /dev/pts/<number>; this conforms |
| 432 | * to the System V naming convention |
| 433 | */ |
| 434 | |
Sukadev Bhattiprolu | 15f1a63 | 2008-10-13 10:42:59 +0100 | [diff] [blame] | 435 | int devpts_new_index(struct inode *ptmx_inode) |
Sukadev Bhattiprolu | 718a916 | 2008-04-30 00:54:21 -0700 | [diff] [blame] | 436 | { |
Sukadev Bhattiprolu | e76b7c0 | 2009-01-02 13:41:21 +0000 | [diff] [blame] | 437 | struct super_block *sb = pts_sb_from_inode(ptmx_inode); |
| 438 | struct pts_fs_info *fsi = DEVPTS_SB(sb); |
Sukadev Bhattiprolu | 718a916 | 2008-04-30 00:54:21 -0700 | [diff] [blame] | 439 | int index; |
Alexey Dobriyan | 7ee7c12 | 2008-07-26 11:42:16 +0400 | [diff] [blame] | 440 | int ida_ret; |
Sukadev Bhattiprolu | 718a916 | 2008-04-30 00:54:21 -0700 | [diff] [blame] | 441 | |
| 442 | retry: |
Alan Cox | 835aa44 | 2009-01-02 13:42:48 +0000 | [diff] [blame] | 443 | if (!ida_pre_get(&fsi->allocated_ptys, GFP_KERNEL)) |
Sukadev Bhattiprolu | 718a916 | 2008-04-30 00:54:21 -0700 | [diff] [blame] | 444 | return -ENOMEM; |
Sukadev Bhattiprolu | 718a916 | 2008-04-30 00:54:21 -0700 | [diff] [blame] | 445 | |
| 446 | mutex_lock(&allocated_ptys_lock); |
Sukadev Bhattiprolu | e76b7c0 | 2009-01-02 13:41:21 +0000 | [diff] [blame] | 447 | ida_ret = ida_get_new(&fsi->allocated_ptys, &index); |
Alexey Dobriyan | 7ee7c12 | 2008-07-26 11:42:16 +0400 | [diff] [blame] | 448 | if (ida_ret < 0) { |
Sukadev Bhattiprolu | 718a916 | 2008-04-30 00:54:21 -0700 | [diff] [blame] | 449 | mutex_unlock(&allocated_ptys_lock); |
Alexey Dobriyan | 7ee7c12 | 2008-07-26 11:42:16 +0400 | [diff] [blame] | 450 | if (ida_ret == -EAGAIN) |
Sukadev Bhattiprolu | 718a916 | 2008-04-30 00:54:21 -0700 | [diff] [blame] | 451 | goto retry; |
| 452 | return -EIO; |
| 453 | } |
| 454 | |
| 455 | if (index >= pty_limit) { |
Sukadev Bhattiprolu | e76b7c0 | 2009-01-02 13:41:21 +0000 | [diff] [blame] | 456 | ida_remove(&fsi->allocated_ptys, index); |
Sukadev Bhattiprolu | 718a916 | 2008-04-30 00:54:21 -0700 | [diff] [blame] | 457 | mutex_unlock(&allocated_ptys_lock); |
| 458 | return -EIO; |
| 459 | } |
| 460 | mutex_unlock(&allocated_ptys_lock); |
| 461 | return index; |
| 462 | } |
| 463 | |
Sukadev Bhattiprolu | 15f1a63 | 2008-10-13 10:42:59 +0100 | [diff] [blame] | 464 | void devpts_kill_index(struct inode *ptmx_inode, int idx) |
Sukadev Bhattiprolu | 718a916 | 2008-04-30 00:54:21 -0700 | [diff] [blame] | 465 | { |
Sukadev Bhattiprolu | e76b7c0 | 2009-01-02 13:41:21 +0000 | [diff] [blame] | 466 | struct super_block *sb = pts_sb_from_inode(ptmx_inode); |
| 467 | struct pts_fs_info *fsi = DEVPTS_SB(sb); |
| 468 | |
Sukadev Bhattiprolu | 718a916 | 2008-04-30 00:54:21 -0700 | [diff] [blame] | 469 | mutex_lock(&allocated_ptys_lock); |
Sukadev Bhattiprolu | e76b7c0 | 2009-01-02 13:41:21 +0000 | [diff] [blame] | 470 | ida_remove(&fsi->allocated_ptys, idx); |
Sukadev Bhattiprolu | 718a916 | 2008-04-30 00:54:21 -0700 | [diff] [blame] | 471 | mutex_unlock(&allocated_ptys_lock); |
| 472 | } |
| 473 | |
Sukadev Bhattiprolu | 15f1a63 | 2008-10-13 10:42:59 +0100 | [diff] [blame] | 474 | int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | { |
Alan Cox | 835aa44 | 2009-01-02 13:42:48 +0000 | [diff] [blame] | 476 | /* tty layer puts index from devpts_new_index() in here */ |
| 477 | int number = tty->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | struct tty_driver *driver = tty->driver; |
| 479 | dev_t device = MKDEV(driver->major, driver->minor_start+number); |
| 480 | struct dentry *dentry; |
Sukadev Bhattiprolu | 59e55e6 | 2009-01-02 13:41:11 +0000 | [diff] [blame] | 481 | struct super_block *sb = pts_sb_from_inode(ptmx_inode); |
| 482 | struct inode *inode = new_inode(sb); |
| 483 | struct dentry *root = sb->s_root; |
Sukadev Bhattiprolu | 31af0ab | 2009-01-02 13:41:33 +0000 | [diff] [blame] | 484 | struct pts_fs_info *fsi = DEVPTS_SB(sb); |
| 485 | struct pts_mount_opts *opts = &fsi->mount_opts; |
Sukadev Bhattiprolu | 89a52e1 | 2008-10-13 10:43:18 +0100 | [diff] [blame] | 486 | char s[12]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | |
| 488 | /* We're supposed to be given the slave end of a pty */ |
| 489 | BUG_ON(driver->type != TTY_DRIVER_TYPE_PTY); |
| 490 | BUG_ON(driver->subtype != PTY_TYPE_SLAVE); |
| 491 | |
| 492 | if (!inode) |
| 493 | return -ENOMEM; |
| 494 | |
David Howells | d0eafc7 | 2009-01-02 13:44:49 +0000 | [diff] [blame] | 495 | inode->i_ino = number + 3; |
| 496 | inode->i_uid = opts->setuid ? opts->uid : current_fsuid(); |
| 497 | inode->i_gid = opts->setgid ? opts->gid : current_fsgid(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; |
Sukadev Bhattiprolu | 31af0ab | 2009-01-02 13:41:33 +0000 | [diff] [blame] | 499 | init_special_inode(inode, S_IFCHR|opts->mode, device); |
Theodore Ts'o | 8e18e29 | 2006-09-27 01:50:46 -0700 | [diff] [blame] | 500 | inode->i_private = tty; |
Sukadev Bhattiprolu | a6f37da | 2008-10-13 10:43:27 +0100 | [diff] [blame] | 501 | tty->driver_data = inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | |
Sukadev Bhattiprolu | 89a52e1 | 2008-10-13 10:43:18 +0100 | [diff] [blame] | 503 | sprintf(s, "%d", number); |
| 504 | |
Sukadev Bhattiprolu | 59e55e6 | 2009-01-02 13:41:11 +0000 | [diff] [blame] | 505 | mutex_lock(&root->d_inode->i_mutex); |
Sukadev Bhattiprolu | 89a52e1 | 2008-10-13 10:43:18 +0100 | [diff] [blame] | 506 | |
Sukadev Bhattiprolu | 59e55e6 | 2009-01-02 13:41:11 +0000 | [diff] [blame] | 507 | dentry = d_alloc_name(root, s); |
Sukadev Bhattiprolu | 89a52e1 | 2008-10-13 10:43:18 +0100 | [diff] [blame] | 508 | if (!IS_ERR(dentry)) { |
| 509 | d_add(dentry, inode); |
Sukadev Bhattiprolu | 59e55e6 | 2009-01-02 13:41:11 +0000 | [diff] [blame] | 510 | fsnotify_create(root->d_inode, dentry); |
Florin Malita | 3972b7f | 2007-05-08 00:24:18 -0700 | [diff] [blame] | 511 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | |
Sukadev Bhattiprolu | 59e55e6 | 2009-01-02 13:41:11 +0000 | [diff] [blame] | 513 | mutex_unlock(&root->d_inode->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | |
| 515 | return 0; |
| 516 | } |
| 517 | |
Sukadev Bhattiprolu | 15f1a63 | 2008-10-13 10:42:59 +0100 | [diff] [blame] | 518 | struct tty_struct *devpts_get_tty(struct inode *pts_inode, int number) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | { |
Sukadev Bhattiprolu | 527b3e4 | 2008-10-13 10:43:08 +0100 | [diff] [blame] | 520 | BUG_ON(pts_inode->i_rdev == MKDEV(TTYAUX_MAJOR, PTMX_MINOR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | |
Sukadev Bhattiprolu | 527b3e4 | 2008-10-13 10:43:08 +0100 | [diff] [blame] | 522 | if (pts_inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) |
| 523 | return (struct tty_struct *)pts_inode->i_private; |
| 524 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | } |
| 526 | |
Sukadev Bhattiprolu | 15f1a63 | 2008-10-13 10:42:59 +0100 | [diff] [blame] | 527 | void devpts_pty_kill(struct tty_struct *tty) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | { |
Sukadev Bhattiprolu | a6f37da | 2008-10-13 10:43:27 +0100 | [diff] [blame] | 529 | struct inode *inode = tty->driver_data; |
Sukadev Bhattiprolu | 59e55e6 | 2009-01-02 13:41:11 +0000 | [diff] [blame] | 530 | struct super_block *sb = pts_sb_from_inode(inode); |
| 531 | struct dentry *root = sb->s_root; |
Sukadev Bhattiprolu | a6f37da | 2008-10-13 10:43:27 +0100 | [diff] [blame] | 532 | struct dentry *dentry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | |
Sukadev Bhattiprolu | a6f37da | 2008-10-13 10:43:27 +0100 | [diff] [blame] | 534 | BUG_ON(inode->i_rdev == MKDEV(TTYAUX_MAJOR, PTMX_MINOR)); |
| 535 | |
Sukadev Bhattiprolu | 59e55e6 | 2009-01-02 13:41:11 +0000 | [diff] [blame] | 536 | mutex_lock(&root->d_inode->i_mutex); |
Sukadev Bhattiprolu | a6f37da | 2008-10-13 10:43:27 +0100 | [diff] [blame] | 537 | |
| 538 | dentry = d_find_alias(inode); |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 539 | if (IS_ERR(dentry)) |
| 540 | goto out; |
| 541 | |
| 542 | if (dentry) { |
Sukadev Bhattiprolu | a6f37da | 2008-10-13 10:43:27 +0100 | [diff] [blame] | 543 | inode->i_nlink--; |
| 544 | d_delete(dentry); |
Alan Cox | 835aa44 | 2009-01-02 13:42:48 +0000 | [diff] [blame] | 545 | dput(dentry); /* d_alloc_name() in devpts_pty_new() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | } |
Sukadev Bhattiprolu | a6f37da | 2008-10-13 10:43:27 +0100 | [diff] [blame] | 547 | |
Alan Cox | 835aa44 | 2009-01-02 13:42:48 +0000 | [diff] [blame] | 548 | dput(dentry); /* d_find_alias above */ |
Sukadev Bhattiprolu | 2a1b2dc | 2009-01-02 13:42:27 +0000 | [diff] [blame] | 549 | out: |
Sukadev Bhattiprolu | 59e55e6 | 2009-01-02 13:41:11 +0000 | [diff] [blame] | 550 | mutex_unlock(&root->d_inode->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | static int __init init_devpts_fs(void) |
| 554 | { |
| 555 | int err = register_filesystem(&devpts_fs_type); |
| 556 | if (!err) { |
| 557 | devpts_mnt = kern_mount(&devpts_fs_type); |
Alan Cox | 93d5581 | 2009-06-11 14:03:55 +0100 | [diff] [blame] | 558 | if (IS_ERR(devpts_mnt)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | err = PTR_ERR(devpts_mnt); |
Alan Cox | 93d5581 | 2009-06-11 14:03:55 +0100 | [diff] [blame] | 560 | unregister_filesystem(&devpts_fs_type); |
| 561 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | } |
| 563 | return err; |
| 564 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | module_init(init_devpts_fs) |