Contiki-Inga 3.x
|
Additional function for the FAT file system. More...
Files | |
file | cfs-fat.c |
FAT driver implementation | |
file | cfs-fat.h |
FAT driver definitions | |
file | fat_mkfs.c |
FAT driver mkfs implementation | |
Data Structures | |
struct | FAT_Info |
Holds boot sector information. More... | |
struct | dir_entry |
Fat table entry for file. More... | |
Macros | |
#define | CFS_CONF_OFFSET_TYPE uint32_t |
Seek type is 32 bit for FAT files. More... | |
#define | FAT_SYNC 0 |
Allows to enable synchronization of FATs when unmounting device. More... | |
Functions | |
void | cfs_fat_print_file_info (int fd) |
void | cfs_fat_print_dir_entry (struct dir_entry *dir_entry) |
void | cfs_fat_get_fat_info (struct FAT_Info *info) |
Populates the given FAT_Info with the mounted FAT_Info. More... | |
uint16_t | cfs_fat_get_last_date (int fd) |
Returns the date of last modification. More... | |
uint16_t | cfs_fat_get_last_time (int fd) |
Returns the time of last modification. More... | |
uint16_t | cfs_fat_get_create_date (int fd) |
Returns the date of creation. More... | |
uint16_t | cfs_fat_get_create_time (int fd) |
Returns the time of creation. More... | |
void | cfs_fat_flush () |
Writes the current buffered block back to the disk if it was changed. | |
uint8_t | cfs_fat_mount_device (struct diskio_device_info *dev) |
Tries to mount the defined device. More... | |
void | cfs_fat_umount_device () |
Umounts the mounted device. More... | |
int | cfs_open (const char *name, int flags) |
Open a file. More... | |
void | cfs_close (int fd) |
Close an open file. More... | |
int | cfs_read (int fd, void *buf, unsigned int len) |
Read data from an open file. More... | |
int | cfs_write (int fd, const void *buf, unsigned int len) |
Write data to an open file. More... | |
cfs_offset_t | cfs_seek (int fd, cfs_offset_t offset, int whence) |
Seek to a specified position in an open file. More... | |
int | cfs_remove (const char *name) |
Remove a file. More... | |
int | cfs_opendir (struct cfs_dir *dirp, const char *name) |
Open a directory for reading directory entries. More... | |
int | cfs_readdir (struct cfs_dir *dirp, struct cfs_dirent *dirent) |
Read a directory entry. More... | |
void | cfs_closedir (struct cfs_dir *dirp) |
Close a directory opened with cfs_opendir(). More... | |
uint32_t | cfs_fat_file_size (int fd) |
Returns the file size of the associated file. More... | |
void | cfs_fat_sync_fats () |
Syncs every FAT with the first. More... | |
uint8_t | is_a_power_of_2 (uint32_t value) |
Tests if the given value is a power of 2. More... | |
uint32_t | round_down_to_power_of_2 (uint32_t value) |
Rounds the value down to the next lower power of 2. More... | |
int | cfs_fat_mkfs (struct diskio_device_info *dev) |
Formats the specified device as FAT16/32. More... | |
void | cfs_fat_print_cluster_chain (int fd) |
Variables | |
struct file_system | mounted |
From fat.c. | |
struct file | fat_file_pool [FAT_FD_POOL_SIZE] |
From fat.c. | |
struct file_desc | fat_fd_pool [FAT_FD_POOL_SIZE] |
From fat.c. | |
Additional function for the FAT file system.
#define CFS_CONF_OFFSET_TYPE uint32_t |
#define FAT_SYNC 0 |
void cfs_close | ( | int | fd | ) |
Close an open file.
fd | The file descriptor of the open file. This function closes a file that has previously been opened with cfs_open(). |
Definition at line 934 of file cfs-fat.c.
References cfs_fat_flush(), fat_fd_pool, and NULL.
void cfs_closedir | ( | struct cfs_dir * | dirp | ) |
Close a directory opened with cfs_opendir().
dirp | A pointer to a struct cfs_dir that has been opened with cfs_opendir(). |
uint32_t cfs_fat_file_size | ( | int | fd | ) |
Returns the file size of the associated file.
fd |
Definition at line 1384 of file cfs-fat.c.
References fat_fd_pool, fat_file_pool, and NULL.
uint16_t cfs_fat_get_create_date | ( | int | fd | ) |
Returns the date of creation.
Format: [15-9: year sine 1980, 8-5: month, 4-0: day]
fd | File descriptor |
Definition at line 424 of file cfs-fat.c.
References fat_file_pool.
uint16_t cfs_fat_get_create_time | ( | int | fd | ) |
Returns the time of creation.
Format: [15-11: hours, 10-5: minutes, 4-0: seconds/2]
fd | File descriptor |
Definition at line 430 of file cfs-fat.c.
References fat_file_pool.
void cfs_fat_get_fat_info | ( | struct FAT_Info * | info | ) |
uint16_t cfs_fat_get_last_date | ( | int | fd | ) |
Returns the date of last modification.
Format: [15-9: year sine 1980, 8-5: month, 4-0: day]
fd | File descriptor |
Definition at line 412 of file cfs-fat.c.
References fat_file_pool.
uint16_t cfs_fat_get_last_time | ( | int | fd | ) |
Returns the time of last modification.
Format: [15-11: hours, 10-5: minutes, 4-0: seconds/2]
fd | File descriptor |
Definition at line 418 of file cfs-fat.c.
References fat_file_pool.
int cfs_fat_mkfs | ( | struct diskio_device_info * | dev | ) |
Formats the specified device as FAT16/32.
dev | device to format |
Definition at line 74 of file fat_mkfs.c.
uint8_t cfs_fat_mount_device | ( | struct diskio_device_info * | dev | ) |
Tries to mount the defined device.
dev | The device on which a FAT-FS should be mounted. |
Definition at line 808 of file cfs-fat.c.
References cfs_fat_umount_device(), diskio_read_block(), and mounted.
void cfs_fat_print_cluster_chain | ( | int | fd | ) |
fd |
void cfs_fat_print_dir_entry | ( | struct dir_entry * | dir_entry | ) |
dir_entry |
Definition at line 388 of file cfs-fat.c.
References dir_entry::DIR_CrtDate, dir_entry::DIR_CrtTime, dir_entry::DIR_FileSize, dir_entry::DIR_LstAccessDate, dir_entry::DIR_WrtDate, and dir_entry::DIR_WrtTime.
void cfs_fat_print_file_info | ( | int | fd | ) |
fd |
Definition at line 361 of file cfs-fat.c.
References dir_entry::DIR_CrtDate, dir_entry::DIR_CrtTime, dir_entry::DIR_FileSize, dir_entry::DIR_LstAccessDate, dir_entry::DIR_WrtDate, dir_entry::DIR_WrtTime, fat_fd_pool, and fat_file_pool.
void cfs_fat_sync_fats | ( | ) |
Syncs every FAT with the first.
Syncs every FAT with the first FAT.
Can take much time.
Definition at line 1401 of file cfs-fat.c.
References cfs_fat_flush(), diskio_read_block(), diskio_write_block(), and mounted.
Referenced by cfs_fat_umount_device().
void cfs_fat_umount_device | ( | ) |
Umounts the mounted device.
Invalidates all file descriptors. (Syncs all FATs (only if FAT_SYNC is set)) and flushes cached data.
Definition at line 843 of file cfs-fat.c.
References cfs_fat_flush(), cfs_fat_sync_fats(), fat_fd_pool, and mounted.
Referenced by cfs_fat_mount_device().
int cfs_open | ( | const char * | name, |
int | flags | ||
) |
Open a file.
name | The name of the file. |
flags | CFS_READ, or CFS_WRITE/CFS_APPEND, or both. |
This function opens a file and returns a file descriptor for the opened file. If the file could not be opened, the function returns -1. The function can open a file for reading or writing, or both.
An opened file must be closed with cfs_close().
Definition at line 867 of file cfs-fat.c.
References CFS_APPEND, cfs_remove(), cfs_seek(), CFS_SEEK_END, CFS_WRITE, fat_fd_pool, and fat_file_pool.
int cfs_opendir | ( | struct cfs_dir * | dirp, |
const char * | name | ||
) |
Open a directory for reading directory entries.
dirp | A pointer to a struct cfs_dir that is filled in by the function. |
name | The name of the directory. |
int cfs_read | ( | int | fd, |
void * | buf, | ||
unsigned int | len | ||
) |
Read data from an open file.
fd | The file descriptor of the open file. |
buf | The buffer in which data should be read from the file. |
len | The number of bytes that should be read. |
This function reads data from an open file into a buffer. The file must have first been opened with cfs_open() and the CFS_READ flag.
Definition at line 952 of file cfs-fat.c.
References CFS_READ, and fat_fd_pool.
int cfs_readdir | ( | struct cfs_dir * | dirp, |
struct cfs_dirent * | dirent | ||
) |
Read a directory entry.
dirp | A pointer to a struct cfs_dir that has been opened with cfs_opendir(). |
dirent | A pointer to a struct cfs_dirent that is filled in by cfs_readdir() |
0 | If a directory entry was read. |
-1 | If no more directory entries can be read. |
Definition at line 1107 of file cfs-fat.c.
References dir_entry::DIR_FileSize, and mounted.
int cfs_remove | ( | const char * | name | ) |
Remove a file.
name | The name of the file. |
0 | If the file was removed. |
Definition at line 1068 of file cfs-fat.c.
References cfs_fat_flush().
cfs_offset_t cfs_seek | ( | int | fd, |
cfs_offset_t | offset, | ||
int | whence | ||
) |
Seek to a specified position in an open file.
fd | The file descriptor of the open file. |
offset | A position, either relative or absolute, in the file. |
whence | Determines how to interpret the offset parameter. |
This function moves the file position to the specified position in the file. The next byte that is read from or written to the file will be at the position given determined by the combination of the offset parameter and the whence parameter.
Definition at line 1036 of file cfs-fat.c.
References CFS_SEEK_CUR, CFS_SEEK_END, CFS_SEEK_SET, dir_entry::DIR_FileSize, fat_fd_pool, and fat_file_pool.
int cfs_write | ( | int | fd, |
const void * | buf, | ||
unsigned int | len | ||
) |
Write data to an open file.
fd | The file descriptor of the open file. |
buf | The buffer from which data should be written to the file. |
len | The number of bytes that should be written. |
This function reads writes data from a memory buffer to an open file. The file must have been opened with cfs_open() and the CFS_WRITE flag.
uint8_t is_a_power_of_2 | ( | uint32_t | value | ) |