|
GitOS
|
#include "file.h"#include <common/assert.h>#include <stdint.h>#include "Path.hpp"#include "common/status.h"#include "common/string.h"#include "kernel.h"#include "memory/heap/kheap.h"#include "memory/memory.h"Functions | |
| void | fs_insert_filesystem (struct filesystem *filesystem) |
| Inserts filesystem struct into internal array. | |
| void | fs_init () |
| Initializes internal filesystem arrays. | |
| struct filesystem * | fs_resolve (struct disk *disk) |
| Resolves filesystem for given disk. | |
| int | fopen (const char *filename, const char *str_mode) |
| Opens file. | |
| int | fread (void *ptr, uint32_t size, uint32_t nmemb, int fd) |
| Reads from file. | |
| int | fwrite (void *ptr, uint32_t size, uint32_t nmemb, int fd) |
| Writes to file. | |
| int | fseek (int fd, int offset, FILE_SEEK_MODE whence) |
| Seeks into file. | |
| int | fstat (int fd, struct file_stat *stat) |
| Returns file status. | |
| int | fclose (int fd) |
| Closes file descriptor. | |
| void | mount (const char *filename, struct filesystem *fs, void *data) |
Variables | |
| struct filesystem * | filesystems [MAX_FILESYSTEMS] |
| Array holding all registered filesystems. | |
| struct file_descriptor * | file_descriptors [MAX_FILEDESCRIPTORS] |
| Array holding all open file descriptors. | |
| struct mounted_file ** | mounted |
| Array holding all mounted files. | |
| int fclose | ( | int | fd | ) |
Closes file descriptor.
| fd | File descriptor |
References filesystem::close, EIO, file_descriptor::filesystem, and file_descriptor::private_fs_descriptor.
| int fopen | ( | const char * | filename, |
| const char * | str_mode ) |
Opens file.
| filename | File to open |
| str_mode | Open mode |
References assert, data, EINVARG, FILE_MODE_INVALID, filename, file_descriptor::filesystem, file_descriptor::index, kfree(), kzalloc(), MAX_MOUNTED, MAX_PATH, memset(), mounted, path_part::next, path_part::part, pathparser_free(), pathparser_parse(), file_descriptor::private_fs, file_descriptor::private_fs_descriptor, strcmp(), strcpy(), and strlen().
| int fread | ( | void * | ptr, |
| uint32_t | size, | ||
| uint32_t | nmemb, | ||
| int | fd ) |
Reads from file.
| ptr | Output buffer |
| size | Size in bytes of block |
| nmemb | Number of blocks to read |
| fd | File descriptor |
References EINVARG, file_descriptor::filesystem, file_descriptor::private_fs, file_descriptor::private_fs_descriptor, filesystem::read, and size.
| void fs_init | ( | ) |
Initializes internal filesystem arrays.
References file_descriptors, filesystems, kzalloc(), MAX_MOUNTED, memset(), and mounted.
| void fs_insert_filesystem | ( | struct filesystem * | filesystem | ) |
Inserts filesystem struct into internal array.
| filesystem |
References fs, kernel_panic(), kprintf(), and filesystem::name.
| struct filesystem * fs_resolve | ( | struct disk * | disk | ) |
Resolves filesystem for given disk.
| disk | Disk to resolve |
References ALL_OK, filesystems, disk::fs_private, disk::id, kprintf(), MAX_FILESYSTEMS, mount(), and filesystem::resolve.
| int fseek | ( | int | fd, |
| int | offset, | ||
| FILE_SEEK_MODE | whence ) |
Seeks into file.
| fd | File descriptor |
| offset | Seek offset |
| whence | File seek mode (SEEK_SET for absolute, SEEK_CUR for relative) |
References EIO, file_descriptor::filesystem, offset, file_descriptor::private_fs_descriptor, and filesystem::seek.
| int fstat | ( | int | fd, |
| struct file_stat * | stat ) |
Returns file status.
| fd | File descriptor |
| stat | Output file status struct |
References EIO, file_descriptor::filesystem, file_descriptor::private_fs_descriptor, and filesystem::stat.
| int fwrite | ( | void * | ptr, |
| uint32_t | size, | ||
| uint32_t | nmemb, | ||
| int | fd ) |
Writes to file.
| ptr | Input buffer |
| size | Size in bytes of block |
| nmemb | Number of blocks to read |
| fd | File descriptor |
References EINVARG, file_descriptor::filesystem, file_descriptor::private_fs, file_descriptor::private_fs_descriptor, size, and filesystem::write.
| void mount | ( | const char * | filename, |
| struct filesystem * | fs, | ||
| void * | data ) |
References data, mounted_file::data, filename, mounted_file::filename, fs, mounted_file::fs, kdebug, kernel_panic(), kzalloc(), MAX_MOUNTED, and mounted.
| struct file_descriptor* file_descriptors[MAX_FILEDESCRIPTORS] |
Array holding all open file descriptors.
| struct filesystem* filesystems[MAX_FILESYSTEMS] |
Array holding all registered filesystems.
| struct mounted_file** mounted |
Array holding all mounted files.