From bea90c29cf61f871298e846b38edfc19ae441f01 Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Tue, 15 Jan 2002 03:10:33 +0000 Subject: [PATCH] Reinstate linux_ifname. Although the Linuxulator doesn't use it itself, it's used outside the Linuxulator. Reimplement the function so that its behaviour matches the current renaming scheme. It's probably better to formalize these interdependencies. --- sys/compat/linux/linux_ioctl.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c index acf71d920e3e..4e72f85e4911 100644 --- a/sys/compat/linux/linux_ioctl.c +++ b/sys/compat/linux/linux_ioctl.c @@ -1817,6 +1817,33 @@ linux_ioctl_console(struct thread *td, struct linux_ioctl_args *args) */ #define IFP_IS_ETH(ifp) (ifp->if_type == IFT_ETHER) +/* + * Interface function used by linprocfs (at the time of writing). It's not + * used by the Linuxulator itself. + */ +int +linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen) +{ + struct ifnet *ifscan; + int ethno; + + /* Short-circuit non ethernet interfaces */ + if (!IFP_IS_ETH(ifp)) + return (snprintf(buffer, buflen, "%s%d", ifp->if_name, + ifp->if_unit)); + + /* Determine the (relative) unit number for ethernet interfaces */ + ethno = 0; + TAILQ_FOREACH(ifscan, &ifnet, if_link) { + if (ifscan == ifp) + return (snprintf(buffer, buflen, "eth%d", ethno)); + if (IFP_IS_ETH(ifscan)) + ethno++; + } + + return (0); +} + /* * Translate a Linux interface name to a FreeBSD interface name, * and return the associated ifnet structure