1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-10 14:02:43 +00:00

Adding SIOCGIFNAME support in Linuxulator. This should silence the console warning associated

with linux-opera:
	linux: pid 23492 (opera): ioctl fd=5, cmd=0x8910 ('\M^I',16) is not implemented
	linux: pid 23492 (opera): ioctl fd=28, cmd=0x8910 ('\M^I',16) is not implemented
	...

Reviewed by:	kib, marcel, dchagin
Tested with:	linux-opera-12.16_3
MFC after:	1 month
This commit is contained in:
Tai-hwa Liang 2017-04-09 15:27:04 +00:00
parent 23852d5ce3
commit 113bb55f71
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=316658
2 changed files with 49 additions and 0 deletions

View File

@ -2166,6 +2166,49 @@ ifname_linux_to_bsd(struct thread *td, const char *lxname, char *bsdname)
return (ifp);
}
/*
* Implement the SIOCGIFNAME ioctl
*/
static int
linux_ioctl_ifname(struct thread *td, struct l_ifreq *uifr)
{
struct l_ifreq ifr;
struct ifnet *ifp;
int error, ethno, index;
error = copyin(uifr, &ifr, sizeof(ifr));
if (error != 0)
return (error);
CURVNET_SET(TD_TO_VNET(curthread));
IFNET_RLOCK();
index = 1; /* ifr.ifr_ifindex starts from 1 */
ethno = 0;
error = ENODEV;
TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifr.ifr_ifindex == index) {
if (IFP_IS_ETH(ifp))
snprintf(ifr.ifr_name, LINUX_IFNAMSIZ,
"eth%d", ethno);
else
strlcpy(ifr.ifr_name, ifp->if_xname,
LINUX_IFNAMSIZ);
error = 0;
break;
}
if (IFP_IS_ETH(ifp))
ethno++;
index++;
}
IFNET_RUNLOCK();
if (error == 0)
error = copyout(&ifr, uifr, sizeof(ifr));
CURVNET_RESTORE();
return (error);
}
/*
* Implement the SIOCGIFCONF ioctl
*/
@ -2393,6 +2436,7 @@ linux_ioctl_socket(struct thread *td, struct linux_ioctl_args *args)
case LINUX_SIOCADDMULTI:
case LINUX_SIOCATMARK:
case LINUX_SIOCDELMULTI:
case LINUX_SIOCGIFNAME:
case LINUX_SIOCGIFCONF:
case LINUX_SIOCGPGRP:
case LINUX_SIOCSPGRP:
@ -2478,6 +2522,10 @@ linux_ioctl_socket(struct thread *td, struct linux_ioctl_args *args)
/* LINUX_SIOCGSTAMP */
case LINUX_SIOCGIFNAME:
error = linux_ioctl_ifname(td, (struct l_ifreq *)args->arg);
break;
case LINUX_SIOCGIFCONF:
error = linux_ifconf(td, (struct ifconf *)args->arg);
break;

View File

@ -226,6 +226,7 @@
#define LINUX_SIOCGPGRP 0x8904
#define LINUX_SIOCATMARK 0x8905
#define LINUX_SIOCGSTAMP 0x8906
#define LINUX_SIOCGIFNAME 0x8910
#define LINUX_SIOCGIFCONF 0x8912
#define LINUX_SIOCGIFFLAGS 0x8913
#define LINUX_SIOCGIFADDR 0x8915