PatchworkOS  c9fea19
A non-POSIX operating system.
Loading...
Searching...
No Matches
sysfs.h File Reference
#include <kernel/fs/dentry.h>
#include <kernel/fs/inode.h>
#include <sys/io.h>
Include dependency graph for sysfs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SYSFS_NAME   "sysfs"
 

Typedefs

typedef struct file file_t
 
typedef struct file_ops file_ops_t
 
typedef struct superblock superblock_t
 
typedef struct superblock_ops superblock_ops_t
 

Functions

void sysfs_init (void)
 Initializes the SysFS.
 
dentry_tsysfs_get_dev (void)
 Gets the default SysFS directory.
 
mount_tsysfs_mount_new (const path_t *parent, const char *name, namespace_t *ns, mount_flags_t flags, mode_t mode, const superblock_ops_t *superblockOps)
 Mount a new instance of SysFS.
 
dentry_tsysfs_dir_new (dentry_t *parent, const char *name, const inode_ops_t *inodeOps, void *private)
 Create a new directory inside a mounted SysFS instance.
 
dentry_tsysfs_file_new (dentry_t *parent, const char *name, const inode_ops_t *inodeOps, const file_ops_t *fileOps, void *private)
 Create a new file inside a mounted SysFS instance.
 

Macro Definition Documentation

◆ SYSFS_NAME

#define SYSFS_NAME   "sysfs"

Definition at line 23 of file sysfs.h.

Typedef Documentation

◆ file_t

typedef struct file file_t

Definition at line 7 of file sysfs.h.

◆ file_ops_t

typedef struct file_ops file_ops_t

Definition at line 8 of file sysfs.h.

◆ superblock_t

typedef struct superblock superblock_t

Definition at line 10 of file sysfs.h.

◆ superblock_ops_t

typedef struct superblock_ops superblock_ops_t

Definition at line 11 of file sysfs.h.

Function Documentation

◆ sysfs_init()

void sysfs_init ( void  )

Initializes the SysFS.

Definition at line 82 of file sysfs.c.

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

◆ sysfs_get_dev()

dentry_t * sysfs_get_dev ( void  )

Gets the default SysFS directory.

The default SysFS directory is the root of the /dev mount. The /dev directory is for devices or "other" resources which may not warrant an entire dedicated filesystem.

Returns
A reference to the /dev SysFS directory.

Definition at line 99 of file sysfs.c.

◆ sysfs_mount_new()

mount_t * sysfs_mount_new ( const path_t parent,
const char *  name,
namespace_t ns,
mount_flags_t  flags,
mode_t  mode,
const superblock_ops_t superblockOps 
)

Mount a new instance of SysFS.

Used to, for example, create /dev, /proc and directories whose contents should only be visible within a specific namespace.

If parent is NULL, then the sysfs instance will be mounted to a already existing directory in the root of the namespace. If it is not NULL, then it must point to a sysfs directory, a new directory of the name name will be created inside it and the SysFS instance will be mounted there.

Parameters
parentThe parent directory to mount the SysFS in. If NULL, the root of the namespace is used.
nameThe name of the directory to mount the SysFS in.
nsThe namespace to mount the SysFS in, or NULL to use the current process's namespace.
flagsMount flags.
modeThe maximum allowed permissions for files/directories opened under this mount.
superblockOpsThe superblock operations for the new SysFS instance, can be NULL.
Returns
On success, the mounted SysFS instance. On failure, NULL and errno is set.

Definition at line 104 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 inode_ops_t inodeOps,
void *  private 
)

Create a new directory inside a mounted SysFS instance.

Used to, for example, create a new directory for a device or resource inside /dev or /proc.

Parameters
parentThe parent directory, if NULL then sysfs_get_dev() is used.
nameThe name of the new directory.
inodeOpsThe inode operations for the new directory, can be NULL.
privatePrivate data associated with the new directory, can be NULL, will be stored in the inode.
Returns
On success, the new SysFS directory. On failure, NULL and errno is set.

Definition at line 177 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 inode_ops_t inodeOps,
const file_ops_t fileOps,
void *  private 
)

Create a new file inside a mounted SysFS instance.

Used to, for example, create a new file for a device or resource inside /dev or /proc.

Parameters
parentThe parent directory, if NULL then sysfs_get_dev() is used.
nameThe name of the new file.
inodeOpsThe inode operations for the new file, can be NULL.
fileOpsThe file operations for the new file, can be NULL.
privatePrivate data associated with the new file, can be NULL.
Returns
On success, the new SysFS file. On failure, NULL and errno is set.

Definition at line 216 of file sysfs.c.

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