From owner-freebsd-emulation@FreeBSD.ORG Thu Feb 19 21:00:01 2009 Return-Path: Delivered-To: freebsd-emulation@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0B98E1065679 for ; Thu, 19 Feb 2009 21:00:01 +0000 (UTC) (envelope-from rdivacky@vlk.vlakno.cz) Received: from vlakno.cz (77-93-215-190.static.masterinter.net [77.93.215.190]) by mx1.freebsd.org (Postfix) with ESMTP id AD41F8FC0C for ; Thu, 19 Feb 2009 20:59:59 +0000 (UTC) (envelope-from rdivacky@vlk.vlakno.cz) Received: from localhost (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id C94359CB093; Thu, 19 Feb 2009 21:56:56 +0100 (CET) X-Virus-Scanned: amavisd-new at vlakno.cz Received: from vlakno.cz ([127.0.0.1]) by localhost (lev.vlakno.cz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dUfTnXqMDnK8; Thu, 19 Feb 2009 21:56:54 +0100 (CET) Received: from vlk.vlakno.cz (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id 2A2A49CB126; Thu, 19 Feb 2009 21:56:54 +0100 (CET) Received: (from rdivacky@localhost) by vlk.vlakno.cz (8.14.3/8.14.3/Submit) id n1JKuslW078552; Thu, 19 Feb 2009 21:56:54 +0100 (CET) (envelope-from rdivacky) Date: Thu, 19 Feb 2009 21:56:54 +0100 From: Roman Divacky To: Ed Schouten Message-ID: <20090219205653.GA78242@freebsd.org> References: <20090219205645.GF19161@hoeg.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090219205645.GF19161@hoeg.nl> User-Agent: Mutt/1.4.2.3i Cc: freebsd-emulation@FreeBSD.org Subject: Re: Making Linux stat() less evil X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2009 21:00:01 -0000 On Thu, Feb 19, 2009 at 09:56:45PM +0100, Ed Schouten wrote: > Hi folks, > > I may have mentioned this earlier, but our Linuxolator's stat() > implementation calls kern_openat(), followed by an > translate_fd_major_minor() to perform a device major/minor number > lookup. This is very evil, because it causes random chardevs to be > opened when you run ls -l /dev. > > I propose the following patch: > > http://80386.nl/pub/linux-stat.diff > > I've copied kern_stat() into the Linuxolator. Not the ideal solution, > but it's better than what we have right now. Comments? why cant you use kern_statat() and perform this after it returns? + if (S_ISCHR(sb.st_mode) && nd.ni_vp->v_un.vu_cdev != NULL && + linux_driver_get_major_minor( + nd.ni_vp->v_un.vu_cdev->si_name, &major, &minor) == 0) { + sb.st_rdev = (major << 8 | minor); + }