home *** CD-ROM | disk | FTP | other *** search
/ ftp.muug.mb.ca / 2014.06.ftp.muug.mb.ca.tar / ftp.muug.mb.ca / pub / src / perl / msdos / eg / drives.bat < prev    next >
DOS Batch File  |  1992-04-11  |  1KB  |  42 lines

  1. @REM=("
  2. @perl %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
  3. @end ") if 0 ;
  4.  
  5. #
  6. # Test the ioctl function for MS-DOS.  Provide a list of drives and their
  7. # characteristics.
  8. #
  9. # By Diomidis Spinellis.
  10. #
  11.  
  12. @fdnum = ("STDIN", "STDOUT", "STDERR");
  13. $maxdrives = 15;
  14. for ($i = 3; $i < $maxdrives; $i++) {
  15.     open("FD$i", "nul");
  16.     @fdnum[$i - 1] = "FD$i";
  17. }
  18. @mediatype = (
  19.     "320/360 k floppy drive",
  20.     "1.2M floppy",
  21.     "720K floppy",
  22.     "8'' single density floppy",
  23.     "8'' double density floppy",
  24.     "fixed disk",
  25.     "tape drive",
  26.     "1.44M floppy",
  27.     "other"
  28. );
  29. print "The system has the following drives:\n";
  30. for ($i = 1; $i < $maxdrives; $i++) {
  31.     if ($ret = ioctl(@fdnum[$i], 8, 0)) {
  32.         $type = ($ret == 0) ? "removable" : "fixed";
  33.         $ret = ioctl(@fdnum[$i], 9, 0);
  34.         $location = ($ret & 0x800) ? "local" : "remote";
  35.         ioctl(@fdnum[$i], 0x860d, $param);
  36.         @par = unpack("CCSSSC31S", $param);
  37.         $lock = (@par[2] & 2) ? "supporting door lock" : "not supporting door lock";
  38.         printf "%c:$type $location @mediatype[@par[1]] @par[3] cylinders @par[6]
  39.  sectors/track $lock\n", ord('A') + $i - 1;
  40.     }
  41. }
  42.