15 #include <linux/kernel.h>
18 #include <linux/device.h>
24 #include <linux/sched.h>
25 #include <linux/slab.h>
30 #if defined CONFIG_DEVTMPFS_MOUNT
31 static int mount_dev = 1;
52 __setup(
"devtmpfs.mount=", mount_param);
55 const char *dev_name,
void *
data)
71 static inline int is_blockdev(
struct device *
dev)
76 static inline int is_blockdev(
struct device *
dev) {
return 0; }
101 init_completion(&req.done);
131 init_completion(&req.done);
153 return PTR_ERR(dentry);
163 static int create_path(
const char *nodepath)
180 err = dev_mkdir(path, 0755);
181 if (err && err != -
EEXIST)
190 static int handle_create(
const char *nodename,
umode_t mode,
struct device *
dev)
192 struct dentry *dentry;
197 if (dentry == ERR_PTR(-
ENOENT)) {
198 create_path(nodename);
202 return PTR_ERR(dentry);
205 dentry, mode, dev->
devt);
207 struct iattr newattrs;
223 static int dev_rmdir(
const char *name)
226 struct dentry *dentry;
231 return PTR_ERR(dentry);
233 if (dentry->
d_inode->i_private == &thread)
246 static int delete_path(
const char *nodepath)
262 err = dev_rmdir(path);
278 if (is_blockdev(dev)) {
292 static int handle_remove(
const char *nodename,
struct device *dev)
295 struct dentry *dentry;
301 return PTR_ERR(dentry);
306 if (!err && dev_mynode(dev, dentry->
d_inode, &stat)) {
307 struct iattr newattrs;
314 newattrs.ia_mode = stat.
mode & ~0777;
321 if (!err || err == -
ENOENT)
331 if (deleted &&
strchr(nodename,
'/'))
332 delete_path(nodename);
363 return handle_create(name, mode, dev);
365 return handle_remove(name, dev);
368 static int devtmpfsd(
void *
p)
384 struct req *
req = requests;
388 struct req *
next = req->next;
389 req->err =
handle(req->name, req->mode, req->dev);
418 thread =
kthread_run(devtmpfsd, &err,
"kdevtmpfs");
419 if (!IS_ERR(thread)) {
422 err = PTR_ERR(thread);