Skip to content

Commit

Permalink
pty: implemented ioctl() for slave ptys
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Oct 2, 2024
1 parent f99a94c commit 131c6a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions devices/pty/src/include/pty/pty.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define PTY_GET_SLAVE (0x10 | IOCTL_OUT_PARAM)
#define PTY_GRANT_PT 0x20
#define PTY_UNLOCK_PT 0x30
#define PTY_TTY_NAME (0x40 | IOCTL_OUT_PARAM)

typedef struct {
// master read() will read from slave, write() will write to master
Expand Down
21 changes: 19 additions & 2 deletions devices/pty/src/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,26 @@ void ptyIoctlMaster(IOCTLCommand *cmd) {
*/

void ptyIoctlSlave(IOCTLCommand *cmd) {
/* todo */
cmd->header.header.response = 1;
cmd->header.header.length = sizeof(IOCTLCommand);
cmd->header.header.status = -ENOTTY;

int id = atoi(&cmd->path[4]); // slave ID

switch(cmd->opcode) {
case PTY_TTY_NAME:
// return the number of the pty device
cmd->parameter = id;
cmd->header.header.status = 0;
break;

default:
if((cmd->opcode & IOCTL_IN_PARAM) || (cmd->opcode & IOCTL_OUT_PARAM))
luxLogf(KPRINT_LEVEL_WARNING, "unimplemented slave pty %d ioctl() opcode 0x%X with input param %d\n", cmd->id, cmd->opcode, cmd->parameter);
else
luxLogf(KPRINT_LEVEL_WARNING, "unimplemented slave pty %d ioctl() opcode 0x%X\n", cmd->id, cmd->opcode);

cmd->header.header.status = -ENOTTY;
}

luxSendDependency(cmd);
}

0 comments on commit 131c6a1

Please sign in to comment.