load_fat.c

Vai alla documentazione di questo file.
00001 
00013 #include <stdio.h>
00014 #include <stdlib.h>
00015 #include <errno.h>
00016 
00017 #include "Include/fat.h"
00018 #include "Include/load_fat.h"
00019 #include "Include/sfaterror.h" 
00020 
00021 int mount_fat(FILE *fs, struct fat_ctrl *f_ctrl){
00022         
00023         if ( !(fs) || !(f_ctrl) ) return EBDP;
00024         /* Lettura informazioni del boot sector */
00025         if (!(fread(&(f_ctrl->b_sector), sizeof(struct boot_sector), 1, fs))){;
00026         sfaterror(ERFCD);
00027         return ERFCD;
00028         }
00029 
00030         /* Alloco memoria per la FAT */
00031         if (!(f_ctrl->fat_ptr = calloc((f_ctrl->b_sector).num_block, sizeof(unsigned int)))){
00032         sfaterror(STDLIBERR);
00033         return STDLIBERR;
00034         } 
00035         
00036         /* Lettura dei dati della FAT */
00037         if (!(fread(f_ctrl->fat_ptr,((f_ctrl->b_sector).num_block * sizeof(unsigned int)), 1, fs))){
00038         sfaterror(ERFCD);
00039         return ERFCD;
00040         }
00041         
00042         f_ctrl->blk_base = sizeof(struct boot_sector) + (sizeof(unsigned int) * (f_ctrl->b_sector).num_block); 
00043         
00044         return 0;
00045 }
Generato il Fri Jan 28 22:16:31 2011 per SFAT: Simplified File Allocation Table Project da  doxygen 1.6.3