gpt4 book ai didi

Python mmap/开发/端口

转载 作者:太空狗 更新时间:2023-10-29 11:46:42 25 4
gpt4 key购买 nike

是否可以 mmap/dev/port?我在尝试时收到“没有这样的设备”。

Python 2.7.2+ (default, Oct  4 2011, 20:06:09) 
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import mmap
>>> os.open('/dev/port', os.O_RDWR|os.O_NDELAY)
3
>>> mapfd = mmap.mmap(3, 0xfff)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
mmap.error: [Errno 19] No such device
>>>

我已经能够使用相同的选项映射一个常规文件。

最佳答案

Errno 19 被列为“没有这样的设备”(Linux),或“设备不支持的操作”(FreeBSD)。

查看 drivers/char/mem.c/dev/port 的源代码,尤其是 struct file_operations,您我 see :

770 #ifdef CONFIG_DEVPORT
771 static const struct file_operations port_fops = {
772 .llseek = memory_lseek,
773 .read = read_port,
774 .write = write_port,
775 .open = open_port,
776 };
777 #endif

此设备不支持 mmap。只有开、求、读、写。

关于Python mmap/开发/端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9379329/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com