Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <dos.h>
- #include <memory.h>
- #include <stdlib.h>
- #include <string.h>
- struct BOOT { //for FAT16
- char jmp[3];
- char OEM[8];
- int bytes_per_sector;
- char sectors_per_cluster;
- int reserved;
- char FAT_cnt;
- int ROOT_size;
- int total_sectors;
- char media;
- int FAT_size;
- int sectors_per_track;
- int head_cnt;
- long hidden_sectors;
- long total_sectors_long;
- char unknown[3];
- long serial;
- char volume[11];
- char FAT_type[8];
- char loader[448];
- char mark[2];
- };
- struct ROOT {
- char name[8];
- char ext[3];
- char attr;
- char reserved[10];
- char time[2];
- char date[2];
- int first_cluster;
- long size;
- };
- void main()
- {
- int i;
- int drive = 3;
- BOOT boot;
- int res = absread(drive, 1, 0, &boot);
- unsigned int *fat = (unsigned int *)malloc (boot.FAT_size * boot.bytes_per_sector);
- res = absread(drive, boot.FAT_size, boot.reserved, fat);
- unsigned int n = 5;
- unsigned int cur = n;
- int num_byte = boot.ROOT_size * 32;
- ROOT *root = (ROOT *)malloc(num_byte);
- if(root == NULL) return;
- int num_sector = num_byte / boot.bytes_per_sector;
- int root_begin = boot.reserved + boot.FAT_size * boot.FAT_cnt;
- res = absread(drive, num_sector, root_begin, (void *)root);
- printf("3. In ra bang bit cua 100 cluster dau tien\n");
- for (i = 2; i < 100; i++){ //first 2 clusters are not used
- if(fat[i] == 0) {
- printf("%d ", 1);
- }else{
- printf("%d ", 0);
- }
- }
- free(root);
- free(fat);
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement