changing EINVAL for SIOCSIFCAP to something else

Yar Tikhiy yar at comp.chem.msu.su
Mon Feb 27 01:14:30 PST 2006


On Mon, Feb 27, 2006 at 11:38:15AM +0300, Gleb Smirnoff wrote:
>   Colleagues,
> 
>   I'd like to replace the unpleasant one-for-all error code
> EINVAL to something else in this part of code of
> src/sys/net/if.c:ifhwioctl()
> 
>         case SIOCSIFCAP:
>                 error = suser(td);
>                 if (error) 
>                         return (error);
>                 if (ifp->if_ioctl == NULL)
>                         return (EOPNOTSUPP);
>                 if (ifr->ifr_reqcap & ~ifp->if_capabilities)
>                         return (EINVAL);
>                 IFF_LOCKGIANT(ifp);
>                 error = (*ifp->if_ioctl)(ifp, cmd, data);
>                 IFF_UNLOCKGIANT(ifp);
>                 if (error == 0)
>                         getmicrotime(&ifp->if_lastchange);
>                 break;

I'm afraid that this is a case when EINVAL is used properly: an
argument to ioctl doesn't make sense to a particular device.  It's
true that EINVAL may be abused in other places though.  I wish each
EINVAL being returned to the userland were accompanied by log().

-- 
Yar


More information about the freebsd-arch mailing list