mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
init: add an init_chdir helper
Add a simple helper to chdir with a kernel space file name and switch the early init code over to it. Remove the now unused ksys_chdir. Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
20cce026c3
commit
db63f1e315
7 changed files with 24 additions and 13 deletions
16
fs/init.c
16
fs/init.c
|
@ -7,6 +7,7 @@
|
|||
#include <linux/mount.h>
|
||||
#include <linux/namei.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/fs_struct.h>
|
||||
#include <linux/init_syscalls.h>
|
||||
#include "internal.h"
|
||||
|
||||
|
@ -38,6 +39,21 @@ int __init init_umount(const char *name, int flags)
|
|||
return path_umount(&path, flags);
|
||||
}
|
||||
|
||||
int __init init_chdir(const char *filename)
|
||||
{
|
||||
struct path path;
|
||||
int error;
|
||||
|
||||
error = kern_path(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path);
|
||||
if (error)
|
||||
return error;
|
||||
error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);
|
||||
if (!error)
|
||||
set_fs_pwd(current->fs, &path);
|
||||
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