|
MentOS
0.8.0
The Mentoring Operating System
|
Proc file system implementation. More...
Classes | |
| struct | procfs_file_t |
| Information concerning a file. More... | |
| struct | procfs_t |
| The details regarding the filesystem. More... | |
Macros | |
| #define | __DEBUG_HEADER__ "[PROCFS]" |
| Change header. | |
| #define | __DEBUG_LEVEL__ LOGLEVEL_NOTICE |
| Set log level. | |
| #define | PROCFS_NAME_MAX 255U |
| Maximum length of name in PROCFS. | |
| #define | PROCFS_MAX_FILES 1024U |
| Maximum number of files in PROCFS. | |
| #define | PROCFS_MAGIC_NUMBER 0xBF |
| The magic number used to check if the procfs file is valid. | |
Typedefs | |
| typedef struct procfs_file_t | procfs_file_t |
| Information concerning a file. | |
| typedef struct procfs_t | procfs_t |
| The details regarding the filesystem. More... | |
Functions | |
| static int | procfs_mkdir (const char *path, mode_t mode) |
| Creates a new directory. More... | |
| static int | procfs_rmdir (const char *path) |
| Removes a directory. More... | |
| static int | procfs_stat (const char *path, stat_t *stat) |
| Retrieves information concerning the file at the given position. More... | |
| static vfs_file_t * | procfs_open (const char *path, int flags, mode_t mode) |
| Open the file at the given path and returns its file descriptor. More... | |
| static int | procfs_unlink (const char *path) |
| Deletes the file at the given path. More... | |
| static int | procfs_close (vfs_file_t *file) |
| Closes the given file. More... | |
| static ssize_t | procfs_read (vfs_file_t *file, char *buffer, off_t offset, size_t nbyte) |
| Reads from the file identified by the file descriptor. More... | |
| static ssize_t | procfs_write (vfs_file_t *file, const void *buffer, off_t offset, size_t nbyte) |
| Writes the given content inside the file. More... | |
| static off_t | procfs_lseek (vfs_file_t *file, off_t offset, int whence) |
| Repositions the file offset inside a file. More... | |
| static int | procfs_fstat (vfs_file_t *file, stat_t *stat) |
| Retrieves information concerning the file at the given position. More... | |
| static int | procfs_ioctl (vfs_file_t *file, int request, void *data) |
| Perform the I/O control operation specified by REQUEST on FD. One argument may follow; its presence and type depend on REQUEST. More... | |
| static ssize_t | procfs_getdents (vfs_file_t *file, dirent_t *dirp, off_t doff, size_t count) |
| Reads contents of the directories to a dirent buffer, updating the offset and returning the number of written bytes in the buffer, it assumes that all paths are well-formed. More... | |
| static bool_t | procfs_check_file (procfs_file_t *procfs_file) |
| Checks if the file is a valid PROCFS file. More... | |
| static procfs_file_t * | procfs_get_file (list_head *entry) |
| Returns the PROCFS file associated with the given list entry. More... | |
| static procfs_file_t * | procfs_find_entry_path (const char *path) |
| Finds the PROCFS file at the given path. More... | |
| static procfs_file_t * | procfs_find_entry_inode (uint32_t inode) |
| Finds the PROCFS file with the given inode. More... | |
| static int | procfs_find_inode (const char *path) |
| Finds the inode associated with a PROCFS file at the given path. More... | |
| static int | procfs_get_free_inode (void) |
| Finds a free inode. More... | |
| static int | procfs_check_if_empty (const char *path) |
| Checks if the PROCFS directory at the given path is empty. More... | |
| static procfs_file_t * | procfs_create_file (const char *path, unsigned flags) |
| Creates a new PROCFS file. More... | |
| static int | procfs_destroy_file (procfs_file_t *procfs_file) |
| Destroyes the given PROCFS file. More... | |
| static vfs_file_t * | procfs_create_file_struct (procfs_file_t *procfs_file) |
| Creates a VFS file, from a PROCFS file. More... | |
| static void | dump_procfs (void) |
| Dumps on debugging output the PROCFS. | |
| static int | __procfs_stat (procfs_file_t *file, stat_t *stat) |
| Saves the information concerning the file. More... | |
| static vfs_file_t * | procfs_mount (vfs_file_t *block_device, const char *path) |
| Mounts the block device as a procfs filesystem. More... | |
| static vfs_file_t * | procfs_mount_callback (const char *path, const char *device) |
| Mounts the filesystem at the given path. More... | |
| int | procfs_module_init (void) |
| Initialize the procfs filesystem. More... | |
| int | procfs_cleanup_module (void) |
| Clean up the procfs filesystem. More... | |
| proc_dir_entry_t * | proc_dir_entry_get (const char *name, proc_dir_entry_t *parent) |
Finds the direntry inside /proc or under the given parent. More... | |
| proc_dir_entry_t * | proc_mkdir (const char *name, proc_dir_entry_t *parent) |
| Creates a new directory inside the procfs filesystem. More... | |
| int | proc_rmdir (const char *name, proc_dir_entry_t *parent) |
| Removes a directory from the procfs filesystem. More... | |
| proc_dir_entry_t * | proc_create_entry (const char *name, proc_dir_entry_t *parent) |
| Creates a new entry inside the procfs filesystem. More... | |
| int | proc_destroy_entry (const char *name, proc_dir_entry_t *parent) |
| Removes an entry from the procfs filesystem. More... | |
| int | proc_entry_set_mask (proc_dir_entry_t *entry, mode_t mask) |
| Sets the mask of a given procfs entry. More... | |
Variables | |
| procfs_t | fs |
| The procfs filesystem. | |
| static vfs_sys_operations_t | procfs_sys_operations |
| Filesystem general operations. More... | |
| static vfs_file_operations_t | procfs_fs_operations |
| Filesystem file operations. More... | |
| static file_system_type | procfs_file_system_type |
| Filesystem information. More... | |
Proc file system implementation.
The details regarding the filesystem.
Contains the number of files inside the procfs filesystem.
|
static |
Saves the information concerning the file.
| file | The file containing the data. |
| stat | The structure where the information are stored. |
| proc_dir_entry_t* proc_create_entry | ( | const char * | name, |
| proc_dir_entry_t * | parent | ||
| ) |
Creates a new entry inside the procfs filesystem.
| name | The name of the entry we are creating. |
| parent | The parent (optional). |
| int proc_destroy_entry | ( | const char * | name, |
| proc_dir_entry_t * | parent | ||
| ) |
Removes an entry from the procfs filesystem.
| name | The name of the entry we are removing. |
| parent | The parent (optional). |
| proc_dir_entry_t* proc_dir_entry_get | ( | const char * | name, |
| proc_dir_entry_t * | parent | ||
| ) |
Finds the direntry inside /proc or under the given parent.
| name | The name of the entry we are searching. |
| parent | The parent (optional). |
| int proc_entry_set_mask | ( | proc_dir_entry_t * | entry, |
| mode_t | mask | ||
| ) |
Sets the mask of a given procfs entry.
| entry | Pointer to the entry. |
| mask | The mask to set. |
| proc_dir_entry_t* proc_mkdir | ( | const char * | name, |
| proc_dir_entry_t * | parent | ||
| ) |
Creates a new directory inside the procfs filesystem.
| name | The name of the entry we are creating. |
| parent | The parent (optional). |
| int proc_rmdir | ( | const char * | name, |
| proc_dir_entry_t * | parent | ||
| ) |
Removes a directory from the procfs filesystem.
| name | The name of the entry we are removing. |
| parent | The parent (optional). |
|
inlinestatic |
Checks if the file is a valid PROCFS file.
| procfs_file | the file to check. |
|
inlinestatic |
Checks if the PROCFS directory at the given path is empty.
| path | the path to the directory. |
| int procfs_cleanup_module | ( | void | ) |
Clean up the procfs filesystem.
|
static |
Closes the given file.
| file | The file structure. |
|
inlinestatic |
Creates a new PROCFS file.
| path | where the file resides. |
| flags | the creation flags. |
|
inlinestatic |
Creates a VFS file, from a PROCFS file.
| procfs_file | the PROCFS file. |
|
inlinestatic |
Destroyes the given PROCFS file.
| procfs_file | pointer to the PROCFS file to destroy. |
|
inlinestatic |
Finds the PROCFS file with the given inode.
| inode | the inode we search. |
|
inlinestatic |
Finds the PROCFS file at the given path.
| path | the path to the entry. |
|
inlinestatic |
Finds the inode associated with a PROCFS file at the given path.
| path | the path to the entry. |
|
static |
Retrieves information concerning the file at the given position.
| file | The file struct. |
| stat | The structure where the information are stored. |
|
inlinestatic |
Returns the PROCFS file associated with the given list entry.
| entry | the entry to transform to PROCFS file. |
|
inlinestatic |
Finds a free inode.
|
inlinestatic |
Reads contents of the directories to a dirent buffer, updating the offset and returning the number of written bytes in the buffer, it assumes that all paths are well-formed.
| file | The directory handler. |
| dirp | The buffer where the data should be written. |
| doff | The offset inside the buffer where the data should be written. |
| count | The maximum length of the buffer. |
|
static |
Perform the I/O control operation specified by REQUEST on FD. One argument may follow; its presence and type depend on REQUEST.
| file | the file on which we perform the operations. |
| request | the device-dependent request code |
| data | an untyped pointer to memory. |
|
static |
Repositions the file offset inside a file.
| file | the file we are working with. |
| offset | the offest to use for the operation. |
| whence | the type of operation. |
|
static |
Creates a new directory.
| path | The path to the new directory. |
| mode | The file mode. |
| int procfs_module_init | ( | void | ) |
Initialize the procfs filesystem.
|
static |
Mounts the block device as a procfs filesystem.
| block_device | the block device formatted as procfs. |
| path | location where we mount the filesystem. |
|
static |
Mounts the filesystem at the given path.
| path | the path where we want to mount a procfs. |
| device | we expect it to be NULL. |
|
static |
Open the file at the given path and returns its file descriptor.
| path | The path to the file. |
| flags | The flags used to determine the behavior of the function. |
| mode | The mode with which we open the file. |
|
static |
Reads from the file identified by the file descriptor.
| file | The file. |
| buffer | Buffer where the read content must be placed. |
| offset | Offset from which we start reading from the file. |
| nbyte | The number of bytes to read. |
|
static |
Removes a directory.
| path | The path to the directory. |
|
static |
Retrieves information concerning the file at the given position.
| path | The path to the file. |
| stat | The structure where the information are stored. |
|
inlinestatic |
Deletes the file at the given path.
| path | The path to the file. |
|
static |
Writes the given content inside the file.
| file | The file descriptor of the file. |
| buffer | The content to write. |
| offset | Offset from which we start writing in the file. |
| nbyte | The number of bytes to write. |
|
static |
Filesystem information.
|
static |
Filesystem file operations.
|
static |
Filesystem general operations.