---559023410-851401618-832169602=:14979
Content-Type: TEXT/PLAIN; charset=US-ASCII
Several people seem to have independently suggested the following (including
me), so here it is.
The attached patch (to the old, decrepit 1.3.100 actually) causes a
userland program (/bin/usrexec) to be invoked on unrecognised executable
files. (It's done within binfmt_script to avoid duplicate code, but you
could easily do it as a separate binfmt if you wanted too.)
/bin/usrexec is supposed to look for and invoke a userland interpreter to
execute the "executable".
Also attached is version 0.000001 of such an interpreter that can
recognise windows binaries (seems to work, but it's a hack) and java binaries
and invoke their respective interpreters. Clearly it can be improved.
With this patch, there is no need for all that BINFMT_JAVA stuff in
the kernel.
Cheers,
Dr. Bradley Broom,
School of Data Communications, Email: broom@fit.qut.edu.au
Queensland University of Technology, Bus. : +61 7 3864 2769
GPO Box 2434, Brisbane, 4001, Australia. Fax : +61 7 3221 2384
---559023410-851401618-832169602=:14979
Content-Type: TEXT/PLAIN; charset=US-ASCII; name=patch
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.SOL.3.91.960516001322.14979B@bohr.fit.qut.edu.au>
Content-Description: patch
LS0tIGxpbnV4L2ZzL2V4ZWMuYy5vbGQJV2VkIE1heSAxNSAyMzowODowMCAx
OTk2DQorKysgbGludXgvZnMvZXhlYy5jCVdlZCBNYXkgMTUgMjM6MDg6MDYg
MTk5Ng0KQEAgLTYzLDE5ICs2MywyNCBAQA0KIA0KIHZvaWQgYmluZm10X3Nl
dHVwKHZvaWQpDQogew0KLSNpZmRlZiBDT05GSUdfQklORk1UX0VMRg0KLQlp
bml0X2VsZl9iaW5mbXQoKTsNCi0jZW5kaWYNCisJLyogVGhpcyBjYW5ub3Qg
YmUgY29uZmlndXJlZCBvdXQgb2YgdGhlIGtlcm5lbCAqLw0KKwkvKiBGb3Jt
YXRzIGFyZSBhY3R1YWxseSB0cmllZCBpbiB0aGUgcmV2ZXJzZSBvcmRlciBv
Zg0KKwkgKiByZWdpc3RyYXRpb24sIGFuZCBzY3JpcHQgZm9ybWF0IG11c3Qg
YmUgdGhlIGxhc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DOyAvKiBObyBpbnRlcnByZXRlciBuYW1lIGZvdW5kICov
DQorCQlpbnRlcnAgPSBpX25hbWUgPSBjcDsNCisJCWlfYXJnID0gMDsNCisJ
CWZvciAoIDsgKmNwICYmICgqY3AgIT0gJyAnKSAmJiAoKmNwICE9ICdcdCcp
OyBjcCsrKSB7DQorCQkJaWYgKCpjcCA9PSAnLycpDQorCQkJCWlfbmFtZSA9
IGNwKzE7DQorCQl9DQorCQl3aGlsZSAoKCpjcCA9PSAnICcpIHx8ICgqY3Ag
PT0gJ1x0JykpDQorCQkJKmNwKysgPSAnXDAnOw0KKwkJaWYgKCpjcCkNCisJ
CQlpX2FyZyA9IGNwOw0KIAl9DQotCXdoaWxlICgoKmNwID09ICcgJykgfHwg
KCpjcCA9PSAnXHQnKSkNCi0JCSpjcCsrID0gJ1wwJzsNCi0JaWYgKCpjcCkN
Ci0JCWlfYXJnID0gY3A7DQorDQogCS8qDQogCSAqIE9LLCB3ZSd2ZSBwYXJz
ZWQgb3V0IHRoZSBpbnRlcnByZXRlciBuYW1lIGFuZA0KIAkgKiAob3B0aW9u
YWwpIGFyZ3VtZW50Lg0K
---559023410-851401618-832169602=:14979
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="usrexec.c"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.SOL.3.91.960516001322.14979C@bohr.fit.qut.edu.au>
Content-Description: usrexec demo prog
I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3RkbGliLmg+DQojaW5j
bHVkZSA8ZmNudGwuaD4NCg0KdW5zaWduZWQgY2hhcglidWZbMTAyNF07DQpp
bnQJbGVuOw0KDQppbnQNCm1haW4gKGludCBhcmdjLCBjaGFyICphcmd2W10p
DQp7DQoJaW50CWZkOw0KDQoJaWYgKGFyZ2MgIT0gMikgew0KCQlmcHJpbnRm
IChzdGRlcnIsICJVc2FnZTogJXMgZmlsZXRvZXhlY1xuIiwgYXJndlswXSk7
DQoJCWV4aXQgKDEpOw0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