From owner-svn-src-user@FreeBSD.ORG Fri May 10 11:15:45 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 294B9477; Fri, 10 May 2013 11:15:45 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 1B66B1EC; Fri, 10 May 2013 11:15:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4ABFist039932; Fri, 10 May 2013 11:15:44 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4ABFiKx039929; Fri, 10 May 2013 11:15:44 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201305101115.r4ABFiKx039929@svn.freebsd.org> From: Dmitry Chagin Date: Fri, 10 May 2013 11:15:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r250449 - in user/dchagin/lemul/sys/compat: linprocfs linux X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 May 2013 11:15:45 -0000 Author: dchagin Date: Fri May 10 11:15:44 2013 New Revision: 250449 URL: http://svnweb.freebsd.org/changeset/base/250449 Log: As from now for amd64 we have two linuxulator modules and can't depend on both partialy detach linprocfs from linux.ko by using appropriate sysctl. Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c user/dchagin/lemul/sys/compat/linux/linux_ioctl.c user/dchagin/lemul/sys/compat/linux/linux_ioctl.h Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c ============================================================================== --- user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Fri May 10 11:12:39 2013 (r250448) +++ user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Fri May 10 11:15:44 2013 (r250449) @@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -77,7 +78,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include #include @@ -97,11 +98,6 @@ __FBSDID("$FreeBSD$"); #include #endif /* __i386__ || __amd64__ */ -#ifdef COMPAT_FREEBSD32 -#include -#endif - -#include #include #include #include @@ -598,10 +594,30 @@ linprocfs_doversion(PFS_FILL_ARGS) { char osname[LINUX_MAX_UTSNAME]; char osrelease[LINUX_MAX_UTSNAME]; + size_t size; + int error = 0; + + size = sizeof(osname); + if (SV_CURPROC_FLAG(SV_LP64)) + error = kernel_sysctlbyname(td, "compat.linux64.osname", &osname, &size, 0, 0, 0, 0); + if (SV_CURPROC_FLAG(SV_ILP32) || error) + error = kernel_sysctlbyname(td, "compat.linux.osname", &osname, &size, 0, 0, 0, 0); + if (error) + sbuf_printf(sb, "unknown "); + else + sbuf_printf(sb, "%s ", osname); + + error = 0; + size = sizeof(osrelease); + if (SV_CURPROC_FLAG(SV_LP64)) + error = kernel_sysctlbyname(td, "compat.linux64.osrelease", &osrelease, &size, 0, 0, 0, 0); + if (SV_CURPROC_FLAG(SV_ILP32) || error) + error = kernel_sysctlbyname(td, "compat.linux.osrelease", &osrelease, &size, 0, 0, 0, 0); + if (error) + sbuf_printf(sb, "version unknown ("); + else + sbuf_printf(sb, "version %s (", osrelease); - linux_get_osname(td, osname); - linux_get_osrelease(td, osrelease); - sbuf_printf(sb, "%s version %s (", osname, osrelease); linprocfs_osbuilder(td, sb); sbuf_cat(sb, ") (gcc version " __VERSION__ ") "); linprocfs_osbuild(td, sb); @@ -1116,6 +1132,35 @@ linprocfs_doprocmaps(PFS_FILL_ARGS) } /* + * Criteria for interface name translation + */ +#define IFP_IS_ETH(ifp) (ifp->if_type == IFT_ETHER) + +static int +linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen) +{ + struct ifnet *ifscan; + int ethno; + + IFNET_RLOCK_ASSERT(); + + /* Short-circuit non ethernet interfaces */ + if (!IFP_IS_ETH(ifp)) + return (strlcpy(buffer, ifp->if_xname, buflen)); + + /* Determine the (relative) unit number for ethernet interfaces */ + ethno = 0; + TAILQ_FOREACH(ifscan, &V_ifnet, if_link) { + if (ifscan == ifp) + return (snprintf(buffer, buflen, "eth%d", ethno)); + if (IFP_IS_ETH(ifscan)) + ethno++; + } + + return (0); +} + +/* * Filler function for proc/net/dev */ static int @@ -1175,10 +1220,18 @@ static int linprocfs_doosrelease(PFS_FILL_ARGS) { char osrelease[LINUX_MAX_UTSNAME]; + size_t size; + int error = 0; - linux_get_osrelease(td, osrelease); - sbuf_printf(sb, "%s\n", osrelease); - + size = sizeof(osrelease); + if (SV_CURPROC_FLAG(SV_LP64)) + error = kernel_sysctlbyname(td, "compat.linux64.osrelease", &osrelease, &size, 0, 0, 0, 0); + if (SV_CURPROC_FLAG(SV_ILP32) || error) + error = kernel_sysctlbyname(td, "compat.linux.osrelease", &osrelease, &size, 0, 0, 0, 0); + if (error) + sbuf_printf(sb, "unknown\n"); + else + sbuf_printf(sb, "%s\n", osrelease); return (0); } @@ -1189,10 +1242,18 @@ static int linprocfs_doostype(PFS_FILL_ARGS) { char osname[LINUX_MAX_UTSNAME]; + size_t size; + int error = 0; - linux_get_osname(td, osname); - sbuf_printf(sb, "%s\n", osname); - + size = sizeof(osname); + if (SV_CURPROC_FLAG(SV_LP64)) + error = kernel_sysctlbyname(td, "compat.linux64.osname", &osname, &size, 0, 0, 0, 0); + if (SV_CURPROC_FLAG(SV_ILP32) || error) + error = kernel_sysctlbyname(td, "compat.linux.osname", &osname, &size, 0, 0, 0, 0); + if (error) + sbuf_printf(sb, "unknown\n"); + else + sbuf_printf(sb, "%s\n", osname); return (0); } @@ -1262,8 +1323,6 @@ linprocfs_doscsiscsi(PFS_FILL_ARGS) return (0); } -extern struct cdevsw *cdevsw[]; - /* * Filler function for proc/devices */ Modified: user/dchagin/lemul/sys/compat/linux/linux_ioctl.c ============================================================================== --- user/dchagin/lemul/sys/compat/linux/linux_ioctl.c Fri May 10 11:12:39 2013 (r250448) +++ user/dchagin/lemul/sys/compat/linux/linux_ioctl.c Fri May 10 11:15:44 2013 (r250449) @@ -68,7 +68,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include @@ -2089,34 +2088,6 @@ linux_ioctl_console(struct thread *td, s #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; - - IFNET_RLOCK_ASSERT(); - - /* Short-circuit non ethernet interfaces */ - if (!IFP_IS_ETH(ifp)) - return (strlcpy(buffer, ifp->if_xname, buflen)); - - /* Determine the (relative) unit number for ethernet interfaces */ - ethno = 0; - TAILQ_FOREACH(ifscan, &V_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 * bsdname and lxname need to be least IFNAMSIZ bytes long, but Modified: user/dchagin/lemul/sys/compat/linux/linux_ioctl.h ============================================================================== --- user/dchagin/lemul/sys/compat/linux/linux_ioctl.h Fri May 10 11:12:39 2013 (r250448) +++ user/dchagin/lemul/sys/compat/linux/linux_ioctl.h Fri May 10 11:15:44 2013 (r250449) @@ -581,13 +581,6 @@ #define LINUX_IOCTL_DRM_MAX 0x64ff /* - * This doesn't really belong here, but I can't think of a better - * place to put it. - */ -struct ifnet; -int linux_ifname(struct ifnet *, char *, size_t); - -/* * video */ #define LINUX_VIDIOCGCAP 0x7601