blob: d697634bc0d48cdf0c3465bd2227cd13b1751583 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Kay Sievers2b2af542009-04-30 15:23:42 +02002/*
3 * devtmpfs - kernel-maintained tmpfs-based /dev
4 *
5 * Copyright (C) 2009, Kay Sievers <kay.sievers@vrfy.org>
6 *
7 * During bootup, before any driver core device is registered,
8 * devtmpfs, a tmpfs-based filesystem is created. Every driver-core
9 * device which requests a device node, will add a node in this
Kay Sieverse454cea2009-09-18 23:01:12 +020010 * filesystem.
Peter Korsgaard02fbe5e2012-04-17 12:13:18 +020011 * By default, all devices are named after the name of the device,
12 * owned by root and have a default mode of 0600. Subsystems can
13 * overwrite the default setting if needed.
Kay Sievers2b2af542009-04-30 15:23:42 +020014 */
15
16#include <linux/kernel.h>
17#include <linux/syscalls.h>
18#include <linux/mount.h>
19#include <linux/device.h>
20#include <linux/genhd.h>
21#include <linux/namei.h>
22#include <linux/fs.h>
23#include <linux/shmem_fs.h>
Peter Korsgaardda5e4ef2010-03-16 21:55:21 +010024#include <linux/ramfs.h>
Kay Sieverse454cea2009-09-18 23:01:12 +020025#include <linux/sched.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090026#include <linux/slab.h>
Al Viro2780f1f2011-06-27 16:25:29 -040027#include <linux/kthread.h>
David Howellse262e32d2018-11-01 23:07:23 +000028#include <uapi/linux/mount.h>
Greg Kroah-Hartmanc3a30422013-04-10 09:00:15 -070029#include "base.h"
Kay Sievers2b2af542009-04-30 15:23:42 +020030
Al Viro2780f1f2011-06-27 16:25:29 -040031static struct task_struct *thread;
Kay Sievers2b2af542009-04-30 15:23:42 +020032
Rasmus Villemoesfad1db82020-01-15 19:41:52 +010033static int __initdata mount_dev = IS_ENABLED(CONFIG_DEVTMPFS_MOUNT);
Kay Sievers2b2af542009-04-30 15:23:42 +020034
Al Viro2780f1f2011-06-27 16:25:29 -040035static DEFINE_SPINLOCK(req_lock);
36
37static struct req {
38 struct req *next;
39 struct completion done;
40 int err;
41 const char *name;
Al Viro2c9ede52011-07-23 20:24:48 -040042 umode_t mode; /* 0 => delete */
Greg Kroah-Hartman4e4098a2013-04-11 11:43:29 -070043 kuid_t uid;
44 kgid_t gid;
Al Viro2780f1f2011-06-27 16:25:29 -040045 struct device *dev;
46} *requests;
Kay Sieversed413ae2009-10-28 19:51:06 +010047
Kay Sievers2b2af542009-04-30 15:23:42 +020048static int __init mount_param(char *str)
49{
Al Virofc14f2f2010-07-25 01:48:30 +040050 mount_dev = simple_strtoul(str, NULL, 0);
Kay Sievers2b2af542009-04-30 15:23:42 +020051 return 1;
52}
53__setup("devtmpfs.mount=", mount_param);
54
Al Virod4017272019-06-01 18:43:09 -040055static struct vfsmount *mnt;
56
57static struct dentry *public_dev_mount(struct file_system_type *fs_type, int flags,
58 const char *dev_name, void *data)
59{
60 struct super_block *s = mnt->mnt_sb;
61 atomic_inc(&s->s_active);
62 down_write(&s->s_umount);
63 return dget(s->s_root);
64}
65
Al Virod4017272019-06-01 18:43:09 -040066static struct file_system_type internal_fs_type = {
Kay Sievers2b2af542009-04-30 15:23:42 +020067 .name = "devtmpfs",
David Howellsf3235622019-03-25 16:38:31 +000068#ifdef CONFIG_TMPFS
69 .init_fs_context = shmem_init_fs_context,
Al Virod7167b12019-09-07 07:23:15 -040070 .parameters = shmem_fs_parameters,
David Howellsf3235622019-03-25 16:38:31 +000071#else
72 .init_fs_context = ramfs_init_fs_context,
Al Virod7167b12019-09-07 07:23:15 -040073 .parameters = ramfs_fs_parameters,
David Howellsf3235622019-03-25 16:38:31 +000074#endif
Kay Sievers2b2af542009-04-30 15:23:42 +020075 .kill_sb = kill_litter_super,
76};
77
Al Virod4017272019-06-01 18:43:09 -040078static struct file_system_type dev_fs_type = {
79 .name = "devtmpfs",
80 .mount = public_dev_mount,
81};
82
Kay Sievers2b2af542009-04-30 15:23:42 +020083#ifdef CONFIG_BLOCK
84static inline int is_blockdev(struct device *dev)
85{
86 return dev->class == &block_class;
87}
88#else
89static inline int is_blockdev(struct device *dev) { return 0; }
90#endif
91
Rasmus Villemoes72a9cc92020-01-15 19:41:53 +010092static int devtmpfs_submit_req(struct req *req, const char *tmp)
93{
94 init_completion(&req->done);
95
96 spin_lock(&req_lock);
97 req->next = requests;
98 requests = req;
99 spin_unlock(&req_lock);
100
101 wake_up_process(thread);
102 wait_for_completion(&req->done);
103
104 kfree(tmp);
105
106 return req->err;
107}
108
Al Viro2780f1f2011-06-27 16:25:29 -0400109int devtmpfs_create_node(struct device *dev)
110{
111 const char *tmp = NULL;
112 struct req req;
113
114 if (!thread)
115 return 0;
116
117 req.mode = 0;
Greg Kroah-Hartman4e4098a2013-04-11 11:43:29 -0700118 req.uid = GLOBAL_ROOT_UID;
119 req.gid = GLOBAL_ROOT_GID;
Kay Sievers3c2670e2013-04-06 09:56:00 -0700120 req.name = device_get_devnode(dev, &req.mode, &req.uid, &req.gid, &tmp);
Al Viro2780f1f2011-06-27 16:25:29 -0400121 if (!req.name)
122 return -ENOMEM;
123
124 if (req.mode == 0)
125 req.mode = 0600;
126 if (is_blockdev(dev))
127 req.mode |= S_IFBLK;
128 else
129 req.mode |= S_IFCHR;
130
131 req.dev = dev;
132
Rasmus Villemoes72a9cc92020-01-15 19:41:53 +0100133 return devtmpfs_submit_req(&req, tmp);
Al Viro2780f1f2011-06-27 16:25:29 -0400134}
135
136int devtmpfs_delete_node(struct device *dev)
137{
138 const char *tmp = NULL;
139 struct req req;
140
141 if (!thread)
142 return 0;
143
Kay Sievers3c2670e2013-04-06 09:56:00 -0700144 req.name = device_get_devnode(dev, NULL, NULL, NULL, &tmp);
Al Viro2780f1f2011-06-27 16:25:29 -0400145 if (!req.name)
146 return -ENOMEM;
147
148 req.mode = 0;
149 req.dev = dev;
150
Rasmus Villemoes72a9cc92020-01-15 19:41:53 +0100151 return devtmpfs_submit_req(&req, tmp);
Al Viro2780f1f2011-06-27 16:25:29 -0400152}
153
Al Virofbd48a62011-07-24 10:47:56 -0400154static int dev_mkdir(const char *name, umode_t mode)
Kay Sievers2b2af542009-04-30 15:23:42 +0200155{
Kay Sievers2b2af542009-04-30 15:23:42 +0200156 struct dentry *dentry;
Al Viro69753a02011-06-27 16:35:45 -0400157 struct path path;
Kay Sievers2b2af542009-04-30 15:23:42 +0200158 int err;
159
Jeff Layton1ac12b42012-12-11 12:10:06 -0500160 dentry = kern_path_create(AT_FDCWD, name, &path, LOOKUP_DIRECTORY);
Al Viro69753a02011-06-27 16:35:45 -0400161 if (IS_ERR(dentry))
162 return PTR_ERR(dentry);
Kay Sievers2b2af542009-04-30 15:23:42 +0200163
David Howells75c3cfa2015-03-17 22:26:12 +0000164 err = vfs_mkdir(d_inode(path.dentry), dentry, mode);
Al Viro69753a02011-06-27 16:35:45 -0400165 if (!err)
166 /* mark as kernel-created inode */
David Howells75c3cfa2015-03-17 22:26:12 +0000167 d_inode(dentry)->i_private = &thread;
Al Viro921a1652012-07-20 01:15:31 +0400168 done_path_create(&path, dentry);
Kay Sievers2b2af542009-04-30 15:23:42 +0200169 return err;
170}
171
172static int create_path(const char *nodepath)
173{
Al Viro5da4e682011-06-27 16:37:12 -0400174 char *path;
175 char *s;
Al Viro9d108d22011-07-27 22:27:33 -0400176 int err = 0;
Kay Sievers2b2af542009-04-30 15:23:42 +0200177
Al Viro5da4e682011-06-27 16:37:12 -0400178 /* parent directories do not exist, create them */
179 path = kstrdup(nodepath, GFP_KERNEL);
180 if (!path)
181 return -ENOMEM;
Kay Sievers2b2af542009-04-30 15:23:42 +0200182
Al Viro5da4e682011-06-27 16:37:12 -0400183 s = path;
184 for (;;) {
185 s = strchr(s, '/');
186 if (!s)
187 break;
188 s[0] = '\0';
189 err = dev_mkdir(path, 0755);
190 if (err && err != -EEXIST)
191 break;
192 s[0] = '/';
193 s++;
Kay Sievers2b2af542009-04-30 15:23:42 +0200194 }
Al Viro5da4e682011-06-27 16:37:12 -0400195 kfree(path);
Kay Sievers2b2af542009-04-30 15:23:42 +0200196 return err;
197}
198
Greg Kroah-Hartman4e4098a2013-04-11 11:43:29 -0700199static int handle_create(const char *nodename, umode_t mode, kuid_t uid,
200 kgid_t gid, struct device *dev)
Kay Sievers2b2af542009-04-30 15:23:42 +0200201{
Kay Sievers2b2af542009-04-30 15:23:42 +0200202 struct dentry *dentry;
Al Viro69753a02011-06-27 16:35:45 -0400203 struct path path;
Kay Sievers2b2af542009-04-30 15:23:42 +0200204 int err;
205
Al Viro69753a02011-06-27 16:35:45 -0400206 dentry = kern_path_create(AT_FDCWD, nodename, &path, 0);
207 if (dentry == ERR_PTR(-ENOENT)) {
Kay Sievers2b2af542009-04-30 15:23:42 +0200208 create_path(nodename);
Al Viro69753a02011-06-27 16:35:45 -0400209 dentry = kern_path_create(AT_FDCWD, nodename, &path, 0);
Kay Sievers2b2af542009-04-30 15:23:42 +0200210 }
Al Viro69753a02011-06-27 16:35:45 -0400211 if (IS_ERR(dentry))
212 return PTR_ERR(dentry);
Kay Sievers2b2af542009-04-30 15:23:42 +0200213
David Howells75c3cfa2015-03-17 22:26:12 +0000214 err = vfs_mknod(d_inode(path.dentry), dentry, mode, dev->devt);
Al Viro69753a02011-06-27 16:35:45 -0400215 if (!err) {
216 struct iattr newattrs;
Kay Sievers00926992009-10-28 19:50:57 +0100217
Al Viro69753a02011-06-27 16:35:45 -0400218 newattrs.ia_mode = mode;
Greg Kroah-Hartman4e4098a2013-04-11 11:43:29 -0700219 newattrs.ia_uid = uid;
220 newattrs.ia_gid = gid;
Kay Sievers3c2670e2013-04-06 09:56:00 -0700221 newattrs.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID;
Al Viro59551022016-01-22 15:40:57 -0500222 inode_lock(d_inode(dentry));
J. Bruce Fields27ac0ff2011-09-20 17:19:26 -0400223 notify_change(dentry, &newattrs, NULL);
Al Viro59551022016-01-22 15:40:57 -0500224 inode_unlock(d_inode(dentry));
Kay Sievers00926992009-10-28 19:50:57 +0100225
Al Viro69753a02011-06-27 16:35:45 -0400226 /* mark as kernel-created inode */
David Howells75c3cfa2015-03-17 22:26:12 +0000227 d_inode(dentry)->i_private = &thread;
Kay Sievers2b2af542009-04-30 15:23:42 +0200228 }
Al Viro921a1652012-07-20 01:15:31 +0400229 done_path_create(&path, dentry);
Kay Sievers2b2af542009-04-30 15:23:42 +0200230 return err;
231}
232
233static int dev_rmdir(const char *name)
234{
Al Viro79714f72012-06-15 03:01:42 +0400235 struct path parent;
Kay Sievers2b2af542009-04-30 15:23:42 +0200236 struct dentry *dentry;
237 int err;
238
Al Viro79714f72012-06-15 03:01:42 +0400239 dentry = kern_path_locked(name, &parent);
240 if (IS_ERR(dentry))
241 return PTR_ERR(dentry);
David Howells75c3cfa2015-03-17 22:26:12 +0000242 if (d_really_is_positive(dentry)) {
243 if (d_inode(dentry)->i_private == &thread)
244 err = vfs_rmdir(d_inode(parent.dentry), dentry);
Al Viro79714f72012-06-15 03:01:42 +0400245 else
246 err = -EPERM;
Kay Sievers2b2af542009-04-30 15:23:42 +0200247 } else {
Al Viro79714f72012-06-15 03:01:42 +0400248 err = -ENOENT;
Kay Sievers2b2af542009-04-30 15:23:42 +0200249 }
Al Viro79714f72012-06-15 03:01:42 +0400250 dput(dentry);
Al Viro59551022016-01-22 15:40:57 -0500251 inode_unlock(d_inode(parent.dentry));
Al Viro79714f72012-06-15 03:01:42 +0400252 path_put(&parent);
Kay Sievers2b2af542009-04-30 15:23:42 +0200253 return err;
254}
255
256static int delete_path(const char *nodepath)
257{
Rasmus Villemoesbe6b1df2018-08-22 13:00:07 +0200258 char *path;
Kay Sievers2b2af542009-04-30 15:23:42 +0200259 int err = 0;
260
261 path = kstrdup(nodepath, GFP_KERNEL);
262 if (!path)
263 return -ENOMEM;
264
Kay Sieversed413ae2009-10-28 19:51:06 +0100265 for (;;) {
Kay Sievers2b2af542009-04-30 15:23:42 +0200266 char *base;
267
268 base = strrchr(path, '/');
269 if (!base)
270 break;
271 base[0] = '\0';
272 err = dev_rmdir(path);
273 if (err)
274 break;
275 }
276
277 kfree(path);
278 return err;
279}
280
281static int dev_mynode(struct device *dev, struct inode *inode, struct kstat *stat)
282{
283 /* did we create it */
Al Viro2780f1f2011-06-27 16:25:29 -0400284 if (inode->i_private != &thread)
Kay Sievers2b2af542009-04-30 15:23:42 +0200285 return 0;
286
287 /* does the dev_t match */
288 if (is_blockdev(dev)) {
289 if (!S_ISBLK(stat->mode))
290 return 0;
291 } else {
292 if (!S_ISCHR(stat->mode))
293 return 0;
294 }
295 if (stat->rdev != dev->devt)
296 return 0;
297
298 /* ours */
299 return 1;
300}
301
Al Viro2780f1f2011-06-27 16:25:29 -0400302static int handle_remove(const char *nodename, struct device *dev)
Kay Sievers2b2af542009-04-30 15:23:42 +0200303{
Al Viro79714f72012-06-15 03:01:42 +0400304 struct path parent;
Kay Sievers2b2af542009-04-30 15:23:42 +0200305 struct dentry *dentry;
Axel Linfbde7c62013-11-16 16:15:23 +0800306 int deleted = 0;
Kay Sievers2b2af542009-04-30 15:23:42 +0200307 int err;
308
Al Viro79714f72012-06-15 03:01:42 +0400309 dentry = kern_path_locked(nodename, &parent);
310 if (IS_ERR(dentry))
311 return PTR_ERR(dentry);
Kay Sievers2b2af542009-04-30 15:23:42 +0200312
David Howells75c3cfa2015-03-17 22:26:12 +0000313 if (d_really_is_positive(dentry)) {
Al Viro79714f72012-06-15 03:01:42 +0400314 struct kstat stat;
Al Viro3dadecc2013-01-24 02:18:08 -0500315 struct path p = {.mnt = parent.mnt, .dentry = dentry};
David Howellsa528d352017-01-31 16:46:22 +0000316 err = vfs_getattr(&p, &stat, STATX_TYPE | STATX_MODE,
317 AT_STATX_SYNC_AS_STAT);
David Howells75c3cfa2015-03-17 22:26:12 +0000318 if (!err && dev_mynode(dev, d_inode(dentry), &stat)) {
Al Viro79714f72012-06-15 03:01:42 +0400319 struct iattr newattrs;
320 /*
321 * before unlinking this node, reset permissions
322 * of possible references like hardlinks
323 */
Eric W. Biederman91fa2cc2012-04-25 04:25:35 -0700324 newattrs.ia_uid = GLOBAL_ROOT_UID;
325 newattrs.ia_gid = GLOBAL_ROOT_GID;
Al Viro79714f72012-06-15 03:01:42 +0400326 newattrs.ia_mode = stat.mode & ~0777;
327 newattrs.ia_valid =
328 ATTR_UID|ATTR_GID|ATTR_MODE;
Al Viro59551022016-01-22 15:40:57 -0500329 inode_lock(d_inode(dentry));
J. Bruce Fields27ac0ff2011-09-20 17:19:26 -0400330 notify_change(dentry, &newattrs, NULL);
Al Viro59551022016-01-22 15:40:57 -0500331 inode_unlock(d_inode(dentry));
David Howells75c3cfa2015-03-17 22:26:12 +0000332 err = vfs_unlink(d_inode(parent.dentry), dentry, NULL);
Al Viro79714f72012-06-15 03:01:42 +0400333 if (!err || err == -ENOENT)
334 deleted = 1;
Kay Sievers2b2af542009-04-30 15:23:42 +0200335 }
Kay Sievers2b2af542009-04-30 15:23:42 +0200336 } else {
Al Viro79714f72012-06-15 03:01:42 +0400337 err = -ENOENT;
Kay Sievers2b2af542009-04-30 15:23:42 +0200338 }
Al Viro79714f72012-06-15 03:01:42 +0400339 dput(dentry);
Al Viro59551022016-01-22 15:40:57 -0500340 inode_unlock(d_inode(parent.dentry));
Kay Sievers2b2af542009-04-30 15:23:42 +0200341
Al Viro79714f72012-06-15 03:01:42 +0400342 path_put(&parent);
Kay Sievers2b2af542009-04-30 15:23:42 +0200343 if (deleted && strchr(nodename, '/'))
344 delete_path(nodename);
Kay Sievers2b2af542009-04-30 15:23:42 +0200345 return err;
346}
347
348/*
349 * If configured, or requested by the commandline, devtmpfs will be
350 * auto-mounted after the kernel mounted the root filesystem.
351 */
Rasmus Villemoesfad1db82020-01-15 19:41:52 +0100352int __init devtmpfs_mount(void)
Kay Sievers2b2af542009-04-30 15:23:42 +0200353{
Kay Sievers2b2af542009-04-30 15:23:42 +0200354 int err;
355
Al Virofc14f2f2010-07-25 01:48:30 +0400356 if (!mount_dev)
Kay Sievers2b2af542009-04-30 15:23:42 +0200357 return 0;
358
Al Viro2780f1f2011-06-27 16:25:29 -0400359 if (!thread)
Kay Sievers2b2af542009-04-30 15:23:42 +0200360 return 0;
361
Dominik Brodowski5e787db2018-10-23 22:10:35 +0200362 err = do_mount("devtmpfs", "dev", "devtmpfs", MS_SILENT, NULL);
Kay Sievers2b2af542009-04-30 15:23:42 +0200363 if (err)
364 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
365 else
366 printk(KERN_INFO "devtmpfs: mounted\n");
Kay Sievers2b2af542009-04-30 15:23:42 +0200367 return err;
368}
369
Arnaud Lacombef9e0b152011-07-21 13:16:19 -0400370static DECLARE_COMPLETION(setup_done);
Al Viro2780f1f2011-06-27 16:25:29 -0400371
Greg Kroah-Hartman4e4098a2013-04-11 11:43:29 -0700372static int handle(const char *name, umode_t mode, kuid_t uid, kgid_t gid,
Kay Sievers3c2670e2013-04-06 09:56:00 -0700373 struct device *dev)
Al Viro2780f1f2011-06-27 16:25:29 -0400374{
375 if (mode)
Kay Sievers3c2670e2013-04-06 09:56:00 -0700376 return handle_create(name, mode, uid, gid, dev);
Al Viro2780f1f2011-06-27 16:25:29 -0400377 else
378 return handle_remove(name, dev);
379}
380
Christoph Hellwigbcbacc42020-07-22 10:48:25 +0200381static void __noreturn devtmpfs_work_loop(void)
Al Viro2780f1f2011-06-27 16:25:29 -0400382{
Al Viro2780f1f2011-06-27 16:25:29 -0400383 while (1) {
384 spin_lock(&req_lock);
385 while (requests) {
386 struct req *req = requests;
387 requests = NULL;
388 spin_unlock(&req_lock);
389 while (req) {
Al Viroe13889b2011-07-25 14:15:50 -0400390 struct req *next = req->next;
Kay Sievers3c2670e2013-04-06 09:56:00 -0700391 req->err = handle(req->name, req->mode,
392 req->uid, req->gid, req->dev);
Al Viro2780f1f2011-06-27 16:25:29 -0400393 complete(&req->done);
Al Viroe13889b2011-07-25 14:15:50 -0400394 req = next;
Al Viro2780f1f2011-06-27 16:25:29 -0400395 }
396 spin_lock(&req_lock);
397 }
Kautuk Consul65e67572011-11-15 14:52:34 -0800398 __set_current_state(TASK_INTERRUPTIBLE);
Al Viro2780f1f2011-06-27 16:25:29 -0400399 spin_unlock(&req_lock);
400 schedule();
Al Viro2780f1f2011-06-27 16:25:29 -0400401 }
Christoph Hellwigbcbacc42020-07-22 10:48:25 +0200402}
403
404static int __init devtmpfs_setup(void *p)
405{
406 int err;
407
408 err = ksys_unshare(CLONE_NEWNS);
409 if (err)
410 goto out;
411 err = do_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, NULL);
412 if (err)
413 goto out;
414 ksys_chdir("/.."); /* will traverse into overmounted root */
415 ksys_chroot(".");
416out:
417 *(int *)p = err;
418 complete(&setup_done);
419 return err;
420}
421
422/*
423 * The __ref is because devtmpfs_setup needs to be __init for the routines it
424 * calls. That call is done while devtmpfs_init, which is marked __init,
425 * synchronously waits for it to complete.
426 */
427static int __ref devtmpfsd(void *p)
428{
429 int err = devtmpfs_setup(p);
430
431 if (err)
432 return err;
433 devtmpfs_work_loop();
Al Viro2780f1f2011-06-27 16:25:29 -0400434 return 0;
Al Viro2780f1f2011-06-27 16:25:29 -0400435}
436
Kay Sievers2b2af542009-04-30 15:23:42 +0200437/*
438 * Create devtmpfs instance, driver-core devices will add their device
439 * nodes here.
440 */
441int __init devtmpfs_init(void)
442{
Al Virod4017272019-06-01 18:43:09 -0400443 char opts[] = "mode=0755";
444 int err;
445
446 mnt = vfs_kern_mount(&internal_fs_type, 0, "devtmpfs", opts);
447 if (IS_ERR(mnt)) {
448 printk(KERN_ERR "devtmpfs: unable to create devtmpfs %ld\n",
449 PTR_ERR(mnt));
450 return PTR_ERR(mnt);
451 }
452 err = register_filesystem(&dev_fs_type);
Kay Sievers2b2af542009-04-30 15:23:42 +0200453 if (err) {
454 printk(KERN_ERR "devtmpfs: unable to register devtmpfs "
455 "type %i\n", err);
456 return err;
457 }
458
Al Viro2780f1f2011-06-27 16:25:29 -0400459 thread = kthread_run(devtmpfsd, &err, "kdevtmpfs");
460 if (!IS_ERR(thread)) {
461 wait_for_completion(&setup_done);
462 } else {
463 err = PTR_ERR(thread);
464 thread = NULL;
465 }
466
467 if (err) {
Kay Sievers2b2af542009-04-30 15:23:42 +0200468 printk(KERN_ERR "devtmpfs: unable to create devtmpfs %i\n", err);
469 unregister_filesystem(&dev_fs_type);
470 return err;
471 }
Kay Sievers2b2af542009-04-30 15:23:42 +0200472
473 printk(KERN_INFO "devtmpfs: initialized\n");
474 return 0;
475}