【发布时间】:2019-11-13 03:44:19
【问题描述】:
我读到我们需要超级用户权限才能从用户空间访问 I/O 端口。但我说的是不同的行为。 ioperm 在普通用户下成功。
#include <stdio.h>
#include <errno.h>
#include <sys/io.h>
int main(int argc, char *argv[])
{
if (!ioperm(0x70, 3, 1)) {
perror("ioperm failed");
}
else {
printf("ioperm on 0x70 success\n");
}
return 0;
}
$ ./prog
ioperm on 0x70 success
这是预期的行为吗
【问题讨论】:
-
使用
strace解码系统调用;该健全性检查会向您显示ioperm正在返回-EPERM。投票结束为题外话:错字/不是真正的问题。