Skip to content

Commit

Permalink
added interpositioning on read system call
Browse files Browse the repository at this point in the history
  • Loading branch information
FlareCoding authored and tommy-u committed Dec 31, 2022
1 parent 612665f commit d3b633a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions bin/ipc_shortcut/ipc_shortcut.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,23 @@ ssize_t write(int fd, const void* buf, size_t len) {

return s_JobBuffer->response;
}

ssize_t read(int fd, void* buf, size_t len) {
if (s_JobBuffer == NULL) {
fprintf(stderr, "[IPC Server] Failed to retrieve a working job buffer\n");
exit(1);
}

s_JobBuffer->cmd = CMD_READ;
s_JobBuffer->arg1 = fd;
s_JobBuffer->buffer_len = len;

// Indicate that the job was requested
submit_job_request(s_JobBuffer);

// Wait for the job to be completed
wait_for_job_completion(s_JobBuffer);

memcpy(buf, s_JobBuffer->buffer, len);
return s_JobBuffer->response;
}

0 comments on commit d3b633a

Please sign in to comment.