-
Notifications
You must be signed in to change notification settings - Fork 0
/
fatinfo.c
44 lines (37 loc) · 1.35 KB
/
fatinfo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Program to print information about a FAT file system.
*/
#include <stdio.h>
#include "fatfs.h"
#include "wordio.h"
#include "blockio.h"
#include "directory.h"
/*
* Function to print information about a FAT filesystem (useful for debugging).
*/
void print_filesystem_info(const filesystem_info *fsinfo)
{
printf ("Sector size: %zu\n", fsinfo->sector_size);
printf ("Cluster size in sectors: %u\n", fsinfo->cluster_size);
printf ("Root directory size (nb of entries): %u\n", fsinfo->rootdir_size);
printf ("Sectors per fat: %u\n", fsinfo->sectors_per_fat);
printf ("Reserved sectors: %u\n", fsinfo->reserved_sectors);
printf ("Hidden sectors: %u\n", fsinfo->hidden_sectors);
printf ("Fat offset in sectors: %u\n", fsinfo->fat_offset);
printf ("Root directory offset in sectors: %u\n", fsinfo->rootdir_offset);
printf ("First cluster offset in sectors: %u\n", fsinfo->cluster_offset + (2 * fsinfo->cluster_size));
}
/*
* Main function.
*/
int main(int argc, char *argv[])
{
void * mem = open_filesystem(argc, argv);
int i;
filesystem_info *fsinfo = initialize_filesystem_info(mem);
print_filesystem_info(fsinfo);
putchar('\n');
char root[2] = {'\\', '\0'};
// print all the files and directories!
print_directory(fsinfo, (fsinfo->rootdir_offset), &root[0]);
}