PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
Current Working Directory

Current Working Directory. More...

Collaboration diagram for Current Working Directory:

Detailed Description

Current Working Directory.

The current working directory (CWD) is a per-process structure to track the current location in the filesystem for the process.

Data Structures

struct  cwd_t
 

Functions

void cwd_init (cwd_t *cwd)
 Initialize a CWD structure.
 
void cwd_deinit (cwd_t *cwd)
 Deinitialize a CWD structure.
 
path_t cwd_get (cwd_t *cwd)
 Get the current working directory.
 
void cwd_set (cwd_t *cwd, const path_t *newPath)
 Set the current working directory.
 
void cwd_clear (cwd_t *cwd)
 Clear the current working directory.
 

Function Documentation

◆ cwd_init()

void cwd_init ( cwd_t cwd)

Initialize a CWD structure.

Will by default lazily resolve to the root path of the kernel process's namespace until set to another path.

Parameters
cwdThe CWD structure to initialize.

Definition at line 5 of file cwd.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cwd_deinit()

void cwd_deinit ( cwd_t cwd)

Deinitialize a CWD structure.

Parameters
cwdThe CWD structure to deinitialize.

Definition at line 11 of file cwd.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cwd_get()

path_t cwd_get ( cwd_t cwd)

Get the current working directory.

Note
If the cwd has not been set, this will return the root path of the kernel process's namespace. This is to solve a circular dependency where the kernel process needs to be initialized before the vfs.
Parameters
cwdThe CWD structure.
Returns
The current working directory path.

Definition at line 18 of file cwd.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cwd_set()

void cwd_set ( cwd_t cwd,
const path_t newPath 
)

Set the current working directory.

Parameters
cwdThe CWD structure.
newPathThe new current working directory.

Definition at line 44 of file cwd.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cwd_clear()

void cwd_clear ( cwd_t cwd)

Clear the current working directory.

Needed as a process might have its working directory inside its own /proc/[pid] directory which, since that directory holds references to the process itself, would result in a memory leak.

Parameters
cwdThe CWD structure.

Definition at line 51 of file cwd.c.

Here is the call graph for this function:
Here is the caller graph for this function: