website: docs: zh_CN: Sync to en as path_umount (#1516)
Signed-off-by: xiaoleGun <1592501605@qq.com>
This commit is contained in:
@@ -291,6 +291,55 @@ index 45306f9ef247..815091ebfca4 100755
|
|||||||
add_input_randomness(type, code, value);
|
add_input_randomness(type, code, value);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 如何backport(向旧版本移植) path_umount {#how-to-backport-path-umount}
|
||||||
|
|
||||||
|
你可以通过从K5.9向旧版本移植`path_umount`,在GKI之前的内核上获得卸载模块的功能。你可以通过以下补丁作为参考:
|
||||||
|
|
||||||
|
```diff
|
||||||
|
--- a/fs/namespace.c
|
||||||
|
+++ b/fs/namespace.c
|
||||||
|
@@ -1739,6 +1739,39 @@ static inline bool may_mandlock(void)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+static int can_umount(const struct path *path, int flags)
|
||||||
|
+{
|
||||||
|
+ struct mount *mnt = real_mount(path->mnt);
|
||||||
|
+
|
||||||
|
+ if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW))
|
||||||
|
+ return -EINVAL;
|
||||||
|
+ if (!may_mount())
|
||||||
|
+ return -EPERM;
|
||||||
|
+ if (path->dentry != path->mnt->mnt_root)
|
||||||
|
+ return -EINVAL;
|
||||||
|
+ if (!check_mnt(mnt))
|
||||||
|
+ return -EINVAL;
|
||||||
|
+ if (mnt->mnt.mnt_flags & MNT_LOCKED) /* Check optimistically */
|
||||||
|
+ return -EINVAL;
|
||||||
|
+ if (flags & MNT_FORCE && !capable(CAP_SYS_ADMIN))
|
||||||
|
+ return -EPERM;
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int path_umount(struct path *path, int flags)
|
||||||
|
+{
|
||||||
|
+ struct mount *mnt = real_mount(path->mnt);
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ ret = can_umount(path, flags);
|
||||||
|
+ if (!ret)
|
||||||
|
+ ret = do_umount(mnt, flags);
|
||||||
|
+
|
||||||
|
+ /* we mustn't call path_put() as that would clear mnt_expiry_mark */
|
||||||
|
+ dput(path->dentry);
|
||||||
|
+ mntput_no_expire(mnt);
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
/*
|
||||||
|
* Now umount can handle mount points as well as block devices.
|
||||||
|
* This is important for filesystems which use unnamed block devices.
|
||||||
|
```
|
||||||
|
|
||||||
改完之后重新编译内核即可。
|
改完之后重新编译内核即可。
|
||||||
|
|
||||||
:::info 莫名其妙进入安全模式?
|
:::info 莫名其妙进入安全模式?
|
||||||
|
|||||||
Reference in New Issue
Block a user