# modules/minfs/minfs.h File Reference

`#include <stdint.h>`
`#include <stddef.h>`

## Data Structures
struct | MINFS_fs_info_t
struct | MINFS_fs_header_t
struct | MINFS_fs_calc_t
struct | MINFS_fs_t
struct | MINFS_file_info_t
struct | MINFS_file_header_t
struct | MINFS_file_t
struct | MINFS_block_buf_t
## Defines
#define | MINFS_FS_SIG "MIFS"
#define | MINFS_FILE_SIG "MIFL"
#define | MINFS_FLAGS_NOPEC 0x00
#define | MINFS_FLAGS_PEC8 0x01
#define | MINFS_FLAGS_PEC16 0x02
#define | MINFS_FLAGS_PEC32 0x03
#define | MINFS_FLAGMASK_PEC 0x03
#define | MINFS_SEEK_END 0xFFFFFFFF
#define | MINFS_BLOCK_NULL 0xFFFFFFFF
#define | MINFS_FILE_NULL 0xFFFFFFFF
#define | MINFS_FILE_INDEX 0x00000000
#define | MINFS_BLOCK_EOC 0
#define | MINFS_ERROR_NO_BUFFER -1
#define | MINFS_ERROR_FS_SIG -2
#define | MINFS_ERROR_NUM_BLOCKS -3
#define | MINFS_ERROR_BLOCK_SIZE -4
#define | MINFS_ERROR_BLOCK_N -5
#define | MINFS_ERROR_PEC -6
#define | MINFS_ERROR_BNP -7
#define | MINFS_ERROR_FILE_SIG -9
#define | MINFS_ERROR_FILE_CHAIN -10
#define | MINFS_ERROR_FILE_ID -11
#define | MINFS_ERROR_FILE_EXISTS -12
#define | MINFS_ERROR_FILE_NOT_EXISTS -13
#define | MINFS_ERROR_BAD_MODE -14
#define | MINFS_STATUS_EOF -128
#define | MINFS_STATUS_FULL -129
#define | MINFS_MIN_BLOCKSIZE_EXP 4
#define | MINFS_MAX_BLOCKSIZE_EXP 12
#define | MINFS_MAX_NUMBLOCKS 0x000FFFFF
#define | MINFS_MAX_FILE_ID 0x000FFFFD
#define | MINFS_MODE_FFID_NEXT 0
#define | MINFS_MODE_FFID_FIRST 0
## Functions
int32_t | MINFS_InitBlockBuffer (MINFS_block_buf_t *p_block_buf)
int32_t | MINFS_FlushBlockBuffer (MINFS_fs_t *p_fs, MINFS_block_buf_t *p_block_buf)
int32_t | MINFS_Format (MINFS_fs_t *p_fs, MINFS_block_buf_t *p_block_buf)
int32_t | MINFS_FSOpen (MINFS_fs_t *p_fs, MINFS_block_buf_t *p_block_buf)
int32_t | MINFS_FileOpen (MINFS_fs_t *p_fs, uint32_t file_id, MINFS_file_t *p_file, MINFS_block_buf_t *p_block_buf)
int32_t | MINFS_FileRead (MINFS_file_t *p_file, void *p_buf, uint32_t *p_len, MINFS_block_buf_t *p_block_buf)
int32_t | MINFS_FileWrite (MINFS_file_t *p_file, void *p_buf, uint32_t len, MINFS_block_buf_t *p_block_buf)
int32_t | MINFS_FileSeek (MINFS_file_t *p_file, uint32_t pos, MINFS_block_buf_t *p_block_buf)
int32_t | MINFS_FileSetSize (MINFS_file_t *p_file, uint32_t new_size, MINFS_block_buf_t *p_block_buf)
int32_t | MINFS_FileTouch (MINFS_fs_t *p_fs, uint32_t file_id, MINFS_block_buf_t *p_block_buf)
int32_t | MINFS_FileUnlink (MINFS_fs_t *p_fs, uint32_t file_id, uint8_t check_last_truncate, MINFS_block_buf_t *block_buf)
int32_t | MINFS_FileMove (MINFS_fs_t *p_fs, uint32_t src_file_id, uint32_t dst_file_id, uint8_t check_last_truncate, MINFS_block_buf_t *p_block_buf)
int32_t | MINFS_FileExists (MINFS_fs_t *p_fs, uint32_t file_id, MINFS_block_buf_t *p_block_buf)
int32_t | MINFS_FileGetFreeID (MINFS_fs_t *p_fs, uint8_t mode, MINFS_block_buf_t *p_block_buf)
int32_t | MINFS_FileIndexTruncate (MINFS_fs_t *p_fs, MINFS_block_buf_t *p_block_buf)

## Define Documentation

#define MINFS_BLOCK_EOC 0

#define MINFS_BLOCK_NULL 0xFFFFFFFF

#define MINFS_ERROR_BAD_MODE -14

#define MINFS_ERROR_BLOCK_N -5

#define MINFS_ERROR_BLOCK_SIZE -4

#define MINFS_ERROR_BNP -7

#define MINFS_ERROR_FILE_CHAIN -10

#define MINFS_ERROR_FILE_EXISTS -12

#define MINFS_ERROR_FILE_ID -11

#define MINFS_ERROR_FILE_NOT_EXISTS -13

#define MINFS_ERROR_FILE_SIG -9

#define MINFS_ERROR_FS_SIG -2

#define MINFS_ERROR_NO_BUFFER -1

#define MINFS_ERROR_NUM_BLOCKS -3

#define MINFS_ERROR_PEC -6

#define MINFS_FILE_INDEX 0x00000000

#define MINFS_FILE_NULL 0xFFFFFFFF

#define MINFS_FILE_SIG "MIFL"

#define MINFS_FLAGMASK_PEC 0x03

#define MINFS_FLAGS_NOPEC 0x00

#define MINFS_FLAGS_PEC16 0x02

#define MINFS_FLAGS_PEC32 0x03

#define MINFS_FLAGS_PEC8 0x01

#define MINFS_FS_SIG "MIFS"

#define MINFS_MAX_BLOCKSIZE_EXP 12

#define MINFS_MAX_FILE_ID 0x000FFFFD

#define MINFS_MAX_NUMBLOCKS 0x000FFFFF

#define MINFS_MIN_BLOCKSIZE_EXP 4

#define MINFS_MODE_FFID_FIRST 0

#define MINFS_MODE_FFID_NEXT 0

#define MINFS_SEEK_END 0xFFFFFFFF

#define MINFS_STATUS_EOF -128

#define MINFS_STATUS_FULL -129

## Function Documentation

int32_t MINFS_FileExists | ( | MINFS_fs_t * | p_fs,
|  | uint32_t | file_id,
|  | MINFS_block_buf_t * | p_block_buf |
| ) |  |  |

int32_t MINFS_FileGetFreeID | ( | MINFS_fs_t * | p_fs,
|  | uint8_t | mode,
|  | MINFS_block_buf_t * | p_block_buf |
| ) |  |  |

int32_t MINFS_FileIndexTruncate | ( | MINFS_fs_t * | p_fs,
|  | MINFS_block_buf_t * | p_block_buf |
| ) |  |  |

int32_t MINFS_FileMove | ( | MINFS_fs_t * | p_fs,
|  | uint32_t | src_file_id,
|  | uint32_t | dst_file_id,
|  | uint8_t | check_last_truncate,
|  | MINFS_block_buf_t * | p_block_buf |
| ) |  |  |

int32_t MINFS_FileOpen | ( | MINFS_fs_t * | p_fs,
|  | uint32_t | file_id,
|  | MINFS_file_t * | p_file,
|  | MINFS_block_buf_t * | p_block_buf |
| ) |  |  |

int32_t MINFS_FileRead | ( | MINFS_file_t * | p_file,
|  | void * | p_buf,
|  | uint32_t * | p_len,
|  | MINFS_block_buf_t * | p_block_buf |
| ) |  |  |

int32_t MINFS_FileSeek | ( | MINFS_file_t * | p_file,
|  | uint32_t | pos,
|  | MINFS_block_buf_t * | p_block_buf |
| ) |  |  |

int32_t MINFS_FileSetSize | ( | MINFS_file_t * | p_file,
|  | uint32_t | new_size,
|  | MINFS_block_buf_t * | p_block_buf |
| ) |  |  |

int32_t MINFS_FileTouch | ( | MINFS_fs_t * | p_fs,
|  | uint32_t | file_id,
|  | MINFS_block_buf_t * | p_block_buf |
| ) |  |  |

int32_t MINFS_FileUnlink | ( | MINFS_fs_t * | p_fs,
|  | uint32_t | file_id,
|  | uint8_t | check_last_truncate,
|  | MINFS_block_buf_t * | block_buf |
| ) |  |  |

int32_t MINFS_FileWrite | ( | MINFS_file_t * | p_file,
|  | void * | p_buf,
|  | uint32_t | len,
|  | MINFS_block_buf_t * | p_block_buf |
| ) |  |  |

int32_t MINFS_FlushBlockBuffer | ( | MINFS_fs_t * | p_fs,
|  | MINFS_block_buf_t * | p_block_buf |
| ) |  |  |

int32_t MINFS_Format | ( | MINFS_fs_t * | p_fs,
|  | MINFS_block_buf_t * | p_block_buf |
| ) |  |  |

int32_t MINFS_FSOpen | ( | MINFS_fs_t * | p_fs,
|  | MINFS_block_buf_t * | p_block_buf |
| ) |  |  |

int32_t MINFS_InitBlockBuffer | ( | MINFS_block_buf_t * | p_block_buf | ) |