|
ginnOS
The reference: libc, the libraries and the kernel
|
#include "ext2_internal.h"Macros | |
| #define | EXT2_REV0_FILE_MAX 0x7FFFFFFFull |
Functions | |
| uint64_t | ext2_inode_size (const ext2_inode_t *inode) |
| the size of an inode's file in bytes. | |
| uint64_t | ext2_max_file_size (const ext2_volume_t *volume) |
| the largest size a regular file can have on a volume: what the direct, single, double and triple indirect blocks can map, and at most what i_blocks can count (2 TiB). | |
| kerr_t | ext2_open (ext2_volume_t *volume, const char *path, ext2_file_t *file) |
| open a file or directory by absolute path. | |
| uint32_t | ext2_read (ext2_file_t *file, uint32_t byteCount, void *dataOut) |
| read bytes from an open ext2 file handle. | |
| uint32_t | ext2_write (ext2_file_t *file, uint32_t byteCount, const void *dataIn) |
| write bytes to an open ext2 file at the current cursor position. | |
| kerr_t | ext2_truncate (ext2_file_t *file, uint64_t length) |
| cut or grow an open file to length bytes (growth reads as zeros). | |
| kerr_t | ext2_read_entry (ext2_file_t *file, ext2_directory_entry_t *entryOut) |
| read one directory entry from an open directory handle. | |
| void | ext2_close (ext2_file_t *file) |
| close an open ext2 file handle. | |
| kerr_t | ext2_read_file (ext2_volume_t *volume, uint32_t inode_number, uint64_t offset, uint32_t length, void *buffer) |
| read bytes from a file inode into buffer. | |
| kerr_t | ext2_create_file (ext2_volume_t *volume, const char *path) |
| create a regular file at an absolute path. | |
| kerr_t | ext2_create_dir (ext2_volume_t *volume, const char *path) |
| create a directory at an absolute path. | |
| kerr_t | ext2_remove_file (ext2_volume_t *volume, const char *path) |
| remove a regular file at an absolute path. | |
| kerr_t | ext2_remove_dir (ext2_volume_t *volume, const char *path) |
| remove a directory at an absolute path. | |
| kerr_t | ext2_rename (ext2_volume_t *volume, const char *old_path, const char *new_path) |
| rename a file or directory (both paths absolute and normalized). | |
| kerr_t | ext2_write_file (ext2_volume_t *volume, uint32_t inode_number, uint64_t offset, uint32_t length, const void *buffer) |
| write bytes to a file inode. | |
| kerr_t | ext2_truncate_file (ext2_volume_t *volume, uint32_t inode_number, uint64_t length) |
| cut or grow a file to length bytes. | |
| #define EXT2_REV0_FILE_MAX 0x7FFFFFFFull |
| uint64_t ext2_inode_size | ( | const ext2_inode_t * | inode | ) |
the size of an inode's file in bytes.
a regular file keeps the high 32 bits in i_dir_acl.
| inode | the inode. |
| uint64_t ext2_max_file_size | ( | const ext2_volume_t * | volume | ) |
the largest size a regular file can have on a volume: what the direct, single, double and triple indirect blocks can map, and at most what i_blocks can count (2 TiB).
on a revision 0 volume (no feature flags), 2 GiB - 1.
| volume | the volume. |
| kerr_t ext2_open | ( | ext2_volume_t * | volume, |
| const char * | path, | ||
| ext2_file_t * | file ) |
open a file or directory by absolute path.
| volume | initialized ext2 volume. |
| path | absolute path. |
| file | output file handle. |
| uint32_t ext2_read | ( | ext2_file_t * | file, |
| uint32_t | byteCount, | ||
| void * | dataOut ) |
read bytes from an open ext2 file handle.
| file | open file handle. |
| byteCount | max bytes to read. |
| dataOut | destination buffer. |
| uint32_t ext2_write | ( | ext2_file_t * | file, |
| uint32_t | byteCount, | ||
| const void * | dataIn ) |
write bytes to an open ext2 file at the current cursor position.
allocates blocks as needed. advances the cursor.
| file | open file handle. |
| byteCount | bytes to write. |
| dataIn | source buffer. |
| kerr_t ext2_truncate | ( | ext2_file_t * | file, |
| uint64_t | length ) |
cut or grow an open file to length bytes (growth reads as zeros).
the cursor stays.
| kerr_t ext2_read_entry | ( | ext2_file_t * | file, |
| ext2_directory_entry_t * | entryOut ) |
read one directory entry from an open directory handle.
| file | open directory handle. |
| entryOut | output directory entry. |
| void ext2_close | ( | ext2_file_t * | file | ) |
close an open ext2 file handle.
| file | file handle to close. |
| kerr_t ext2_read_file | ( | ext2_volume_t * | volume, |
| uint32_t | inode_number, | ||
| uint64_t | offset, | ||
| uint32_t | length, | ||
| void * | buffer ) |
read bytes from a file inode into buffer.
| volume | initialized ext2 volume. |
| inode_number | file inode number. |
| offset | byte offset in file. |
| length | bytes to read. |
| buffer | destination buffer. |
| kerr_t ext2_create_file | ( | ext2_volume_t * | volume, |
| const char * | path ) |
create a regular file at an absolute path.
| kerr_t ext2_create_dir | ( | ext2_volume_t * | volume, |
| const char * | path ) |
create a directory at an absolute path.
| kerr_t ext2_remove_file | ( | ext2_volume_t * | volume, |
| const char * | path ) |
remove a regular file at an absolute path.
| kerr_t ext2_remove_dir | ( | ext2_volume_t * | volume, |
| const char * | path ) |
remove a directory at an absolute path.
| kerr_t ext2_rename | ( | ext2_volume_t * | volume, |
| const char * | old_path, | ||
| const char * | new_path ) |
rename a file or directory (both paths absolute and normalized).
an existing new_path is replaced first, as POSIX rename does: a file by a file, an empty directory by a directory. this is not atomic: if the rename then fails, the replaced entry is gone.
| kerr_t ext2_write_file | ( | ext2_volume_t * | volume, |
| uint32_t | inode_number, | ||
| uint64_t | offset, | ||
| uint32_t | length, | ||
| const void * | buffer ) |
write bytes to a file inode.
allocates blocks as needed (direct blocks only, up to 48KB with 4K blocks).
| volume | initialized ext2 volume. |
| inode_number | file inode number. |
| offset | byte offset in file to start writing. |
| length | bytes to write. |
| buffer | source data. |
| kerr_t ext2_truncate_file | ( | ext2_volume_t * | volume, |
| uint32_t | inode_number, | ||
| uint64_t | length ) |
cut or grow a file to length bytes.
the blocks past a shorter end are freed; a longer file gets a hole, which reads as zeros.
| volume | initialized ext2 volume. |
| inode_number | file inode number. |
| length | the new size. |