Skip to content

Commit 131c6a1

Browse files
committed
pty: implemented ioctl() for slave ptys
1 parent f99a94c commit 131c6a1

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

devices/pty/src/include/pty/pty.h

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define PTY_GET_SLAVE (0x10 | IOCTL_OUT_PARAM)
1919
#define PTY_GRANT_PT 0x20
2020
#define PTY_UNLOCK_PT 0x30
21+
#define PTY_TTY_NAME (0x40 | IOCTL_OUT_PARAM)
2122

2223
typedef struct {
2324
// master read() will read from slave, write() will write to master

devices/pty/src/ioctl.c

+19-2
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,26 @@ void ptyIoctlMaster(IOCTLCommand *cmd) {
9292
*/
9393

9494
void ptyIoctlSlave(IOCTLCommand *cmd) {
95-
/* todo */
9695
cmd->header.header.response = 1;
9796
cmd->header.header.length = sizeof(IOCTLCommand);
98-
cmd->header.header.status = -ENOTTY;
97+
98+
int id = atoi(&cmd->path[4]); // slave ID
99+
100+
switch(cmd->opcode) {
101+
case PTY_TTY_NAME:
102+
// return the number of the pty device
103+
cmd->parameter = id;
104+
cmd->header.header.status = 0;
105+
break;
106+
107+
default:
108+
if((cmd->opcode & IOCTL_IN_PARAM) || (cmd->opcode & IOCTL_OUT_PARAM))
109+
luxLogf(KPRINT_LEVEL_WARNING, "unimplemented slave pty %d ioctl() opcode 0x%X with input param %d\n", cmd->id, cmd->opcode, cmd->parameter);
110+
else
111+
luxLogf(KPRINT_LEVEL_WARNING, "unimplemented slave pty %d ioctl() opcode 0x%X\n", cmd->id, cmd->opcode);
112+
113+
cmd->header.header.status = -ENOTTY;
114+
}
115+
99116
luxSendDependency(cmd);
100117
}

0 commit comments

Comments
 (0)