--- os2sdk/demos/examples/fsinfo/fsinfo.c 2018/08/09 12:25:13 1.1.1.1 +++ os2sdk/demos/examples/fsinfo/fsinfo.c 2018/08/09 12:26:10 1.1.1.2 @@ -1,18 +1,24 @@ /*** - * Example of DOSQFSINFO and DOSSETFSINFO. Also DOSERROR. + * Example of DosQFSInfo and DosSetFSInfo. Also DosError. * - * First do a DOSQFSINFO level 1 to get the A drive - * parameters, then a DOSQFSINFO level 2 to check the volume - * label of the A drive. Next do a DOSSETFSINFO to + * First do a DosQFSInfo level 1 to get the A drive + * parameters, then a DosQFSInfo level 2 to check the volume + * label of the A drive. Next do a DosSetFSInfo to * change the volume label to FSIDEMO, and lastly another - * DOSQFSINFO level 2 to verify the set. + * DosQFSInfo level 2 to verify the set. + * + * Created by Microsoft Corp. 1988 */ -#include +#define INCL_DOSFILEMGR +#define INCL_DOSMISC + +#include +#include #define FSIBUF 40 -unsigned drive; /* drive number */ +USHORT drive; /* drive number */ unsigned retcode; /* return code from call */ unsigned testbufsiz; /* length of volume label to set */ int *date_time; /* date and time returned by level 2 query */ @@ -20,15 +26,7 @@ char setlabel[] = "\007FSIDEMO"; /* b /* starts with byte of string length */ /* FSInfoBuf level 1 */ -typedef struct { - unsigned long fsID; /* file system ID */ - unsigned long SecPerAU; /* number of sectors per alloc. unit */ - unsigned long NumAU; /* number of allocation units */ - unsigned long NumAUAvail; /* available allocation units */ - unsigned BytesSec; /* number of bytes per sector */ -} lev1buf; - -lev1buf fsinfobuf; +FSALLOCATE fsinfobuf; /* the level 2 FSInfoBuf buffer contains * 2 bytes - volume label date of creation @@ -41,32 +39,32 @@ char buffer[FSIBUF]; /* buffer for DosQ main() { - unsigned level; + USHORT level; drive = 1; /* A drive */ /* turn off hard errors so we see if user has drive A open */ - DOSERROR(0); + DosError(0); - /* check the parameters of the A drive using DOSQFSINFO level 1 */ + /* check the parameters of the A drive using DosQFSInfo level 1 */ level = 1; - retcode = DOSQFSINFO( drive, level, (char *)&fsinfobuf, FSIBUF); + retcode = DosQFSInfo( drive, level, (PBYTE)&fsinfobuf, FSIBUF); if ( retcode ) - printf("Received error %d from DOSQFSINFO\n", retcode); + printf("Received error %d from DosQFSInfo\n", retcode); else { - printf("DOSQFSINFO provided the following information:\n"); - printf(" File System ID - %ld\n", fsinfobuf.fsID); + printf("DosQFSInfo provided the following information:\n"); + printf(" File System ID - %ld\n", fsinfobuf.idFileSystem); printf(" Sectors per allocation unit - %ld\n", - fsinfobuf.SecPerAU); + fsinfobuf.cSectorUnit); printf(" Number of allocation units - %ld\n", - fsinfobuf.NumAU); + fsinfobuf.cUnit); printf(" Available allocation units - %ld\n", - fsinfobuf.NumAUAvail); + fsinfobuf.cUnitAvail); printf(" Bytes per sector - %d\n\n", - fsinfobuf.BytesSec); + fsinfobuf.cbSector); } - /* check for a volume label on the A drive using DOSQFSINFO + /* check for a volume label on the A drive using DosQFSInfo * level 2. Access the data in the buffer as follows: * time - first pair of bytes in the buffer (date_time[0]) * date - second pair of bytes in the buffer (date_time[1]) @@ -75,34 +73,34 @@ main() */ level = 2; - retcode = DOSQFSINFO( drive, level, (char *)buffer, FSIBUF); + retcode = DosQFSInfo( drive, level, (PBYTE)buffer, FSIBUF); date_time = (int *)buffer; /* pointer into time/date info */ if ( !retcode ) { /* got volume label */ - printf("DOSQFSINFO found volume label %s on drive %d\n", + printf("DosQFSInfo found volume label %s on drive %d\n", buffer+5, drive ); printf(" label length %d, date 0x%x, time 0x%x\n\n", buffer[4], date_time[0], date_time[1] ); } else if ( retcode == 125 ) - printf("No volume label found by DOSQFSINFO on drive %d\n\n", + printf("No volume label found by DosQFSInfo on drive %d\n\n", drive ); else - printf("DOSQFSINFO call failed with error %d\n\n", retcode ); + printf("DosQFSInfo call failed with error %d\n\n", retcode ); /* do a DosSetFSInfo, changing the volume label to FSIDEMO */ testbufsiz = strlen( setlabel ); - retcode = DOSSETFSINFO( drive, level, setlabel, testbufsiz); + retcode = DosSetFSInfo( drive, level, setlabel, testbufsiz); if ( retcode ) printf("Error %d setting volume label to %s on drive %d\n\n", retcode, setlabel, drive); else { - printf("DOSSETFSINFO set volume label %s\n", setlabel+1); + printf("DosSetFSInfo set volume label %s\n", setlabel+1); /* do a DosQFSInfo to verify the set */ - DOSQFSINFO( drive, level, (char *)buffer, FSIBUF); - printf("DOSQFSINFO found label %s\n", buffer+5); + DosQFSInfo( drive, level, (PBYTE)buffer, FSIBUF); + printf("DosQFSInfo found label %s\n", buffer+5); } }