The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
ext2_inode.c File Reference
#include "ext2_internal.h"

Functions

bool inode_is_dir (const ext2_inode_t *inode)
 determines if a given inode represents a directory by checking its mode against the directory file type constant.
bool inode_is_regular (const ext2_inode_t *inode)
 determines if a given inode represents a regular file by checking its mode against the regular file type constant.
bool inode_is_directory (const ext2_inode_t *inode)
 determines if a given inode represents a directory by checking its mode against the directory file type constant.
uint8_t inode_to_file_type (const ext2_inode_t *inode)
 maps an inode's mode to the corresponding EXT2 file type constant, returning the appropriate value for directory or regular file types, or 0 for unsupported types.
kerr_t find_in_directory (ext2_volume_t *volume, uint32_t dir_inode_number, const char *name, uint32_t name_len, uint32_t *inode_out)
 searches for a directory entry with a specific name within a given directory inode, returning the inode number of the found entry if it exists.
bool resolve_data_block (ext2_volume_t *volume, const ext2_inode_t *inode, uint32_t logical_block_index, uint32_t *physical_block_out)
 resolves a logical block index within an inode to its corresponding physical block number on disk, handling direct, single indirect, double indirect, and triple indirect block addressing as defined by the EXT2 filesystem structure.
kerr_t ext2_read_inode (ext2_volume_t *volume, uint32_t inode_number, ext2_inode_t *inode_out)
 read one inode by inode number.
kerr_t ext2_list_directory (ext2_volume_t *volume, uint32_t inode_number)
 list entries in a directory inode.
kerr_t ext2_lookup_path (ext2_volume_t *volume, const char *path, uint32_t *inode_out)
 resolve an absolute path to an inode.

Function Documentation

◆ inode_is_dir()

bool inode_is_dir ( const ext2_inode_t * inode)

determines if a given inode represents a directory by checking its mode against the directory file type constant.

Parameters
inodepointer to the ext2_inode_t structure to be checked.
Returns
true if the inode represents a directory, false otherwise.

◆ inode_is_regular()

bool inode_is_regular ( const ext2_inode_t * inode)

determines if a given inode represents a regular file by checking its mode against the regular file type constant.

Parameters
inodepointer to the ext2_inode_t structure to be checked.
Returns
true if the inode represents a regular file, false otherwise.

◆ inode_is_directory()

bool inode_is_directory ( const ext2_inode_t * inode)

determines if a given inode represents a directory by checking its mode against the directory file type constant.

Parameters
inodepointer to the ext2_inode_t structure to be checked.
Returns
true if the inode represents a directory, false otherwise.

◆ inode_to_file_type()

uint8_t inode_to_file_type ( const ext2_inode_t * inode)

maps an inode's mode to the corresponding EXT2 file type constant, returning the appropriate value for directory or regular file types, or 0 for unsupported types.

Parameters
inodepointer to the ext2_inode_t structure whose file type is to be determined.
Returns
the EXT2 file type constant corresponding to the inode's mode, or 0 if the inode does not represent a directory or regular file.

◆ find_in_directory()

kerr_t find_in_directory ( ext2_volume_t * volume,
uint32_t dir_inode_number,
const char * name,
uint32_t name_len,
uint32_t * inode_out )

searches for a directory entry with a specific name within a given directory inode, returning the inode number of the found entry if it exists.

Parameters
volumepointer to the ext2_volume_t structure representing the filesystem volume.
dir_inode_numberthe inode number of the directory to search within.
namethe name of the directory entry to search for.
name_lenthe length of the name to search for.
inode_outpointer to a variable where the inode number of the found entry will be stored if the entry is found.
Returns
KERR_OK if the entry was found and its inode number is stored in inode_out, KERR_NOTFOUND if the entry does not exist, or KERR_IO if an error occurred during the search or if the directory inode could not be read.

◆ resolve_data_block()

bool resolve_data_block ( ext2_volume_t * volume,
const ext2_inode_t * inode,
uint32_t logical_block_index,
uint32_t * physical_block_out )

resolves a logical block index within an inode to its corresponding physical block number on disk, handling direct, single indirect, double indirect, and triple indirect block addressing as defined by the EXT2 filesystem structure.

Parameters
volumepointer to the ext2_volume_t structure representing the filesystem volume.
inodepointer to the ext2_inode_t structure representing the inode whose block is being resolved.
logical_block_indexthe logical block index to resolve (0-based).
physical_block_outpointer to a variable where the resolved physical block number will be stored.
Returns
true if the logical block index was successfully resolved to a physical block number, false if an error occurred during the resolution process or if the logical block index is out of range for the given inode.

◆ ext2_read_inode()

kerr_t ext2_read_inode ( ext2_volume_t * volume,
uint32_t inode_number,
ext2_inode_t * inode_out )

read one inode by inode number.

Parameters
volumeinitialized ext2 volume.
inode_numberinode to read.
inode_outoutput inode.
Returns
KERR_OK on success, or an error code on failure.

◆ ext2_list_directory()

kerr_t ext2_list_directory ( ext2_volume_t * volume,
uint32_t inode_number )

list entries in a directory inode.

Parameters
volumeinitialized ext2 volume.
inode_numberdirectory inode number.
Returns
KERR_OK on success, or an error code on failure.

◆ ext2_lookup_path()

kerr_t ext2_lookup_path ( ext2_volume_t * volume,
const char * path,
uint32_t * inode_out )

resolve an absolute path to an inode.

Parameters
volumeinitialized ext2 volume.
pathabsolute path.
inode_outresolved inode.
Returns
KERR_OK on success, or an error code on failure.