Write to port 0cf8h fails with segfault

点点圈 提交于 2019-12-02 03:00:08

Linux does not, by default, allow userland code to write to I/O ports. (Doing so can be quite dangerous from a security perspective.) If you’d like Linux to give your process access to the I/O ports, you have two options:

  1. You can use the ioperm system call. However, ioperm has been deprecated for some time, and Josh Triplett recently pushed a patch that allows users to remove it from the kernel. Avoid ioperm if you want your code to continue working for the forseeable future.

  2. You can read from and write to /dev/port. See mem(4). Your process will, obviously, need read and write permissions for /dev/mem; on Wheezy, that means it needs to run as root, unless you change the permissions on the device.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!