VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
author: Christoph Hellwig <hch@lst.de> 2020-07-22 11:14:36 +0200 committer: Christoph Hellwig <hch@lst.de> 2020-07-31 08:17:53 +0200 commit: cd3acb6a79349f346714ab3d26d203a0c6ca5ab0 parent: 812931d693da58cc24d2bb8dec01c2b4a7f4668f
Commit Summary:
init: add an init_symlink helper
Diffstat:
1 file changed, 15 insertions, 0 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));