/** * Carry out the syscall specified in the stub stack. * @param proc the PCB of the process to execute the stub call * @return the return value of the call */ static int host_syscall_in_child (struct proc_struct *proc) { struct user_regs_struct regs; int err, pid = proc->arch.host->host_pid; err = syscall4 (__NR_ptrace, PTRACE_GETREGS, pid, 0, (long)®s); if (err < 0) { kprintf ("host_syscall_in_child: cannot get regs\n"); return -1; } /* 'stub_exec_syscall' is the entry of all stub calls. */ regs.eip = STUB_CODE + (unsigned long)stub_exec_syscall - (unsigned long) &__syscall_stub_start; err = syscall4 (__NR_ptrace, PTRACE_SETREGS, pid, 0, (long)®s); if (err < 0) { kprintf ("host_syscall_in_child: cannot set regs\n"); return -1; } err = syscall4 (__NR_ptrace, PTRACE_CONT, pid, 0, 0); if (err < 0) { kprintf ("host_syscall_in_child: cannot continue the child\n"); return -1; } err = wait_stub_done (pid); if (err < 0) { kprintf ("host_syscall_in_child: wait stub done failed with err = %d\n", err); return -1; } err = current_stub_frame(proc->arch.host->stub_stack)->eax; return err; }
int peek_ipc_message( ipc_port_id port_id, uint32_t* code, size_t* size, uint64_t timeout ) { return syscall4( SYS_peek_ipc_message, port_id, ( int )code, ( int )size, ( int )&timeout ); }
int send_ipc_message( ipc_port_id port_id, uint32_t code, const void* data, size_t size ) { return syscall4( SYS_send_ipc_message, port_id, code, ( int )data, size ); }
ssize_t pread( int fd, void* buf, size_t count, off_t offset ) { int error; error = syscall4( SYS_pread, fd, ( int )buf, count, ( int )&offset ); if ( error < 0 ) { errno = -error; return -1; } return error; }
off_t lseek( int fd, off_t offset, int whence ) { int error; off_t result; error = syscall4( SYS_lseek, fd, ( int )&offset, whence, ( int )&result ); if ( error < 0 ) { errno = -error; return ( off_t )-1; } return result; }
pid_t wait4( pid_t pid, int* status, int options, struct rusage* rusage ) { int error; error = syscall4( SYS_wait4, pid, ( int )status, options, ( int )rusage ); if ( error < 0 ) { errno = -error; return -1; } return error; }
int createdev(const char *path,mode_t mode,uint type,uint ops) { char apath[MAX_PATH_LEN]; return syscall4(SYSCALL_CRTDEV,(ulong)abspath(apath,sizeof(apath),path),mode,type,ops); }