Xemu [doxygen]  hyppo 0a42be3a057156924bc1b626a687bd6e27349c45 @ Sat 19 Mar 02:15:11 CET 2022
Macros | Typedefs | Functions | Variables
fat32.c File Reference
#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include "fat32.h"
Include dependency graph for fat32.c:

Go to the source code of this file.

Macros

#define FDISK_SUPPORT
 
#define NL   "\n"
 
#define FATDEBUG   printf
 
#define FATDEBUGPRINT   printf
 
#define FATAL(...)   do { fprintf(stderr, "FATAL: "); fprintf(stderr, __VA_ARGS__); exit(1); } while(0)
 
#define ERROR_WINDOW(...)   do { fprintf(stderr, "ERROR: "); fprintf(stderr, __VA_ARGS__); } while(0)
 
#define OFF_T_ERROR   ((off_t)-1)
 
#define FS_MINIMAL_SIZE_IN_BLOCKS   10
 
#define AS_WORD(p, o)   (p[o] + (p[o+1] << 8))
 
#define AS_DWORD(p, o)   (p[o] + (p[o+1] << 8) + (p[o+2] << 16) + (p[o+3] << 24))
 

Typedefs

typedef uint32_t Uint32
 
typedef uint16_t Uint16
 
typedef uint8_t Uint8
 

Functions

Uint32 mfat_allocate_linear_fat_chunk (Uint32 size)
 
void mfat_init (mfat_io_callback_func_t reader, mfat_io_callback_func_t writer, Uint32 device_size)
 
int mfat_init_mbr (void)
 
int mfat_use_part (int part)
 
void mfat_open_stream (mfat_stream_t *p, Uint32 cluster)
 
void mfat_open_rootdir (mfat_stream_t *p)
 
void mfat_rewind_stream (mfat_stream_t *p)
 
Uint32 mfat_get_real_size (mfat_stream_t *p, int *fragmented)
 
int mfat_read_stream (mfat_stream_t *p, void *buf, int size)
 
int mfat_read_directory (mfat_dirent_t *p, int type_filter)
 
int mfat_search_in_directory (mfat_dirent_t *p, const char *name, int type_filter)
 
Uint32 mfat_overwrite_file_with_direct_linear_device_block_write (mfat_dirent_t *dirent, const char *name, Uint32 size)
 
int mfat_open_file_by_dirent (mfat_dirent_t *p)
 
int mfat_open_file_by_name (mfat_dirent_t *p, const char *name, int type_filter)
 
int mfat_read_file (mfat_dirent_t *p, void *buf, int size)
 
int mfat_fatize_name (char *d, const char *s)
 
int mfat_normalize_name (char *d, const char *s)
 
int main (int argc, char **argv)
 

Variables

struct mfat_part_st mfat_partitions [4]
 

Macro Definition Documentation

◆ AS_DWORD

#define AS_DWORD (   p,
 
)    (p[o] + (p[o+1] << 8) + (p[o+2] << 16) + (p[o+3] << 24))

Definition at line 151 of file fat32.c.

◆ AS_WORD

#define AS_WORD (   p,
 
)    (p[o] + (p[o+1] << 8))

Definition at line 150 of file fat32.c.

◆ ERROR_WINDOW

#define ERROR_WINDOW (   ...)    do { fprintf(stderr, "ERROR: "); fprintf(stderr, __VA_ARGS__); } while(0)

Definition at line 41 of file fat32.c.

◆ FATAL

#define FATAL (   ...)    do { fprintf(stderr, "FATAL: "); fprintf(stderr, __VA_ARGS__); exit(1); } while(0)

Definition at line 40 of file fat32.c.

◆ FATDEBUG

#define FATDEBUG   printf

Definition at line 38 of file fat32.c.

◆ FATDEBUGPRINT

#define FATDEBUGPRINT   printf

Definition at line 39 of file fat32.c.

◆ FDISK_SUPPORT

#define FDISK_SUPPORT

Definition at line 28 of file fat32.c.

◆ FS_MINIMAL_SIZE_IN_BLOCKS

#define FS_MINIMAL_SIZE_IN_BLOCKS   10

Definition at line 66 of file fat32.c.

◆ NL

#define NL   "\n"

Definition at line 37 of file fat32.c.

◆ OFF_T_ERROR

#define OFF_T_ERROR   ((off_t)-1)

Definition at line 42 of file fat32.c.

Typedef Documentation

◆ Uint16

typedef uint16_t Uint16

Definition at line 50 of file fat32.c.

◆ Uint32

typedef uint32_t Uint32

Definition at line 49 of file fat32.c.

◆ Uint8

typedef uint8_t Uint8

Definition at line 51 of file fat32.c.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 1009 of file fat32.c.

◆ mfat_allocate_linear_fat_chunk()

Uint32 mfat_allocate_linear_fat_chunk ( Uint32  size)

Definition at line 277 of file fat32.c.

◆ mfat_fatize_name()

int mfat_fatize_name ( char *  d,
const char *  s 
)

Definition at line 921 of file fat32.c.

Here is the caller graph for this function:

◆ mfat_get_real_size()

Uint32 mfat_get_real_size ( mfat_stream_t p,
int *  fragmented 
)

Definition at line 560 of file fat32.c.

◆ mfat_init()

void mfat_init ( mfat_io_callback_func_t  reader,
mfat_io_callback_func_t  writer,
Uint32  device_size 
)

Definition at line 323 of file fat32.c.

◆ mfat_init_mbr()

int mfat_init_mbr ( void  )

Definition at line 339 of file fat32.c.

◆ mfat_normalize_name()

int mfat_normalize_name ( char *  d,
const char *  s 
)

Definition at line 956 of file fat32.c.

Here is the caller graph for this function:

◆ mfat_open_file_by_dirent()

int mfat_open_file_by_dirent ( mfat_dirent_t p)

Definition at line 887 of file fat32.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mfat_open_file_by_name()

int mfat_open_file_by_name ( mfat_dirent_t p,
const char *  name,
int  type_filter 
)

Definition at line 898 of file fat32.c.

Here is the call graph for this function:

◆ mfat_open_rootdir()

void mfat_open_rootdir ( mfat_stream_t p)

Definition at line 542 of file fat32.c.

Here is the call graph for this function:

◆ mfat_open_stream()

void mfat_open_stream ( mfat_stream_t p,
Uint32  cluster 
)

Definition at line 529 of file fat32.c.

Here is the caller graph for this function:

◆ mfat_overwrite_file_with_direct_linear_device_block_write()

Uint32 mfat_overwrite_file_with_direct_linear_device_block_write ( mfat_dirent_t dirent,
const char *  name,
Uint32  size 
)

Definition at line 813 of file fat32.c.

Here is the call graph for this function:

◆ mfat_read_directory()

int mfat_read_directory ( mfat_dirent_t p,
int  type_filter 
)

Definition at line 718 of file fat32.c.

Here is the caller graph for this function:

◆ mfat_read_file()

int mfat_read_file ( mfat_dirent_t p,
void *  buf,
int  size 
)

Definition at line 907 of file fat32.c.

Here is the call graph for this function:

◆ mfat_read_stream()

int mfat_read_stream ( mfat_stream_t p,
void *  buf,
int  size 
)

Definition at line 593 of file fat32.c.

Here is the caller graph for this function:

◆ mfat_rewind_stream()

void mfat_rewind_stream ( mfat_stream_t p)

Definition at line 548 of file fat32.c.

Here is the caller graph for this function:

◆ mfat_search_in_directory()

int mfat_search_in_directory ( mfat_dirent_t p,
const char *  name,
int  type_filter 
)

Definition at line 786 of file fat32.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mfat_use_part()

int mfat_use_part ( int  part)

Definition at line 406 of file fat32.c.

Variable Documentation

◆ block

Uint32 block

Definition at line 156 of file fat32.c.

◆ blocks

Uint32 blocks

Definition at line 73 of file fat32.c.

◆ buf

Uint8 buf[512]

Definition at line 155 of file fat32.c.

◆ cluster

Uint32 cluster

Definition at line 581 of file fat32.c.

◆ cluster_block

int cluster_block

Definition at line 582 of file fat32.c.

◆ dirty

int dirty

Definition at line 157 of file fat32.c.

◆ mfat_partitions

struct mfat_part_st mfat_partitions[4]

Definition at line 78 of file fat32.c.

◆ ofs

int ofs

Definition at line 158 of file fat32.c.

◆ part

int part

Definition at line 74 of file fat32.c.

◆ reader

Definition at line 72 of file fat32.c.

◆ writer

Definition at line 72 of file fat32.c.