为什么Linux系统在跨体系结构之间有所不同

发布于 2025-01-30 17:03:06 字数 536 浏览 4 评论 0原文

根据此 System Call> System Call> System Call table ,Linux System Call在架构中,架构,linux System Call都不同但是,IMO Syscall是更高的封装,并不依赖于任何特定的架构。为什么这样设计?

在特定情况下,riscv64 linux没有mkdir,而是具有mkdirat,但奇怪的是,它没有rmdirrmdirat,它如何实现/bin/rmdir没有rmdir,即使可以(通过其他Syscalls) ),为什么不为mkdir做相同的操作?这两个syscall不匹配真是令人困惑。

According to this system calls table, linux system calls are different across architecture, but IMO syscalls are higher level encapsulation which do not depent on any specific architechture. Why is it designed this way?

In a specific case, riscv64 linux doesn't have mkdir, instead it has mkdirat, but weirdly it doesn't have rmdir or rmdirat, how could it implement /bin/rmdir without rmdir, even if it could (via other syscalls like read and write), why not do the same for mkdir? It's really confusing that these two syscalls don't match.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北座城市 2025-02-06 17:03:07

您正在从错误的方向看。 mkdirat可以完成mkdir可以做的所有事情,然后是一些,所以问题不是为什么RISCV64 not 没有 mkdir < /code>,而是为什么x86 day 有。答案是向后的用户空间兼容性。由于Linux永远不会破坏它,并且首先存在mkdir,因此它将永远存在。但是RISCV64从未有过它,因此没有使用它的用户空间程序可以打破它。

至于rmdir,它的替换不是rmdirat,而是unlinkat,用AT_REMEVER。然后,同样的论点适用于此。

You're looking at this from the wrong direction. mkdirat can do everything that mkdir can do and then some, so the question isn't why riscv64 doesn't have mkdir, but rather why x86 does have it. The answer to that is backwards userspace compatibility. Since Linux never breaks that, and mkdir existed first, it will exist there forever. But riscv64 never had it, so there are no userspace programs for it to break by not having it.

As for rmdir, the replacement for that isn't rmdirat, but rather unlinkat with AT_REMOVEDIR. The same argument then applies to it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文