int copyinstr(const void *udaddr, void *kaddr, size_t len, size_t *done) { struct thread *td; faultbuf env; const char *up; char *kp; size_t l; int rv, c; if (!is_uaddr(udaddr) || is_uaddr(kaddr)) return (EFAULT); td = curthread; if (setfault(env)) { td->td_pcb->pcb_onfault = NULL; return (EFAULT); } kp = kaddr; up = udaddr; rv = ENAMETOOLONG; for (l = 0; len-- > 0; l++) { c = *up++; if (!(*kp++ = c)) { l++; rv = 0; break; } } if (done != NULL) { *done = l; } td->td_pcb->pcb_onfault = NULL; return (rv); }
int copyin(const void *udaddr, void *kaddr, size_t len) { struct thread *td; faultbuf env; if (!is_uaddr(udaddr) || is_uaddr(kaddr)) return (EFAULT); td = curthread; if (setfault(env)) { td->td_pcb->pcb_onfault = NULL; return (EFAULT); } bcopy(udaddr, kaddr, len); td->td_pcb->pcb_onfault = NULL; return (0); }
int suword(void *addr, long word) { struct thread *td; faultbuf env; if (!is_uaddr(addr)) return (EFAULT); td = curthread; if (setfault(env)) { td->td_pcb->pcb_onfault = NULL; return (EFAULT); } *(long *)addr = word; td->td_pcb->pcb_onfault = NULL; return (0); }
int subyte(void *addr, int byte) { struct thread *td; faultbuf env; if (!is_uaddr(addr)) return (EFAULT); td = curthread; if (setfault(env)) { td->td_pcb->pcb_onfault = NULL; return (EFAULT); } *(char *)addr = (char)byte; td->td_pcb->pcb_onfault = NULL; return (0); }
int copyout(const void *kaddr, void *udaddr, size_t len) { struct thread *td; faultbuf env; if (!is_uaddr(udaddr)) return (EFAULT); td = PCPU_GET(curthread); if (setfault(env)) { td->td_pcb->pcb_onfault = NULL; return (EFAULT); } bcopy(kaddr, udaddr, len); td->td_pcb->pcb_onfault = NULL; return (0); }
long fuword(const void *addr) { struct thread *td; faultbuf env; long val; if (!is_uaddr(addr)) return (EFAULT); td = curthread; if (setfault(env)) { td->td_pcb->pcb_onfault = NULL; return (EFAULT); } val = *(const long *)addr; td->td_pcb->pcb_onfault = NULL; return (val); }
int fubyte(const void *addr) { struct thread *td; faultbuf env; int val; if (!is_uaddr(addr)) return (EFAULT); td = curthread; if (setfault(env)) { td->td_pcb->pcb_onfault = NULL; return (EFAULT); } val = *(const u_char *)addr; td->td_pcb->pcb_onfault = NULL; return (val); }