MOS Source Code
Loading...
Searching...
No Matches
sysfs.c File Reference
+ Include dependency graph for sysfs.c:

Go to the source code of this file.

Classes

struct  sysfs_file_t
 

Macros

#define pr_fmt(fmt)
 

Functions

static void sysfs_do_register (sysfs_dir_t *sysfs_dir)
 
static u64 sysfs_get_ino (void)
 
void sysfs_register (sysfs_dir_t *dir)
 Register a sysfs directory.
 
static void sysfs_expand_buffer (sysfs_file_t *buffer, size_t new_npages)
 
ssize_t sysfs_printf (sysfs_file_t *file, const char *fmt,...)
 
ssize_t sysfs_put_data (sysfs_file_t *file, const void *data, size_t count)
 
void sysfs_file_set_data (sysfs_file_t *file, void *data)
 
voidsysfs_file_get_data (sysfs_file_t *file)
 
sysfs_item_tsysfs_file_get_item (sysfs_file_t *file)
 
static bool sysfs_fops_open (inode_t *inode, file_t *file, bool created)
 
static void sysfs_fops_release (file_t *file)
 
static __nodiscard bool sysfs_file_ensure_ready (const file_t *file)
 
static ssize_t sysfs_fops_read (const file_t *file, void *buf, size_t size, off_t offset)
 
static ssize_t sysfs_fops_write (const file_t *file, const void *buf, size_t size, off_t offset)
 
static off_t sysfs_fops_seek (file_t *file, off_t offset, io_seek_whence_t whence)
 
bool sysfs_fops_mmap (file_t *file, vmap_t *vmap, off_t offset)
 
bool sysfs_fops_munmap (file_t *file, vmap_t *vmap, bool *unmapped)
 
static void sysfs_iops_iterate_dir (dentry_t *dentry, vfs_listdir_state_t *state, dentry_iterator_op add_record)
 
static bool sysfs_iops_lookup (inode_t *dir, dentry_t *dentry)
 
static bool sysfs_iops_create (inode_t *dir, dentry_t *dentry, file_type_t type, file_perm_t perm)
 
static dentry_tsysfs_fsop_mount (filesystem_t *fs, const char *dev, const char *options)
 
inode_tsysfs_create_inode (file_type_t type, void *data)
 
void sysfs_register_file (sysfs_dir_t *sysfs_dir, sysfs_item_t *item)
 Register an entry in a sysfs directory.
 
 MOS_INIT (VFS, register_sysfs)
 

Variables

static list_head sysfs_dirs = LIST_HEAD_INIT(sysfs_dirs)
 
static filesystem_t fs_sysfs
 
static superblock_tsysfs_sb = NULL
 
static const file_ops_t sysfs_dir_file_ops = { 0 }
 
static const file_ops_t sysfs_file_ops
 
static const inode_ops_t sysfs_dir_i_ops
 
static const file_perm_t sysfs_dir_perm = PERM_READ | PERM_EXEC
 

Macro Definition Documentation

◆ pr_fmt

#define pr_fmt ( fmt)
Value:
"sysfs: " fmt
u32 const char * fmt
Definition assert.h:36

Definition at line 3 of file sysfs.c.

Function Documentation

◆ sysfs_do_register()

static void sysfs_do_register ( sysfs_dir_t * sysfs_dir)
static

< for convenience

Definition at line 360 of file sysfs.c.

Referenced by sysfs_register().

+ Here is the call graph for this function:

◆ sysfs_get_ino()

static u64 sysfs_get_ino ( void )
static

Definition at line 42 of file sysfs.c.

Referenced by MOS_INIT(), sysfs_create_inode(), sysfs_do_register(), and sysfs_register_file().

◆ sysfs_register()

void sysfs_register ( sysfs_dir_t * entry)

Register a sysfs directory.

Parameters
entrythe sysfs directory to register

Definition at line 48 of file sysfs.c.

+ Here is the call graph for this function:

◆ sysfs_expand_buffer()

static void sysfs_expand_buffer ( sysfs_file_t * buffer,
size_t new_npages )
static

Definition at line 57 of file sysfs.c.

Referenced by sysfs_printf(), and sysfs_put_data().

+ Here is the call graph for this function:

◆ sysfs_printf()

◆ sysfs_put_data()

ssize_t sysfs_put_data ( sysfs_file_t * file,
const void * data,
size_t count )

Definition at line 93 of file sysfs.c.

+ Here is the call graph for this function:

◆ sysfs_file_set_data()

void sysfs_file_set_data ( sysfs_file_t * file,
void * data )

Definition at line 105 of file sysfs.c.

Referenced by mmstat_sysfs_phyframe_stat_store(), and mmstat_sysfs_store_pid().

◆ sysfs_file_get_data()

void * sysfs_file_get_data ( sysfs_file_t * file)

◆ sysfs_file_get_item()

sysfs_item_t * sysfs_file_get_item ( sysfs_file_t * file)

Definition at line 115 of file sysfs.c.

Referenced by acpi_sysfs_mmap().

◆ sysfs_fops_open()

static bool sysfs_fops_open ( inode_t * inode,
file_t * file,
bool created )
static

Definition at line 120 of file sysfs.c.

◆ sysfs_fops_release()

static void sysfs_fops_release ( file_t * file)
static

Definition at line 130 of file sysfs.c.

+ Here is the call graph for this function:

◆ sysfs_file_ensure_ready()

static __nodiscard bool sysfs_file_ensure_ready ( const file_t * file)
static

Definition at line 139 of file sysfs.c.

Referenced by sysfs_fops_mmap(), sysfs_fops_read(), and sysfs_fops_seek().

◆ sysfs_fops_read()

static ssize_t sysfs_fops_read ( const file_t * file,
void * buf,
size_t size,
off_t offset )
static

Definition at line 151 of file sysfs.c.

+ Here is the call graph for this function:

◆ sysfs_fops_write()

static ssize_t sysfs_fops_write ( const file_t * file,
const void * buf,
size_t size,
off_t offset )
static

Definition at line 171 of file sysfs.c.

◆ sysfs_fops_seek()

static off_t sysfs_fops_seek ( file_t * file,
off_t offset,
io_seek_whence_t whence )
static

Definition at line 179 of file sysfs.c.

+ Here is the call graph for this function:

◆ sysfs_fops_mmap()

bool sysfs_fops_mmap ( file_t * file,
vmap_t * vmap,
off_t offset )

Definition at line 201 of file sysfs.c.

+ Here is the call graph for this function:

◆ sysfs_fops_munmap()

bool sysfs_fops_munmap ( file_t * file,
vmap_t * vmap,
bool * unmapped )

Definition at line 223 of file sysfs.c.

◆ sysfs_iops_iterate_dir()

static void sysfs_iops_iterate_dir ( dentry_t * dentry,
vfs_listdir_state_t * state,
dentry_iterator_op add_record )
static

Definition at line 244 of file sysfs.c.

+ Here is the call graph for this function:

◆ sysfs_iops_lookup()

static bool sysfs_iops_lookup ( inode_t * dir,
dentry_t * dentry )
static

Definition at line 281 of file sysfs.c.

+ Here is the call graph for this function:

◆ sysfs_iops_create()

static bool sysfs_iops_create ( inode_t * dir,
dentry_t * dentry,
file_type_t type,
file_perm_t perm )
static

Definition at line 307 of file sysfs.c.

+ Here is the call graph for this function:

◆ sysfs_fsop_mount()

static dentry_t * sysfs_fsop_mount ( filesystem_t * fs,
const char * dev,
const char * options )
static

Definition at line 334 of file sysfs.c.

+ Here is the call graph for this function:

◆ sysfs_create_inode()

inode_t * sysfs_create_inode ( file_type_t type,
void * data )

Definition at line 376 of file sysfs.c.

Referenced by ipc_sysfs_create_ino().

+ Here is the call graph for this function:

◆ sysfs_register_file()

void sysfs_register_file ( sysfs_dir_t * sysfs_dir,
sysfs_item_t * item )

Register an entry in a sysfs directory.

Parameters
sysfs_dirthe sysfs directory to register the item in
itemthe sysfs item to register

Definition at line 383 of file sysfs.c.

Referenced by register_sysfs_acpi_node(), register_sysfs_acpi_rsdp(), sysfs_do_register(), and sysfs_register_root_file().

+ Here is the call graph for this function:

◆ MOS_INIT()

MOS_INIT ( VFS ,
register_sysfs  )

Definition at line 423 of file sysfs.c.

+ Here is the call graph for this function:

Variable Documentation

◆ sysfs_dirs

list_head sysfs_dirs = LIST_HEAD_INIT(sysfs_dirs)
static

Definition at line 35 of file sysfs.c.

Referenced by sysfs_register().

◆ fs_sysfs

static filesystem_t fs_sysfs
static
Initial value:
= {
.list_node = LIST_HEAD_INIT(fs_sysfs.list_node),
.name = "sysfs",
.mount = sysfs_fsop_mount,
}
#define LIST_HEAD_INIT(container)
Definition list.h:38
static filesystem_t fs_sysfs
Definition sysfs.c:36
static dentry_t * sysfs_fsop_mount(filesystem_t *fs, const char *dev, const char *options)
Definition sysfs.c:334

Definition at line 36 of file sysfs.c.

Referenced by MOS_INIT(), and sysfs_fsop_mount().

◆ sysfs_sb

◆ sysfs_dir_file_ops

const file_ops_t sysfs_dir_file_ops = { 0 }
static

Definition at line 38 of file sysfs.c.

Referenced by MOS_INIT(), and sysfs_do_register().

◆ sysfs_file_ops

const file_ops_t sysfs_file_ops
static
Initial value:
= {
.open = sysfs_fops_open,
.release = sysfs_fops_release,
.read = sysfs_fops_read,
.write = sysfs_fops_write,
.seek = sysfs_fops_seek,
.mmap = sysfs_fops_mmap,
.munmap = sysfs_fops_munmap,
}
static off_t sysfs_fops_seek(file_t *file, off_t offset, io_seek_whence_t whence)
Definition sysfs.c:179
bool sysfs_fops_munmap(file_t *file, vmap_t *vmap, bool *unmapped)
Definition sysfs.c:223
static ssize_t sysfs_fops_write(const file_t *file, const void *buf, size_t size, off_t offset)
Definition sysfs.c:171
static void sysfs_fops_release(file_t *file)
Definition sysfs.c:130
static bool sysfs_fops_open(inode_t *inode, file_t *file, bool created)
Definition sysfs.c:120
bool sysfs_fops_mmap(file_t *file, vmap_t *vmap, off_t offset)
Definition sysfs.c:201
static ssize_t sysfs_fops_read(const file_t *file, void *buf, size_t size, off_t offset)
Definition sysfs.c:151

Definition at line 234 of file sysfs.c.

Referenced by sysfs_register_file().

◆ sysfs_dir_i_ops

const inode_ops_t sysfs_dir_i_ops
static
Initial value:
= {
.iterate_dir = sysfs_iops_iterate_dir,
.lookup = sysfs_iops_lookup,
.newfile = sysfs_iops_create,
}
static void sysfs_iops_iterate_dir(dentry_t *dentry, vfs_listdir_state_t *state, dentry_iterator_op add_record)
Definition sysfs.c:244
static bool sysfs_iops_create(inode_t *dir, dentry_t *dentry, file_type_t type, file_perm_t perm)
Definition sysfs.c:307
static bool sysfs_iops_lookup(inode_t *dir, dentry_t *dentry)
Definition sysfs.c:281

Definition at line 328 of file sysfs.c.

Referenced by MOS_INIT(), and sysfs_do_register().

◆ sysfs_dir_perm

const file_perm_t sysfs_dir_perm = PERM_READ | PERM_EXEC
static

Definition at line 358 of file sysfs.c.

Referenced by sysfs_do_register().