GitOS
Operating system exercise
|
#include "fat16.h"
#include "common/string.h"
#include "common/status.h"
#include "memory/memory.h"
#include "memory/heap/kheap.h"
#include "kernel.h"
#include "common/assert.h"
Functions | |
struct filesystem * | fat16_init_filesystem () |
Prepares filesystem struct for generic filesystem driver use. | |
int | fat16_resolve (struct disk *disk) |
FAT16 filesystem resolver. | |
void * | fat16_open (void *private_fs, struct path_part *path, FILE_MODE mode) |
FAT16 Implementation of fopen. | |
int | fat16_read (void *private_fs, void *desc, uint32_t size, uint32_t nmemb, char *out) |
FAT16 Implementation of fread. | |
int | fat16_write (void *private_fs, void *desc, uint32_t size, uint32_t nmemb, char *in) |
int | fat16_seek (void *desc, uint32_t offset, FILE_SEEK_MODE seek_mode) |
FAT16 Implementation of fseek. | |
int | fat16_stat (void *desc, struct file_stat *stat) |
FAT16 Implementation of fstat. | |
int | fat16_close (void *desc) |
FAT16 Implementation of fclose. | |
Variables | |
struct filesystem | fat16_fs |
Describes driver as filesystem struct for generic filesystem driver use. | |
int fat16_close | ( | void * | desc | ) |
struct filesystem * fat16_init_filesystem | ( | ) |
Prepares filesystem struct for generic filesystem driver use.
References fat16_fs, filesystem::name, and strcpy().
FAT16 Implementation of fopen.
private_fs | Private filesystem data |
path | Path to file |
mode | Open mode (FILE_MODE_READ for readonly) |
References fat_file_descriptor::cached_cluster, fat_file_descriptor::cached_offset_bytes, fat_file_descriptor::file, FILE_MODE_READ, kdebug, kzalloc(), path_part::part, and fat_file_descriptor::pos.
int fat16_read | ( | void * | private_fs, |
void * | desc, | ||
uint32_t | size, | ||
uint32_t | nmemb, | ||
char * | out | ||
) |
FAT16 Implementation of fread.
private_fs | Private filesystem data |
desc | Internal file descriptor |
size | Size of block |
nmemb | Number of blocks to read |
out | Output buffer |
References ALL_OK, fat_private::cluster_read_stream, fat_item::file, fat_file_descriptor::file, kdebug, offset, fat_file_descriptor::pos, and size.
int fat16_resolve | ( | struct disk * | disk | ) |
FAT16 filesystem resolver.
disk | Disk to resolve |
References ALL_OK, diskstreamer_close(), diskstreamer_new(), diskstreamer_read(), diskstreamer_seek(), EIO, ENOMEM, fat_header::fat_header_extended::extended, fat16_fs, disk::filesystem, disk::fs_private, fat_private::header, disk::id, kdebug, kzalloc(), fat_private::partition_offset, fat_private::root_directory, disk::sector_size, fat_header::shared, fat16_header_extended::signature, partition_entry::starting_lba, and type.
int fat16_seek | ( | void * | desc, |
uint32_t | offset, | ||
FILE_SEEK_MODE | seek_mode | ||
) |
FAT16 Implementation of fseek.
desc | Internal file descriptor |
offset | Offset |
seek_mode | Seek mode (SEEK_SET for absolute, SEEK_CUR for relative) |
References ALL_OK, EINVARG, FAT_ITEM_TYPE_FILE, fat_item::file, fat_file_descriptor::file, fat_file::filesize, kdebug, offset, fat_file_descriptor::pos, SEEK_CUR, SEEK_END, SEEK_SET, and fat_item::type.
int fat16_stat | ( | void * | desc, |
struct file_stat * | stat | ||
) |
FAT16 Implementation of fstat.
desc | Internal file descriptor |
stat | Output fstat struct |
References ALL_OK, assert_not_reached, fat_file::attribute, FAT_FILE_READONLY, FAT_ITEM_TYPE_DIRECTORY, FAT_ITEM_TYPE_FILE, fat_item::file, fat_file_descriptor::file, FILE_STAT_FOLDER, FILE_STAT_READ_ONLY, fat_file::filesize, file_stat::filesize, file_stat::flags, kdebug, and fat_item::type.
int fat16_write | ( | void * | private_fs, |
void * | desc, | ||
uint32_t | size, | ||
uint32_t | nmemb, | ||
char * | in | ||
) |
struct filesystem fat16_fs |
Describes driver as filesystem struct for generic filesystem driver use.