Messages in this thread Patch in this message | | | Date | Wed, 16 Jul 1997 14:12:39 +0200 (MESZ) | From | Richard Guenther <> | Subject | [PATCH] to pre-2.1.45-7, esp. binfmt_misc / ksyms |
| |
Hi!
Below a patch to pre-2.1.45-7 is attached that does the following: - update binfmt_misc docs (esp. Java section) - revert some changes to binfmt_misc (well, the 'quickshot'/'fast draw') - add dput and dget symbols to kernel/ksyms.c to let binfmt_misc compile as a module
Please apply before 2.1.45
Richard.
diff -u --recursive --new-file pre-linux-2.1.45-6/Documentation/binfmt_misc.txt pre-linux-2.1.45-6x/Documentation/binfmt_misc.txt --- pre-linux-2.1.45-6/Documentation/binfmt_misc.txt Tue Jul 15 14:29:11 1997 +++ pre-linux-2.1.45-6x/Documentation/binfmt_misc.txt Tue Jul 15 18:23:29 1997 @@ -1,26 +1,26 @@ - Kernel Support for miscellaneous (your favourite) Binary Formats v1.1 - ===================================================================== + Kernel Support for miscellaneous (your favourite) Binary Formats v1.1 + ===================================================================== This Kernel feature allows to invoke almost (for restrictions see below) every -program by simply typing it's name in the shell. +program by simply typing its name in the shell. This includes for example compiled Java(TM), Python or Emacs programs. -To achieve this you must tell binfmt_misc which interpreter has to be invoked with -which binary. Binfmt_misc recognises the binary-type by matching some bytes at the -beginning of the file with a magic byte sequence (masking out specified bits) you -have supplied. Binfmt_misc can also recognise a filename extension (aka .com) and -optionally strip it off. +To achieve this you must tell binfmt_misc which interpreter has to be invoked +with which binary. Binfmt_misc recognises the binary-type by matching some bytes +at the beginning of the file with a magic byte sequence (masking out specified +bits) you have supplied. Binfmt_misc can also recognise a filename extension +(aka .com) and optionally strip it off. To actually register a new binary type, you have to set up a string looking like -:name:type:offset:magic:mask:interpreter: (where you can choose the ':' upon your -needs) and echo it to /proc/sys/fs/binfmt_misc/register. +:name:type:offset:magic:mask:interpreter: (where you can choose the ':' upon +your needs) and echo it to /proc/sys/fs/binfmt_misc/register. Here is what the fields mean: - 'name' is an identifier string. A new /proc file will be created with this - this name below /proc/sys/fs/binfmt_misc + name below /proc/sys/fs/binfmt_misc - 'type' is the type of recognition. Give 'M' for magic and 'E' for extension. - Give the corresponding lowercase letter to let binfmt_misc strip of the + Give the corresponding lowercase letter to let binfmt_misc strip off the filename extension. - - 'offset' is the offset of the magic/mask in the file counted in bytes. This + - 'offset' is the offset of the magic/mask in the file, counted in bytes. This defaults to 0 if you omit it (i.e. you write ':name:type::magic...') - 'magic' is the byte sequence binfmt_misc is matching for. The magic string may contain hex-encoded characters like \x0a or \xA4. In a shell environment @@ -28,26 +28,23 @@ If you chose filename extension matching, this is the extension to be recognised (the \x0a specials are not allowed). Extension matching is case sensitive! - - 'mask' is an (optional, defaults to all 0xff) mask. You can mask out some bits - from matching by supplying a string like magic and as long as magic. The - mask is anded with the byte sequence of the file. + - 'mask' is an (optional, defaults to all 0xff) mask. You can mask out some + bits from matching by supplying a string like magic and as long as magic. + The mask is anded with the byte sequence of the file. - 'interpreter' is the program that should be invoked with the binary as first argument (specify the full path) There are some restrictions: - the whole register string may not exceed 255 characters - - the magic must resist in the first 128 bytes of the file, i.e. offset+size(magic) - has to be less than 128 + - the magic must resist in the first 128 bytes of the file, i.e. + offset+size(magic) has to be less than 128 - the interpreter string may not exceed 127 characters -You may want to add the binary formats in one of your /etc/rc scripts during boot-up. -Read the manual of your init program to figure out how to do this right. +You may want to add the binary formats in one of your /etc/rc scripts during +boot-up. Read the manual of your init program to figure out how to do this +right. A few examples (assumed you are in /proc/sys/fs/binfmt_misc): -- enable Java(TM)-support (like binfmt_java): - echo ":Java:M::\xca\xfe\xba\xbe::/usr/local/bin/java:" > register - echo :Applet:M::\<\!--applet::/usr/local/bin/appletviewer: > register - - enable support for em86 (like binfmt_em86, for Alpha AXP only): echo ":i386:M::\x7fELF\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xff\xff:/bin/em86:" > register echo ":i486:M::\x7fELF\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xff\xff:/bin/em86:" > register @@ -57,8 +54,9 @@ - enable support for DOS/Windows executables (using mzloader and dosemu/wine): echo ":DOSWin:M::MZ::/usr/sbin/mzloader:" > register - echo ":DOS:E::com::/usr/sbin/mzloader:" > register - echo ":DOS2:E::exe::/usr/sbin/mzloader:" > register + echo ":DOScom:E::com::/usr/sbin/mzloader:" > register + echo ":DOSexe:E::exe::/usr/sbin/mzloader:" > register + You can enable/disable binfmt_misc or one binary type by echoing 0 (to disable) or 1 (to enable) to /proc/sys/fs/binfmt_misc/status or /proc/.../the_name. @@ -66,6 +64,25 @@ You can remove one entry or all entries by echoing -1 to /proc/.../the_name or /proc/sys/fs/binfmt_misc/status. + + +Emulating binfmt_java: +====================== + +To emulate binfmt_java the following register-strings are necessary +(the first two for byte-compiled Java binaries, the third for applets +contained in a html-file). Register exactly in this order! + ":Java:M::\xca\xfe\xba\xbe::/usr/local/java/bin/java:" + ":JavaC:e::class::/usr/local/java/bin/java:" + ":Applet:E::html::/usr/local/java/bin/appletviewer:" + +To add a Java-executable to your path you can either make a symbolic +link to the .class file elsewhere in your path (cut the .class-extension +in the destination name for convenience) or add the directory of your +.class files to your PATH environment. In both cases, ensure that the +.class files are in your CLASSPATH environment! + +This is sort of ugly - Javas filename handling is just broken. HINTS: diff -u --recursive --new-file pre-linux-2.1.45-6/fs/binfmt_misc.c pre-linux-2.1.45-6x/fs/binfmt_misc.c --- pre-linux-2.1.45-6/fs/binfmt_misc.c Tue Jul 15 14:29:01 1997 +++ pre-linux-2.1.45-6x/fs/binfmt_misc.c Tue Jul 15 23:00:57 1997 @@ -50,7 +50,7 @@ #define ENTRY_ENABLED 1 /* the old binfmt_entry.enabled */ #define ENTRY_MAGIC 8 /* not filename detection */ -#define ENTRY_STRIP_EXT 32 /* strip of last filename extension */ +#define ENTRY_STRIP_EXT 32 /* strip off last filename extension */ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs); static void entry_proc_cleanup(struct binfmt_entry *e); @@ -162,6 +162,7 @@ char *iname_addr = iname, *p; int retval, fmt_flags = 0; + MOD_INC_USE_COUNT; if (!enabled) { retval = -ENOEXEC; goto _ret; @@ -208,6 +209,7 @@ if (retval >= 0) retval = search_binary_handler(bprm, regs); _ret: + MOD_DEC_USE_COUNT; return retval; } @@ -266,13 +268,18 @@ struct binfmt_entry *e; int memsize, cnt = count - 1, err = 0; + MOD_INC_USE_COUNT; /* some sanity checks */ - if ((count < 11) || (count > 256)) - return -EINVAL; + if ((count < 11) || (count > 256)) { + err = -EINVAL; + goto _err; + } memsize = sizeof(struct binfmt_entry) + count; - if (!(e = (struct binfmt_entry *) kmalloc(memsize, GFP_USER))) - return -ENOMEM; + if (!(e = (struct binfmt_entry *) kmalloc(memsize, GFP_USER))) { + err = -ENOMEM; + goto _err; + } sp = buffer + 1; del = buffer[0]; @@ -309,7 +316,8 @@ !(e->proc_name) || !(e->interpreter) || entry_proc_setup(e)) { kfree(e); - return -EINVAL; + err = -EINVAL; + goto _err; } write_lock(&entries_lock); @@ -317,7 +325,10 @@ entries = e; write_unlock(&entries_lock); - return count; + err = count; +_err: + MOD_DEC_USE_COUNT; + return err; } /* @@ -332,6 +343,7 @@ char *dp; int elen, i; + MOD_INC_USE_COUNT; #ifndef VERBOSE_STATUS if (data) { read_lock(&entries_lock); @@ -391,6 +403,7 @@ *eof = (elen <= count) ? 1 : 0; *start = page + off; + MOD_DEC_USE_COUNT; return elen; } @@ -404,6 +417,7 @@ struct binfmt_entry *e; int res = count; + MOD_INC_USE_COUNT; if (((buffer[0] == '1') || (buffer[0] == '0')) && ((count == 1) || ((count == 2) && (buffer[1] == '\n')))) { if (data) { @@ -423,6 +437,7 @@ } else { res = -EINVAL; } + MOD_DEC_USE_COUNT; return res; } diff -u --recursive --new-file pre-linux-2.1.45-6/kernel/ksyms.c pre-linux-2.1.45-6x/kernel/ksyms.c --- pre-linux-2.1.45-6/kernel/ksyms.c Tue Jul 15 15:47:49 1997 +++ pre-linux-2.1.45-6x/kernel/ksyms.c Tue Jul 15 15:48:04 1997 @@ -178,6 +178,8 @@ EXPORT_SYMBOL(posix_test_lock); EXPORT_SYMBOL(posix_block_lock); EXPORT_SYMBOL(posix_unblock_lock); +EXPORT_SYMBOL(dput); +EXPORT_SYMBOL(dget); #if !defined(CONFIG_NFSD) && defined(CONFIG_NFSD_MODULE) EXPORT_SYMBOL(do_nfsservctl);
| |