embpart/mount/mount.h

52 lines
1.4 KiB
C

#ifndef EMBPART_MOUNT_H
#define EMBPART_MOUNT_H
#include <stdint.h>
#include "../MassStorage.h"
#include "../fs/fs_driver.h"
#define MNT_MAX_MOUNTED_VOLUMES (4)
#define MNT_MAX_MOUNT_NAME_LENGTH (15)
#define MNT_CTRL_BLOCK_PREALLOC_SIZE (64)
#define MNT_MAX_OPEN_FILES (6)
#define MNT_FILE_HELPER_PREALLOC_SIZE (47)
typedef struct {
uint32_t part_size; // partition size
char mnt_name[MNT_MAX_MOUNT_NAME_LENGTH + 1]; // name of the mount
Fs_Driver driver; // file system driver
uint8_t fs_control_block_area[MNT_CTRL_BLOCK_PREALLOC_SIZE]; // pointer to file system control block
} Mnt_Volume;
typedef struct {
Mnt_Volume vols[MNT_MAX_MOUNTED_VOLUMES]; // volume slots
uint8_t mounted_vols; // number of mounted volumes
} Mnt_MountTable;
typedef struct {
Mnt_Volume * vol; // pointer to volume
uint8_t helper[MNT_FILE_HELPER_PREALLOC_SIZE]; // pointer to helper object
uint8_t ctrl_word; // control word
} Mnt_File;
typedef struct {
Mnt_File files[MNT_MAX_OPEN_FILES]; // file helpers
uint8_t open_files; // number of open files
} Mnt_FileTable;
int mnt_automount_disk(MassStorage * mstg); // attempt to automount volumes
void mnt_list(const char * dir);
Mnt_File * mnt_open(const char * path);
int mnt_read(Mnt_File * file, unsigned long len, void * buf);
int mnt_seek(Mnt_File * file, unsigned long pos);
void mnt_close(Mnt_File * file);
void mnt_print_info();
#endif //EMBPART_MOUNT_H