Index abc.com.pl 7 rozdzial 05 (14) Sienkiewicz Henryk Potop ENTER.1996 2001 3.22. MFC i elementy zaawansowanego interfejsu użytkownika (2) Linux735 (4) forsyth Fałszerz Anthony Piers Zaklecie kameleona t.2 251 02 rozdzial 09 (204) |
[ Pobierz całość w formacie PDF ] .*/static int __get_fd_set(int nr, unsigned int * fs_pointer, fd_set * fdset){int error, i;unsigned int * tmp;FD_ZERO(fdset);if (!fs_pointer)return 0;error = verify_area(VERIFY_WRITE,fs_pointer,sizeof(fd_set));if (error)return error;tmp = fdset->fds_bits;for (i = __FDSET_INTS; i > 0; i--) {if (nr <= 0)break;*tmp = get_user(fs_pointer);tmp++;fs_pointer++;nr -= 8 * sizeof(unsigned int);}return 0;}static void __set_fd_set(int nr, unsigned int * fs_pointer, unsigned int * fdset){int i;if (!fs_pointer)return;for (i = __FDSET_INTS; i > 0; i--) {if (nr <= 0)break;put_user(*fdset, fs_pointer);fdset++;fs_pointer++;nr -= 8 * sizeof(unsigned int);}}#define get_fd_set(nr,fsp,fdp) \__get_fd_set(nr, (unsigned int *) (fsp), fdp)#define set_fd_set(nr,fsp,fdp) \__set_fd_set(nr, (unsigned int *) (fsp), (unsigned int *) (fdp))/** We can actually return ERESTARTSYS instead of EINTR, but I'd* like to be certain this leads to no problems.So I return* EINTR just for safety.** Update: ERESTARTSYS breaks at least the xview clock binary, so* I'm trying ERESTARTNOHAND which restart only when you want to.*/asmlinkage int sys_select(int n, fd_set *inp, fd_set *outp, fd_set *exp, struct timeval *tvp){int i;fd_set res_in, in;fd_set res_out, out;fd_set res_ex, ex;unsigned long timeout;if (n < 0)return -EINVAL;if (n > NR_OPEN)n = NR_OPEN;if ((i = get_fd_set(n, inp, &in)) ||(i = get_fd_set(n, outp, &out)) ||(i = get_fd_set(n, exp, &ex))) return i;timeout = ~0UL;if (tvp) {i = verify_area(VERIFY_WRITE, tvp, sizeof(*tvp));if (i)return i;timeout = ROUND_UP(get_user(&tvp->tv_usec),(1000000/HZ));timeout += get_user(&tvp->tv_sec) * (unsigned long) HZ;if (timeout)timeout += jiffies + 1;}current->timeout = timeout;i = do_select(n, &in, &out, &ex, &res_in, &res_out, &res_ex);timeout = current->timeout - jiffies - 1;current->timeout = 0;if ((long) timeout < 0)timeout = 0;if (tvp && !(current->personality & STICKY_TIMEOUTS)) {put_user(timeout/HZ, &tvp->tv_sec);timeout %= HZ;timeout *= (1000000/HZ);put_user(timeout, &tvp->tv_usec);}if (i < 0)return i;if (!i && (current->signal & ~current->blocked))return -ERESTARTNOHAND;set_fd_set(n, inp, &res_in);set_fd_set(n, outp, &res_out);set_fd_set(n, exp, &res_ex);return i;} [ Pobierz całość w formacie PDF ] |
||||
Wszelkie Prawa Zastrzeżone! Kawa była słaba i bez smaku. Nie miała treści, a jedynie formę. Design by SZABLONY.maniak.pl. | |||||