|
ginnOS
The reference: libc, the libraries and the kernel
|
#include "ext2_internal.h"Macros | |
| #define | EXT2_FALLBACK_TIME 1700000000u |
Functions | |
| uint32_t | ext2_now (void) |
| the time for inode times: ext2_clock, or a fixed time without one. | |
| bool | find_directory_entry (ext2_volume_t *volume, uint32_t dir_inode_number, const char *name, uint32_t name_len, uint32_t *block_index_out, uint32_t *offset_out, ext2_dir_entry_t *entry_out) |
| searches for a directory entry with a specific name within a given directory inode, returning the block index, offset, and entry details if found. | |
| bool | append_or_replace_directory_entry (ext2_volume_t *volume, uint32_t parent_inode_number, ext2_inode_t *parent_inode, const char *name, uint32_t name_len, uint32_t child_inode_number, uint8_t file_type) |
| appends a new directory entry to a parent directory inode or replaces an existing entry with the same name, ensuring proper space allocation and alignment within the directory's data blocks. | |
| bool | update_directory_entry_name (ext2_volume_t *volume, uint32_t dir_inode_number, const char *old_name, uint32_t old_name_len, const char *new_name, uint32_t new_name_len) |
| updates the name of an existing directory entry within a specified directory inode, ensuring that the new name fits within the allocated space for the entry. | |
| bool | directory_is_empty (ext2_volume_t *volume, uint32_t inode_number) |
| checks if a directory represented by a given inode number is empty, meaning it contains no entries other than the standard '. | |
| bool | update_directory_parent_link (ext2_volume_t *volume, uint32_t dir_inode_number, uint32_t parent_inode_number) |
| updates the '..' entry in a directory to point to a new parent inode number, effectively changing the parent directory reference for that directory. | |
| bool | remove_directory_entry (ext2_volume_t *volume, uint32_t dir_inode_number, const char *name, uint32_t name_len) |
| removes a directory entry with a specific name from a given directory inode, effectively deleting the entry from the directory's data blocks. | |
| bool | setup_new_file_inode (ext2_inode_t *inode) |
| initializes a new inode structure for a regular file, setting its mode, link count, and clearing other fields to prepare it for use in the filesystem. | |
| bool | setup_new_dir_inode (ext2_inode_t *inode, ext2_volume_t *volume) |
| initializes a new inode structure for a directory, setting its mode, link count, size, and block count to prepare it for use in the filesystem. | |
| bool | initialize_directory_block (ext2_volume_t *volume, uint32_t inode_number, uint32_t parent_inode_number, uint32_t block_number) |
| initializes a new directory block with the standard '. | |
| bool | lookup_parent_and_name (ext2_volume_t *volume, const char *path, uint32_t *parent_inode_out, char *name_out, uint32_t name_out_size, char *parent_path, uint32_t parent_path_size) |
| looks up the parent directory inode and the name of the final component in a given path, splitting the path into its parent and child components and verifying that the parent is a valid directory. | |
| bool | lookup_child_type (ext2_volume_t *volume, uint32_t parent_inode_number, const char *name, uint32_t name_len, uint32_t *child_inode_out, uint8_t *child_type_out) |
| looks up a child directory entry by name within a specified parent directory inode, returning the child's inode number and file type if found. | |
| bool | free_inode_and_blocks (ext2_volume_t *volume, uint32_t inode_number, ext2_inode_t *inode) |
| frees the blocks associated with a given inode and then frees the inode itself, effectively removing the file or directory represented by that inode from the filesystem. | |
Variables | |
| uint32_t(*) | ext2_clock (void) |
| where the driver gets the time for inode times, in seconds since 1970. | |
| #define EXT2_FALLBACK_TIME 1700000000u |
| uint32_t ext2_now | ( | void | ) |
the time for inode times: ext2_clock, or a fixed time without one.
| bool find_directory_entry | ( | ext2_volume_t * | volume, |
| uint32_t | dir_inode_number, | ||
| const char * | name, | ||
| uint32_t | name_len, | ||
| uint32_t * | block_index_out, | ||
| uint32_t * | offset_out, | ||
| ext2_dir_entry_t * | entry_out ) |
searches for a directory entry with a specific name within a given directory inode, returning the block index, offset, and entry details if found.
| volume | pointer to the ext2_volume_t structure representing the filesystem volume. |
| dir_inode_number | the inode number of the directory to search within. |
| name | the name of the directory entry to search for. |
| name_len | the length of the name to search for. |
| block_index_out | pointer to a variable where the block index of the found entry will be stored. |
| offset_out | pointer to a variable where the byte offset of the found entry within the block will be stored. |
| entry_out | pointer to an ext2_dir_entry_t structure where the details of the found entry will be stored. |
| bool append_or_replace_directory_entry | ( | ext2_volume_t * | volume, |
| uint32_t | parent_inode_number, | ||
| ext2_inode_t * | parent_inode, | ||
| const char * | name, | ||
| uint32_t | name_len, | ||
| uint32_t | child_inode_number, | ||
| uint8_t | file_type ) |
appends a new directory entry to a parent directory inode or replaces an existing entry with the same name, ensuring proper space allocation and alignment within the directory's data blocks.
| volume | pointer to the ext2_volume_t structure representing the filesystem volume. |
| parent_inode_number | the inode number of the parent directory where the entry will be added or replaced. |
| parent_inode | pointer to the ext2_inode_t structure representing the parent directory inode. |
| name | the name of the directory entry to add or replace. |
| name_len | the length of the name of the directory entry. |
| child_inode_number | the inode number of the child entry to be added or replaced. |
| file_type | the type of the file (e.g., regular file, directory) for the new directory entry. |
| bool update_directory_entry_name | ( | ext2_volume_t * | volume, |
| uint32_t | dir_inode_number, | ||
| const char * | old_name, | ||
| uint32_t | old_name_len, | ||
| const char * | new_name, | ||
| uint32_t | new_name_len ) |
updates the name of an existing directory entry within a specified directory inode, ensuring that the new name fits within the allocated space for the entry.
| volume | pointer to the ext2_volume_t structure representing the filesystem volume. |
| dir_inode_number | the inode number of the directory containing the entry to be renamed. |
| old_name | the current name of the directory entry to be renamed. |
| old_name_len | the length of the current name of the directory entry. |
| new_name | the new name to assign to the directory entry. |
| new_name_len | the length of the new name to assign to the directory entry. |
| bool directory_is_empty | ( | ext2_volume_t * | volume, |
| uint32_t | inode_number ) |
checks if a directory represented by a given inode number is empty, meaning it contains no entries other than the standard '.
' and '..' entries.
| volume | pointer to the ext2_volume_t structure representing the filesystem volume. |
| inode_number | the inode number of the directory to check. |
| bool update_directory_parent_link | ( | ext2_volume_t * | volume, |
| uint32_t | dir_inode_number, | ||
| uint32_t | parent_inode_number ) |
updates the '..' entry in a directory to point to a new parent inode number, effectively changing the parent directory reference for that directory.
| volume | pointer to the ext2_volume_t structure representing the filesystem volume. |
| dir_inode_number | the inode number of the directory whose parent link is to be updated. |
| parent_inode_number | the inode number of the new parent directory to which the '..' entry should point. |
| bool remove_directory_entry | ( | ext2_volume_t * | volume, |
| uint32_t | dir_inode_number, | ||
| const char * | name, | ||
| uint32_t | name_len ) |
removes a directory entry with a specific name from a given directory inode, effectively deleting the entry from the directory's data blocks.
| volume | pointer to the ext2_volume_t structure representing the filesystem volume. |
| dir_inode_number | the inode number of the directory from which the entry will be removed. |
| name | the name of the directory entry to be removed. |
| name_len | the length of the name of the directory entry to be removed. |
| bool setup_new_file_inode | ( | ext2_inode_t * | inode | ) |
initializes a new inode structure for a regular file, setting its mode, link count, and clearing other fields to prepare it for use in the filesystem.
| inode | pointer to the ext2_inode_t structure to be initialized. |
| bool setup_new_dir_inode | ( | ext2_inode_t * | inode, |
| ext2_volume_t * | volume ) |
initializes a new inode structure for a directory, setting its mode, link count, size, and block count to prepare it for use in the filesystem.
| inode | pointer to the ext2_inode_t structure to be initialized. |
| volume | pointer to the ext2_volume_t structure representing the filesystem volume, used to determine the block size and sectors per block for the directory inode. |
| bool initialize_directory_block | ( | ext2_volume_t * | volume, |
| uint32_t | inode_number, | ||
| uint32_t | parent_inode_number, | ||
| uint32_t | block_number ) |
initializes a new directory block with the standard '.
' and '..' entries, setting their inode numbers and ensuring proper formatting for the directory structure.
| volume | pointer to the ext2_volume_t structure representing the filesystem volume. |
| inode_number | the inode number of the directory being initialized (for the '.' entry). |
| parent_inode_number | the inode number of the parent directory (for the '..' entry). |
| block_number | the block number where the new directory block will be written. |
| bool lookup_parent_and_name | ( | ext2_volume_t * | volume, |
| const char * | path, | ||
| uint32_t * | parent_inode_out, | ||
| char * | name_out, | ||
| uint32_t | name_out_size, | ||
| char * | parent_path, | ||
| uint32_t | parent_path_size ) |
looks up the parent directory inode and the name of the final component in a given path, splitting the path into its parent and child components and verifying that the parent is a valid directory.
| volume | pointer to the ext2_volume_t structure representing the filesystem volume. |
| path | the input path string to be looked up (must start with '/'). |
| parent_inode_out | pointer to a variable where the inode number of the parent directory will be stored. |
| name_out | buffer to store the name of the final component (file or directory) in the path. |
| name_out_size | the size of the name_out buffer in bytes. |
| parent_path | buffer to store the parent directory path. |
| parent_path_size | the size of the parent_path buffer in bytes. |
| bool lookup_child_type | ( | ext2_volume_t * | volume, |
| uint32_t | parent_inode_number, | ||
| const char * | name, | ||
| uint32_t | name_len, | ||
| uint32_t * | child_inode_out, | ||
| uint8_t * | child_type_out ) |
looks up a child directory entry by name within a specified parent directory inode, returning the child's inode number and file type if found.
| volume | pointer to the ext2_volume_t structure representing the filesystem volume. |
| parent_inode_number | the inode number of the parent directory to search within. |
| name | the name of the child directory entry to look up. |
| name_len | the length of the name of the child directory entry. |
| child_inode_out | pointer to a variable where the inode number of the found child entry will be stored. |
| child_type_out | pointer to a variable where the file type of the found child entry will be stored. |
| bool free_inode_and_blocks | ( | ext2_volume_t * | volume, |
| uint32_t | inode_number, | ||
| ext2_inode_t * | inode ) |
frees the blocks associated with a given inode and then frees the inode itself, effectively removing the file or directory represented by that inode from the filesystem.
| volume | pointer to the ext2_volume_t structure representing the filesystem volume. |
| inode_number | the inode number of the file or directory to be freed. |
| inode | pointer to the ext2_inode_t structure representing the inode to be freed. If null, the function will read the inode from the filesystem. |
| uint32_t(*) ext2_clock(void) | ( | void | ) |
where the driver gets the time for inode times, in seconds since 1970.
the kernel sets it at boot; while it is NULL (the bootloader) the driver uses a fixed time.