1 // SPDX-License-Identifier: GPL-2.0
3 * Routines that mimic syscalls, but don't use the user address space or file
4 * descriptors. Only for init/ and related early init code.
6 #include <linux/init.h>
7 #include <linux/mount.h>
8 #include <linux/namei.h>
10 #include <linux/fs_struct.h>
11 #include <linux/init_syscalls.h>
14 int __init init_mount(const char *dev_name, const char *dir_name,
15 const char *type_page, unsigned long flags, void *data_page)
20 ret = kern_path(dir_name, LOOKUP_FOLLOW, &path);
23 ret = path_mount(dev_name, &path, type_page, flags, data_page);
28 int __init init_umount(const char *name, int flags)
30 int lookup_flags = LOOKUP_MOUNTPOINT;
34 if (!(flags & UMOUNT_NOFOLLOW))
35 lookup_flags |= LOOKUP_FOLLOW;
36 ret = kern_path(name, lookup_flags, &path);
39 return path_umount(&path, flags);
42 int __init init_chdir(const char *filename)
47 error = kern_path(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path);
50 error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);
52 set_fs_pwd(current->fs, &path);
57 int __init init_unlink(const char *pathname)
59 return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
62 int __init init_rmdir(const char *pathname)
64 return do_rmdir(AT_FDCWD, getname_kernel(pathname));