Mail Archives: djgpp-workers/1999/01/04/04:48:48
According to Eli Zaretskii:
> > I'm mainly thinking of what would happen if somebody
> > reformats their D: drive to another FAT system, while a DJGPP program
> > is running.
>
> Can Windows itself survive such an atrocity? I would guess not. It
> should be the same as disabling long file names (which requires to
> reboot).
You did see that said D:? At least DOZE do that (for example after
fdisking and the reboot, you format the drive and you don't need to
reboot again).
> > The X in FAT32X (cf. Subject)? Is that relevant?
>
> I don't know. Where did it come from? Did I somehow mistyped the
> subject? If so, it's not relevant.
There's something called FAT32X, see
<http://www.compuclinic.com/osr2faq/index.html#fat32x>. Unfortunately
the link is broken.
Here's the result this far. The functions _get_fs_type() and
_get_fat_size() seems to me to be generally useful. But where in the
libc directories do they belong?
Additionaly, is there a template for libc's .txh files?
Right,
MartinS
No hick-ups in my computer this time; although I can't guarantee yours.
----- start -----
#include <go32.h>
#include <dpmi.h>
#include <stdio.h>
int /* 0 == error; 1 == result_str filled in. */
_get_fs_type(const int drive /* drive number (1=A:). */
, char *const result_str /* String to put result in. At
least 9 char
s long. */
)
{
int n;
__dpmi_regs r;
/* Check DOZE version and return -1 if too low. */
if( ( _get_dos_version(1) >> 8) < 4 )
{
return( 0 );
}
/* Call INT21, ax==0x6900 i.e. Get Disk Serial Number (sic!). */
r.x.ax = 0x6900;
r.h.bl = drive;
r.h.bh = 0;
r.x.ds = __tb >> 4;
r.x.dx = __tb & 0x0f;
__dpmi_int(0x21, &r);
if( (r.x.flags & 1) == 0 )
{
/* Get the file system type. */
for(n = 0; n < 8; n++)
{
result_str[n] = _farpeekb( _dos_ds, __tb + 0x11 + n);
}
result_str[8] = 0;
return( 1 );
}
return( 0 );
}
int /* Number of bits in FAT; 0 == not FAT; -1 == error. */
_get_fat_size(const int drive /* drive number (1=A:). */
)
{
char s[9];
int n;
if( _get_fs_type( drive, s ) )
{
if( sscanf(s, " FAT%d", &n) == 1 )
{
return( n );
}
else
{
return( 0 );
}
}
return( -1 );
}
int main(void)
{
int ret;
int i;
for(i = 3; i < 20; i++)
{
ret = _get_fat_size(i);
printf("%c: -> %d.\n", 'A' - 1 + i, ret);
}
return(0);
}
----- end -----
- Raw text -