aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-06-17 23:06:41 +0000
committerUlrich Drepper <drepper@redhat.com>2004-06-17 23:06:41 +0000
commitc7be5c15e2fbccdc00b970c3b5b9c27e95dee5be (patch)
treed67fbbaa2fdad7f99e8a7ed5ed4ddb5407d8d4a6
parent5b2892d54ed237f232cb3219df4ebcadf7146471 (diff)
downloadglibc-c7be5c15e2fbccdc00b970c3b5b9c27e95dee5be.tar
glibc-c7be5c15e2fbccdc00b970c3b5b9c27e95dee5be.tar.gz
glibc-c7be5c15e2fbccdc00b970c3b5b9c27e95dee5be.tar.bz2
glibc-c7be5c15e2fbccdc00b970c3b5b9c27e95dee5be.zip
(if_indextoname): Correct error value for unknown interface.
-rw-r--r--sysdeps/unix/sysv/linux/if_index.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/sysdeps/unix/sysv/linux/if_index.c b/sysdeps/unix/sysv/linux/if_index.c
index 9922cedf43..76349bd96d 100644
--- a/sysdeps/unix/sysv/linux/if_index.c
+++ b/sysdeps/unix/sysv/linux/if_index.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997,98,99,2000,2002,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1997,98,99,2000,2002,2003,2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -211,18 +211,26 @@ if_indextoname (unsigned int ifindex, char *ifname)
close_not_cancel_no_status (fd);
-# if __ASSUME_SIOCGIFNAME == 0
if (status < 0)
{
+# if __ASSUME_SIOCGIFNAME == 0
if (errno == EINVAL)
siocgifname_works_not = 1; /* Don't make the same mistake twice. */
+ else
+# endif
+ {
+ if (errno == ENODEV)
+ /* POSIX requires ENXIO. */
+ __set_errno (ENXIO);
+
+ return NULL;
+ }
}
else
return strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
+# if __ASSUME_SIOCGIFNAME == 0
__set_errno (serrno);
-# else
- return status < 0 ? NULL : strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
# endif
}
# endif
@@ -240,6 +248,9 @@ if_indextoname (unsigned int ifindex, char *ifname)
}
if_freenameindex (idx);
+
+ if (result == NULL)
+ __set_errno (ENXIO);
}
return result;
# endif