int SCOPE replay__newselect(const struct syscall_regs * regs) { int32_t eax = read_int32(); int n; uint32_t inp; uint32_t outp; uint32_t exp; read_obj(n); read_obj(inp); read_obj(outp); read_obj(exp); ASSERT(n == regs->ebx, regs, ""); ASSERT(inp == regs->ecx, regs, ""); ASSERT(outp == regs->edx, regs, ""); ASSERT(exp == regs->esi, regs, ""); int fd_bytes = FDS_BYTES(n); if (inp != 0) read_mem(inp, fd_bytes); if (outp != 0) read_mem(outp, fd_bytes); if (exp != 0) read_mem(exp, fd_bytes); return eax; }
void output__newselect(int nr) { int retval; retval = read_eax(); printf("_newselect:\t0x%x\n", retval); int n; uint32_t inp, outp, exp; read_obj(n); read_obj(inp); read_obj(outp); read_obj(exp); int fd_bytes = FDS_BYTES(n); if (inp != 0) skip(fd_bytes); if (outp != 0) skip(fd_bytes); if (exp != 0) skip(fd_bytes); }
int SCOPE post__newselect(const struct syscall_regs * regs) { write_eax(regs); int n = regs->ebx; uint32_t inp = regs->ecx; uint32_t outp = regs->edx; uint32_t exp = regs->esi; write_obj(n); write_obj(inp); write_obj(outp); write_obj(exp); int fd_bytes = FDS_BYTES(n); if (inp != 0) write_mem(inp, fd_bytes); if (outp != 0) write_mem(outp, fd_bytes); if (exp != 0) write_mem(exp, fd_bytes); return 0; }
asmlinkage long sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, struct timeval __user *tvp) { fd_set_bits fds; char *bits; long timeout; int ret, size, max_fdset; timeout = MAX_SCHEDULE_TIMEOUT; if (tvp) { time_t sec, usec; if ((ret = verify_area(VERIFY_READ, tvp, sizeof(*tvp))) || (ret = __get_user(sec, &tvp->tv_sec)) || (ret = __get_user(usec, &tvp->tv_usec))) goto out_nofds; ret = -EINVAL; if (sec < 0 || usec < 0) goto out_nofds; if ((unsigned long) sec < MAX_SELECT_SECONDS) { timeout = ROUND_UP(usec, 1000000/HZ); timeout += sec * (unsigned long) HZ; } } ret = -EINVAL; if (n < 0) goto out_nofds; /* max_fdset can increase, so grab it once to avoid race */ max_fdset = current->files->max_fdset; if (n > max_fdset) n = max_fdset; /* * We need 6 bitmaps (in/out/ex for both incoming and outgoing), * since we used fdset we need to allocate memory in units of * long-words. */ ret = -ENOMEM; size = FDS_BYTES(n); bits = select_bits_alloc(size); if (!bits) goto out_nofds; fds.in = (unsigned long *) bits; fds.out = (unsigned long *) (bits + size); fds.ex = (unsigned long *) (bits + 2*size); fds.res_in = (unsigned long *) (bits + 3*size); fds.res_out = (unsigned long *) (bits + 4*size); fds.res_ex = (unsigned long *) (bits + 5*size); if ((ret = get_fd_set(n, inp, fds.in)) || (ret = get_fd_set(n, outp, fds.out)) || (ret = get_fd_set(n, exp, fds.ex))) goto out; zero_fd_set(n, fds.res_in); zero_fd_set(n, fds.res_out); zero_fd_set(n, fds.res_ex); ret = do_select(n, &fds, &timeout); if (tvp && !(current->personality & STICKY_TIMEOUTS)) { time_t sec = 0, usec = 0; if (timeout) { sec = timeout / HZ; usec = timeout % HZ; usec *= (1000000/HZ); } put_user(sec, &tvp->tv_sec); put_user(usec, &tvp->tv_usec); } if (ret < 0) goto out; if (!ret) { ret = -ERESTARTNOHAND; if (signal_pending(current)) goto out; ret = 0; } if (set_fd_set(n, inp, fds.res_in) || set_fd_set(n, outp, fds.res_out) || set_fd_set(n, exp, fds.res_ex)) ret = -EFAULT; out: select_bits_free(bits, size); out_nofds: return ret; }