]>
Commit | Line | Data |
---|---|---|
c60166f0 CH |
1 | // SPDX-License-Identifier: GPL-2.0 |
2 | /* | |
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. | |
5 | */ | |
6 | #include <linux/init.h> | |
7 | #include <linux/mount.h> | |
8 | #include <linux/namei.h> | |
9 | #include <linux/fs.h> | |
db63f1e3 | 10 | #include <linux/fs_struct.h> |
c60166f0 CH |
11 | #include <linux/init_syscalls.h> |
12 | #include "internal.h" | |
13 | ||
14 | int __init init_mount(const char *dev_name, const char *dir_name, | |
15 | const char *type_page, unsigned long flags, void *data_page) | |
16 | { | |
17 | struct path path; | |
18 | int ret; | |
19 | ||
20 | ret = kern_path(dir_name, LOOKUP_FOLLOW, &path); | |
21 | if (ret) | |
22 | return ret; | |
23 | ret = path_mount(dev_name, &path, type_page, flags, data_page); | |
24 | path_put(&path); | |
25 | return ret; | |
26 | } | |
09267def CH |
27 | |
28 | int __init init_umount(const char *name, int flags) | |
29 | { | |
30 | int lookup_flags = LOOKUP_MOUNTPOINT; | |
31 | struct path path; | |
32 | int ret; | |
33 | ||
34 | if (!(flags & UMOUNT_NOFOLLOW)) | |
35 | lookup_flags |= LOOKUP_FOLLOW; | |
36 | ret = kern_path(name, lookup_flags, &path); | |
37 | if (ret) | |
38 | return ret; | |
39 | return path_umount(&path, flags); | |
40 | } | |
8fb9f73e | 41 | |
db63f1e3 CH |
42 | int __init init_chdir(const char *filename) |
43 | { | |
44 | struct path path; | |
45 | int error; | |
46 | ||
47 | error = kern_path(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path); | |
48 | if (error) | |
49 | return error; | |
50 | error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR); | |
51 | if (!error) | |
52 | set_fs_pwd(current->fs, &path); | |
53 | path_put(&path); | |
54 | return error; | |
55 | } | |
56 | ||
8fb9f73e CH |
57 | int __init init_unlink(const char *pathname) |
58 | { | |
59 | return do_unlinkat(AT_FDCWD, getname_kernel(pathname)); | |
60 | } | |
20cce026 CH |
61 | |
62 | int __init init_rmdir(const char *pathname) | |
63 | { | |
64 | return do_rmdir(AT_FDCWD, getname_kernel(pathname)); | |
65 | } |