[PATCH 2/5] manual: Document error codes missing for 'if_indextoname'

Maciej W. Rozycki macro@redhat.com
Tue May 27 15:08:51 GMT 2025


On Tue, 27 May 2025, Florian Weimer wrote:

> >  Is it this code sequence:
> >
> >   if (__ioctl (fd, SIOCGIFNAME, &ifr) < 0)
> >     {
> >       int saved_errno = errno;
> >       __close (fd);
> >       if (saved_errno == EINVAL || saved_errno == ENOTTY)
> >         __hurd_fail (ENOSYS);
> >
> > that you refer to?  If so, then it seems like an implementation bug to me, 
> > as POSIX has it:
> >
> > [ENOSYS]
> >      Functionality not supported.  An attempt was made to use optional 
> >      functionality that is not supported in this implementation.
> >
> > which does not seem adequate for reporting a request failure coming from a 
> > race condition.
> 
> I would say that the race condition (due to closing file descriptors
> used by the implementation) triggers undefined behavior, and as a result
> the error codes mandated by POSIX do not matter.

 I've looked at the history of this code and it's been there since the 
original introduction of the current implementation back in 2001, with 
commit 5bd5e3574840.  Little is written about that change, but it is 
mentioned that the code had been modelled after the Linux variant, which 
had a similar arrangement for EINVAL returned by SIOCGIFNAME meaning a 
missing feature, which indeed might have been a possibility at run time 
back then.

 The arrangement for Linux has been removed with commit ffb7875d03e2 
("Remove pre-2.2 Linux kernel support."), but a similar one still remains 
for SIOCGIFINDEX, which I think should be removed, because we no longer 
support Linux kernels older than 2.1.72.  Shouldn't the translation of 
error codes be similarly removed for Hurd, as no longer relevant?

  Maciej



More information about the Libc-alpha mailing list