• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

How to read FAT table in memory?

I am using Turbo C 3.0 and want to read the FAT table
(File Allocation Table) from disk sectors into memory.
The size of FAT16 is sizeof(int)*0xFFFF = 128k
The absread() works fine, but....

This does't work:
unsigned int fat_table[0xFFFE];
unsigned int huge fat_table[0xFFFE];

because compilers max datasize is 64k
If I use (integer) the size is two times 64k=128k

This does't work either:
unsigned int far *fat_ptr;
fat_ptr=(unsigned int far *) calloc(0xFFFE,2);
fat_ptr=(unsigned int far *) malloc(2L*65535L);

But this work!
unsigned int far *fat_ptr;
fat_ptr=(unsigned int far *) calloc(0x6FFE,2);

How to do YOU read fat_table into memory?
Do I have to do XMS or EMS calls?
0
robowe
Asked:
robowe
  • 2
1 Solution
 
AVaulinCommented:
Use huge model (Options/Compiler/Code generator/Huge). This has to help you. Good luck.
0
 
cphCommented:
Are you sure that you need to read all the FAT conentens at once?
'cos I did a program which dealt with the FAT and at the beginning I thought I got to have everything. The solution I found was to treat it by pack of 512 bytes.
If you want, my program is available at:
      http://www.mygale.org/03/cph

Its name is Safer...

Enjoy,
      CpH
0
 
roboweAuthor Commented:
Yes!, Option/Compiler/Code generation must be set either for:
Model=Compact (64k for code, 1MB for static data)
Model=Large (1MB code, 1MB for static data)
Model=Huge (1MB code, static data >64k)

But the problem was when i was using the debug option
in Turbo-C. Here I have to change the Option/Debugger
Program Heap Size = 300K Bytes

This should work:
unsigned int huge *fat_ptr;
fat_ptr=(unsigned int huge *) malloc( (long)0xFFFF*2L);

 huge (type modifier)
 ----------------------------
 Similar to far type modifier

 Syntax:  <type> huge <pointer-definition> ;

 The huge modifier is similar to the far
 modifier except for two additional features.

 * Its segment is normalized during pointer
   arithmetic so that pointer comparisons are
   accurate.

 * Huge pointers can be incremented without
   suffering from segment wraparound.
0
 
roboweAuthor Commented:
Yes!, Option/Compiler/Code generation must be set either for:
Model=Compact (64k for code, 1MB for static data)
Model=Large (1MB code, 1MB for static data)
Model=Huge (1MB code, static data >64k)

But the problem was when i was using the debug option
in Turbo-C. Here I have to change the Option/Debugger
Program Heap Size = 300K Bytes

This should work:
unsigned int huge *fat_ptr;
fat_ptr=(unsigned int huge *) malloc( (long)0xFFFF*2L);

 huge (type modifier)
 ----------------------------
 Similar to far type modifier

 Syntax:  <type> huge <pointer-definition> ;

 The huge modifier is similar to the far
 modifier except for two additional features.

 * Its segment is normalized during pointer
   arithmetic so that pointer comparisons are
   accurate.

 * Huge pointers can be incremented without
   suffering from segment wraparound.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now