[OpenAFS-devel] afs_pioctl.c error returns

Jeffrey Hutzelman jhutz@cmu.edu
Thu, 21 Apr 2005 12:22:01 -0400


On Wednesday, April 20, 2005 03:49:29 PM -0700 lamont@scriptkiddie.org 
wrote:

>
> afs_HandlePioctl() returns E2BIG when you pass it a buffer which isn't
> large enough to hold the output data from the pioctl call.  E2BIG
> translates to "Argument List Too Long" which isn't describing the right
> problem at all.  EINVAL fits better.  There may be an even more
> appropriate return (EOVERFLOW?) but E2BIG definitely isn't the right one.
>
> --- src/afs/afs_pioctl.c~       Wed Apr 20 15:48:28 2005
> +++ src/afs/afs_pioctl.c        Wed Apr 20 15:49:05 2005
> @@ -1117,7 +1117,7 @@
>
>       /* Do all range checking before continuing */
>       if (inSize > MAXPIOCTLTOKENLEN || inSize < 0 || ablob->out_size < 0)
> -       return E2BIG;
> +       return EINVAL;
>
>       /* Note that we use osi_Alloc for large allocs and
> osi_AllocLargeSpace for small ones */
>       if (inSize > AFS_LRALLOCSIZ) {
> @@ -1167,7 +1167,7 @@
>       }
>       if (code == 0 && ablob->out_size > 0) {
>          if (outSize > ablob->out_size) {
> -           code = E2BIG;       /* data wont fit in user buffer */
> +           code = EINVAL;      /* data wont fit in user buffer */
>          } else if (outSize) {
>              AFS_COPYOUT(outData, ablob->out, outSize, code);
>          }


This seems a gratuitous change to me.  Error codes always need to be 
interpreted in context, and pioctl has ~always returned E2BIG to indicate 
that the input or output arguments were too large.

-- Jeffrey T. Hutzelman (N3NHS) <jhutz+@cmu.edu>
   Sr. Research Systems Programmer
   School of Computer Science - Research Computing Facility
   Carnegie Mellon University - Pittsburgh, PA