feature (file_descriptors): added a few more standard file descriptors
This commit is contained in:
parent
e3d3faf8e0
commit
18be33952f
|
@ -9,10 +9,15 @@
|
|||
|
||||
#define FILE_DESCRIPTOR_ARRAY_CHUNK_SIZE 32
|
||||
|
||||
typedef int32_t file_descriptor_t;
|
||||
typedef uint32_t file_descriptor_t;
|
||||
|
||||
typedef enum {
|
||||
FILE_DESCRIPTOR_INVALID = -1
|
||||
FILE_DESCRIPTOR_INVALID,
|
||||
FILE_DESCRIPTOR_STDOUT,
|
||||
FILE_DESCRIPTOR_STDIN,
|
||||
FILE_DESCRIPTOR_STDERR,
|
||||
|
||||
FILE_DESCRIPTORS_ENUM_END
|
||||
} std_file_descriptors_E;
|
||||
|
||||
typedef struct file_descriptor_array_chunk_T file_descriptor_array_chunk_T;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
|
||||
file_descriptor_t file_descriptor_request(file_descriptor_array_T* fd_array, vfs_node_T* node) {
|
||||
file_descriptor_t fd = 0;
|
||||
file_descriptor_t fd = FILE_DESCRIPTORS_ENUM_END;
|
||||
|
||||
file_descriptor_array_chunk_T* chunk = fd_array->base_chunk;
|
||||
while (chunk->amount == FILE_DESCRIPTOR_ARRAY_CHUNK_SIZE) {
|
||||
|
@ -30,8 +30,9 @@ file_descriptor_t file_descriptor_request(file_descriptor_array_T* fd_array, vfs
|
|||
}
|
||||
|
||||
vfs_node_T* file_descriptor_resolve(file_descriptor_array_T* fd_array, file_descriptor_t fd) {
|
||||
if (fd == FILE_DESCRIPTOR_INVALID) return NULL;
|
||||
if (fd < FILE_DESCRIPTORS_ENUM_END) return NULL;
|
||||
|
||||
fd -= FILE_DESCRIPTORS_ENUM_END;
|
||||
|
||||
uint32_t chunk_selector = fd / FILE_DESCRIPTOR_ARRAY_CHUNK_SIZE;
|
||||
file_descriptor_array_chunk_T* chunk = fd_array->base_chunk;
|
||||
|
@ -49,7 +50,9 @@ vfs_node_T* file_descriptor_resolve(file_descriptor_array_T* fd_array, file_desc
|
|||
}
|
||||
|
||||
void file_descriptor_free(file_descriptor_array_T* fd_array, file_descriptor_t fd) {
|
||||
if (fd == FILE_DESCRIPTOR_INVALID) return;
|
||||
if (fd < FILE_DESCRIPTORS_ENUM_END) return;
|
||||
|
||||
fd -= FILE_DESCRIPTORS_ENUM_END;
|
||||
|
||||
uint32_t chunk_selector = fd / FILE_DESCRIPTOR_ARRAY_CHUNK_SIZE;
|
||||
file_descriptor_array_chunk_T* chunk = fd_array->base_chunk;
|
||||
|
|
Loading…
Reference in New Issue