MentOS  0.8.0
The Mentoring Operating System
Functions | Variables
proc_running.c File Reference

Implementaiton of procr filesystem. More...

Functions

static char __procr_get_task_state_char (int state)
 Returns the character identifying the process state. More...
 
static ssize_t __procr_do_cmdline (char *buffer, size_t bufsize, task_struct *task)
 Returns the data for the /proc/<PID>/cmdline file. More...
 
static ssize_t __procr_do_stat (char *buffer, size_t bufsize, task_struct *task)
 Returns the data for the /proc/<PID>/stat file. More...
 
static ssize_t __procr_read (vfs_file_t *file, char *buffer, off_t offset, size_t nbyte)
 Performs a read of files inside the /proc/<PID>/ folder. More...
 
int procr_create_entry_pid (task_struct *entry)
 Create the entire procfs entry tree for the give process. More...
 
int procr_destroy_entry_pid (task_struct *entry)
 Destroy the entire procfs entry tree for the give process. More...
 

Variables

static vfs_sys_operations_t procr_sys_operations
 Filesystem general operations. More...
 
static vfs_file_operations_t procr_fs_operations
 Filesystem file operations. More...
 

Detailed Description

Implementaiton of procr filesystem.

Function Documentation

◆ __procr_do_cmdline()

static ssize_t __procr_do_cmdline ( char *  buffer,
size_t  bufsize,
task_struct task 
)
inlinestatic

Returns the data for the /proc/<PID>/cmdline file.

Parameters
bufferthe buffer where the data should be placed.
bufsizethe size of the buffer.
taskthe task associated with the /proc/<PID> folder.
Returns
size of the written data in buffer.

◆ __procr_do_stat()

static ssize_t __procr_do_stat ( char *  buffer,
size_t  bufsize,
task_struct task 
)
inlinestatic

Returns the data for the /proc/<PID>/stat file.

Parameters
bufferthe buffer where the data should be placed.
bufsizethe size of the buffer.
taskthe task associated with the /proc/<PID> folder.
Returns
size of the written data in buffer.

◆ __procr_get_task_state_char()

static char __procr_get_task_state_char ( int  state)
inlinestatic

Returns the character identifying the process state.

Parameters
statethe process state.
Returns
a character describing the state.

R Running S Sleeping in an interruptible wait D Waiting in uninterruptible disk sleep Z Zombie T Stopped t Tracing stop X Dead

◆ __procr_read()

static ssize_t __procr_read ( vfs_file_t file,
char *  buffer,
off_t  offset,
size_t  nbyte 
)
inlinestatic

Performs a read of files inside the /proc/<PID>/ folder.

Parameters
fileis the /proc/<PID>/ folder, thus, it should be a proc_dir_entry_t data.
bufferbuffer where the read content must be placed.
offsetoffset from which we start reading from the file.
nbytethe number of bytes to read.
Returns
The number of bytes we read.

◆ procr_create_entry_pid()

int procr_create_entry_pid ( task_struct entry)

Create the entire procfs entry tree for the give process.

Parameters
entryPointer to the task_struct of the process.
Returns
0 if succeed, or -errno in case of error.

◆ procr_destroy_entry_pid()

int procr_destroy_entry_pid ( task_struct entry)

Destroy the entire procfs entry tree for the give process.

Parameters
entryPointer to the task_struct of the process.
Returns
0 if succeed, or -errno in case of error.

Variable Documentation

◆ procr_fs_operations

vfs_file_operations_t procr_fs_operations
static
Initial value:
= {
.open_f = NULL,
.unlink_f = NULL,
.close_f = NULL,
.read_f = __procr_read,
.write_f = NULL,
.lseek_f = NULL,
.stat_f = NULL,
.ioctl_f = NULL,
.getdents_f = NULL,
.readlink_f = NULL,
}
static ssize_t __procr_read(vfs_file_t *file, char *buffer, off_t offset, size_t nbyte)
Performs a read of files inside the /proc/<PID>/ folder.
Definition: proc_running.c:377
#define NULL
Define NULL.
Definition: stddef.h:10

Filesystem file operations.

◆ procr_sys_operations

vfs_sys_operations_t procr_sys_operations
static
Initial value:
= {
.mkdir_f = NULL,
.rmdir_f = NULL,
.stat_f = NULL,
.creat_f = NULL,
.symlink_f = NULL,
}

Filesystem general operations.