/* This is the Windows prototype (with C arg types). * Only the first two arguments are used in this Unix exercise * (the remainder are ignored). * As with the Windows version, you must open the file before calling * this function, and assign the file descriptor to theDisk->floppyDisk */ #include #include "disk.h" int DeviceIoControl( Disk theDisk, // handle to device of interest int dwIoControlCode, // control code of operation to perform char *bootRecord, // pointer to buffer to supply input data int bootRecLen, // size of input buffer char *lpOutBuffer, // pointer to buffer to receive output data int nOutBufferSize, // size of output buffer int *lpBytesReturned, // pointer to variable to receive output byte count void *lpOverlapped // ptr to overlapped structure for asynchronous op ) { if(dwIoControlCode != 0) return 0; /* Rely on theDisk-> containing the file/device descriptor */ lseek(theDisk->floppyDisk, 0, SEEK_SET); read(theDisk->floppyDisk, bootRecord, bootRecLen); /* Read the geometry, storing the result in theDisk */ theDisk->bytesPerSector = bootRecLen; theDisk->sect = bootRecord[0x18] & 0xffff; theDisk->head = bootRecord[0x1a] & 0xffff; theDisk->track = 80; theDisk->size = theDisk->sect * theDisk->track; return 1; }