Deleted Added
full compact
linux_ioctl.c (105477) linux_ioctl.c (108172)
1/*
2 * Copyright (c) 1994-1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
1/*
2 * Copyright (c) 1994-1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sys/compat/linux/linux_ioctl.c 105477 2002-10-19 21:11:43Z marcel $
28 * $FreeBSD: head/sys/compat/linux/linux_ioctl.c 108172 2002-12-22 05:35:03Z hsu $
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/sysproto.h>
34#include <sys/cdio.h>
35#include <sys/dvdio.h>
36#include <sys/consio.h>

--- 1865 unchanged lines hidden (view full) ---

1902
1903 /* Short-circuit non ethernet interfaces */
1904 if (!IFP_IS_ETH(ifp))
1905 return (snprintf(buffer, buflen, "%s%d", ifp->if_name,
1906 ifp->if_unit));
1907
1908 /* Determine the (relative) unit number for ethernet interfaces */
1909 ethno = 0;
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/sysproto.h>
34#include <sys/cdio.h>
35#include <sys/dvdio.h>
36#include <sys/consio.h>

--- 1865 unchanged lines hidden (view full) ---

1902
1903 /* Short-circuit non ethernet interfaces */
1904 if (!IFP_IS_ETH(ifp))
1905 return (snprintf(buffer, buflen, "%s%d", ifp->if_name,
1906 ifp->if_unit));
1907
1908 /* Determine the (relative) unit number for ethernet interfaces */
1909 ethno = 0;
1910 IFNET_RLOCK();
1910 TAILQ_FOREACH(ifscan, &ifnet, if_link) {
1911 TAILQ_FOREACH(ifscan, &ifnet, if_link) {
1911 if (ifscan == ifp)
1912 if (ifscan == ifp) {
1913 IFNET_RUNLOCK();
1912 return (snprintf(buffer, buflen, "eth%d", ethno));
1914 return (snprintf(buffer, buflen, "eth%d", ethno));
1915 }
1913 if (IFP_IS_ETH(ifscan))
1914 ethno++;
1915 }
1916 if (IFP_IS_ETH(ifscan))
1917 ethno++;
1918 }
1919 IFNET_RUNLOCK();
1916
1917 return (0);
1918}
1919
1920/*
1921 * Translate a Linux interface name to a FreeBSD interface name,
1922 * and return the associated ifnet structure
1923 * bsdname and lxname need to be least IFNAMSIZ bytes long, but

--- 13 unchanged lines hidden (view full) ---

1937 break;
1938 if (len == 0 || len == LINUX_IFNAMSIZ)
1939 return (NULL);
1940 unit = (int)strtoul(lxname + len, &ep, 10);
1941 if (ep == NULL || ep == lxname + len || ep >= lxname + LINUX_IFNAMSIZ)
1942 return (NULL);
1943 index = 0;
1944 is_eth = (len == 3 && !strncmp(lxname, "eth", len)) ? 1 : 0;
1920
1921 return (0);
1922}
1923
1924/*
1925 * Translate a Linux interface name to a FreeBSD interface name,
1926 * and return the associated ifnet structure
1927 * bsdname and lxname need to be least IFNAMSIZ bytes long, but

--- 13 unchanged lines hidden (view full) ---

1941 break;
1942 if (len == 0 || len == LINUX_IFNAMSIZ)
1943 return (NULL);
1944 unit = (int)strtoul(lxname + len, &ep, 10);
1945 if (ep == NULL || ep == lxname + len || ep >= lxname + LINUX_IFNAMSIZ)
1946 return (NULL);
1947 index = 0;
1948 is_eth = (len == 3 && !strncmp(lxname, "eth", len)) ? 1 : 0;
1949 IFNET_RLOCK();
1945 TAILQ_FOREACH(ifp, &ifnet, if_link) {
1946 /*
1947 * Allow Linux programs to use FreeBSD names. Don't presume
1948 * we never have an interface named "eth", so don't make
1949 * the test optional based on is_eth.
1950 */
1951 if (ifp->if_unit == unit && ifp->if_name[len] == '\0' &&
1952 strncmp(ifp->if_name, lxname, len) == 0)
1953 break;
1954 if (is_eth && IFP_IS_ETH(ifp) && unit == index++)
1955 break;
1956 }
1950 TAILQ_FOREACH(ifp, &ifnet, if_link) {
1951 /*
1952 * Allow Linux programs to use FreeBSD names. Don't presume
1953 * we never have an interface named "eth", so don't make
1954 * the test optional based on is_eth.
1955 */
1956 if (ifp->if_unit == unit && ifp->if_name[len] == '\0' &&
1957 strncmp(ifp->if_name, lxname, len) == 0)
1958 break;
1959 if (is_eth && IFP_IS_ETH(ifp) && unit == index++)
1960 break;
1961 }
1962 IFNET_RUNLOCK();
1957 if (ifp != NULL)
1958 snprintf(bsdname, IFNAMSIZ, "%s%d", ifp->if_name, ifp->if_unit);
1959 return (ifp);
1960}
1961
1962/*
1963 * Implement the SIOCGIFCONF ioctl
1964 */

--- 23 unchanged lines hidden (view full) ---

1988 uio.uio_segflg = UIO_USERSPACE;
1989 uio.uio_rw = UIO_READ;
1990 uio.uio_td = td;
1991
1992 /* Keep track of eth interfaces */
1993 ethno = 0;
1994
1995 /* Return all AF_INET addresses of all interfaces */
1963 if (ifp != NULL)
1964 snprintf(bsdname, IFNAMSIZ, "%s%d", ifp->if_name, ifp->if_unit);
1965 return (ifp);
1966}
1967
1968/*
1969 * Implement the SIOCGIFCONF ioctl
1970 */

--- 23 unchanged lines hidden (view full) ---

1994 uio.uio_segflg = UIO_USERSPACE;
1995 uio.uio_rw = UIO_READ;
1996 uio.uio_td = td;
1997
1998 /* Keep track of eth interfaces */
1999 ethno = 0;
2000
2001 /* Return all AF_INET addresses of all interfaces */
2002 IFNET_RLOCK(); /* could sleep XXX */
1996 TAILQ_FOREACH(ifp, &ifnet, if_link) {
1997 if (uio.uio_resid <= 0)
1998 break;
1999
2000 bzero(&ifr, sizeof ifr);
2001 if (IFP_IS_ETH(ifp))
2002 snprintf(ifr.ifr_name, LINUX_IFNAMSIZ, "eth%d",
2003 ethno++);

--- 10 unchanged lines hidden (view full) ---

2014
2015 if (sa->sa_family == AF_INET) {
2016 ifr.ifr_addr.sa_family = LINUX_AF_INET;
2017 memcpy(ifr.ifr_addr.sa_data, sa->sa_data,
2018 sizeof(ifr.ifr_addr.sa_data));
2019
2020 error = uiomove((caddr_t)&ifr, sizeof ifr,
2021 &uio);
2003 TAILQ_FOREACH(ifp, &ifnet, if_link) {
2004 if (uio.uio_resid <= 0)
2005 break;
2006
2007 bzero(&ifr, sizeof ifr);
2008 if (IFP_IS_ETH(ifp))
2009 snprintf(ifr.ifr_name, LINUX_IFNAMSIZ, "eth%d",
2010 ethno++);

--- 10 unchanged lines hidden (view full) ---

2021
2022 if (sa->sa_family == AF_INET) {
2023 ifr.ifr_addr.sa_family = LINUX_AF_INET;
2024 memcpy(ifr.ifr_addr.sa_data, sa->sa_data,
2025 sizeof(ifr.ifr_addr.sa_data));
2026
2027 error = uiomove((caddr_t)&ifr, sizeof ifr,
2028 &uio);
2022 if (error != 0)
2029 if (error != 0) {
2030 IFNET_RUNLOCK();
2023 return (error);
2031 return (error);
2032 }
2024 }
2025 }
2026 }
2033 }
2034 }
2035 }
2036 IFNET_RUNLOCK();
2027
2028 ifc.ifc_len -= uio.uio_resid;
2029 error = copyout(&ifc, uifc, sizeof ifc);
2030
2031 return (error);
2032}
2033
2034static int

--- 418 unchanged lines hidden ---
2037
2038 ifc.ifc_len -= uio.uio_resid;
2039 error = copyout(&ifc, uifc, sizeof ifc);
2040
2041 return (error);
2042}
2043
2044static int

--- 418 unchanged lines hidden ---