Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. fat_begin_lba = 0x00;
  2. cluster_begin_lba = 0x00;
  3. sectors_per_cluster= 0x00;
  4. root_dir_first_cluster = 0x00;
  5.  
  6. readSector(0x00, Cluster);
  7. for (i = 0;i < 4;i++){
  8. Partition_LBA_Begin <<= 8;
  9. Partition_LBA_Begin |= Cluster[457 - i];
  10. }
  11.  
  12. readSector(Partition_LBA_Begin,Cluster);//Read VolumeID Partition1
  13. for (i = 0;i < 2;i++){
  14. Number_of_Reserved_Sectors <<= 8;
  15. Number_of_Reserved_Sectors |= Cluster[15 - i];
  16. }
  17. fat_begin_lba = Partition_LBA_Begin + Number_of_Reserved_Sectors;
  18. for (i = 0;i < 4;i++){
  19. Sectors_Per_FAT <<= 8;
  20. Sectors_Per_FAT |= Cluster[39 - i];
  21. }
  22. cluster_begin_lba = Partition_LBA_Begin + Number_of_Reserved_Sectors + (2 * Sectors_Per_FAT);
  23. sectors_per_cluster = Cluster[13];
  24. for (i = 0;i < 4;i++){
  25. root_dir_first_cluster <<= 8;
  26. root_dir_first_cluster |= Cluster[47 - i];
  27. }
  28.  
  29. if (sectors_per_cluster > 8){
  30. return 1; //Format Unsupported
  31. }
  32. else{
  33. Cluster = (uint8_t*)realloc(Cluster, 512 * sectors_per_cluster);
  34. FAT = (uint32_t*)realloc(FAT, 128);
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement