为什么Linux系统在跨体系结构之间有所不同
根据此 System Call> System Call> System Call table ,Linux System Call在架构中,架构,linux System Call都不同但是,IMO Syscall是更高的封装,并不依赖于任何特定的架构。为什么这样设计?
在特定情况下,riscv64 linux没有mkdir
,而是具有mkdirat
,但奇怪的是,它没有rmdir
或rmdirat
,它如何实现/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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在从错误的方向看。
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 thatmkdir
can do and then some, so the question isn't why riscv64 doesn't havemkdir
, but rather why x86 does have it. The answer to that is backwards userspace compatibility. Since Linux never breaks that, andmkdir
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'trmdirat
, but ratherunlinkat
withAT_REMOVEDIR
. The same argument then applies to it.