Functions | |
struct fat16_fs_struct * | fat16_open (struct partition_struct *partition) |
void | fat16_close (struct fat16_fs_struct *fs) |
static uint8_t | fat16_read_header (struct fat16_fs_struct *fs) |
static uint16_t | fat16_get_next_cluster (const struct fat16_fs_struct *fs, uint16_t cluster_num) |
static uint16_t | fat16_append_clusters (const struct fat16_fs_struct *fs, uint16_t cluster_num, uint16_t count) |
static uint8_t | fat16_free_clusters (const struct fat16_fs_struct *fs, uint16_t cluster_num) |
static uint8_t | fat16_terminate_clusters (const struct fat16_fs_struct *fs, uint16_t cluster_num) |
static uint8_t | fat16_clear_cluster (const struct fat16_fs_struct *fs, uint16_t cluster_num) |
static uint16_t | fat16_clear_cluster_callback (uint8_t *buffer, uint32_t offset, void *p) |
static uint32_t | fat16_cluster_offset (const struct fat16_fs_struct *fs, uint16_t cluster_num) |
static uint8_t | fat16_dir_entry_read_callback (uint8_t *buffer, uint32_t offset, void *p) |
static uint8_t | fat16_interpret_dir_entry (struct fat16_dir_entry_struct *dir_entry, const uint8_t *raw_entry) |
static uint32_t | fat16_find_offset_for_dir_entry (const struct fat16_fs_struct *fs, const struct fat16_dir_struct *parent, const struct fat16_dir_entry_struct *dir_entry) |
static uint8_t | fat16_write_dir_entry (const struct fat16_fs_struct *fs, struct fat16_dir_entry_struct *dir_entry) |
uint32_t | fat16_get_fs_size (const struct fat16_fs_struct *fs) |
uint32_t | fat16_get_fs_free (const struct fat16_fs_struct *fs) |
static uint8_t | fat16_get_fs_free_callback (uint8_t *buffer, uint32_t offset, void *p) |
uint16_t fat16_append_clusters | ( | const struct fat16_fs_struct * | fs, | |
uint16_t | cluster_num, | |||
uint16_t | count | |||
) | [static] |
Appends a new cluster chain to an existing one.
Set cluster_num to zero to create a completely new one.
[in] | fs | The file system on which to operate. |
[in] | cluster_num | The cluster to which to append the new chain. |
[in] | count | The number of clusters to allocate. |
Definition at line 504 of file fat16.c.
References partition_struct::device_read, partition_struct::device_write, FAT16_CLUSTER_FREE, FAT16_CLUSTER_LAST_MAX, fat16_free_clusters(), fat16_header_struct::fat_offset, fat16_header_struct::fat_size, fat16_fs_struct::header, and fat16_fs_struct::partition.
Referenced by fat16_create_dir(), fat16_find_offset_for_dir_entry(), fat16_resize_file(), and fat16_write_file().
uint8_t fat16_clear_cluster | ( | const struct fat16_fs_struct * | fs, | |
uint16_t | cluster_num | |||
) | [static] |
Clears a single cluster.
The complete cluster is filled with zeros.
[in] | fs | The filesystem on which to operate. |
[in] | cluster_num | The cluster to clear. |
Definition at line 690 of file fat16.c.
References fat16_header_struct::cluster_size, partition_struct::device_write_interval, fat16_clear_cluster_callback(), fat16_cluster_offset(), fat16_fs_struct::header, and fat16_fs_struct::partition.
Referenced by fat16_create_dir(), and fat16_find_offset_for_dir_entry().
uint16_t fat16_clear_cluster_callback | ( | uint8_t * | buffer, | |
uint32_t | offset, | |||
void * | p | |||
) | [static] |
Callback function for clearing a cluster.
Definition at line 713 of file fat16.c.
Referenced by fat16_clear_cluster().
void fat16_close | ( | struct fat16_fs_struct * | fs | ) |
Closes a FAT16 filesystem.
When this function returns, the given filesystem descriptor will be invalid.
[in] | fs | The filesystem to close. |
Definition at line 275 of file fat16.c.
References fat16_fs_struct::partition.
uint32_t fat16_cluster_offset | ( | const struct fat16_fs_struct * | fs, | |
uint16_t | cluster_num | |||
) | [static] |
Calculates the offset of the specified cluster.
[in] | fs | The filesystem on which to operate. |
[in] | cluster_num | The cluster whose offset to calculate. |
Definition at line 731 of file fat16.c.
References fat16_header_struct::cluster_size, fat16_header_struct::cluster_zero_offset, and fat16_fs_struct::header.
Referenced by fat16_clear_cluster(), fat16_find_offset_for_dir_entry(), fat16_read_dir(), fat16_read_file(), and fat16_write_file().
uint8_t fat16_dir_entry_read_callback | ( | uint8_t * | buffer, | |
uint32_t | offset, | |||
void * | p | |||
) | [static] |
Callback function for reading a directory entry.
Definition at line 1343 of file fat16.c.
References fat16_read_dir_callback_arg::bytes_read, fat16_read_dir_callback_arg::dir_entry, fat16_dir_entry_struct::entry_offset, FAT16_DIRENTRY_DELETED, fat16_interpret_dir_entry(), and fat16_read_dir_callback_arg::finished.
Referenced by fat16_read_dir().
uint32_t fat16_find_offset_for_dir_entry | ( | const struct fat16_fs_struct * | fs, | |
const struct fat16_dir_struct * | parent, | |||
const struct fat16_dir_entry_struct * | dir_entry | |||
) | [static] |
Searches for space where to store a directory entry.
[in] | fs | The filesystem on which to operate. |
[in] | parent | The directory in which to search. |
[in] | dir_entry | The directory entry for which to search space. |
Definition at line 1477 of file fat16.c.
References fat16_dir_entry_struct::cluster, fat16_header_struct::cluster_size, fat16_header_struct::cluster_zero_offset, partition_struct::device_read, fat16_dir_struct::dir_entry, fat16_append_clusters(), fat16_clear_cluster(), fat16_cluster_offset(), FAT16_DIRENTRY_DELETED, fat16_get_next_cluster(), fat16_fs_struct::header, fat16_dir_entry_struct::long_name, fat16_fs_struct::partition, and fat16_header_struct::root_dir_offset.
Referenced by fat16_create_dir(), and fat16_create_file().
uint8_t fat16_free_clusters | ( | const struct fat16_fs_struct * | fs, | |
uint16_t | cluster_num | |||
) | [static] |
Frees a cluster chain, or a part thereof.
Marks the specified cluster and all clusters which are sequentially referenced by it as free. They may then be used again for future file allocations.
[in] | fs | The filesystem on which to operate. |
[in] | cluster_num | The starting cluster of the chain which to free. |
Definition at line 596 of file fat16.c.
References partition_struct::device_read, partition_struct::device_write, FAT16_CLUSTER_BAD, FAT16_CLUSTER_FREE, FAT16_CLUSTER_LAST_MAX, FAT16_CLUSTER_LAST_MIN, FAT16_CLUSTER_RESERVED_MAX, FAT16_CLUSTER_RESERVED_MIN, fat16_header_struct::fat_offset, fat16_fs_struct::header, and fat16_fs_struct::partition.
Referenced by fat16_append_clusters(), fat16_create_dir(), fat16_delete_file(), fat16_resize_file(), and fat16_terminate_clusters().
uint32_t fat16_get_fs_free | ( | const struct fat16_fs_struct * | fs | ) |
Returns the amount of free storage capacity on the filesystem in bytes.
[in] | fs | The filesystem on which to operate. |
Definition at line 2100 of file fat16.c.
References fat16_usage_count_callback_arg::buffer_size, fat16_usage_count_callback_arg::cluster_count, fat16_header_struct::cluster_size, partition_struct::device_read_interval, fat16_get_fs_free_callback(), fat16_header_struct::fat_offset, fat16_header_struct::fat_size, fat16_fs_struct::header, and fat16_fs_struct::partition.
Referenced by print_disk_info().
uint8_t fat16_get_fs_free_callback | ( | uint8_t * | buffer, | |
uint32_t | offset, | |||
void * | p | |||
) | [static] |
Callback function used for counting free clusters.
Definition at line 2139 of file fat16.c.
References fat16_usage_count_callback_arg::buffer_size, fat16_usage_count_callback_arg::cluster_count, and FAT16_CLUSTER_FREE.
Referenced by fat16_get_fs_free().
uint32_t fat16_get_fs_size | ( | const struct fat16_fs_struct * | fs | ) |
Returns the amount of total storage capacity of the filesystem in bytes.
[in] | fs | The filesystem on which to operate. |
Definition at line 2082 of file fat16.c.
References fat16_header_struct::cluster_size, fat16_header_struct::fat_size, and fat16_fs_struct::header.
Referenced by print_disk_info().
uint16_t fat16_get_next_cluster | ( | const struct fat16_fs_struct * | fs, | |
uint16_t | cluster_num | |||
) | [static] |
Retrieves the next following cluster of a given cluster.
Using the filesystem file allocation table, this function returns the number of the cluster containing the data directly following the data within the cluster with the given number.
[in] | fs | The filesystem for which to determine the next cluster. |
[in] | cluster_num | The number of the cluster for which to determine its successor. |
Definition at line 470 of file fat16.c.
References partition_struct::device_read, FAT16_CLUSTER_BAD, FAT16_CLUSTER_FREE, FAT16_CLUSTER_LAST_MAX, FAT16_CLUSTER_LAST_MIN, FAT16_CLUSTER_RESERVED_MAX, FAT16_CLUSTER_RESERVED_MIN, fat16_header_struct::fat_offset, fat16_fs_struct::header, and fat16_fs_struct::partition.
Referenced by fat16_find_offset_for_dir_entry(), fat16_read_dir(), fat16_read_file(), fat16_resize_file(), fat16_terminate_clusters(), and fat16_write_file().
uint8_t fat16_interpret_dir_entry | ( | struct fat16_dir_entry_struct * | dir_entry, | |
const uint8_t * | raw_entry | |||
) | [static] |
Interprets a raw directory entry and puts the contained information into the directory entry.
For a single file there may exist multiple directory entries. All except the last one are lfn entries, which contain parts of the long filename. The last directory entry is a traditional 8.3 style one. It contains all other information like size, cluster, date and time.
[in,out] | dir_entry | The directory entry to fill. |
[in] | raw_entry | A pointer to 32 bytes of raw data. |
Definition at line 1393 of file fat16.c.
References fat16_dir_entry_struct::attributes, fat16_dir_entry_struct::cluster, FAT16_DIRENTRY_DELETED, fat16_dir_entry_struct::file_size, and fat16_dir_entry_struct::long_name.
Referenced by fat16_dir_entry_read_callback().
struct fat16_fs_struct* fat16_open | ( | struct partition_struct * | partition | ) | [read] |
Opens a FAT16 filesystem.
[in] | partition | Discriptor of partition on which the filesystem resides. |
Definition at line 219 of file fat16.c.
References partition_struct::device_write, partition_struct::device_write_interval, FAT16_FS_COUNT, fat16_fs_handles, fat16_read_header(), FAT16_WRITE_SUPPORT, and fat16_fs_struct::partition.
Referenced by main().
uint8_t fat16_read_header | ( | struct fat16_fs_struct * | fs | ) | [static] |
Reads and parses the header of a FAT16 filesystem.
inout] | fs The filesystem for which to parse the header. |
Definition at line 294 of file fat16.c.
References fat16_header_struct::cluster_size, fat16_header_struct::cluster_zero_offset, partition_struct::device_read, fat16_header_struct::fat_offset, fat16_header_struct::fat_size, fat16_fs_struct::header, partition_struct::offset, fat16_fs_struct::partition, PARTITION_TYPE_FAT16, fat16_header_struct::root_dir_offset, fat16_header_struct::sector_size, fat16_header_struct::size, and partition_struct::type.
Referenced by fat16_open().
uint8_t fat16_terminate_clusters | ( | const struct fat16_fs_struct * | fs, | |
uint16_t | cluster_num | |||
) | [static] |
Frees a part of a cluster chain and correctly terminates the rest.
Marks the specified cluster as the new end of a cluster chain and frees all following clusters.
[in] | fs | The filesystem on which to operate. |
[in] | cluster_num | The new end of the cluster chain. |
Definition at line 654 of file fat16.c.
References partition_struct::device_write, FAT16_CLUSTER_LAST_MAX, fat16_free_clusters(), fat16_get_next_cluster(), fat16_header_struct::fat_offset, fat16_fs_struct::header, and fat16_fs_struct::partition.
Referenced by fat16_resize_file().
uint8_t fat16_write_dir_entry | ( | const struct fat16_fs_struct * | fs, | |
struct fat16_dir_entry_struct * | dir_entry | |||
) | [static] |
Writes a directory entry to disk.
The generation of the short 8.3 file name is quite simple. The first eight characters are used for the filename. The extension, if any, is made up of the first three characters following the last dot within the long filename. If the filename (without the extension) is longer than eight characters, the lower byte of the cluster number replaces the last two characters to avoid name clashes. In any other case, it is your responsibility to avoid name clashes.
[in] | fs | The filesystem on which to operate. |
[in] | dir_entry | The directory entry to write. |
Definition at line 1589 of file fat16.c.
References fat16_dir_entry_struct::attributes, fat16_dir_entry_struct::cluster, partition_struct::device_write, fat16_dir_entry_struct::entry_offset, FAT16_DIRENTRY_DELETED, FAT16_DIRENTRY_LFNLAST, fat16_get_datetime, fat16_set_file_modification_date(), fat16_set_file_modification_time(), fat16_dir_entry_struct::file_size, fat16_dir_entry_struct::long_name, and fat16_fs_struct::partition.
Referenced by fat16_create_dir(), fat16_create_file(), fat16_resize_file(), and fat16_write_file().