Eric, Leland Holliday (sp?) told me that he reworked your freetest.asm in that
zip file and got it outputting correct numbers (the numbers were bogus) and
displaying usable output.
If that code is yours, and I get it from him, I could email it to you (or post
it here if you wish).
Jim Michaels
________________________________
From: Jim Michaels <jmich...@yahoo.com>
To: freedos-devel@lists.sourceforge.net
Sent: Tue, February 15, 2011 1:36:34 PM
Subject: Re: [Freedos-devel] documentation for FreeDOS filesystem or other
programming functions/interfaces?
define "nonsense sector sizes". there are new large sector drives coming out,
where 1k sectors, 2k sectors, and 4k sector sizes are not uncommon. I heard
noises of this from a warning kb post from microsoft.
...but the disk industry's tech support says they have no knowledge of it (but
they probably don't know anything more than what's in their scripts). so how
do
you define nonsense, now that these drives are a possibility? scsi drives,
worm
drives, MO drives (I used to have one) already have the possibility of 1k
sectors.
alas, I tried my disk free space program, and I got nonsense results from
windows xp... usually I get something weird back. so I am going to have to
have somebody else test it who has a proper OS. my spare box has linux on it.
I need a freedos box. (maybe I should wipe it again?).
what I can't tell is if it fails over correctly. I know I checked the carry
flag correctly, if (1==r.x.flags&0x0001) {....
this is the frustrating side of programming...
here's a part of my source if it would help any.
typedef struct extFAT32FreeSpaceStructure {
/* 00h WORD*/uint16_t ret_size_of_returned_structure;
/* 02h WORD*/uint16_t
call_structure_version_ret_actual_structure_version;// (0000h)
/* 04h DWORD*/uint32_t
number_of_sectors_per_cluster_with_adjustment_for_compression;
/* 08h DWORD*/uint32_t number_of_bytes_per_sector;
/* 0Ch DWORD*/uint32_t number_of_available_clusters;
/* 10h DWORD*/uint32_t total_number_of_clusters_on_the_drive;
/* 14h DWORD*/uint32_t
number_of_physical_sectors_available_on_the_drive_without_adjustment_for_compression;
/* 18h DWORD*/uint32_t
total_number_of_physical_sectors_on_the_drive_without_adjustment_for_compression;
/* 1Ch DWORD*/uint32_t
number_of_available_allocation_units_without_adjustment_for_compression;
/* 20h DWORD*/uint32_t
total_allocation_units_without_adjustment_for_compression;
/* 24h 8 BYTEs*/uint64_t reserved;
} extFAT32FreeSpaceStructure;
void ShowDrive(unsigned int drive, bool verbose) {
ld total, davail;
int percent;
int64_t iDAvail, iTotal;
struct diskfree_t df;
//-------------------------start of meat-----------------------------------
extFAT32FreeSpaceStructure *pds = (extFAT32FreeSpaceStructure
*)calloc(sizeof(extFAT32FreeSpaceStructure), 1);
char * str = (char *)calloc(strlen("c:\\")+1, 1);
str[0]='A'+drive;
str[1]=':';
str[2]='\\';
str[3]='\0';
dosmemput(str, strlen(str)+1,
_go32_info_block.linear_address_of_transfer_buffer + 48);
pds->call_structure_version_ret_actual_structure_version=0;
dosmemput(pds, sizeof(extFAT32FreeSpaceStructure),
_go32_info_block.linear_address_of_transfer_buffer);
__dpmi_regs r;
r.x.ax=0x7303;
r.x.cx=sizeof(extFAT32FreeSpaceStructure);
r.x.ds=_go32_info_block.linear_address_of_transfer_buffer>>4;
r.x.dx=_go32_info_block.linear_address_of_transfer_buffer& 0x0f;
r.x.es=(_go32_info_block.linear_address_of_transfer_buffer+48)>>4;
r.x.di=(_go32_info_block.linear_address_of_transfer_buffer+48)&0x0f;
r.x.flags &= 0xfffe; //clear carry bit
__dpmi_int(0x21, &r);
if (r.x.flags & 1) {
//CF set on error
//error, so try fallback method of using old dos int21h
function
36h _dos_getdiskfree()
//long long iTotal, iDAvail;
if (0==_dos_getdiskfree(drive, &df)) { // 0=default, 1=a, 2=b...
iDAvail=df.avail_clusters; iTotal=
df.total_clusters;
iDAvail*=df.bytes_per_sector;
iTotal*=df.bytes_per_sector;
iDAvail*=df.sectors_per_cluster;
iTotal*=df.sectors_per_cluster;
//cout.setf(ios::fixed);
//cout.unsetf(ios::scientific);
davail = ld(df.avail_clusters);
davail*= ld(df.bytes_per_sector);
davail*= ld(df.sectors_per_cluster);
total = ld(df.total_clusters);
total*= ld(df.bytes_per_sector);
total*= ld(df.sectors_per_cluster);
} else {
printf("ERROR:_dos_getdiskfree() failed. everything
failed.
drive %c:\n", drive+'a');
return;
}
} else {
//success on int 21h 7303h, so extract results.
dosmemget(_go32_info_block.linear_address_of_transfer_buffer,
sizeof(extFAT32FreeSpaceStructure), pds);
iDAvail =
pds->number_of_sectors_per_cluster_with_adjustment_for_compression;
iDAvail *= pds->number_of_bytes_per_sector;
iDAvail *= pds->number_of_available_clusters;
iTotal =
pds->number_of_sectors_per_cluster_with_adjustment_for_compression;
iTotal *= pds->number_of_bytes_per_sector;
iTotal *= pds->total_number_of_clusters_on_the_drive;
//__dpmi_free_dos_memory(segds);
}
free(pds);
free(str);
//-------------------------end of meat-----------------------------------
iTotalDAvail += iDAvail;
iTotalTotal += iTotal;
if (drive == thisDrive) { // if current drive, show it.
printf("*");
} else {
printf(" ");
}
printf("%s", drivename[drive-a_drive]);
if (verbose) {
#if defined(__BORLANDC__) || defined(_MSC_VER) || defined (__MINGW32__)
printf("%I64d/%I64d (%I64d%%)\n",
#elif defined(__DJGPP__)
printf("%lld/%lld (%lld%%)\n",
#endif
iDAvail,
iTotal,
(iDAvail*100)/iTotal
);
} else { //if verbose
//-----disk usage graph
for (percent = int(graphLength); percent >= 1; percent--) {
if ((double(percent)/graphLength) >= (davail/total))
{
//left part of graph
if (isAscii) {
printf("-"); //°
} else {
printf("°");
}
} else {
//right part of graph
if (isAscii) {
printf("*");
} else {
printf("Û");
}
}
}
//-----disk free/total disk numbers
PrintSIint64_t(iDAvail);
printf("/");
PrintSIint64_t(iTotal);
double nd=davail*100.0;nd/=total;
printf(" (%4.2f%%)\n", nd); //compiler bug doesn't allow %%
} //end if verbose
}
Jim Michaels
________________________________
From: Eric Auer <e.a...@jpberlin.de>
To: freedos-devel@lists.sourceforge.net
Sent: Mon, February 14, 2011 3:10:34 PM
Subject: Re: [Freedos-devel] documentation for FreeDOS filesystem or other
programming functions/interfaces?
Hi again,
> I was hoping a hint might spark some documentation on the
> FreeDOS filesystem API so others (like me) can do development. :-)
>
> you might see an increase in freedos programs if your API was documented.
> who knows, maybe even commercial systems might be made or something.
That is not a FreeDOS API, it is simply Win9x / MS DOS 7 compatible
so you can get documentation by reading about Win9x / MS DOS 7 :-)
> I am hoping to implement some sort of fallback mechanism into the program
> so that if int 21h, 7303h fails, I have int 21h, 36h to fall back on.
As you can see in my example program, you indeed have to do that.
In particular, if the kernel does not support FAT32, for example
in WinNT / MS DOS 6 and older / FreeDOS "16" style kernels, then
you have to stick to int 21 function 36... By the way, of course
I do use both 21.36 and 21.7303 but maybe Assembly is not the
programming language that you like best :-)
> but I need to know exactly how to detect failure. not every programmer
> writing production code does that... so I need documentation.
> like for instance, is the carry bit set or cleared or something?
That is also documented in my example program.
http://ericauer.cosmodata.virtuaserver.com.br/soft/specials/
free-disk-space-tester-freetest.zip
1. ax=7300h dl=0 cl=1 int 21h - if it returns ax unchanged,
then the kernel is not aware of the 21.73xx FAT32 functions.
2. if the kernel does support FAT32, you can set ax=7303h,
ds:dx = pointer to db "x:\",0 where X is the drive where
you want to know the free / used space, es:di = pointer to
30h byte buffer for results, cx=30h, int 21h - if it sets
carry or the bytes per sector is nonsense (buffer+8, dword)
then it failed, otherwise buffer+14h has a dword with the
number of free sectors.
3. if the kernel does not support FAT32, use good old 21.36
Enjoy :-)
Eric
PS: Depending on your memory model, you do not have to set
the ES or DS part of the pointers, only the offset. Easier.
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel