patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / include / linux / binfmts.h
1 #ifndef _LINUX_BINFMTS_H
2 #define _LINUX_BINFMTS_H
3
4 #include <linux/capability.h>
5 #include <linux/vs_memory.h>
6
7 struct pt_regs;
8
9 /*
10  * MAX_ARG_PAGES defines the number of pages allocated for arguments
11  * and envelope for the new program. 32 should suffice, this gives
12  * a maximum env+arg of 128kB w/4KB pages!
13  */
14 #define MAX_ARG_PAGES 32
15
16 /* sizeof(linux_binprm->buf) */
17 #define BINPRM_BUF_SIZE 128
18
19 #ifdef __KERNEL__
20
21 /*
22  * This structure is used to hold the arguments that are used when loading binaries.
23  */
24 struct linux_binprm{
25         char buf[BINPRM_BUF_SIZE];
26         struct page *page[MAX_ARG_PAGES];
27         struct mm_struct *mm;
28         unsigned long p; /* current top of mem */
29         int sh_bang;
30         struct file * file;
31         int e_uid, e_gid;
32         kernel_cap_t cap_inheritable, cap_permitted, cap_effective;
33         void *security;
34         int argc, envc;
35         char * filename;        /* Name of binary as seen by procps */
36         char * interp;          /* Name of the binary really executed. Most
37                                    of the time same as filename, but could be
38                                    different for binfmt_{misc,script} */
39         unsigned long loader, exec;
40 };
41
42 /*
43  * This structure defines the functions that are used to load the binary formats that
44  * linux accepts.
45  */
46 struct linux_binfmt {
47         struct linux_binfmt * next;
48         struct module *module;
49         int (*load_binary)(struct linux_binprm *, struct  pt_regs * regs);
50         int (*load_shlib)(struct file *);
51         int (*core_dump)(long signr, struct pt_regs * regs, struct file * file);
52         unsigned long min_coredump;     /* minimal dump size */
53 };
54
55 extern int register_binfmt(struct linux_binfmt *);
56 extern int unregister_binfmt(struct linux_binfmt *);
57
58 extern int prepare_binprm(struct linux_binprm *);
59 extern void remove_arg_zero(struct linux_binprm *);
60 extern int search_binary_handler(struct linux_binprm *,struct pt_regs *);
61 extern int flush_old_exec(struct linux_binprm * bprm);
62
63 /* Stack area protections */
64 #define EXSTACK_DEFAULT   0     /* Whatever the arch defaults to */
65 #define EXSTACK_DISABLE_X 1     /* Disable executable stacks */
66 #define EXSTACK_ENABLE_X  2     /* Enable executable stacks */
67
68 extern int setup_arg_pages(struct linux_binprm * bprm, int executable_stack);
69 extern int copy_strings(int argc,char __user * __user * argv,struct linux_binprm *bprm); 
70 extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm);
71 extern void compute_creds(struct linux_binprm *binprm);
72 extern int do_coredump(long signr, int exit_code, struct pt_regs * regs);
73 extern int set_binfmt(struct linux_binfmt *new);
74
75 #endif /* __KERNEL__ */
76 #endif /* _LINUX_BINFMTS_H */