miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
procfs.c File Reference
#include <miniOS/fs/procfs.h>
#include <miniOS/fs/vfs.h>
#include <miniOS/mm/pmm.h>
#include <miniOS/mm/vmm.h>
#include <miniOS/sched/sched.h>
#include <miniOS/io.h>
#include <string.h>
Include dependency graph for procfs.c:

Macros

#define PROCFS_INO_ROOT   1
#define PROCFS_INO_MEMINFO   2
#define PROCFS_INO_MOUNTS   3
#define PROCFS_INO_STAT   4
#define PROCFS_PID_BASE   0x1000u
#define PROCFS_PID_SHIFT   3u
#define PROCFS_SUB_MASK   ((1u << PROCFS_PID_SHIFT) - 1u)
#define PROCFS_SUB_DIR   0u
#define PROCFS_SUB_STATUS   1u
#define PROCFS_SUB_STAT   2u
#define PROCFS_SUB_CMDLINE   3u
#define PROCFS_SUB_CWD   4u
#define PROCFS_SUB_MAPS   5u

Functions

static uint32_t procfs_pid_ino (uint32_t pid, uint32_t sub)
static int procfs_ino_is_pid (uint32_t ino)
static uint32_t procfs_ino_pid (uint32_t ino)
static uint32_t procfs_ino_sub (uint32_t ino)
static struct threadprocfs_find_thread (uint32_t pid)
static int procfs_generate_mounts (char *buf, uint32_t bufsiz)
static int procfs_generate_meminfo (char *buf, uint32_t bufsiz)
static int procfs_generate_stat_global (char *buf, uint32_t bufsiz)
static char procfs_state_char (thread_state_t s)
static const char * procfs_state_str (thread_state_t s)
static int procfs_generate_status (struct thread *t, char *buf, uint32_t bufsiz)
static int procfs_generate_stat (struct thread *t, char *buf, uint32_t bufsiz)
static int procfs_generate_cmdline (struct thread *t, char *buf, uint32_t bufsiz)
static int procfs_generate_cwd (struct thread *t, char *buf, uint32_t bufsiz)
static int procfs_generate_maps (struct thread *t, char *buf, uint32_t bufsiz)
static int procfs_lookup (const char *path, vfs_inode_info_t *out)
static int procfs_read (uint32_t ino, uint64_t off, void *buf, uint32_t len)
static int procfs_readdir (uint32_t ino, uint64_t *offset, vfs_dirent_cb_t cb, void *ud)
static int procfs_statfs (vfs_statfs_t *out)
static int procfs_unlink (uint32_t parent_ino, const char *name)
static int procfs_rmdir (uint32_t parent_ino, const char *name)
static int procfs_mount (const char *source, const char *target, const void *data)
void procfs_init (void)

Variables

static vfs_ops_t procfs_ops

Macro Definition Documentation

◆ PROCFS_INO_MEMINFO

#define PROCFS_INO_MEMINFO   2

◆ PROCFS_INO_MOUNTS

#define PROCFS_INO_MOUNTS   3

◆ PROCFS_INO_ROOT

#define PROCFS_INO_ROOT   1

◆ PROCFS_INO_STAT

#define PROCFS_INO_STAT   4

◆ PROCFS_PID_BASE

#define PROCFS_PID_BASE   0x1000u

◆ PROCFS_PID_SHIFT

#define PROCFS_PID_SHIFT   3u

◆ PROCFS_SUB_CMDLINE

#define PROCFS_SUB_CMDLINE   3u

◆ PROCFS_SUB_CWD

#define PROCFS_SUB_CWD   4u

◆ PROCFS_SUB_DIR

#define PROCFS_SUB_DIR   0u

◆ PROCFS_SUB_MAPS

#define PROCFS_SUB_MAPS   5u

◆ PROCFS_SUB_MASK

#define PROCFS_SUB_MASK   ((1u << PROCFS_PID_SHIFT) - 1u)

◆ PROCFS_SUB_STAT

#define PROCFS_SUB_STAT   2u

◆ PROCFS_SUB_STATUS

#define PROCFS_SUB_STATUS   1u

Function Documentation

◆ procfs_find_thread()

struct thread * procfs_find_thread ( uint32_t pid)
static
Here is the caller graph for this function:

◆ procfs_generate_cmdline()

int procfs_generate_cmdline ( struct thread * t,
char * buf,
uint32_t bufsiz )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ procfs_generate_cwd()

int procfs_generate_cwd ( struct thread * t,
char * buf,
uint32_t bufsiz )
static
Here is the caller graph for this function:

◆ procfs_generate_maps()

int procfs_generate_maps ( struct thread * t,
char * buf,
uint32_t bufsiz )
static
Here is the caller graph for this function:

◆ procfs_generate_meminfo()

int procfs_generate_meminfo ( char * buf,
uint32_t bufsiz )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ procfs_generate_mounts()

int procfs_generate_mounts ( char * buf,
uint32_t bufsiz )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ procfs_generate_stat()

int procfs_generate_stat ( struct thread * t,
char * buf,
uint32_t bufsiz )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ procfs_generate_stat_global()

int procfs_generate_stat_global ( char * buf,
uint32_t bufsiz )
static
Here is the caller graph for this function:

◆ procfs_generate_status()

int procfs_generate_status ( struct thread * t,
char * buf,
uint32_t bufsiz )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ procfs_init()

void procfs_init ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ procfs_ino_is_pid()

int procfs_ino_is_pid ( uint32_t ino)
static
Here is the caller graph for this function:

◆ procfs_ino_pid()

uint32_t procfs_ino_pid ( uint32_t ino)
static
Here is the caller graph for this function:

◆ procfs_ino_sub()

uint32_t procfs_ino_sub ( uint32_t ino)
static
Here is the caller graph for this function:

◆ procfs_lookup()

int procfs_lookup ( const char * path,
vfs_inode_info_t * out )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ procfs_mount()

int procfs_mount ( const char * source,
const char * target,
const void * data )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ procfs_pid_ino()

uint32_t procfs_pid_ino ( uint32_t pid,
uint32_t sub )
static
Here is the caller graph for this function:

◆ procfs_read()

int procfs_read ( uint32_t ino,
uint64_t off,
void * buf,
uint32_t len )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ procfs_readdir()

int procfs_readdir ( uint32_t ino,
uint64_t * offset,
vfs_dirent_cb_t cb,
void * ud )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ procfs_rmdir()

int procfs_rmdir ( uint32_t parent_ino,
const char * name )
static
Here is the caller graph for this function:

◆ procfs_state_char()

char procfs_state_char ( thread_state_t s)
static
Here is the caller graph for this function:

◆ procfs_state_str()

const char * procfs_state_str ( thread_state_t s)
static
Here is the caller graph for this function:

◆ procfs_statfs()

int procfs_statfs ( vfs_statfs_t * out)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ procfs_unlink()

int procfs_unlink ( uint32_t parent_ino,
const char * name )
static
Here is the caller graph for this function:

Variable Documentation

◆ procfs_ops

vfs_ops_t procfs_ops
static