|
ginnOS
The reference: libc, the libraries and the kernel
|
Go to the source code of this file.
Data Structures | |
| struct | ext2_volume_t |
| struct | ext2_file_t |
| struct | ext2_directory_entry_t |
Functions | |
| struct | __attribute__ ((packed)) |
| uint32_t | ext2_now (void) |
| the time for inode times: ext2_clock, or a fixed time without one. | |
| bool | ext2_write_inode (ext2_volume_t *volume, uint32_t inode_number, const ext2_inode_t *inode) |
| write an inode back to the volume. | |
| kerr_t | ext2_initialize (ext2_volume_t *volume, block_device_t *disk) |
| initialize an ext2 volume from a disk. | |
| 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. | |
| 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_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_lookup_path (ext2_volume_t *volume, const char *path, uint32_t *inode_out) |
| resolve an absolute path to an inode. | |
| kerr_t | ext2_find_link (ext2_volume_t *volume, const char *path, bool follow_last, char *target, uint32_t size, uint32_t *end_out) |
| find the first symbolic link along a path. | |
| kerr_t | ext2_readlink (ext2_volume_t *volume, const char *path, char *target, uint32_t size) |
| read a symbolic link's target, with a NUL. | |
| kerr_t | ext2_symlink (ext2_volume_t *volume, const char *path, const char *target) |
| make a symbolic link at path that points at target. | |
| kerr_t | ext2_link (ext2_volume_t *volume, const char *old_path, const char *new_path) |
| give the file at old_path one more name, new_path. | |
| kerr_t | ext2_mknod (ext2_volume_t *volume, const char *path, uint32_t mode, uint32_t major, uint32_t minor) |
| make a named pipe or a device node. | |
| void | ext2_device_numbers (const ext2_inode_t *inode, uint32_t *major, uint32_t *minor) |
| the numbers of a device node, as ext2_mknod stored them. | |
| 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_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. | |
Variables | |
| ext2_superblock_t | |
| ext2_block_group_desc_t | |
| ext2_inode_t | |
| ext2_dir_entry_t | |
| uint32_t(*) | ext2_clock (void) |
| where the driver gets the time for inode times, in seconds since 1970. | |
| #define EXT2_SUPERBLOCK_OFFSET 1024u |
| #define EXT2_SUPERBLOCK_MAGIC 0xEF53u |
| #define EXT2_NDIR_BLOCKS 12u |
| #define EXT2_INODE_ROOT 2u |
| #define EXT2_FT_REG_FILE 1u |
| #define EXT2_FT_DIR 2u |
| #define EXT2_FT_CHRDEV 3u |
| #define EXT2_FT_BLKDEV 4u |
| #define EXT2_FT_FIFO 5u |
| #define EXT2_FT_SYMLINK 7u |
| #define EXT2_S_IFREG 0x8000u |
| #define EXT2_S_IFDIR 0x4000u |
| #define EXT2_S_IFLNK 0xA000u |
| #define EXT2_S_IFIFO 0x1000u |
| #define EXT2_S_IFCHR 0x2000u |
| #define EXT2_S_IFBLK 0x6000u |
| #define EXT2_LINK_MAX 32000u |
| #define EXT2_S_IFMT 0xF000u |
| #define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001u |
| #define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002u |
| #define EXT2_FEATURE_INCOMPAT_RECOVER 0x0004u |
| #define EXT2_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008u |
| #define EXT2_FEATURE_INCOMPAT_META_BG 0x0010u |
| #define EXT2_FEATURE_INCOMPAT_EXTENTS 0x0040u |
| #define EXT2_FEATURE_INCOMPAT_64BIT 0x0080u |
| #define EXT2_FEATURE_INCOMPAT_MMP 0x0100u |
| #define EXT2_FEATURE_INCOMPAT_FLEX_BG 0x0200u |
| #define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002u |
| #define EXT2_MAX_BLOCK_SIZE 4096u |
| #define EXT2_MAX_INODE_SIZE 256u |
| #define EXT2_NAME_MAX 256u |
| struct __attribute__ | ( | (packed) | ) |
| uint32_t ext2_now | ( | void | ) |
the time for inode times: ext2_clock, or a fixed time without one.
| bool ext2_write_inode | ( | ext2_volume_t * | volume, |
| uint32_t | inode_number, | ||
| const ext2_inode_t * | inode ) |
write an inode back to the volume.
| kerr_t ext2_initialize | ( | ext2_volume_t * | volume, |
| block_device_t * | disk ) |
initialize an ext2 volume from a disk.
| volume | volume object to initialize. |
| disk | initialized block device backend. |
| kerr_t ext2_read_inode | ( | ext2_volume_t * | volume, |
| uint32_t | inode_number, | ||
| ext2_inode_t * | inode_out ) |
read one inode by inode number.
| volume | initialized ext2 volume. |
| inode_number | inode to read. |
| inode_out | output inode. |
| kerr_t ext2_list_directory | ( | ext2_volume_t * | volume, |
| uint32_t | inode_number ) |
list entries in a directory inode.
| volume | initialized ext2 volume. |
| inode_number | directory inode number. |
| 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_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_lookup_path | ( | ext2_volume_t * | volume, |
| const char * | path, | ||
| uint32_t * | inode_out ) |
resolve an absolute path to an inode.
| volume | initialized ext2 volume. |
| path | absolute path. |
| inode_out | resolved inode. |
| kerr_t ext2_find_link | ( | ext2_volume_t * | volume, |
| const char * | path, | ||
| bool | follow_last, | ||
| char * | target, | ||
| uint32_t | size, | ||
| uint32_t * | end_out ) |
find the first symbolic link along a path.
| follow_last | also the last name of the path, when it is a link. |
| target | gets the link's target, with a NUL. |
| end_out | gets the length of the path up to and with the link's name, or 0 when there is no link (or a name is missing). |
| kerr_t ext2_readlink | ( | ext2_volume_t * | volume, |
| const char * | path, | ||
| char * | target, | ||
| uint32_t | size ) |
read a symbolic link's target, with a NUL.
| kerr_t ext2_symlink | ( | ext2_volume_t * | volume, |
| const char * | path, | ||
| const char * | target ) |
make a symbolic link at path that points at target.
| kerr_t ext2_link | ( | ext2_volume_t * | volume, |
| const char * | old_path, | ||
| const char * | new_path ) |
give the file at old_path one more name, new_path.
| kerr_t ext2_mknod | ( | ext2_volume_t * | volume, |
| const char * | path, | ||
| uint32_t | mode, | ||
| uint32_t | major, | ||
| uint32_t | minor ) |
make a named pipe or a device node.
| mode | the type (EXT2_S_IFIFO, EXT2_S_IFCHR, EXT2_S_IFBLK) and the permission bits. |
| major | the device's numbers (a device node only). |
| void ext2_device_numbers | ( | const ext2_inode_t * | inode, |
| uint32_t * | major, | ||
| uint32_t * | minor ) |
the numbers of a device node, as ext2_mknod stored them.
| 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_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. |
| ext2_superblock_t |
| ext2_block_group_desc_t |
| ext2_inode_t |
| ext2_dir_entry_t |
|
extern |
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.