static int __abi4_semctl(int first, int second, int third, union semun *fourth) { struct abi4_semid_ds is, *isp; struct semid_ds ls; union semun lsemun; mm_segment_t fs; int err; err = get_user(isp, (struct abi4_semid_ds **)&fourth->buf); if (err) return (err); err = copy_from_user(&is, isp, sizeof(is)) ? -EFAULT : 0; if (err) return (err); isem_to_lsem_l(&is, &ls); lsemun.buf = &ls; fs = get_fs(); set_fs(get_ds()); #ifdef CONFIG_65BIT err = SYS(semctl, first, second, third, &lsemun,0); #else err = SYS(ipc,SEMCTL, first, second, third, &lsemun,0); #endif set_fs(fs); if (err < 0) return (err); lsem_to_isem_l(&ls, &is); return copy_to_user(isp, &is, sizeof(is)) ? -EFAULT : 0; }
static int svr4_semctl(int arg1, int arg2, int arg3, union semun *arg4) { int retval, cmd = svr4sem2linux[arg3]; switch (arg3) { case SVR4_SEM_SETALL: case SVR4_SEM_GETALL: return __ibcs2_semctl(arg1, 0, cmd, arg4); case SVR4_IPC_RMID: case SVR4_IPC_RMID_L: case SVR4_SEM_SETVAL: case SVR4_SEM_GETVAL: case SVR4_SEM_GETPID: case SVR4_SEM_GETNCNT: case SVR4_SEM_GETZCNT: #ifdef CONFIG_65BIT retval = SYS(semctl, arg1, arg2, cmd, arg4, 0); #else retval = SYS(ipc,SEMCTL, arg1, arg2, cmd, arg4, 0); #endif return retval; case SVR4_IPC_SET: case SVR4_IPC_STAT: return __ibcs2_semctl(arg1, arg2, cmd, arg4); case SVR4_IPC_STAT_L: case SVR4_IPC_SET_L: return __abi4_semctl(arg1, arg2, cmd, arg4); } #if defined(CONFIG_ABI_TRACE) __abi_trace("semctl: unsupported command %d\n", arg3); #endif return -EINVAL; }
static int svr4_semop(int arg1, struct sembuf *arg2, int arg3) { int retval; #if defined(CONFIG_ABI_TRACE) if (abi_traced(ABI_TRACE_API)) { struct sembuf tmp, *tp = arg2; int i; for (i = 0; i < arg3; i++) { if (copy_from_user (&tmp, tp, sizeof(tmp))) { __abi_trace("semop(-EFAULT)\n"); break; } __abi_trace("semop(%d, %d, 0%o)\n", tmp.sem_num, tmp.sem_op, tmp.sem_flg); tp++; } } #endif #ifdef CONFIG_65BIT retval=SYS(semop, arg1, arg2, arg3); #else retval=SYS(ipc,SEMOP,arg1,arg3,0,arg2); #endif return retval; }
static int svr4_shmdt(struct pt_regs *regp) { caddr_t addr = (caddr_t)get_syscall_parameter(regp, 1); int retval; #if defined(CONFIG_ABI_TRACE) abi_trace(ABI_TRACE_API, "shmdt(%p)\n", addr); #endif #ifdef CONFIG_65BIT retval=SYS(shmdt,addr); #else retval=SYS(ipc,SHMDT,0,0,0,addr); #endif return retval; }
static int svr4_semget(int arg1, int arg2, int arg3) { int retval; #if defined(CONFIG_ABI_TRACE) abi_trace(ABI_TRACE_API, "semget(%d, %d, %o)\n", arg1, arg2, arg3); #endif #ifdef CONFIG_65BIT retval=SYS(semget, arg1, arg2, arg3); #else retval=SYS(ipc,SEMGET,arg1,arg2,arg3); #endif return retval; }
asmlinkage int solaris_recvfrom(int s, char *buf, int len, int flags, u32 from, u32 fromlen) { int (*sys_recvfrom)(int, void *, size_t, unsigned, struct sockaddr *, int *) = (int (*)(int, void *, size_t, unsigned, struct sockaddr *, int *))SYS(recvfrom); return sys_recvfrom(s, buf, len, solaris_to_linux_msgflags(flags), (struct sockaddr *)A(from), (int *)A(fromlen)); }
asmlinkage int solaris_shutdown(int fd, int how) { int (*sys_shutdown)(int, int) = (int (*)(int, int))SYS(shutdown); return sys_shutdown(fd, how); }
Plot3D::Plot3D(Kernel &k, const Tuple &cmd) : k(k) { spacetype = FLAT_SPACE; var expr = cmd[1]; var xrange = cmd[2]; var yrange = cmd[3]; var xparam = xrange.tuple()[1]; var yparam = yrange.tuple()[1]; xmin = toD(N(k, k.eval(xrange.tuple()[2])).object()); xmax = toD(N(k, k.eval(xrange.tuple()[3])).object()); ymin = toD(N(k, k.eval(yrange.tuple()[2])).object()); ymax = toD(N(k, k.eval(yrange.tuple()[3])).object()); if (cmd[cmd.size - 1].isTuple(SYS(Optional))) { var opts = cmd[cmd.size - 1]; readOptions(opts.tuple()); } sur = new Surface*[1]; surnum = 1; F2P *f3d = new F2P(k, expr, xparam, yparam); sur[0] = new Surface(f3d, xmin, xmax, ymin, ymax); delete f3d; zmin = sur[0]->zmin; zmax = sur[0]->zmax; for (int i = 1; i < surnum; i++) { if (sur[i]->zmin < zmin) zmin = sur[i]->zmin; if (sur[i]->zmax > zmax) zmax = sur[i]->zmax; } }
asmlinkage int solaris_connect(int fd, struct sockaddr *addr, int addrlen) { int (*sys_connect)(int, struct sockaddr *, int) = (int (*)(int, struct sockaddr *, int))SYS(connect); return sys_connect(fd, addr, addrlen); }
asmlinkage int solaris_send(int s, char *buf, int len, int flags) { int (*sys_sendto)(int, void *, size_t, unsigned, struct sockaddr *, int *) = (int (*)(int, void *, size_t, unsigned, struct sockaddr *, int *))SYS(sendto); return sys_sendto(s, buf, len, solaris_to_linux_msgflags(flags), NULL, NULL); }
int uw7_setegid(int gid) { int retval; if (gid < 0 || gid > UW7_MAXUID) return -EINVAL; retval = SYS(setreuid,-1, gid); return retval; }
int svr4_getrlimit(int cmd, void *val) { switch (cmd) { case U_RLIMIT_CPU: cmd = RLIMIT_CPU; break; case U_RLIMIT_FSIZE: cmd = RLIMIT_FSIZE; break; case U_RLIMIT_DATA: cmd = RLIMIT_DATA; break; case U_RLIMIT_STACK: cmd = RLIMIT_STACK; break; case U_RLIMIT_CORE: cmd = RLIMIT_CORE; break; case U_RLIMIT_NOFILE: cmd = RLIMIT_NOFILE; break; case U_RLIMIT_AS: cmd = RLIMIT_AS; break; default: return -EINVAL; } return SYS(getrlimit)(cmd, val); }
void * parser_sys_init(struct ctx_t *dst) { struct store_t *sys; if(NULL == SYS(dst)) return NULL; log(dst, 4, "parser sys init\n"); sys = sys_get(dst, "parser"); if(NULL == sys) { log(dst, 4, "create parser sys\n"); sys = sys_create(dst, "parser", T_STORE); if(NULL == sys) return NULL; store_set(sys, 2, sizeof(struct store_t), parserbscmp); } return sys; }
asmlinkage int abi_sigprocmask(int how, unsigned long *abinset, unsigned long *abioset) { sigset_t new_set, *nset, old_set, *oset; unsigned long new_set_abi, old_set_abi; mm_segment_t old_fs; int error; nset = oset = NULL; if (abinset) { get_user(new_set_abi, abinset); new_set = map_sigvec_to_kernel(new_set_abi, current->exec_domain->signal_map); nset = &new_set; } if (abioset) oset = &old_set; old_fs = get_fs(); set_fs(get_ds()); error = SYS(rt_sigprocmask)(howcnv[how], nset, oset, sizeof(sigset_t)); set_fs(old_fs); if (!error && abioset) { old_set_abi = map_sigvec_from_kernel(old_set, current->exec_domain->signal_invmap); put_user(old_set_abi, abioset); } return error; }
void abi_sigpause (struct pt_regs * regs) { old_sigset_t newset; int sig, answer; #ifdef __sparc__ printk(KERN_ERR "Sparc/iBCS: sigpause not yet implemented\n"); #else if (!abi_signo(regs, &sig)) return; newset = ~0UL; newset &= (1UL << (sig-1)); answer = SYS(sigsuspend)(0, current->blocked, newset, regs->esi, regs->edi, regs->ebp, regs->eax, regs->xds, regs->xes, regs->orig_eax, regs->eip, regs->xcs, regs->eflags, regs->esp, regs->xss); if (answer < 0) { set_error(regs, iABI_errors(-answer)); } #endif }
/* * Process the iBCS sigset function. * * This is basically the same as the signal() routine with the exception * that it will accept a SIG_HOLD parameter. * * A SIG_HOLD will defer the processing of the signal until a sigrelse() * function is called. */ int abi_sigset (struct pt_regs * regs) { sigset_t newmask, oldmask; __sighandler_t vec; int sig, answer; mm_segment_t old_fs; if (abi_signo (regs, &sig)) { vec = (__sighandler_t) SECOND_PARAM; if (vec != SIG_HOLD) { deactivate_signal(current, sig); abi_sig_handler (regs, sig, vec, 0); } else { /* * Process the hold function */ sigemptyset (&newmask); sigaddset (&newmask, sig); TO_KERNEL (old_fs); answer = SYS(rt_sigprocmask) (SIG_BLOCK, &newmask, &oldmask, sizeof(sigset_t)); FROM_KERNEL (old_fs); if (answer < 0) { set_error (regs, iABI_errors (-answer)); } } } return 0; }
void abi_sig_handler (struct pt_regs * regs, int sig, __sighandler_t handler, int oneshot) { struct sigaction act, oact; int answer; mm_segment_t old_fs; sigemptyset (&act.sa_mask); act.sa_restorer = NULL; act.sa_handler = handler; act.sa_flags = 0; if (oneshot) act.sa_flags = SA_ONESHOT | SA_NOMASK; else act.sa_flags = 0; TO_KERNEL (old_fs); answer = SYS(rt_sigaction) (sig, &act, &oact, sizeof(sigset_t)); FROM_KERNEL (old_fs); if (answer < 0) { set_error (regs, iABI_errors (-answer)); } else set_result (regs, (int) oact.sa_handler); }
/* * Linux has a stub sys_ftime. Perhaps this should be there? On the other * hand it's an old call that probably shouldn't be used by most modern * applications so perhaps it's better here where it needn't bloat the * base kernel. */ int xnx_ftime(struct timeb *tp) { struct timeval tv; struct timezone tz; int error; mm_segment_t old_fs; if (!access_ok(VERIFY_WRITE, tp, sizeof(struct timeb))) return -EFAULT; old_fs = get_fs(); set_fs (get_ds()); error = SYS(gettimeofday,&tv, &tz); set_fs(old_fs); if (error) return error; y2k_send(tv.tv_sec); put_user(tv.tv_sec, &tp->time); put_user((unsigned short)(tv.tv_usec/1000), &tp->millitm); put_user((short)tz.tz_minuteswest, &tp->timezone); put_user((short)tz.tz_dsttime, &tp->dstflag); return 0; }
asmlinkage int solaris_getsockname(int fd, struct sockaddr *addr, int *addrlen) { int (*sys_getsockname)(int, struct sockaddr *, int *) = (int (*)(int, struct sockaddr *, int *))SYS(getsockname); return sys_getsockname(fd, addr, addrlen); }
asmlinkage int solaris_accept(int fd, struct sockaddr *addr, int *addrlen) { int (*sys_accept)(int, struct sockaddr *, int *) = (int (*)(int, struct sockaddr *, int *))SYS(accept); return sys_accept(fd, addr, addrlen); }
static void do_getdirentries(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia) { int fd = cpu_registers(processor)->gpr[arg0]; unsigned_word buf_addr = cpu_registers(processor)->gpr[arg0+1]; char *buf; int nbytes = cpu_registers(processor)->gpr[arg0+2]; unsigned_word basep_addr = cpu_registers(processor)->gpr[arg0+3]; long basep; int status; #ifdef SYS_getdirentries SYS(getdirentries); #endif if (buf_addr != 0 && nbytes >= 0) buf = zalloc(nbytes); else buf = NULL; status = getdirentries(fd, (buf_addr == 0 ? NULL : buf), nbytes, (basep_addr == 0 ? NULL : &basep)); emul_write_status(processor, status, errno); if (basep_addr != 0) emul_write_word(basep_addr, basep, processor, cia); if (status > 0) write_direntries(buf_addr, buf, status, processor, cia); if (buf != NULL) free(buf); }
static void do_gettimeofday(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia) { unsigned_word t_addr = cpu_registers(processor)->gpr[arg0]; unsigned_word tz_addr = cpu_registers(processor)->gpr[arg0+1]; struct timeval t; struct timezone tz; int status = gettimeofday((t_addr != 0 ? &t : NULL), (tz_addr != 0 ? &tz : NULL)); int err = errno; if (WITH_TRACE && ppc_trace[trace_os_emul]) printf_filtered ("0x%lx, 0x%lx", (long)t_addr, (long)tz_addr); SYS(gettimeofday); emul_write_status(processor, status, err); if (status == 0) { if (t_addr != 0) write_timeval(t_addr, t, processor, cia); if (tz_addr != 0) write_timezone(tz_addr, tz, processor, cia); } }
int uw7_pwrite64(unsigned int fd, char * buf, int count, unsigned int off, unsigned int off_hi) { if (off_hi != 0) return -EINVAL; return SYS(pread)(fd, buf, count, (loff_t)off); }
static void do_write(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia) { void *scratch_buffer = NULL; int d = (int)cpu_registers(processor)->gpr[arg0]; unsigned_word buf = cpu_registers(processor)->gpr[arg0+1]; int nbytes = cpu_registers(processor)->gpr[arg0+2]; int status; SYS(write); if (WITH_TRACE && ppc_trace[trace_os_emul]) printf_filtered ("%d, 0x%lx, %d", d, (long)buf, nbytes); /* get a tempoary bufer */ scratch_buffer = zalloc(nbytes); /* FIXME - nbytes == 0 */ /* copy in */ emul_read_buffer(scratch_buffer, buf, nbytes, processor, cia); /* write */ status = write(d, scratch_buffer, nbytes); emul_write_status(processor, status, errno); free(scratch_buffer); flush_stdoutput(); }
static void do_ioctl(os_emul_data *emul, unsigned call, const int arg0, cpu *processor, unsigned_word cia) { int d = cpu_registers(processor)->gpr[arg0]; unsigned request = cpu_registers(processor)->gpr[arg0+1]; unsigned_word argp_addr = cpu_registers(processor)->gpr[arg0+2]; #if !WITH_NetBSD_HOST cpu_registers(processor)->gpr[arg0] = 0; /* just succeed */ #else unsigned dir = request & IOC_DIRMASK; int status; SYS(ioctl); /* what we haven't done */ if (dir & IOC_IN /* write into the io device */ || dir & IOC_OUT || !(dir & IOC_VOID)) error("do_ioctl() read or write of parameter not implemented\n"); status = ioctl(d, request, NULL); emul_write_status(processor, status, errno); #endif if (WITH_TRACE && ppc_trace[trace_os_emul]) printf_filtered ("%d, 0x%x, 0x%lx", d, request, (long)argp_addr); }
int abi_sigprocmask(int how, u_long *abinset, u_long *abioset) { sigset_t new_set, *nset = NULL; sigset_t old_set, *oset = NULL; u_long new_set_abi, old_set_abi; mm_segment_t fs; int error; if (abinset) { get_user(new_set_abi, abinset); new_set = map_sigvec_to_kernel(new_set_abi, current_thread_info()->exec_domain->signal_map); nset = &new_set; } if (abioset) oset = &old_set; fs = get_fs(); set_fs(get_ds()); error = SYS(rt_sigprocmask,howcnv[how], nset, oset, sizeof(sigset_t)); set_fs(fs); if (!error && abioset) { old_set_abi = map_sigvec_from_kernel(old_set, current_thread_info()->exec_domain->signal_invmap); put_user(old_set_abi, abioset); } return (error); }
/* * Process the iBCS sigignore * * This is basically a signal (...,SIG_IGN) call. */ void abi_sigignore(struct pt_regs *regp) { struct sigaction act, oact; int error, sig; mm_segment_t fs; if (!abi_signo(regp, &sig)) return; sigemptyset(&act.sa_mask); act.sa_handler = SIG_IGN; act.sa_flags = SA_SIGINFO; act.sa_restorer = (void *)abi_sigret(__NR_rt_sigaction); if (act.sa_restorer) act.sa_flags |= SA_RESTORER; fs = get_fs(); set_fs(get_ds()); error = SYS(rt_sigaction,sig, &act, &oact, sizeof(sigset_t)); set_fs(fs); if (error < 0) set_error(regp, iABI_errors(-error)); }
/* * Process the signal() function from iBCS * * This version appeared in "Advanced Programming in the Unix Environment" * by W. Richard Stevens, page 298. */ void abi_sig_handler(struct pt_regs *regp, int sig, __sighandler_t handler, int oneshot) { struct sigaction act, oact; mm_segment_t fs; int error; sigemptyset(&act.sa_mask); act.sa_flags = SA_SIGINFO; act.sa_restorer = (void *)abi_sigret(__NR_rt_sigaction); if (act.sa_restorer) act.sa_flags |= SA_RESTORER; act.sa_handler = handler; if (oneshot) act.sa_flags |= SA_ONESHOT | SA_NOMASK; fs = get_fs(); set_fs(get_ds()); error = SYS(rt_sigaction,sig, &act, &oact, sizeof(sigset_t)); set_fs(fs); if (error < 0) { set_error(regp, iABI_errors(-error)); } else { set_result(regp, (int)((long)oact.sa_handler)); } }
static int getpeername(int fd, struct sockaddr *name, int *len) { ulong a[3]; a[0] = fd; a[1] = (ulong) name; a[2] = (ulong) len; return SYS(socketcall, SYS_GETPEERNAME, a); }
static int connect(int sock, struct sockaddr *addr, int len) { ulong a[3]; a[0] = sock; a[1] = (ulong) addr; a[2] = len; return SYS(socketcall, SYS_CONNECT, a); }