19#define NR_BINFMT ((sizeof(binfmt_list)/sizeof(binfmt_list[0])))
41 char *name = strdup(path);
int arch_sigcode_map(struct proc *proc)
Maps the page with the code that calls sigreturn() (the sigcode) into a process's new address space.
static int binfmt_fmt_load(struct proc *proc, const char *path, struct vnode *vnode, struct binfmt *binfmt, struct proc **ref)
Replaces a process's memory with a program, loaded by a format: the process's other threads end,...
static struct binfmt binfmt_list[]
int binfmt_elf_check(struct vnode *vnode)
Says whether a file is an ELF program this kernel can run: its magic number, class and machine.
int binfmt_elf_load(struct proc *proc, const char *path, struct vnode *vnode)
Loads an ELF program into a process.
int binfmt_load(struct proc *proc, const char *path, struct proc **ref)
Loads a program into a process, for execve().
int vfs_close(struct vnode *vnode)
Drops a reference to a vnode.
void * kmalloc(size_t size, struct malloc_type *type, int flags)
Allocates memory for one of the kernel's structures.
void kfree(void *)
Frees an object that kmalloc() gave.
void * memset(void *dst, int c, size_t n)
Sets n bytes to c.
int vfs_lookup(const char *path, struct uio *uio, struct vnode **ref)
Finds the vnode a path names.
void proc_threads_exec(struct proc *proc)
Ends every thread of a process but the current one, for execve() (POSIX: they run in the program that...
A format of executable files: says whether a file is one, and loads it into a process (sys/binfmt/).
int(*) load(struct proc *proc, const char *path, struct vnode *vnode)
struct vm_space vm_space
its address space
struct vm_entry * stack_vm
uintptr_t heap_start
where its heap starts, and where it ends now (sbrk())
struct vm_entry * heap_vm
its heap's and its stack's mappings
char * name
its name: the program it runs
struct queue threads
its threads
Who does a filesystem operation: where its paths start, and its credentials and umask.
A mapping (map entry): a range of an address space, its permissions, and where its pages come from.
uint32_t flags
its permissions and flags (VM_*)
vaddr_t base
where the mapping starts in its address space
struct vm_object * vm_object
its object: what its other pages come from (a file)
struct qnode * qnode
its node in its address space's list of mappings
struct queue vm_entries
its mappings (map entries), in address order
A file in memory (a vnode): what its inode says, and the kernel's own state.
int vfs_access(struct vnode *vnode, struct uio *uio, int mode)
Checks whether a user may access a vnode in a way: the owner's permissions apply to its owner,...
#define VM_URW
user read/write
void vm_space_destroy(struct vm_space *vm_space)
Removes all the mappings of an address space: its entries are released and freed, and its page tables...