AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
binfmt.h File Reference
#include <core/system.h>
#include <fs/vfs.h>
#include <sys/proc.h>

Go to the source code of this file.

Data Structures

struct  binfmt
 A format of executable files: says whether a file is one, and loads it into a process (sys/binfmt/). More...

Functions

int binfmt_load (struct proc *proc, const char *path, struct proc **ref)
 Loads a program into a process, for execve().
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.

Function Documentation

◆ binfmt_elf_check()

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.

It is checked before the process's old program is destroyed.

Parameters
vnodethe file
Returns
0 if it is, or -ENOEXEC

Definition at line 199 of file elf.c.

References binfmt_elf_check(), elf32_hdr::e_ident, elf32_hdr::e_machine, EI_CLASS, EI_MAG0, EI_MAG1, EI_MAG2, EI_MAG3, ELF_CLASS, ELF_MACHINE, ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, and vfs_read().

Referenced by binfmt_elf_check().

◆ binfmt_elf_load()

int binfmt_elf_load ( struct proc * proc,
const char * path,
struct vnode * vnode )

Loads an ELF program into a process.

Parameters
procthe process, whose address space is empty
pathnot used
vnodethe program's file
Returns
0, -EINVAL or -ENOMEM

Definition at line 227 of file elf.c.

References binfmt_elf_load(), and binfmt_elf_load_segments().

Referenced by binfmt_elf_load().

◆ binfmt_load()

int binfmt_load ( struct proc * proc,
const char * path,
struct proc ** ref )

Loads a program into a process, for execve().

The file must be a regular file that the process may execute, in a format the kernel knows.

Parameters
procthe process, whose memory the program replaces
paththe program's path
refnot used
Returns
0, or a negative errno: -ENOENT, -EACCES, -ENOEXEC (no format knows the file) or the loader's

Definition at line 124 of file binfmt.c.

References binfmt_fmt_load(), binfmt_list, binfmt_load(), memset(), vnode::mode, NR_BINFMT, NULL, PROC_UIO, vfs_access(), vfs_close(), vfs_lookup(), and VFS_X.

Referenced by binfmt_load(), kmain(), and proc_execve().