[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Suggestion: binfmt_misc handling



>> 2. Suggestion: Would it be possible to somehow integrate this with
>> /etc/mailcap, which already has good support in packages? There are
>> different ways you could do this, eg have in the config file lines that
>> look like:
>> 
>> :Java:M::\xca\xfe\xba\xbe::application/x-java:
>> :JPEG:M::0xffd8::image/jpeg:
>> :JPEG-JFIF:M::JFIF::image/jpeg:
>> :JPEG-HSI:M::hsi1::image/jpeg:
>> 
>> Where the last field is replaced with the appropriate command line from
>> the /etc/mailcap file. Not that there currently is a mailcap entry (at
>> least on my slink system) for java...
>> 
>> This file could potentially be used for more applications then just the
>> kernel - any program that wants to map the file to a MIME type. (Apache
>> already does this - is this any better? I suspect Apache's is hardcoded,
>> but not sure).
>> 
>> I think that this could be done with similar structure as originally
>> proposed.
>
>  This is much better than what I had.  I've had another suggestion to use
>mailcap as well, and I think this is a good idea -- but I'm not quite sure how
>to make it work in Linux (Marcus suggested something like this in the Hurd).  I
>think, though, that what's put in the binfmt_misc database should be restricted:only things that vaguely resemble a program should go into it.  One possibility
>is a meta-config file:
>
>type "Java programs"
>{
>  name "Java"
>  recognize-by "magic"
>  magic-number 0xCAFEBABE
>  mime-type application/x-java
>  executable true
>  load 
>}
>
>  or, more interestingly:
>
>application/x-java; kaffe %s; magic-number="0xCAFEBABE"; \
> executable=true; priority=5
>
>  (this is the format used by update-mime)
>
>  Assume that update-mime was changed to handle this.  For every MIME type for
>which a MIME handler declared "executable=true", update-mime would dump an
>entry to /etc/binfmt_misc with instructions to use the handler which was the
>highest priority of those which declared themselves to be willing to execute
>files of that type.
>  update-mime could also check the architecture it's running on and do something
>different on the Hurd, once it's decided exactly how that system will handle
>stuff like this.
>
>  Does this sound reasonable?

Just one problem I can think of:

Some^h^h^h^h Most entries in /etc/mailcap have tests, for example to
see if the user is running X-Windows or not. If the user is running
text mode, one program can be used, where as if the user is running in
X-Windows, another program can be used.

How could this be implemented?

The only thing that comes to mind, is to implement a mini-program
(unless it already has been written) that takes two parameters, eg

run-mime-type text/html /path/to/file.html

That would automatically parse /etc/mailcap and do the `right' thing,
for the file /path/to/file.html, given it is text/html.

Entries in /etc/binfmt_misc would contain statements like the above
instead of the end program.

This could be implemented with you original proposal with no changes
(except the extra program), but having it integrated with the mime setup
would be nice ;-).
-- 
Brian May <bam@snoopy.apana.org.au>


Reply to: