Cygwin:打开一个字符设备

Cygwin: open a character device

我需要用用户空间程序打开在 Windows 中创建的内核模块 在 Cygwin 中编译;来自 Windows 我可以使用

打开它
CreateFile("\\.\deviceName",
    GENERIC_READ | GENERIC_WRITE,
    0,
    NULL,
    OPEN_ALWAYS,
    FILE_ATTRIBUTE_NORMAL,
    NULL)

但在 Cygwin 中,如果我尝试使用

open("//deviceName", O_RDWR);

没有任何反应;我试过使用“\DosDevices\deviceName”, //deviceName, //DosDevices/deviceName 等....但我无法打开设备。

在 Cygwin 中有一种方法可以做到这一点,或者我必须在 用户空间应用程序?

编辑: 仅供参考,在内核模块中 link 是在正确调用 IoCreateDevice(....)

后以这种方式创建的
#define DOS_DEVICE_NAME         L"\DosDevices\deviceName"
...
RtlInitUnicodeString( &ntWin32NameString, DOS_DEVICE_NAME );
ntStatus = IoCreateSymbolicLink(&ntWin32NameString, &ntUnicodeString );
....

编辑2: 使用 Sysinternals WinObj 我可以正确地看到我的设备 \全球的??符号link \Device\deviceName

好的,看来我已经找到了:在

下指定
"/proc/sys/DosDevices/Global/deviceName"

并且可以用

打开
fd = open("/proc/sys/DosDevices/Global/deviceName", O_RDWR);