[patch] 2.3.40: improved register_binfmt

Chris Sears cbsears en ix.netcom.com
Lun Ene 24 23:09:42 CST 2000


This patch contains an improved fs/exec.c/register_binfmt().

Recently, binfmt support has undergone several changes.
Handlers are registered either statically with __initcall
or, as before, dynamically as loadable modules.

"formats" is a singly linked list of binfmt handlers with
new entries placed at the front.  The ordering of BINFMTS
handlers in the fs/Makefile apparently takes this into account,
and has binfmt_elf as the last entry and thus at the front
of the list.  But when a loadable binfmt module is registered,
it is added to the front of the list.  Not good.

Instead, the patched register_binfmt() appends new entries
to the end of the formats list and reverses the order of
BINFMTS in the fs/Makefile.  A preferred binfmt_elf
will always be at the front of the list.

The new code is also a bit smaller.

Chris Sears
cbsears en ix.netcom.com

--- exec.c.orig Sun Jan 23 22:44:57 2000
+++ exec.c      Sun Jan 23 23:12:47 2000
@@ -57,8 +57,7 @@
                        return -EBUSY;
                tmp = &(*tmp)->next;
        }
-       fmt->next = formats;
-       formats = fmt;
+       *tmp = fmt;
        return 0;
 }

--- Makefile.orig       Sun Jan 23 23:13:35 2000
+++ Makefile    Sun Jan 23 23:14:19 2000
@@ -277,21 +277,16 @@
   endif
 endif

-ifeq ($(CONFIG_BINFMT_AOUT),y)
-BINFMTS += binfmt_aout.o
+ifeq ($(CONFIG_BINFMT_ELF),y)
+BINFMTS += binfmt_elf.o
 else
-  ifeq ($(CONFIG_BINFMT_AOUT),m)
-  M_OBJS += binfmt_aout.o
+  ifeq ($(CONFIG_BINFMT_ELF),m)
+  M_OBJS += binfmt_elf.o
   endif
 endif

-ifeq ($(CONFIG_BINFMT_EM86),y)
-BINFMTS += binfmt_em86.o
-else
-  ifeq ($(CONFIG_BINFMT_EM86),m)
-  M_OBJS += binfmt_em86.o
-  endif
-endif
+# binfmt_script is always there
+BINFMTS += binfmt_script.o

 ifeq ($(CONFIG_BINFMT_MISC),y)
 BINFMTS += binfmt_misc.o
@@ -301,14 +296,19 @@
   endif
 endif

-# binfmt_script is always there
-BINFMTS += binfmt_script.o
+ifeq ($(CONFIG_BINFMT_EM86),y)
+BINFMTS += binfmt_em86.o
+else
+  ifeq ($(CONFIG_BINFMT_EM86),m)
+  M_OBJS += binfmt_em86.o
+  endif
+endif

-ifeq ($(CONFIG_BINFMT_ELF),y)
-BINFMTS += binfmt_elf.o
+ifeq ($(CONFIG_BINFMT_AOUT),y)
+BINFMTS += binfmt_aout.o
 else
-  ifeq ($(CONFIG_BINFMT_ELF),m)
-  M_OBJS += binfmt_elf.o
+  ifeq ($(CONFIG_BINFMT_AOUT),m)
+  M_OBJS += binfmt_aout.o
   endif
 endif


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo en vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



Más información sobre la lista de distribución Ayuda