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:13:26 +0200 committer: Christoph Hellwig <hch@lst.de> 2020-07-31 08:17:52 +0200 commit: b873498f99c77e7b5be3aa5ffe9ca67437232fe0 parent: 4b7ca5014cbef51cdb99fd644eae4f3773747a05
Commit Summary:
init: add an init_chown helper
Diffstat:
1 file changed, 17 insertions, 0 deletions
diff --git a/fs/init.c b/fs/init.c
index 2c78f24814dd..edd024465595 100644
--- a/fs/init.c
+++ b/fs/init.c
@@ -78,6 +78,24 @@ dput_and_out:
 	return error;
 }
 
+int __init init_chown(const char *filename, uid_t user, gid_t group, int flags)
+{
+	int lookup_flags = (flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
+	struct path path;
+	int error;
+
+	error = kern_path(filename, lookup_flags, &path);
+	if (error)
+		return error;
+	error = mnt_want_write(path.mnt);
+	if (!error) {
+		error = chown_common(&path, user, group);
+		mnt_drop_write(path.mnt);
+	}
+	path_put(&path);
+	return error;
+}
+
 int __init init_unlink(const char *pathname)
 {
 	return do_unlinkat(AT_FDCWD, getname_kernel(pathname));