diff options
author | Christoph Hellwig <hch@lst.de> | 2020-07-22 12:41:20 +0300 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2020-07-31 09:17:54 +0300 |
commit | 5fee64fcde0770c41e926ff981022eaa512d8980 (patch) | |
tree | 8519259e205878577de5fb440870457c5a989b4e /fs/init.c | |
parent | 83ff98c3e9cd2b82b4289e185f2ce7d635a9cbd3 (diff) | |
download | linux-5fee64fcde0770c41e926ff981022eaa512d8980.tar.xz |
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.c | 25 |
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; |