@@ -17,4 +17,37 @@ struct fat_directory_entry {
 | 
			
		||||
    uint8_t file_size[4];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct fat12_partition
 | 
			
		||||
{
 | 
			
		||||
    struct pang_io *io;
 | 
			
		||||
 | 
			
		||||
    // Number of bytes in a sector (512)
 | 
			
		||||
    uint32_t sector_size;
 | 
			
		||||
    uint8_t sector_buffer[512];
 | 
			
		||||
 | 
			
		||||
    // These units are "sectors"
 | 
			
		||||
    uint32_t fat_offset;
 | 
			
		||||
    uint32_t fat_size;
 | 
			
		||||
    uint32_t root_offset;
 | 
			
		||||
    uint32_t first_offset;
 | 
			
		||||
    uint32_t cluster_size;
 | 
			
		||||
 | 
			
		||||
    // These are in single-unit quantities
 | 
			
		||||
    uint32_t root_entries;
 | 
			
		||||
    uint32_t cluster_count;
 | 
			
		||||
    uint32_t cluster_bytes;
 | 
			
		||||
    uint32_t sector_count;
 | 
			
		||||
 | 
			
		||||
    void *fat;
 | 
			
		||||
    uint16_t *taf;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum fat_attributes {
 | 
			
		||||
    FAT_ATTR_DIR  = 0x10,
 | 
			
		||||
    FAT_ATTR_FILE = 0x20,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
uint32_t fat12_find_free_cluster(struct fat12_partition *part, uint32_t start);
 | 
			
		||||
 | 
			
		||||
#endif /* FAT12_INTERNALS_H__ */
 | 
			
		||||
@@ -5,10 +5,12 @@
 | 
			
		||||
 | 
			
		||||
struct pang_io;
 | 
			
		||||
struct fat12_partition;
 | 
			
		||||
struct fat12_file;
 | 
			
		||||
struct fat12_dirent
 | 
			
		||||
{
 | 
			
		||||
    char filename[256];
 | 
			
		||||
    uint32_t first_cluster;
 | 
			
		||||
    uint32_t parent_cluster;
 | 
			
		||||
    uint32_t size;
 | 
			
		||||
    uint32_t file_attributes;
 | 
			
		||||
    uint32_t ctime;
 | 
			
		||||
@@ -33,8 +35,14 @@ uint32_t fat12_get_cluster(void *fat, uint32_t cluster);
 | 
			
		||||
 | 
			
		||||
int fat12_ls_foreach(struct fat12_partition *part, uint32_t dir_cluster,
 | 
			
		||||
                     void *data, int (*callback)(void *data, const struct fat12_dirent *dirent));
 | 
			
		||||
int fat12_write_file(struct fat12_partition *part, const char *filename, const void *bfr, uint32_t size);
 | 
			
		||||
int fat12_delete_file(struct fat12_partition *part, const char *filename);
 | 
			
		||||
int fat12_write_file(struct fat12_partition *part, const char *filename[], const void *bfr, uint32_t size);
 | 
			
		||||
int fat12_delete_file(struct fat12_partition *part, const char *filename[]);
 | 
			
		||||
int fat12_defragment_file(struct fat12_partition *part, const char *path[]);
 | 
			
		||||
 | 
			
		||||
struct fat12_file *fat12_fopen(struct fat12_partition *part, const char *filename);
 | 
			
		||||
int fat12_fwrite(struct fat12_file *file, const void *buf, uint32_t size);
 | 
			
		||||
int fat12_fread(struct fat12_file *file, void *buf, uint32_t size);
 | 
			
		||||
int fat12_fclose(struct fat12_file **file);
 | 
			
		||||
 | 
			
		||||
int fat12_defrag(struct pang_io *io);
 | 
			
		||||
int fat12_mkfs(struct pang_io *io, uint32_t bytes);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user