aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-07-22 11:14:36 +0200
committerChristoph Hellwig <hch@lst.de>2020-07-31 08:17:53 +0200
commitcd3acb6a79349f346714ab3d26d203a0c6ca5ab0 (patch)
treeef54d5dfaceca217273e3f4a323c95573b2b681a /fs
parentinit: add an init_link helper (diff)
downloadlinux-dev-cd3acb6a79349f346714ab3d26d203a0c6ca5ab0.tar.xz
linux-dev-cd3acb6a79349f346714ab3d26d203a0c6ca5ab0.zip
init: add an init_symlink helper
Add a simple helper to symlink with a kernel space file name and switch the early init code over to it. Remove the now unused ksys_symlink. Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/init.c16
-rw-r--r--fs/internal.h2
-rw-r--r--fs/namei.c2
3 files changed, 17 insertions, 3 deletions
diff --git a/fs/init.c b/fs/init.c
index 5db9d9f74868..09ef2b58d48c 100644
--- a/fs/init.c
+++ b/fs/init.c
@@ -155,6 +155,22 @@ out:
return error;
}
+int __init init_symlink(const char *oldname, const char *newname)
+{
+ struct dentry *dentry;
+ struct path path;
+ int error;
+
+ dentry = kern_path_create(AT_FDCWD, newname, &path, 0);
+ if (IS_ERR(dentry))
+ return PTR_ERR(dentry);
+ error = security_path_symlink(&path, dentry, oldname);
+ if (!error)
+ error = vfs_symlink(path.dentry->d_inode, dentry, oldname);
+ done_path_create(&path, dentry);
+ return error;
+}
+
int __init init_unlink(const char *pathname)
{
return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
diff --git a/fs/internal.h b/fs/internal.h
index 58451b033d26..40b50a222d7a 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -67,8 +67,6 @@ long do_mknodat(int dfd, const char __user *filename, umode_t mode,
long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
long do_rmdir(int dfd, struct filename *name);
long do_unlinkat(int dfd, struct filename *name);
-long do_symlinkat(const char __user *oldname, int newdfd,
- const char __user *newname);
int may_linkat(struct path *link);
/*
diff --git a/fs/namei.c b/fs/namei.c
index 13de64c6be76..2f6fa53eb3da 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3955,7 +3955,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
}
EXPORT_SYMBOL(vfs_symlink);
-long do_symlinkat(const char __user *oldname, int newdfd,
+static long do_symlinkat(const char __user *oldname, int newdfd,
const char __user *newname)
{
int error;