fat.c File Reference

#include "byteordering.h"
#include "partition.h"
#include "fat.h"
#include "fat_config.h"
#include "sd-reader_config.h"
#include <string.h>

Include dependency graph for fat.c:

Go to the source code of this file.

Data Structures

struct  fat_header_struct
struct  fat_fs_struct
struct  fat_file_struct
struct  fat_dir_struct
struct  fat_read_dir_callback_arg
struct  fat_usage_count_callback_arg

Defines

#define FAT16_CLUSTER_FREE   0x0000
#define FAT16_CLUSTER_RESERVED_MIN   0xfff0
#define FAT16_CLUSTER_RESERVED_MAX   0xfff6
#define FAT16_CLUSTER_BAD   0xfff7
#define FAT16_CLUSTER_LAST_MIN   0xfff8
#define FAT16_CLUSTER_LAST_MAX   0xffff
#define FAT32_CLUSTER_FREE   0x00000000
#define FAT32_CLUSTER_RESERVED_MIN   0x0ffffff0
#define FAT32_CLUSTER_RESERVED_MAX   0x0ffffff6
#define FAT32_CLUSTER_BAD   0x0ffffff7
#define FAT32_CLUSTER_LAST_MIN   0x0ffffff8
#define FAT32_CLUSTER_LAST_MAX   0x0fffffff
#define FAT_DIRENTRY_DELETED   0xe5
#define FAT_DIRENTRY_LFNLAST   (1 << 6)
#define FAT_DIRENTRY_LFNSEQMASK   ((1 << 6) - 1)

Functions

static uint8_t fat_read_header (struct fat_fs_struct *fs)
static cluster_t fat_get_next_cluster (const struct fat_fs_struct *fs, cluster_t cluster_num)
static offset_t fat_cluster_offset (const struct fat_fs_struct *fs, cluster_t cluster_num)
static uint8_t fat_dir_entry_read_callback (uint8_t *buffer, offset_t offset, void *p)
static uint8_t fat_calc_83_checksum (const uint8_t *file_name_83)
static uint8_t fat_get_fs_free_16_callback (uint8_t *buffer, offset_t offset, void *p)
static cluster_t fat_append_clusters (struct fat_fs_struct *fs, cluster_t cluster_num, cluster_t count)
static uint8_t fat_free_clusters (struct fat_fs_struct *fs, cluster_t cluster_num)
static uint8_t fat_terminate_clusters (struct fat_fs_struct *fs, cluster_t cluster_num)
static uint8_t fat_clear_cluster (const struct fat_fs_struct *fs, cluster_t cluster_num)
static uintptr_t fat_clear_cluster_callback (uint8_t *buffer, offset_t offset, void *p)
static offset_t fat_find_offset_for_dir_entry (struct fat_fs_struct *fs, const struct fat_dir_struct *parent, const struct fat_dir_entry_struct *dir_entry)
static uint8_t fat_write_dir_entry (const struct fat_fs_struct *fs, struct fat_dir_entry_struct *dir_entry)
struct fat_fs_structfat_open (struct partition_struct *partition)
void fat_close (struct fat_fs_struct *fs)
uint8_t fat_get_dir_entry_of_path (struct fat_fs_struct *fs, const char *path, struct fat_dir_entry_struct *dir_entry)
struct fat_file_structfat_open_file (struct fat_fs_struct *fs, const struct fat_dir_entry_struct *dir_entry)
void fat_close_file (struct fat_file_struct *fd)
intptr_t fat_read_file (struct fat_file_struct *fd, uint8_t *buffer, uintptr_t buffer_len)
intptr_t fat_write_file (struct fat_file_struct *fd, const uint8_t *buffer, uintptr_t buffer_len)
uint8_t fat_seek_file (struct fat_file_struct *fd, int32_t *offset, uint8_t whence)
uint8_t fat_resize_file (struct fat_file_struct *fd, uint32_t size)
struct fat_dir_structfat_open_dir (struct fat_fs_struct *fs, const struct fat_dir_entry_struct *dir_entry)
void fat_close_dir (struct fat_dir_struct *dd)
uint8_t fat_read_dir (struct fat_dir_struct *dd, struct fat_dir_entry_struct *dir_entry)
uint8_t fat_reset_dir (struct fat_dir_struct *dd)
uint8_t fat_create_file (struct fat_dir_struct *parent, const char *file, struct fat_dir_entry_struct *dir_entry)
uint8_t fat_delete_file (struct fat_fs_struct *fs, struct fat_dir_entry_struct *dir_entry)
uint8_t fat_create_dir (struct fat_dir_struct *parent, const char *dir, struct fat_dir_entry_struct *dir_entry)
offset_t fat_get_fs_size (const struct fat_fs_struct *fs)
offset_t fat_get_fs_free (const struct fat_fs_struct *fs)

Variables

static struct fat_fs_struct fat_fs_handles [FAT_FS_COUNT]
static struct fat_file_struct fat_file_handles [FAT_FILE_COUNT]
static struct fat_dir_struct fat_dir_handles [FAT_DIR_COUNT]


Detailed Description

FAT implementation (license: GPLv2 or LGPLv2.1)

Author:
Roland Riegel

Definition in file fat.c.


Define Documentation

#define FAT16_CLUSTER_BAD   0xfff7

Definition at line 73 of file fat.c.

Referenced by fat_free_clusters(), and fat_get_next_cluster().

#define FAT16_CLUSTER_FREE   0x0000

#define FAT16_CLUSTER_LAST_MAX   0xffff

#define FAT16_CLUSTER_LAST_MIN   0xfff8

Definition at line 74 of file fat.c.

Referenced by fat_free_clusters(), and fat_get_next_cluster().

#define FAT16_CLUSTER_RESERVED_MAX   0xfff6

Definition at line 72 of file fat.c.

Referenced by fat_free_clusters(), and fat_get_next_cluster().

#define FAT16_CLUSTER_RESERVED_MIN   0xfff0

Definition at line 71 of file fat.c.

Referenced by fat_free_clusters(), and fat_get_next_cluster().

#define FAT32_CLUSTER_BAD   0x0ffffff7

Definition at line 80 of file fat.c.

Referenced by fat_free_clusters(), and fat_get_next_cluster().

#define FAT32_CLUSTER_FREE   0x00000000

Definition at line 77 of file fat.c.

Referenced by fat_append_clusters(), fat_free_clusters(), and fat_get_next_cluster().

#define FAT32_CLUSTER_LAST_MAX   0x0fffffff

#define FAT32_CLUSTER_LAST_MIN   0x0ffffff8

Definition at line 81 of file fat.c.

Referenced by fat_free_clusters(), and fat_get_next_cluster().

#define FAT32_CLUSTER_RESERVED_MAX   0x0ffffff6

Definition at line 79 of file fat.c.

Referenced by fat_free_clusters(), and fat_get_next_cluster().

#define FAT32_CLUSTER_RESERVED_MIN   0x0ffffff0

Definition at line 78 of file fat.c.

Referenced by fat_free_clusters(), and fat_get_next_cluster().

#define FAT_DIRENTRY_DELETED   0xe5

#define FAT_DIRENTRY_LFNLAST   (1 << 6)

Definition at line 85 of file fat.c.

Referenced by fat_write_dir_entry().

#define FAT_DIRENTRY_LFNSEQMASK   ((1 << 6) - 1)

Definition at line 86 of file fat.c.


Variable Documentation

struct fat_dir_struct fat_dir_handles[FAT_DIR_COUNT] [static]

Definition at line 197 of file fat.c.

Referenced by fat_open_dir().

struct fat_file_struct fat_file_handles[FAT_FILE_COUNT] [static]

Definition at line 196 of file fat.c.

Referenced by fat_open_file().

struct fat_fs_struct fat_fs_handles[FAT_FS_COUNT] [static]

Definition at line 195 of file fat.c.

Referenced by fat_open().


Generated on Tue Jul 20 09:30:57 2010 for WaspmoteAPI by  doxygen 1.5.6