MentOS
0.8.0
The Mentoring Operating System
|
System Call handler definition. More...
Go to the source code of this file.
Functions | |
void | syscall_init (void) |
Initialize the system calls. | |
void | syscall_handler (pt_regs *f) |
Handler for the system calls. More... | |
pt_regs * | get_current_interrupt_stack_frame (void) |
Returns the current interrupt stack frame. More... | |
void | sys_exit (int exit_code) |
ssize_t | sys_read (int fd, void *buf, size_t nbytes) |
Read data from a file descriptor. More... | |
ssize_t | sys_write (int fd, const void *buf, size_t nbytes) |
Write data into a file descriptor. More... | |
off_t | sys_lseek (int fd, off_t offset, int whence) |
Repositions the file offset inside a file. More... | |
int | sys_open (const char *pathname, int flags, mode_t mode) |
Given a pathname for a file, open() returns a file descriptor, a small, nonnegative integer for use in subsequent system calls. More... | |
int | sys_close (int fd) |
int | sys_unlink (const char *path) |
Delete a name and possibly the file it refers to. More... | |
pid_t | sys_waitpid (pid_t pid, int *status, int options) |
Suspends execution of the calling thread until a child specified by pid argument has changed state. More... | |
int | sys_execve (pt_regs *f) |
Replaces the current process image with a new process image. More... | |
int | sys_chdir (char const *path) |
Changes the working directory. More... | |
int | sys_fchdir (int fd) |
Changes the working directory. More... | |
pid_t | sys_getpid (void) |
Returns the process ID (PID) of the calling process. More... | |
pid_t | sys_getsid (pid_t pid) |
Return session id of the given process. If pid == 0 return the SID of the calling process If pid != 0 return the SID corresponding to the process having identifier == pid. More... | |
pid_t | sys_setsid (void) |
creates a new session if the calling process is not a process group leader. The calling process is the leader of the new session (i.e., its session ID is made the same as its process ID). The calling process also becomes the process group leader of a new process group in the session (i.e., its process group ID is made the same as its process ID). More... | |
pid_t | sys_getpgid (pid_t pid) |
returns the Process Group ID (PGID) of the process specified by pid. If pid is zero, the process ID of the calling process is used. More... | |
int | sys_setpgid (pid_t pid, pid_t pgid) |
Sets the Process Group ID (PGID) of the process specified by pid. If pid is zero, the process ID of the calling process is used. More... | |
gid_t | sys_getgid (void) |
returns the real group ID of the calling process. More... | |
int | sys_setgid (gid_t gid) |
sets the group ID of the calling process. More... | |
gid_t | sys_getegid (void) |
returns the effective group ID of the calling process. More... | |
int | sys_setregid (gid_t rgid, gid_t egid) |
sets the real and effective group ID of the calling process. More... | |
pid_t | sys_getppid (void) |
Returns the parent process ID (PPID) of the calling process. More... | |
uid_t | sys_getuid (void) |
Returns the real User ID (UID) of the calling process. More... | |
int | sys_setuid (uid_t uid) |
Tries to set the User ID (UID) of the calling process. More... | |
uid_t | sys_geteuid (void) |
Returns the effective User ID (UID) of the calling process. More... | |
int | sys_setreuid (uid_t ruid, uid_t euid) |
Set the real and effective User ID (UID) of the calling process. More... | |
int | sys_nice (int increment) |
Adds the increment to the priority value of the task. More... | |
int | sys_reboot (int magic1, int magic2, unsigned int cmd, void *arg) |
Reboots the system, or enables/disables the reboot keystroke. More... | |
char * | sys_getcwd (char *buf, size_t size) |
Get current working directory. More... | |
pid_t | sys_fork (pt_regs *f) |
Clone the calling process, but without copying the whole address space. The calling process is suspended until the new process exits or is replaced by a call to ‘execve’. More... | |
int | sys_stat (const char *path, stat_t *buf) |
Stat the file at the given path. More... | |
int | sys_fstat (int fd, stat_t *buf) |
Retrieves information about the file at the given location. More... | |
int | sys_mkdir (const char *path, mode_t mode) |
Creates a new directory at the given path. More... | |
int | sys_rmdir (const char *path) |
Removes the given directory. More... | |
int | sys_creat (const char *path, mode_t mode) |
Creates a new file or rewrite an existing one. More... | |
int | sys_readlink (const char *path, char *buffer, size_t bufsize) |
Read the symbolic link, if present. More... | |
int | sys_symlink (const char *linkname, const char *path) |
Creates a symbolic link. More... | |
ssize_t | sys_getdents (int fd, dirent_t *dirp, unsigned int count) |
time_t | sys_time (time_t *time) |
Returns the current time. More... | |
System Call handler definition.
pt_regs* get_current_interrupt_stack_frame | ( | void | ) |
Returns the current interrupt stack frame.
int sys_chdir | ( | char const * | path | ) |
Changes the working directory.
path | The new working directory. |
int sys_close | ( | int | fd | ) |
fd |
int sys_creat | ( | const char * | path, |
mode_t | mode | ||
) |
Creates a new file or rewrite an existing one.
path | path to the file. |
mode | mode for file creation. |
It is equivalent to: open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)
int sys_execve | ( | pt_regs * | f | ) |
Replaces the current process image with a new process image.
f | CPU registers whe calling this function. |
void sys_exit | ( | int | exit_code | ) |
The exit() function causes normal process termination.
exit_code | The exit code. |
int sys_fchdir | ( | int | fd | ) |
Changes the working directory.
fd | File descriptor of the new working directory. |
Clone the calling process, but without copying the whole address space. The calling process is suspended until the new process exits or is replaced by a call to ‘execve’.
f | CPU registers whe calling this function. |
int sys_fstat | ( | int | fd, |
stat_t * | buf | ||
) |
Retrieves information about the file at the given location.
fd | The file descriptor of the file that is being inquired. |
buf | A structure where data about the file will be stored. |
char* sys_getcwd | ( | char * | buf, |
size_t | size | ||
) |
Get current working directory.
buf | The array where the CWD will be copied. |
size | The size of the array. |
Provide access to the directory entries.
fd | The file descriptor of the directory for which we accessing the entries. |
dirp | The buffer where de data should be placed. |
count | The size of the buffer. |
gid_t sys_getegid | ( | void | ) |
returns the effective group ID of the calling process.
uid_t sys_geteuid | ( | void | ) |
Returns the effective User ID (UID) of the calling process.
gid_t sys_getgid | ( | void | ) |
returns the real group ID of the calling process.
returns the Process Group ID (PGID) of the process specified by pid. If pid is zero, the process ID of the calling process is used.
pid | process of which we want to know the PGID. |
pid_t sys_getpid | ( | void | ) |
Returns the process ID (PID) of the calling process.
pid_t sys_getppid | ( | void | ) |
Returns the parent process ID (PPID) of the calling process.
Return session id of the given process. If pid == 0 return the SID of the calling process If pid != 0 return the SID corresponding to the process having identifier == pid.
pid | process identifier from wich we want the SID |
uid_t sys_getuid | ( | void | ) |
Returns the real User ID (UID) of the calling process.
Repositions the file offset inside a file.
fd | The file descriptor of the file. |
offset | The offest to use for the operation. |
whence | The type of operation. |
int sys_mkdir | ( | const char * | path, |
mode_t | mode | ||
) |
Creates a new directory at the given path.
path | The path of the new directory. |
mode | The permission of the new directory. |
int sys_nice | ( | int | increment | ) |
Adds the increment to the priority value of the task.
increment | The modifier to apply to the nice value. |
int sys_open | ( | const char * | pathname, |
int | flags, | ||
mode_t | mode | ||
) |
Given a pathname for a file, open() returns a file descriptor, a small, nonnegative integer for use in subsequent system calls.
pathname | A pathname for a file. |
flags | Used to set the file status flags and file access modes of the open file description. |
mode | Specifies the file mode bits be applied when a new file is created. |
Read data from a file descriptor.
fd | The file descriptor. |
buf | The buffer. |
nbytes | The number of bytes to read. |
int sys_readlink | ( | const char * | path, |
char * | buffer, | ||
size_t | bufsize | ||
) |
Read the symbolic link, if present.
path | the file for which we want to read the symbolic link information. |
buffer | the buffer where we will store the symbolic link path. |
bufsize | the size of the buffer. |
int sys_reboot | ( | int | magic1, |
int | magic2, | ||
unsigned int | cmd, | ||
void * | arg | ||
) |
Reboots the system, or enables/disables the reboot keystroke.
magic1 | fails (with the error EINVAL) unless equals LINUX_REBOOT_MAGIC1. |
magic2 | fails (with the error EINVAL) unless equals LINUX_REBOOT_MAGIC2. |
cmd | The command to send to the reboot. |
arg | Argument passed with some specific commands. |
int sys_rmdir | ( | const char * | path | ) |
Removes the given directory.
path | The path to the directory to remove. |
int sys_setgid | ( | gid_t | gid | ) |
sets the group ID of the calling process.
gid | group id |
Sets the Process Group ID (PGID) of the process specified by pid. If pid is zero, the process ID of the calling process is used.
pid | process of which we want to set the PGID. |
pgid | the PGID we want to set. |
sets the real and effective group ID of the calling process.
rgid | real group id |
egid | effective group id |
Set the real and effective User ID (UID) of the calling process.
ruid | the new real User ID. |
euid | the new effective User ID. |
pid_t sys_setsid | ( | void | ) |
creates a new session if the calling process is not a process group leader. The calling process is the leader of the new session (i.e., its session ID is made the same as its process ID). The calling process also becomes the process group leader of a new process group in the session (i.e., its process group ID is made the same as its process ID).
int sys_setuid | ( | uid_t | uid | ) |
Tries to set the User ID (UID) of the calling process.
uid | the new User ID. |
int sys_stat | ( | const char * | path, |
stat_t * | buf | ||
) |
Stat the file at the given path.
path | Path to the file for which we are retrieving the statistics. |
buf | Buffer where we are storing the statistics. |
int sys_symlink | ( | const char * | linkname, |
const char * | path | ||
) |
Creates a symbolic link.
linkname | the name of the link. |
path | the entity it is linking to. |
Returns the current time.
time | Where the time should be stored. |
int sys_unlink | ( | const char * | path | ) |
Delete a name and possibly the file it refers to.
path | A pathname for a file. |
Suspends execution of the calling thread until a child specified by pid argument has changed state.
pid | The pid to wait. |
status | If not NULL, store status information here. |
options | Determines the wait behaviour. |
Write data into a file descriptor.
fd | The file descriptor. |
buf | The buffer collecting data to written. |
nbytes | The number of bytes to write. |
void syscall_handler | ( | pt_regs * | f | ) |
Handler for the system calls.
f | The interrupt stack frame. |