lkml.org 
[lkml]   [1997]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectbinfmt_misc - a generic 'wrapper'-binary format [PATCH on WWW]
Richard Guenther writes:
| Hi!
|
| Today i hacked binfmt_misc, a generic binfmt that is used to start an
| interpreter to execute a binary.
| This work should obsolete binfmt_java and binfmt_em86, as they can easily
| be emulated.
|
| binfmt_misc works as follows:
| - it maintains an array of structs, that contain a description of a binary
| format, including a magic with size, offset and mask, and the
| interpreter name.
| - on request it invokes the given interpreter with the original program
| as argument, as binfmt_java and binfmt_em86 and binfmt_mz do.
| - binfmt_misc does not define any default binary-formats
| - one must actually register an additional binary-format via a sysctl-call
| (pls read the source for more information or see enablejava.c on the
| web-site mentioned below)
| - operating as module is not supported, since you would have to be awared
| of too many module-requests to kerneld to support this properly
|
| Please make comments on this scheme and also on the patch (which is not
| really tested, but compiles) that can be found on:
| http://www.anatom.uni-tuebingen.de/~richi/linux.html

I like the idea (in fact I had made my own for elf programs that
aren't for the current machine) and was thinking about how to do the
same thing for COFF, since one of my GCC embedded targets is COFF
based. I suspect to provide the least amount of grief, it should add
config options for the current java, em86, and mz that uses this
framework to register the appropriate binaries. This way, you don't
get lots of whining that 'I when up to the newest version and can not
get Java, etc. to work'. It will also allow people to run old kernels
without changing init scripts.

I also had a couple of random thoughts (bear in mind I am not a linux
kernel hacker):

I personally don't tend to like static limits on number of array
elements (since if you decided that the limit should be foo, I might
have a good reason to want 2*foo different formats):

spin_lock(&misc_binfmts_lock);
if (misc_binfmts_last == MAX_BINFMT_MISC_ENTRIES) {
kfree(ek);
spin_unlock(&misc_binfmts_lock);
return -ENOSPC;
}

misc_binfmts[++misc_binfmts_last]=ek;

spin_unlock(&misc_binfmts_lock);
return 1;

Writing it as a linked list would avoid the problem.

In load_misc_binary, I suspect you may want to build the arguments
(using copy_string) outside of the spin lock for misc_binfmts_lock,
particularly on a SMP machine if copy_string blocks awaiting for
memory. Whether or not you want to go to separate spin locks for each
element might be something to think about as the kernel goes away from
one giant spin lock around the kernel.

Not knowing the guts of the Linux kernel, I assume that there is
probably a function to do the strlen code you open code in
binfmt_misc_sysctl:

/* strlen of interpreter */
while (!(res=get_user(c, eu.interpreter+len)) && (c!=0))
len++;

--
Michael Meissner, Cygnus Solutions (East Coast)
4th floor, 955 Massachusetts Avenue, Cambridge, MA 02139, USA
meissner@cygnus.com, 617-354-5416 (office), 617-354-7161 (fax)

\
 
 \ /
  Last update: 2005-03-22 13:39    [W:0.044 / U:0.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site