|
|
Microsoft OS/2 SDK 03-01-1988
/***
* 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
* change the volume label to FSIDEMO, and lastly another
* DosQFSInfo level 2 to verify the set.
*
* Created by Microsoft Corp. 1988
*/
#define INCL_DOSFILEMGR
#define INCL_DOSMISC
#include <os2def.h>
#include <bse.h>
#define FSIBUF 40
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 */
char setlabel[] = "\007FSIDEMO"; /* buffer for DosSetFSInfo */
/* starts with byte of string length */
/* FSInfoBuf level 1 */
FSALLOCATE fsinfobuf;
/* the level 2 FSInfoBuf buffer contains
* 2 bytes - volume label date of creation
* 2 bytes - volume label time of creation
* 1 byte - length of volume label
* 'n' bytes - the volume label string
*/
char buffer[FSIBUF]; /* buffer for DosQFSInfo, level 2 */
main()
{
USHORT level;
drive = 1; /* A drive */
/* turn off hard errors so we see if user has drive A open */
DosError(0);
/* check the parameters of the A drive using DosQFSInfo level 1 */
level = 1;
retcode = DosQFSInfo( drive, level, (PBYTE)&fsinfobuf, FSIBUF);
if ( retcode )
printf("Received error %d from DosQFSInfo\n", retcode);
else {
printf("DosQFSInfo provided the following information:\n");
printf(" File System ID - %ld\n", fsinfobuf.idFileSystem);
printf(" Sectors per allocation unit - %ld\n",
fsinfobuf.cSectorUnit);
printf(" Number of allocation units - %ld\n",
fsinfobuf.cUnit);
printf(" Available allocation units - %ld\n",
fsinfobuf.cUnitAvail);
printf(" Bytes per sector - %d\n\n",
fsinfobuf.cbSector);
}
/* 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])
* label length - resides at buffer[4], 4 bytes into buffer
* label - string starts at the fifth byte of the buffer
*/
level = 2;
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",
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",
drive );
else
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);
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);
/* do a DosQFSInfo to verify the set */
DosQFSInfo( drive, level, (PBYTE)buffer, FSIBUF);
printf("DosQFSInfo found label %s\n", buffer+5);
}
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.