|
PatchworkOS
|
#include "file.h"#include <errno.h>#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <sys/io.h>Go to the source code of this file.
Functions | |
| _file_flags_t | _file_flags_parse (const char *mode) |
| FILE * | _file_new (void) |
| void | _file_free (FILE *stream) |
| uint64_t | _file_init (FILE *stream, fd_t fd, _file_flags_t flags, void *buffer, uint64_t bufferSize) |
| void | _file_deinit (FILE *stream) |
| uint64_t | _file_flush_buffer (FILE *stream) |
| uint64_t | _file_fill_buffer (FILE *stream) |
| uint64_t | _file_seek (FILE *stream, int64_t offset, int whence) |
| uint64_t | _file_prepare_read (FILE *stream) |
| uint64_t | _file_prepare_write (FILE *stream) |
| void | _files_init (void) |
| void | _files_push (FILE *file) |
| void | _files_remove (FILE *file) |
| void | _files_close (void) |
| uint64_t | _files_flush (void) |
Variables | |
| static list_t | files |
| static mtx_t | filesMtx |
| void _file_deinit | ( | FILE * | stream | ) |
Definition at line 146 of file file.c.
References _FILE_OWNS_BUFFER, FILE::buf, close(), FILE::fd, FILE::flags, free(), FILE::mtx, and mtx_destroy().
Referenced by fclose().
Definition at line 177 of file file.c.
References _FILE_BIN, _FILE_EOF, _FILE_ERROR, FILE::buf, FILE::bufEnd, FILE::bufIndex, FILE::bufSize, count, ERR, FILE::fd, FILE::flags, fpos_t::offset, FILE::pos, and read().
| _file_flags_t _file_flags_parse | ( | const char * | mode | ) |
Definition at line 12 of file file.c.
References _FILE_APPEND, _FILE_BIN, _FILE_READ, _FILE_RW, _FILE_WRITE, files, and NULL.
Referenced by fopen().
Definition at line 158 of file file.c.
References _FILE_BIN, _FILE_ERROR, FILE::buf, FILE::bufIndex, count, ERR, FILE::fd, FILE::flags, fpos_t::offset, FILE::pos, and write().
Referenced by fclose(), fflush(), fputc(), fputs(), fseek(), fwrite(), puts(), and vfprintf().
| void _file_free | ( | FILE * | stream | ) |
| uint64_t _file_init | ( | FILE * | stream, |
| fd_t | fd, | ||
| _file_flags_t | flags, | ||
| void * | buffer, | ||
| uint64_t | bufferSize | ||
| ) |
Definition at line 100 of file file.c.
References _FILE_OWNS_BUFFER, FILE::buf, FILE::bufEnd, buffer, FILE::bufIndex, FILE::bufSize, ERR, FILE::fd, FILE::flags, free(), malloc(), FILE::mtx, mtx_init(), mtx_recursive, NULL, fpos_t::offset, FILE::pos, fpos_t::status, thrd_success, and FILE::ungetIndex.
Referenced by _std_stream_init(), and fopen().
| FILE * _file_new | ( | void | ) |
Definition at line 80 of file file.c.
References calloc(), FILE::entry, list_entry_init(), and NULL.
Referenced by fopen().
Definition at line 224 of file file.c.
References _FILE_APPEND, _FILE_BYTESTREAM, _FILE_EOF, _FILE_ERROR, _FILE_READ, _FILE_RW, _FILE_WIDESTREAM, _FILE_WRITE, FILE::bufEnd, FILE::bufIndex, EBADF, ERR, errno, and FILE::flags.
Definition at line 239 of file file.c.
References _FILE_APPEND, _FILE_BYTESTREAM, _FILE_EOF, _FILE_ERROR, _FILE_READ, _FILE_RW, _FILE_WIDESTREAM, _FILE_WRITE, FILE::bufEnd, FILE::bufIndex, EBADF, ERR, errno, FILE::flags, and FILE::ungetIndex.
Referenced by fputc(), fputs(), fwrite(), puts(), and vfprintf().
Definition at line 202 of file file.c.
References FILE::bufEnd, FILE::bufIndex, EINVAL, ERR, errno, FILE::fd, fpos_t::offset, FILE::pos, seek(), SEEK_CUR, SEEK_END, SEEK_SET, and FILE::ungetIndex.
Referenced by fseek().
| void _files_close | ( | void | ) |
Definition at line 278 of file file.c.
References fclose(), files, filesMtx, LIST_FOR_EACH_SAFE, mtx_lock(), and mtx_unlock().
Referenced by exit().
| uint64_t _files_flush | ( | void | ) |
Definition at line 292 of file file.c.
References EOF, ERR, fflush(), files, filesMtx, LIST_FOR_EACH, mtx_lock(), and mtx_unlock().
Referenced by fflush().
| void _files_init | ( | void | ) |
Definition at line 254 of file file.c.
References abort(), files, filesMtx, fprintf(), list_init(), mtx_init(), mtx_recursive, stderr, and thrd_success.
Referenced by _user_init().
| void _files_push | ( | FILE * | file | ) |
Definition at line 264 of file file.c.
References file, files, filesMtx, list_push(), mtx_lock(), and mtx_unlock().
Referenced by _std_stream_init(), and fopen().
| void _files_remove | ( | FILE * | file | ) |
Definition at line 271 of file file.c.
References file, files, filesMtx, list_remove(), mtx_lock(), and mtx_unlock().
Referenced by fclose().
|
static |
Definition at line 9 of file file.c.
Referenced by _file_flags_parse(), _files_close(), _files_flush(), _files_init(), _files_push(), _files_remove(), pipe_open2(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), vfs_open2(), vfs_poll(), vfs_poll_ctx_check_events(), and vfs_poll_ctx_init().
|
static |
Definition at line 10 of file file.c.
Referenced by _files_close(), _files_flush(), _files_init(), _files_push(), and _files_remove().