here's my code fragment.
I'm sure I'm doing something wrong.  why else would the free32 program work and 
mine not?

I am using the same 7300h and 7303h function calls.  but no dice.  only diff I 
think is that I am doing this in C rather than assembler.  I didn't read the 
entire program because I figured those were the core 2 functions anyway.  the 
dirty buffers check on a specific drive and then the disk free space check on 
that drive, both fat32 calls. 7303h doesn't work without 7300h being called 
first.

I know it's not your obligation to help me, but I am at my wits end with this 
program.  nothing I try works in freedos except that assembler program free32.  
I know I can't do this on my own.  I need help.


#define STR_OFS 0x30
#define STRUCT_OFS 0x0

#if defined(__DJGPP__)
//#define HANDLE_PRAGMA_PACK_PUSH_POP 1
//#pragma pack(push,1)

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;
uint32_t wastedspace;
} __attribute__((packed)) extFAT32FreeSpaceStructure;
//typedef struct extFAT32FreeSpaceStructure extFAT32FreeSpaceStructure;

//#pragma pack(pop)

#endif

char * dirpath[26] = {
    "A:\\",  "B:\\",  "C:\\",  "D:\\",  "E:\\",
    "F:\\",  "G:\\",  "H:\\",  "I:\\",  "J:\\",
    "K:\\",  "L:\\",  "M:\\",  "N:\\",  "O:\\",
    "P:\\",  "Q:\\",  "R:\\",  "S:\\",  "T:\\",
    "U:\\",  "V:\\",  "W:\\",  "X:\\",  "Y:\\",
    "Z:\\"
};


    int64_t iDAvail, iTotal;
    struct diskfree_t df;
    extFAT32FreeSpaceStructure *pds = (extFAT32FreeSpaceStructure 
*)calloc(sizeof(extFAT32FreeSpaceStructure), 1);
/*BUG:    int21h 7303h returns a maximum of 2GB free space even on an FAT32
      partition larger than 2GB under some versions of Win95 and Win98,
      apparently by limiting the number of reported free clusters to no
      more than 64K -- but only in a DOS window if a TSR has hooked INT 21h
  */
            __dpmi_regs r;
            r.h.dl=drive;//curent drive
            r.h.cl=0x01;//dirty buffers flag
            r.x.ax=0x7300;
            pds->ret_size_of_returned_structure=0x30;
            __dpmi_int(0x21, &r);
            if (0x7300!=r.x.ax) {
                //supports fat32. 7303h doesn't work without this.

                pds->call_structure_version_ret_actual_structure_version=0;
                dosmemput(pds, sizeof(extFAT32FreeSpaceStructure), __tb + 
STRUCT_OFS);
                dosmemput(dirpath[drive-a_drive], 
strlen(dirpath[drive-a_drive])+1, __tb + STR_OFS);
                r.x.ax=0x7303;
                r.x.cx=sizeof(extFAT32FreeSpaceStructure);//0x30 whereas before 
it was 0x2c
                r.x.ds=(__tb+STRUCT_OFS)>>4;
                r.x.dx=(__tb+STRUCT_OFS)& 0x0f;
                r.x.es=(__tb+STR_OFS)>>4;
                r.x.di=(__tb+STR_OFS)&0x0f;
                r.x.flags = 1; //set carry bit to show error in case there is 
no 
change
                r.x.ss=0;
                r.x.sp=0;
                __dpmi_int(0x21, &r);
                if (1==r.x.flags & 1 //carry flag
                || (1==r.x.flags & 1 && 0==r.h.al)
                ) {
                    //error, so try fallback method of using old dos int21h 
function 36h _dos_getdiskfree()
                    //long long iTotal, iDAvail;

                    //for this function, drive starting with 1 is correct.
                    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;
                    } else {
                        printf("ERROR:_dos_getdiskfree() failed, int21h 7303h 
failed.");
                        return false;
                    }
                } else {
                    printf("AX=0x%04x,FLAGS=0x%04x\n", r.x.ax, 
r.x.flags);//DEBUG
                    //success on int 21h 7303h, so extract results.
                    unsigned long adr=r.x.es;
                    adr<<=4;
                    adr += r.x.di;
                    dosmemget(/*__tb+STRUCT_OFS+*/adr, 
sizeof(extFAT32FreeSpaceStructure), pds);

                    if (pds->ret_size_of_returned_structure < 0x24
                    || pds->ret_size_of_returned_structure > 
sizeof(extFAT32FreeSpaceStructure)) {
                        printf("ERROR:structure size returned=0x%04x on drive 
%d\n",pds->ret_size_of_returned_structure, drive);

                        if (0==_dos_getdiskfree(drive, &df)) { // 0=default, 
1=a, 2=b...
                            printf("_dos_getdiskfree() SUCCESS, int21h 7303h 
failed. sizeof struct was 
%hd,flags=0x%04x,AX=0x%04x\n",pds->ret_size_of_returned_structure,r.x.flags,r.x.ax);

                            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;
                        } else {
                            printf("ERROR:_dos_getdiskfree() failed on drive 
%d, 
int21h 7303h failed.\n", drive);
                            return false;
                        }
                    } else {
                        printf("SUCCESS on int21h 7303h\n");//DEBUG
                        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;
                    }
                }
            }
    free(pds);






________________________________
From: Jim Michaels <[email protected]>
To: freedos development <[email protected]>
Sent: Tue, March 15, 2011 11:33:25 AM
Subject: [Freedos-devel] problem with 7303h?


I am calling 7303H, but I am getting failure under freedos.
upon return,
int21h 7303h failed. sizeof struct was 14917=0x3a45,flags=0x3003,AX=0x000f

function 36h succeeded.
I am using djgpp, and while I haven't gotten the best of help on how to 
implement that return of ES:DI buffer pointer, I should think I would have 
gotten it by now with all the things I have tried.

 -------------
Jim Michaels
[email protected]
[email protected]
http://JimsComputerRepairandWebDesign.com
http://JesusnJim.com (my personal site, has software)
http://DoLifeComputers.JesusnJim.com (group which I lead)
---
Computer memory/disk size measurements:
[KB KiB] [MB MiB] [GB GiB] [TB TiB]
[10^3B=1,000B=1KB][2^10B=1,024B=1KiB]
[10^6B=1,000,000B=1MB][2^20B=1,048,576B=1MiB]
[10^9B=1,000,000,000B=1GB][2^30B=1,073,741,824B=1GiB]
[10^12B=1,000,000,000,000B=1TB][2^40B=1,099,511,627,776B=1TiB]
Note: disk size is measured in MB, GB, or TB, not in MiB, GiB, or TiB.  
computer 
memory (RAM) is measured in MiB and GiB.


      
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Freedos-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to