From owner-freebsd-current Thu Feb 6 14:12:29 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id OAA09760 for current-outgoing; Thu, 6 Feb 1997 14:12:29 -0800 (PST) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.211]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id OAA09748 for ; Thu, 6 Feb 1997 14:12:22 -0800 (PST) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id PAA18009; Thu, 6 Feb 1997 15:07:27 -0700 From: Terry Lambert Message-Id: <199702062207.PAA18009@phaeton.artisoft.com> Subject: Re: linux ELF codine no go on 2.2 Gamma To: msmith@atrad.adelaide.edu.au (Michael Smith) Date: Thu, 6 Feb 1997 15:07:27 -0700 (MST) Cc: StevenR362@aol.com, msmith@atrad.adelaide.edu.au, rcarter@consys.com, current@freebsd.org In-Reply-To: <199702060627.QAA01550@genesis.atrad.adelaide.edu.au> from "Michael Smith" at Feb 6, 97 04:57:12 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > I've been wondering if there is any way to abuse the filesystem to > > identify > > Linux, SCO, and BSDI binaries. Why not make the assumption in the > > kernel that any binary loaded from /compat/[linux,sco,bsdi] is an elf binary > > of the type denoted by the subdirectory. This would eliminate any need > > to brand the binaries. You would just install them under the appropriate > > subdirectory of /compat. This makes the implicit and reasonable assumption > > that any elf binary not under /compat is a native FreeBSD one. > > I've already proposed this; I was assuming that SOS had already done it. > > If there's no major disagreement, I'll look at adding the code to > imgact_elf.c at some point soonish. % ln -s /compat/linux/.../somebinary ~/bin/somename % rehash % somename ... BOOM! The "where's it from" inheritance can't work across symlinks because the symlink lookup is implemented as two function buffer recursion instead of as real recursion. Also, if I type "foo", it doesn't look for "foo" in my path, then for "foo" in the same path in the compat hierarchy using the subdirectories of compat as virtual "/". The reason "compat" works at all is that it adulterates the path lookup using system calls *in the emulator's system call table*. If you aren't running the program from a Linux binary (for instance, a Linux binary for your shell), then it won't look in compat when trying to find the program to run it. You *could* write a Linux-branded glue program that loaded a program of the same name that wasn't itself, and link the glue program into the regular path, linked as the name of the linux binary you wanted to load. Then you would load the glue program from the FreeBSD lookup, and the glue program would look up again based on argv[ 0], and if it found its name and it wasn't the glue program, it would exec the program in question. This would even work for symlinks. But it's one mother of a kludge to get arough changing the ld program with the patches that John Polstra already submitted to the Linux and GNU people. 8-). Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.