mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
init: add an init_chown helper
Add a simple helper to chown with a kernel space file name and switch the early init code over to it. Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
4b7ca5014c
commit
b873498f99
5 changed files with 24 additions and 5 deletions
18
fs/init.c
18
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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue