From owner-freebsd-emulation@FreeBSD.ORG Thu Jan 6 10:32:28 2011 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 AF2F91065674 for ; Thu, 6 Jan 2011 10:32:28 +0000 (UTC) (envelope-from Andre.Albsmeier@siemens.com) Received: from thoth.sbs.de (thoth.sbs.de [192.35.17.2]) by mx1.freebsd.org (Postfix) with ESMTP id 34C5A8FC14 for ; Thu, 6 Jan 2011 10:32:27 +0000 (UTC) Received: from mail1.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id p06AWQHp016586; Thu, 6 Jan 2011 11:32:27 +0100 Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.40.130]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id p06AWQUw016896; Thu, 6 Jan 2011 11:32:26 +0100 Received: (from localhost) by curry.mchp.siemens.de (8.14.4/8.14.4) id p06AWQZB093644; Date: Thu, 6 Jan 2011 11:32:26 +0100 From: Andre Albsmeier To: Alexander Leidinger Message-ID: <20110106103226.GA59969@curry.mchp.siemens.de> References: <20101230075124.GA12923@curry.mchp.siemens.de> <20101231144800.00005c6d@unknown> <20110101224629.GA30540@curry.mchp.siemens.de> <20110102115021.00000c8b@unknown> <20110105191915.GA43997@curry.mchp.siemens.de> <20110106085753.21096d6vr5bqpq1w@webmail.leidinger.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110106085753.21096d6vr5bqpq1w@webmail.leidinger.net> X-Echelon: X-Advice: Drop that crappy M$-Outlook, I'm tired of your viruses! User-Agent: Mutt/1.5.20 (2009-06-14) Cc: "freebsd-emulation@freebsd.org" Subject: Re: 7.3-STABLE and Linux version of SIMetrix 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, 06 Jan 2011 10:32:28 -0000 On Thu, 06-Jan-2011 at 08:57:53 +0100, Alexander Leidinger wrote: > Quoting Andre Albsmeier (from Wed, 5 Jan > 2011 20:19:15 +0100): > > > On Sun, 02-Jan-2011 at 11:50:21 +0100, Alexander Leidinger wrote: > >> On Sat, 1 Jan 2011 23:46:29 +0100 Andre Albsmeier > >> wrote: > >> > >> > On Fri, 31-Dec-2010 at 14:48:00 +0100, Alexander Leidinger wrote: > >> > > On Thu, 30 Dec 2010 08:51:24 +0100 Andre Albsmeier > >> > > wrote: > >> > > > >> > > > I try to get the Linux version of SIMetrix (a very nice circuit > >> > > > simulator) running. Everything looks fine: It starts, the GUI > >> > > > comes up, you can draw schematics and so on. But when it comes > >> > > > to simulation, the (SIMetrix-)console says: > >> > > > > >> > > > *** Fatal error, out of memory *** > >> > > > Could not allocate shared heap > >> > > > Exception occurred while executing script command Run > >> > > > >> > > Is there something in the dmesg output? In case it tries to execute > >> > > an unsupported ioctl/syscall it should show up there. If not I > >> > > suggest to give 8.x a try, it has an improved linuxulator. > >> > > >> > Bad luck. I just started the PC-BSD 8.1 live system and > >> > the error there is exactly the same... > >> > >> Then there is only ktrace + linux_kdump (use the package) or dtrace > >> left. > > > > Got it running... A short explanation: > > > > Linux' shm_open() fails because it wants to find some funky shmfs > > to construct the full pathname. It starts to search at the default > > mountpoint which is /dev/shm. If this fails it runs through fstab > > and searches for shmfs and tmpfs. Whatever it finds will be > > statfs()'ed to be checked for Linux' fs magic for shmfs (0x01021994). > > > > My solution is eerie but it works. This is what I did: > > > > 1. cd /compat/linux > > 2. mkdir dev > > 3. cd dev > > 4. ln -s /tmp shm > > As long as you do not need to access something from dev (FreeBSD one), > this works. As soon as you need to access something from there it > depends upon the software. If the software is doing a readdir, the > user experience will be worse. And if it does not allow to enter a Let me see if I got this: Now I have a /compat/linux/dev directory which means that if some Linux programme wants to look into /dev it will see just the shm entry. If there wasn't my dev directory it would have continued to FreeBSD's /dev... > name by hand, you are lost. So this is a solution for your situation, > but not a generic solution which we can use in the ports. Of course not. I was just happy that it works and that that's all what has been missing. But you are right, it is not very generic now that I understand the impact. > > Can you please try a solution with devfs.conf (I never tried if it > allows to link outside of dev)? I added the following line to devfs.conf link /tmp shm and removed my dev stuff under /compat/linux. And it still works ;-). > > > This is not enough since statfs() won't return the proper magic > > because it's no shmfs. So let's fix this ;-): > > > > --- sys/compat/linux/linux_stats.c.ORI 2008-01-10 20:11:51.000000000 +0100 > > +++ sys/compat/linux/linux_stats.c 2011-01-05 20:04:18.000000000 +0100 > > @@ -379,6 +379,8 @@ > > struct statfs bsd_statfs; > > char *path; > > int error; > > + char* cp; > > + unsigned char shm = 0; > > > > LCONVPATHEXIST(td, args->path, &path); > > > > @@ -387,10 +389,15 @@ > > printf(ARGS(statfs, "%s, *"), path); > > #endif > > error = kern_statfs(td, path, UIO_SYSSPACE, &bsd_statfs); > > + if( (cp = strstr( path, "/dev/shm" )) != NULL ) > > + shm = ( cp[8] == '\0' || (cp[8] == '/' && cp[9] == '\0') ); > > + > > LFREEPATH(path); > > if (error) > > return (error); > > bsd_to_linux_statfs(&bsd_statfs, &linux_statfs); > > + if( shm ) > > + linux_statfs.f_type = 0x01021994; > > return copyout(&linux_statfs, args->buf, sizeof(linux_statfs)); > > } > > This is something we could do (with a little bit of cleanup), when we > find a nice solution for the dev-part. The devfs.conf thing makes it possible to simplify the (ugly) patch a bit: --- /sys/compat/linux/linux_stats.c.ORI 2008-01-10 20:11:51.000000000 +0100 +++ /sys/compat/linux/linux_stats.c 2011-01-06 11:26:53.000000000 +0100 @@ -379,6 +379,7 @@ struct statfs bsd_statfs; char *path; int error; + unsigned char shm = 0; LCONVPATHEXIST(td, args->path, &path); @@ -387,10 +388,14 @@ printf(ARGS(statfs, "%s, *"), path); #endif error = kern_statfs(td, path, UIO_SYSSPACE, &bsd_statfs); + if( strncmp( path, "/dev/shm", 8 ) == 0 ) + shm = ( path[8] == '\0' || (path[8] == '/' && path[9] == '\0') ); LFREEPATH(path); if (error) return (error); bsd_to_linux_statfs(&bsd_statfs, &linux_statfs); + if( shm ) + linux_statfs.f_type = 0x01021994; return copyout(&linux_statfs, args->buf, sizeof(linux_statfs)); } Thanks for the hint with devfs.conf, that's a lot better! -Andre > > Bye, > Alexander. > > -- > And do you think (fop that I am) that I could be the Scarlet Pumpernickel? > > http://www.Leidinger.net Alexander @ Leidinger.net: PGP ID = B0063FE7 > http://www.FreeBSD.org netchild @ FreeBSD.org : PGP ID = 72077137 > -- Windows NT Multitasking: Messing up several things at once.