3.3 KiB
file_descriptor.h
Processes have no direct access to the VFS, instead they have file descriptors.
File descriptors are numbers that represent files. They are mostly used in file related syscalls.
FILE_DESCRIPTOR_ARRAY_CHUNK_SIZE
- macro
The amount of file descriptors a file_descriptor_array_chunk_T
(reference needed) can hold.
file_descriptor_t
- typedef
This is a typedef of ìnt32_t
and represents a file descriptor.
std_file_descriptors_E
- enum
These are reserved file descriptors.
FILE_DESCRIPTOR_INVALID
- This represents an invalid file descriptor, just like NULL is an invalid pointer.FILE_DESCRIPTOR_STDOUT
- This represents the file descriptor that is used, when writing to the Standard-Output stream.FILE_DESCRIPTOR_STDIN
- This represents the file descriptor that is used, when reading from the Standard-Input stream.FILE_DESCRIPTOR_STDERR
- This represents the file descriptor that is used, when writing to the Standard-Error stream.
file_descriptor_array_chunk_T
- struct
Name | Type | Description |
---|---|---|
prev | file_descriptor_array_chunk_T* | The previous chunk |
next | file_descriptor_array_chunk_T* | The next chunk |
lookup | vfs_node_T* [FILE_DESCRIPTOR_ARRAY_CHUNK_SIZE] | The array of file pointers, that the file descriptors reference |
bitmap | bitmap_T | This bitmap indicates which file descriptors of this chunk are free nad which are used |
amount | uint32_t | The amount of file descriptors which the chunk actually holds |
file_descriptor_array_T
- struct
Name | Type | Description |
---|---|---|
base_chunk | file_descriptor_array_chunk_T* | The first chunk in the array |
file_descriptor_request(fd_array, node)
- function (file_descriptor_t)
Requests and returns new file descriptor, which will be linked with node.
file_descriptor_resolve(fd_array, fd)
- function (vfs_node_T*)
Returns the VFS node, with which fd is linked.
file_descriptor_free(fd_array, fd)
- function (void)
Frees fd and marks it as reclaimable.
file_descriptor_array_alloc()
- function (file_descriptor_array_T*)
Allocates a new chunked file descriptor array.
file_descriptor_array_destruct(fd_array)
- function (void)
Destructs fd_array and all its resources, like e.g. chunks.
file_descriptor_array_chunk_alloc(prev)
- function (file_descriptor_array_chunk_T*)
Allocates a new chunk for a file descriptor array. prev has to be the last chunk of an array or NULL when the chunk is the base chunk for a fresh file descriptor array.
file_descriptor_array_chunk_destruct(chunk)
- function (void)
Destructs chunk and all its resources.