Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新 30.1 #110

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

更新 30.1 #110

wants to merge 2 commits into from

Conversation

rowheel
Copy link
Collaborator

@rowheel rowheel commented Jun 19, 2023

No description provided.

既然要谈 FreeBSD 对 Linux 应用程序的兼容,那么一切都要从 Linuxluator 这个内核模块开始说起。而 Linuxulator 其实是一个 FreeBSD 内核模块的别名,这个模块其实叫 `linux`。先自己看一下 `linux` 这个内核模块的 `man` 页面吧。
既然要谈 FreeBSD 兼容 Linux 应用程序,那么一切都要从 Linuxluator 开始说起。Linuxulator 的含义是 Linux Emulator——很容易让人联想到这是 Linux 模拟器。然而 Linuxulator 并不是传统意义上的模拟器,其本身甚至都不是具有单独可执行文件的 FreeBSD 应用程序。Linuxulator 只是 FreeBSD 官方文档中对一个 FreeBSD 内核模块的通俗称呼,这个内核模块的本名叫 `linux`。

先自己看一下 `linux` 这个内核模块的 `man` 页面吧。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议给出链接 linux

@@ -19,11 +21,17 @@ $ man 4 linux
> - 针对 Linux 进程的特殊信号处理
> - 路径转换机制
> - Linux 限定的虚拟文件系统实现
>

这是个什么概念呢?就是说 Linuxulator 既不是 WSL 的套壳虚拟机,也不是 WINE 的解释执行。其原理是由 FreeBSD 内核识别并捕获 Linux 进程的系统调用请求,找到 FreeBSD 与之对应的系统调用实现,再用 FreeBSD 内核的系统调用实现来回应 Linux 进程的系统调用请求。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wsl2 是虚拟机,和 wsl1是类似的。另外为何和 wine 不一样?根据以前 handbook 的说明以及你“由 FreeBSD 内核识别并捕获 Linux 进程的系统调用请求”,似乎都是一样的——我看起来只不过一个的 wine 程序捕捉,一个由OS捕捉。


划重点:**用 FreeBSD 内核的系统调用实现来回应 Linux 进程的系统调用请求**。

换句话说就是,借助 Linuxulator 这个内核模块,FreeBSD 内核可以把自己伪装成一个 Linux 内核,但实际上在运行 Linux 进程的依旧是 FreeBSD 内核,负责处理 Linux 系统调用的依旧是 FreeBSD 内核里的代码。并且站在 FreeBSD 内核的角度,通过 Linuxulator 运行的 Linux 进程和 FreeBSD 进程**没有本质区别**。Linux 进程就是 FreeBSD 进程。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handbook 中说 FreeBSD 中有一个 Linux 内核,应该如何理解?

换句话说就是,借助 Linuxulator 这个内核模块,FreeBSD 内核可以把自己伪装成一个 Linux 内核,但实际上在运行 Linux 进程的依旧是 FreeBSD 内核,负责处理 Linux 系统调用的依旧是 FreeBSD 内核里的代码。并且站在 FreeBSD 内核的角度,通过 Linuxulator 运行的 Linux 进程和 FreeBSD 进程**没有本质区别**。Linux 进程就是 FreeBSD 进程。

# 什么是 Linux 兼容层

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我认为应该从简单的或者从概念发展历程上开始说,顺序是 chroot——>Jail——>兼容层。此外可以穿插 docker 等知识来做比较。

@ykla
Copy link
Contributor

ykla commented Jun 20, 2023

如果可以的话请翻译一下 FreeBSD man linux 的“SYSCTL VARIABLES” 部分,这一部分的参数都很重要也很常用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants