Christoph Hellwig | c60166f | 2020-07-21 11:12:08 +0200 | [diff] [blame] | 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> |
| 10 | #include <linux/init_syscalls.h> |
| 11 | #include "internal.h" |
| 12 | |
| 13 | int __init init_mount(const char *dev_name, const char *dir_name, |
| 14 | const char *type_page, unsigned long flags, void *data_page) |
| 15 | { |
| 16 | struct path path; |
| 17 | int ret; |
| 18 | |
| 19 | ret = kern_path(dir_name, LOOKUP_FOLLOW, &path); |
| 20 | if (ret) |
| 21 | return ret; |
| 22 | ret = path_mount(dev_name, &path, type_page, flags, data_page); |
| 23 | path_put(&path); |
| 24 | return ret; |
| 25 | } |
Christoph Hellwig | 09267de | 2020-07-23 08:23:08 +0200 | [diff] [blame^] | 26 | |
| 27 | int __init init_umount(const char *name, int flags) |
| 28 | { |
| 29 | int lookup_flags = LOOKUP_MOUNTPOINT; |
| 30 | struct path path; |
| 31 | int ret; |
| 32 | |
| 33 | if (!(flags & UMOUNT_NOFOLLOW)) |
| 34 | lookup_flags |= LOOKUP_FOLLOW; |
| 35 | ret = kern_path(name, lookup_flags, &path); |
| 36 | if (ret) |
| 37 | return ret; |
| 38 | return path_umount(&path, flags); |
| 39 | } |