diff options
author | Al Viro <viro@ftp.linux.org.uk> | 2009-01-03 02:16:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-03 14:45:54 -0500 |
commit | 3bfacef412b4bc993a8992217e50f1245f2fd3a6 (patch) | |
tree | bcf92bc34b30383dfc542f9850f59858681556cb /arch | |
parent | 17580d7f2f632ff8c9786d609508c35c9f56e1f3 (diff) |
get rid of special-casing the /sbin/loader on alpha
... just make it a binfmt handler like #! one.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/alpha/kernel/Makefile | 2 | ||||
-rw-r--r-- | arch/alpha/kernel/binfmt_loader.c | 51 |
2 files changed, 52 insertions, 1 deletions
diff --git a/arch/alpha/kernel/Makefile b/arch/alpha/kernel/Makefile index ac706c1d7ada..b4697759a123 100644 --- a/arch/alpha/kernel/Makefile +++ b/arch/alpha/kernel/Makefile | |||
@@ -8,7 +8,7 @@ EXTRA_CFLAGS := -Werror -Wno-sign-compare | |||
8 | 8 | ||
9 | obj-y := entry.o traps.o process.o init_task.o osf_sys.o irq.o \ | 9 | obj-y := entry.o traps.o process.o init_task.o osf_sys.o irq.o \ |
10 | irq_alpha.o signal.o setup.o ptrace.o time.o \ | 10 | irq_alpha.o signal.o setup.o ptrace.o time.o \ |
11 | alpha_ksyms.o systbls.o err_common.o io.o | 11 | alpha_ksyms.o systbls.o err_common.o io.o binfmt_loader.o |
12 | 12 | ||
13 | obj-$(CONFIG_VGA_HOSE) += console.o | 13 | obj-$(CONFIG_VGA_HOSE) += console.o |
14 | obj-$(CONFIG_SMP) += smp.o | 14 | obj-$(CONFIG_SMP) += smp.o |
diff --git a/arch/alpha/kernel/binfmt_loader.c b/arch/alpha/kernel/binfmt_loader.c new file mode 100644 index 000000000000..4a0af906b00a --- /dev/null +++ b/arch/alpha/kernel/binfmt_loader.c | |||
@@ -0,0 +1,51 @@ | |||
1 | #include <linux/init.h> | ||
2 | #include <linux/fs.h> | ||
3 | #include <linux/file.h> | ||
4 | #include <linux/mm_types.h> | ||
5 | #include <linux/binfmts.h> | ||
6 | #include <linux/a.out.h> | ||
7 | |||
8 | static int load_binary(struct linux_binprm *bprm, struct pt_regs *regs) | ||
9 | { | ||
10 | struct exec *eh = (struct exec *)bprm->buf; | ||
11 | unsigned long loader; | ||
12 | struct file *file; | ||
13 | int retval; | ||
14 | |||
15 | if (eh->fh.f_magic != 0x183 || (eh->fh.f_flags & 0x3000) != 0x3000) | ||
16 | return -ENOEXEC; | ||
17 | |||
18 | if (bprm->loader) | ||
19 | return -ENOEXEC; | ||
20 | |||
21 | allow_write_access(bprm->file); | ||
22 | fput(bprm->file); | ||
23 | bprm->file = NULL; | ||
24 | |||
25 | loader = bprm->vma->vm_end - sizeof(void *); | ||
26 | |||
27 | file = open_exec("/sbin/loader"); | ||
28 | retval = PTR_ERR(file); | ||
29 | if (IS_ERR(file)) | ||
30 | return retval; | ||
31 | |||
32 | /* Remember if the application is TASO. */ | ||
33 | bprm->taso = eh->ah.entry < 0x100000000UL; | ||
34 | |||
35 | bprm->file = file; | ||
36 | bprm->loader = loader; | ||
37 | retval = prepare_binprm(bprm); | ||
38 | if (retval < 0) | ||
39 | return retval; | ||
40 | return search_binary_handler(bprm,regs); | ||
41 | } | ||
42 | |||
43 | static struct linux_binfmt loader_format = { | ||
44 | .load_binary = load_binary, | ||
45 | }; | ||
46 | |||
47 | static int __init init_loader_binfmt(void) | ||
48 | { | ||
49 | return register_binfmt(&loader_format); | ||
50 | } | ||
51 | arch_initcall(init_loader_binfmt); | ||