HomeCore 0.1.3 (07b5544)
Bare-metal personal computer firmware for Cortex-M
Loading...
Searching...
No Matches

Per-session execution state shared by the shell and libc path hooks. More...

Collaboration diagram for Sessions:

Data Structures

struct  session_t
 Execution state of one shell session. More...
 

Functions

int session_init (session_t *session, const user_t *user)
 Initialize a session for a user in the user's home directory.
 
int session_chdir (session_t *session, const char *path)
 Change a session's working directory.
 
session_t * session_current (void)
 Get the current session.
 
session_t * session_set_current (session_t *session)
 Make a session current.
 

Detailed Description

Per-session execution state shared by the shell and libc path hooks.

One session is current at a time. It is stored in a single global pointer, which a future scheduler must make task-local. The default session runs as root with working directory /. These functions are not interrupt-safe.

Function Documentation

◆ session_init()

int session_init ( session_t *  session,
const user_t *  user 
)

Initialize a session for a user in the user's home directory.

Parameters
[out]sessionSession to initialize. Unchanged on failure.
userIdentity with a name and an absolute home directory. Must outlive the session.
Return values
0The session is initialized with status 0.
-1errno is EINVAL for a missing argument, name, or home, or a relative home; otherwise it is set by session_chdir().

◆ session_chdir()

int session_chdir ( session_t *  session,
const char *  path 
)

Change a session's working directory.

Parameters
sessionSession to update.
pathAbsolute path, or a path relative to the current directory.
Return values
0cwd now names the directory.
-1cwd is unchanged; errno is EINVAL, ENOENT, ENOTDIR, or ENAMETOOLONG.

◆ session_current()

session_t * session_current ( void  )

Get the current session.

libc path operations resolve relative paths against this session.

Returns
The current session; never NULL.

◆ session_set_current()

session_t * session_set_current ( session_t *  session)

Make a session current.

The pointer is retained, so the session must stay valid while it is current.

Parameters
sessionSession to activate, or NULL for the default root session.
Returns
The previously current session, to restore later.