PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches
System Filesystem

System Filesystem. More...

Collaboration diagram for System Filesystem:

Detailed Description

System Filesystem.

The sysfs is a virtual filesystem that provides information about devices and kernel modules.

Data Structures

struct  sysfs_file_desc_t
 Descriptor for batch file creation. More...
 

Macros

#define SYSFS_NAME   "sysfs"
 The name of the system filesystem.
 

Functions

void sysfs_init (void)
 Initializes the sysfs and mount an instance at /sys.
 
dentry_tsysfs_dir_new (dentry_t *parent, const char *name, const vnode_ops_t *vnodeOps, void *data)
 Create a new directory inside a mounted sysfs instance.
 
dentry_tsysfs_file_new (dentry_t *parent, const char *name, const vnode_ops_t *vnodeOps, const file_ops_t *fileOps, void *data)
 Create a new file inside a mounted sysfs instance.
 
dentry_tsysfs_symlink_new (dentry_t *parent, const char *name, const vnode_ops_t *vnodeOps, void *data)
 Create a new symbolic link inside a mounted sysfs instance.
 
uint64_t sysfs_files_new (list_t *out, dentry_t *parent, const sysfs_file_desc_t *descs)
 Create multiple files in a sysfs directory.
 
void sysfs_files_free (list_t *files)
 Free all files in a list created by sysfs_files_new().
 

Macro Definition Documentation

◆ SYSFS_NAME

#define SYSFS_NAME   "sysfs"

The name of the system filesystem.

Definition at line 26 of file sysfs.h.

Function Documentation

◆ sysfs_init()

void sysfs_init ( void  )

Initializes the sysfs and mount an instance at /sys.

The System Filesystem is one of the few filesystem that will be mounted automatically by the kernel, this is necessary as otherwise user space would be unable to access the fs sysfs directory and thus unable to mount any filesystem.

Definition at line 50 of file sysfs.c.

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

◆ sysfs_dir_new()

dentry_t * sysfs_dir_new ( dentry_t parent,
const char *  name,
const vnode_ops_t vnodeOps,
void *  data 
)

Create a new directory inside a mounted sysfs instance.

Parameters
parentThe parent directory, if NULL then the root is used.
nameThe name of the new directory.
vnodeOpsThe vnode operations for the new directory, can be NULL.
privatePrivate data to store in the vnode of the new directory, can be NULL.
Returns
On success, the new sysfs directory. On failure, NULL and errno is set.

Definition at line 114 of file sysfs.c.

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

◆ sysfs_file_new()

dentry_t * sysfs_file_new ( dentry_t parent,
const char *  name,
const vnode_ops_t vnodeOps,
const file_ops_t fileOps,
void *  data 
)

Create a new file inside a mounted sysfs instance.

Parameters
parentThe parent directory, if NULL then the root is used.
nameThe name of the new file.
vnodeOpsThe vnode operations for the new file, can be NULL.
fileOpsThe file operations for the new file, can be NULL.
privatePrivate data to store in the vnode of the new file, can be NULL.
Returns
On success, the new sysfs file. On failure, NULL and errno is set.

Definition at line 153 of file sysfs.c.

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

◆ sysfs_symlink_new()

dentry_t * sysfs_symlink_new ( dentry_t parent,
const char *  name,
const vnode_ops_t vnodeOps,
void *  data 
)

Create a new symbolic link inside a mounted sysfs instance.

Parameters
parentThe parent directory, if NULL then the root is used.
nameThe name of the new symbolic link.
vnodeOpsThe vnode operations for the new symbolic link.
privatePrivate data to store in the vnode of the new symbolic link, can be NULL.
Returns
On success, the new sysfs symbolic link. On failure, NULL and errno is set.

Definition at line 193 of file sysfs.c.

Here is the call graph for this function:

◆ sysfs_files_new()

uint64_t sysfs_files_new ( list_t out,
dentry_t parent,
const sysfs_file_desc_t descs 
)

Create multiple files in a sysfs directory.

Parameters
outOutput list to store created dentries, can be NULL. The dentries use the otherEntry list entry.
parentThe parent directory, if NULL then the root is used.
descsArray of file descriptors, terminated by an entry with name == NULL.
Returns
On success, the number of files created. On failure, ERR and errno is set.

Definition at line 227 of file sysfs.c.

Here is the call graph for this function:

◆ sysfs_files_free()

void sysfs_files_free ( list_t files)

Free all files in a list created by sysfs_files_new().

Parameters
filesThe list of files to free.

Definition at line 282 of file sysfs.c.

Here is the call graph for this function: