Skip to content

Commit c97912c

Browse files
committed
devfs: relay mmap to appropriate drivers
1 parent 60f4618 commit c97912c

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

fs/devfs/src/io.c

+20-1
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,24 @@ void devfsWrite(SyscallHeader *req, SyscallHeader *res) {
9292
*/
9393

9494
void devfsMmap(SyscallHeader *req, SyscallHeader *res) {
95-
/* todo */
95+
MmapCommand *cmd = (MmapCommand *) req;
96+
memcpy(res, req, sizeof(MmapCommand));
97+
98+
res->header.response = 1;
99+
res->header.length = sizeof(MmapCommand);
100+
101+
luxLogf(KPRINT_LEVEL_DEBUG, "mmap for %s\n", cmd->path);
102+
103+
DeviceFile *dev = findDevice(cmd->path);
104+
if(!dev) {
105+
res->header.status = -ENOENT;
106+
luxSendKernel(res);
107+
} else if(dev->external) {
108+
luxSend(dev->socket, cmd);
109+
} else {
110+
// mmap() is only supported for external drivers and not by the default
111+
// devices (null, random, etc) provided by this server
112+
res->header.status = -ENODEV;
113+
luxSendKernel(res);
114+
}
96115
}

0 commit comments

Comments
 (0)