summaryrefslogtreecommitdiff
path: root/fs/init.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-07-22 11:41:20 +0200
committerChristoph Hellwig <hch@lst.de>2020-07-31 08:17:54 +0200
commit5fee64fcde0770c41e926ff981022eaa512d8980 (patch)
tree8519259e205878577de5fb440870457c5a989b4e /fs/init.c
parent83ff98c3e9cd2b82b4289e185f2ce7d635a9cbd3 (diff)
init: add an init_mknod helper
Add a simple helper to mknod with a kernel space file name and switch the early init code over to it. Remove the now unused ksys_mknod. Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/init.c')
-rw-r--r--fs/init.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/fs/init.c b/fs/init.c
index 127033d08426..145fb31b7a5f 100644
--- a/fs/init.c
+++ b/fs/init.c
@@ -122,6 +122,31 @@ int __init init_eaccess(const char *filename)
return error;
}
+int __init init_mknod(const char *filename, umode_t mode, unsigned int dev)
+{
+ struct dentry *dentry;
+ struct path path;
+ int error;
+
+ if (S_ISFIFO(mode) || S_ISSOCK(mode))
+ dev = 0;
+ else if (!(S_ISBLK(mode) || S_ISCHR(mode)))
+ return -EINVAL;
+
+ dentry = kern_path_create(AT_FDCWD, filename, &path, 0);
+ if (IS_ERR(dentry))
+ return PTR_ERR(dentry);
+
+ if (!IS_POSIXACL(path.dentry->d_inode))
+ mode &= ~current_umask();
+ error = security_path_mknod(&path, dentry, mode, dev);
+ if (!error)
+ error = vfs_mknod(path.dentry->d_inode, dentry, mode,
+ new_decode_dev(dev));
+ done_path_create(&path, dentry);
+ return error;
+}
+
int __init init_link(const char *oldname, const char *newname)
{
struct dentry *new_dentry;