Deleted Added
full compact
linux_ioctl.c (180768) linux_ioctl.c (181803)
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

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

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
29#include <sys/cdefs.h>
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

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

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
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_ioctl.c 180768 2008-07-23 17:47:44Z ed $");
30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_ioctl.c 181803 2008-08-17 23:27:27Z bz $");
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/sysproto.h>
35#include <sys/cdio.h>
36#include <sys/dvdio.h>
37#include <sys/conf.h>
38#include <sys/disk.h>

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

51#include <sys/sbuf.h>
52#include <sys/socket.h>
53#include <sys/sockio.h>
54#include <sys/soundcard.h>
55#include <sys/stdint.h>
56#include <sys/sx.h>
57#include <sys/tty.h>
58#include <sys/uio.h>
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/sysproto.h>
35#include <sys/cdio.h>
36#include <sys/dvdio.h>
37#include <sys/conf.h>
38#include <sys/disk.h>

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

51#include <sys/sbuf.h>
52#include <sys/socket.h>
53#include <sys/sockio.h>
54#include <sys/soundcard.h>
55#include <sys/stdint.h>
56#include <sys/sx.h>
57#include <sys/tty.h>
58#include <sys/uio.h>
59#include <sys/vimage.h>
60
59#include <net/if.h>
60#include <net/if_dl.h>
61#include <net/if_types.h>
62
63#include "opt_compat.h"
64
65#ifdef COMPAT_LINUX32
66#include <machine/../linux32/linux.h>

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

2049
2050 /* Short-circuit non ethernet interfaces */
2051 if (!IFP_IS_ETH(ifp))
2052 return (strlcpy(buffer, ifp->if_xname, buflen));
2053
2054 /* Determine the (relative) unit number for ethernet interfaces */
2055 ethno = 0;
2056 IFNET_RLOCK();
61#include <net/if.h>
62#include <net/if_dl.h>
63#include <net/if_types.h>
64
65#include "opt_compat.h"
66
67#ifdef COMPAT_LINUX32
68#include <machine/../linux32/linux.h>

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

2051
2052 /* Short-circuit non ethernet interfaces */
2053 if (!IFP_IS_ETH(ifp))
2054 return (strlcpy(buffer, ifp->if_xname, buflen));
2055
2056 /* Determine the (relative) unit number for ethernet interfaces */
2057 ethno = 0;
2058 IFNET_RLOCK();
2057 TAILQ_FOREACH(ifscan, &ifnet, if_link) {
2059 TAILQ_FOREACH(ifscan, &V_ifnet, if_link) {
2058 if (ifscan == ifp) {
2059 IFNET_RUNLOCK();
2060 return (snprintf(buffer, buflen, "eth%d", ethno));
2061 }
2062 if (IFP_IS_ETH(ifscan))
2063 ethno++;
2064 }
2065 IFNET_RUNLOCK();

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

2088 if (len == 0 || len == LINUX_IFNAMSIZ)
2089 return (NULL);
2090 unit = (int)strtoul(lxname + len, &ep, 10);
2091 if (ep == NULL || ep == lxname + len || ep >= lxname + LINUX_IFNAMSIZ)
2092 return (NULL);
2093 index = 0;
2094 is_eth = (len == 3 && !strncmp(lxname, "eth", len)) ? 1 : 0;
2095 IFNET_RLOCK();
2060 if (ifscan == ifp) {
2061 IFNET_RUNLOCK();
2062 return (snprintf(buffer, buflen, "eth%d", ethno));
2063 }
2064 if (IFP_IS_ETH(ifscan))
2065 ethno++;
2066 }
2067 IFNET_RUNLOCK();

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

2090 if (len == 0 || len == LINUX_IFNAMSIZ)
2091 return (NULL);
2092 unit = (int)strtoul(lxname + len, &ep, 10);
2093 if (ep == NULL || ep == lxname + len || ep >= lxname + LINUX_IFNAMSIZ)
2094 return (NULL);
2095 index = 0;
2096 is_eth = (len == 3 && !strncmp(lxname, "eth", len)) ? 1 : 0;
2097 IFNET_RLOCK();
2096 TAILQ_FOREACH(ifp, &ifnet, if_link) {
2098 TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
2097 /*
2098 * Allow Linux programs to use FreeBSD names. Don't presume
2099 * we never have an interface named "eth", so don't make
2100 * the test optional based on is_eth.
2101 */
2102 if (strncmp(ifp->if_xname, lxname, LINUX_IFNAMSIZ) == 0)
2103 break;
2104 if (is_eth && IFP_IS_ETH(ifp) && unit == index++)

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

2132 if (error != 0)
2133 return (error);
2134
2135 max_len = MAXPHYS - 1;
2136
2137 /* handle the 'request buffer size' case */
2138 if (ifc.ifc_buf == PTROUT(NULL)) {
2139 ifc.ifc_len = 0;
2099 /*
2100 * Allow Linux programs to use FreeBSD names. Don't presume
2101 * we never have an interface named "eth", so don't make
2102 * the test optional based on is_eth.
2103 */
2104 if (strncmp(ifp->if_xname, lxname, LINUX_IFNAMSIZ) == 0)
2105 break;
2106 if (is_eth && IFP_IS_ETH(ifp) && unit == index++)

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

2134 if (error != 0)
2135 return (error);
2136
2137 max_len = MAXPHYS - 1;
2138
2139 /* handle the 'request buffer size' case */
2140 if (ifc.ifc_buf == PTROUT(NULL)) {
2141 ifc.ifc_len = 0;
2140 TAILQ_FOREACH(ifp, &ifnet, if_link) {
2142 TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
2141 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
2142 struct sockaddr *sa = ifa->ifa_addr;
2143 if (sa->sa_family == AF_INET)
2144 ifc.ifc_len += sizeof(ifr);
2145 }
2146 }
2147 error = copyout(&ifc, uifc, sizeof(ifc));
2148 return (error);

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

2159 full = 1;
2160 }
2161 sb = sbuf_new(NULL, NULL, max_len + 1, SBUF_FIXEDLEN);
2162 max_len = 0;
2163 valid_len = 0;
2164
2165 /* Return all AF_INET addresses of all interfaces */
2166 IFNET_RLOCK(); /* could sleep XXX */
2143 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
2144 struct sockaddr *sa = ifa->ifa_addr;
2145 if (sa->sa_family == AF_INET)
2146 ifc.ifc_len += sizeof(ifr);
2147 }
2148 }
2149 error = copyout(&ifc, uifc, sizeof(ifc));
2150 return (error);

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

2161 full = 1;
2162 }
2163 sb = sbuf_new(NULL, NULL, max_len + 1, SBUF_FIXEDLEN);
2164 max_len = 0;
2165 valid_len = 0;
2166
2167 /* Return all AF_INET addresses of all interfaces */
2168 IFNET_RLOCK(); /* could sleep XXX */
2167 TAILQ_FOREACH(ifp, &ifnet, if_link) {
2169 TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
2168 int addrs = 0;
2169
2170 bzero(&ifr, sizeof(ifr));
2171 if (IFP_IS_ETH(ifp))
2172 snprintf(ifr.ifr_name, LINUX_IFNAMSIZ, "eth%d",
2173 ethno++);
2174 else
2175 strlcpy(ifr.ifr_name, ifp->if_xname, LINUX_IFNAMSIZ);

--- 536 unchanged lines hidden ---
2170 int addrs = 0;
2171
2172 bzero(&ifr, sizeof(ifr));
2173 if (IFP_IS_ETH(ifp))
2174 snprintf(ifr.ifr_name, LINUX_IFNAMSIZ, "eth%d",
2175 ethno++);
2176 else
2177 strlcpy(ifr.ifr_name, ifp->if_xname, LINUX_IFNAMSIZ);

--- 536 unchanged lines hidden ---