[2732] in linux-net channel archive

home help back first fref pref prev next nref lref last post

Re: tcp.c, FIONREAD bug?

daemon@ATHENA.MIT.EDU (Alan Cox)
Mon Apr 29 19:27:17 1996

From: Alan Cox <alan@cymru.net>
To: stefan@iandi.demon.co.uk (Stefan Magdalinski)
Date: 	Mon, 29 Apr 1996 11:19:46 +0100 (BST)
Cc: LINUX-NET@vger.rutgers.edu
In-Reply-To: <Pine.LNX.3.91.960429003704.128A-100000@iandi.demon.co.uk> from "Stefan Magdalinski" at Apr 29, 96 00:38:24 am

>                 case TIOCINQ:
> #ifdef FIXME    /* FIXME: */
>                 case FIONREAD:
> #endif

Thats ok.. its just naming

>                 {
>                         unsigned long amount;
> 
>                         if (sk->state == TCP_LISTEN)
>                                 return(-EINVAL);

A listening socket doesnt have bytes queued so the request is silly

>                         lock_sock(sk);

Stop people changing it

>                         amount = tcp_readable(sk);

Actually work out what is there to read - that is the routine to check

>                         release_sock(sk);

Undo the lock sock
>                         err=verify_area(VERIFY_WRITE,(void *)arg, 
> sizeof(int));
>                         if(err)
>                                 return err;

Check we can write to user space here
>                         put_user(amount, (int *)arg);
>                         return(0);

Stuff it in and return

Alan



home help back first fref pref prev next nref lref last post