Changeset 220 for trunk/src/helpers/dosh.c
- Timestamp:
- Sep 2, 2002, 4:00:04 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/dosh.c
r217 r220 685 685 { 686 686 if (pdp->fsDeviceAttr & DEVATTR_PARTITIONALREMOVEABLE) // 0x08 687 return DRVTYPE_PARTITIONABLEREMOVEABLE; 688 else if (fFixed) 687 return DRVTYPE_PRT; 688 689 if (fFixed) 689 690 return DRVTYPE_HARDDISK; 690 else if ( (pdp->bDeviceType == 7) // "other" 691 && (pdp->usBytesPerSector == 2048) 692 && (pdp->usSectorsPerTrack == (USHORT)-1) 693 ) 694 return DRVTYPE_CDROM; 695 else switch (pdp->bDeviceType) 691 692 if ( (pdp->bDeviceType == 7) // "other" 693 && (pdp->usBytesPerSector == 2048) 694 && (pdp->usSectorsPerTrack == (USHORT)-1) 695 ) 696 return DRVTYPE_CDROM; 697 698 switch (pdp->bDeviceType) 696 699 { 697 700 case DEVTYPE_TAPE: // 6 … … 708 711 ) 709 712 return DRVTYPE_FLOPPY; 710 else 711 713 714 return DRVTYPE_VDISK; 712 715 713 716 case DEVTYPE_RWOPTICAL: // 8, what is this?!? … … 716 719 } 717 720 718 return (DRVTYPE_UNKNOWN); 721 return DRVTYPE_UNKNOWN; 722 } 723 724 /* 725 *@@ doshQueryCDDrives: 726 * returns the no. of CD-ROM drives on the system 727 * as well as the drive letter of the first 728 * CD-ROM drive. 729 * 730 *@@added V0.9.21 (2002-08-31) [umoeller] 731 */ 732 733 APIRET doshQueryCDDrives(PBYTE pcCDs, // out: CD-ROM drives count 734 PCHAR pcFirstCD) // out: drive letter of first CD 735 { 736 APIRET arc; 737 HFILE hfCDROM; 738 ULONG ulAction; 739 740 if (!(arc = DosOpen("\\DEV\\CD-ROM2$", 741 &hfCDROM, 742 &ulAction, 743 0, 744 FILE_NORMAL, 745 OPEN_ACTION_OPEN_IF_EXISTS, 746 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 747 NULL))) 748 { 749 struct 750 { 751 USHORT cCDs; 752 USHORT usFirstCD; // 0 == A:, 1 == B:, ... 753 } cdinfo; 754 755 ULONG cb = sizeof(cdinfo); 756 757 if (!(arc = DosDevIOCtl(hfCDROM, 758 0x82, 759 0x60, 760 NULL, 761 0, 762 NULL, 763 &cdinfo, 764 cb, 765 &cb))) 766 { 767 *pcCDs = cdinfo.cCDs; 768 *pcFirstCD = cdinfo.usFirstCD + 'A'; 769 } 770 771 DosClose(hfCDROM); 772 } 773 774 return arc; 775 } 776 777 /* 778 *@@ doshOpenDrive: 779 * opens the given logical drive using 780 * DosOpen with OPEN_FLAGS_DASD. Use 781 * the file handle returned from here 782 * for doshHasAudioCD and doshQueryCDStatus. 783 * 784 * If NO_ERROR is returned, use DosClose 785 * to close the device again. 786 * 787 *@@added V0.9.21 (2002-08-31) [umoeller] 788 */ 789 790 APIRET doshOpenDrive(ULONG ulLogicalDrive, 791 HFILE *phf) // out: open drive's file handle 792 { 793 ULONG dummy; 794 795 CHAR szDrive[] = "C:"; 796 szDrive[0] = 'A' + ulLogicalDrive - 1; 797 798 return DosOpen(szDrive, // "C:", "D:", ... 799 phf, 800 &dummy, 801 0, 802 FILE_NORMAL, 803 // OPEN_ACTION_FAIL_IF_NEW 804 OPEN_ACTION_OPEN_IF_EXISTS, 805 OPEN_FLAGS_DASD 806 | OPEN_FLAGS_FAIL_ON_ERROR 807 // ^^^ if this flag is not set, we get the white 808 // hard-error box 809 | OPEN_FLAGS_NOINHERIT // V0.9.6 (2000-11-25) [pr] 810 // | OPEN_ACCESS_READONLY // V0.9.13 (2001-06-14) [umoeller] 811 | OPEN_SHARE_DENYNONE, 812 NULL); 719 813 } 720 814 … … 729 823 * 730 824 *@@added V0.9.14 (2001-08-01) [umoeller] 731 * /732 733 APIRET doshHasAudioCD(ULONG ulLogicalDrive, 734 825 *@@changed V0.9.21 (2002-08-31) [umoeller]: removed ulLogicalDrive which was not needed 826 */ 827 828 APIRET doshHasAudioCD(HFILE hfDrive, // in: DASD open 735 829 BOOL fMixedModeCD, 736 830 PBOOL pfAudio) … … 758 852 else 759 853 { 854 #pragma pack(1) // V0.9.21 (2002-08-31) [umoeller] 855 760 856 struct { 761 857 UCHAR ucFirstTrack, … … 763 859 ULONG ulLeadOut; 764 860 } cdat; 861 862 struct { 863 ULONG ulTrackAddress; 864 BYTE bFlags; 865 } trackdata; 866 867 #pragma pack() 765 868 766 869 // get track count … … 780 883 { 'C', 'D', '0', '1', (UCHAR)i }; 781 884 782 struct {783 ULONG ulTrackAddress;784 BYTE bFlags;785 } trackdata;786 787 885 if (!(arc = doshDevIOCtl(hfDrive, 788 886 IOCTL_CDROMAUDIO, … … 828 926 // _Pmpf((" CDROMDISK_GETDRIVER returned %d", arc)); 829 927 arc = NO_ERROR; 928 } 929 930 return arc; 931 } 932 933 /* 934 *@@ doshQueryCDStatus: 935 * returns the status bits of a CD-ROM drive. 936 * This calls the CDROMDISK_DEVICESTATUS 937 * ioctl. 938 * 939 * If NO_ERROR is returned, *pflStatus has 940 * received the following flags: 941 * 942 * -- CDFL_DOOROPEN (bit 0) 943 * 944 * -- CDFL_DOORLOCKED (bit 1) 945 * 946 * and many more (see dosh.h). 947 * 948 * Actually I wrote this function to have a way to 949 * find out whether the drive door is already open. 950 * But thanks to IBM's thoughtful design, this ioctl 951 * is 99% useless for that purpose since it requires 952 * a DASD disk handle to be passed in, which cannot 953 * be obtained if there's no media in the drive. 954 * 955 * In other words, it is absolutely impossible to 956 * ever get the CDFL_DOOROPEN flag, because if the 957 * door is open, DosOpen already fails on the drive. 958 * As a consequence, it is seems to be impossible 959 * to find out if the door is open with OS/2. 960 * 961 *@@added V0.9.21 (2002-08-31) [umoeller] 962 */ 963 964 APIRET doshQueryCDStatus(HFILE hfDrive, // in: DASD open 965 PULONG pflStatus) // out: CD-ROM status bits 966 { 967 APIRET arc; 968 969 CHAR cds1[4] = { 'C', 'D', '0', '1' }; 970 ULONG fl; 971 972 *pflStatus = 0; 973 974 if (!(arc = doshDevIOCtl(hfDrive, 975 IOCTL_CDROMDISK, 976 CDROMDISK_DEVICESTATUS, 977 &cds1, sizeof(cds1), 978 &fl, sizeof(fl)))) 979 { 980 *pflStatus = fl; 830 981 } 831 982 … … 965 1116 } 966 1117 967 return (cBootDrive);1118 return cBootDrive; 968 1119 } 969 1120 … … 976 1127 * Use doshIsFixedDisk to find out. 977 1128 * 1129 * Returns: 1130 * 1131 * -- NO_ERROR: media is present. 1132 * 1133 * -- ERROR_AUDIO_CD_ROM (10000): audio CD-ROM is present. 1134 * 1135 * -- ERROR_NOT_READY (21) or other: drive has no media. 1136 * 978 1137 *@@added V0.9.16 (2002-01-13) [umoeller] 979 1138 */ 980 1139 981 APIRET doshQueryMedia(ULONG ulLogicalDrive, 1140 APIRET doshQueryMedia(ULONG ulLogicalDrive, // in: 1 for A:, 2 for B:, 3 for C:, ... 982 1141 BOOL fCDROM, // in: is drive CD-ROM? 983 1142 ULONG fl) // in: DRVFL_* flags … … 985 1144 APIRET arc; 986 1145 987 HFILE hf = NULLHANDLE; 988 ULONG dummy; 989 990 CHAR szDrive[3] = "C:"; 991 szDrive[0] = 'A' + ulLogicalDrive - 1; 992 993 arc = DosOpen(szDrive, // "C:", "D:", ... 994 &hf, 995 &dummy, 996 0, 997 FILE_NORMAL, 998 OPEN_ACTION_FAIL_IF_NEW 999 | OPEN_ACTION_OPEN_IF_EXISTS, 1000 OPEN_FLAGS_DASD 1001 | OPEN_FLAGS_FAIL_ON_ERROR 1002 | OPEN_FLAGS_NOINHERIT // V0.9.6 (2000-11-25) [pr] 1003 // | OPEN_ACCESS_READONLY // V0.9.13 (2001-06-14) [umoeller] 1004 | OPEN_SHARE_DENYNONE, 1005 NULL); 1146 HFILE hf; 1147 1148 // exported this code to doshOpenDrive V0.9.21 (2002-08-31) [umoeller] 1149 arc = doshOpenDrive(ulLogicalDrive, 1150 &hf); 1006 1151 1007 1152 // this still returns NO_ERROR for audio CDs in a … … 1017 1162 { 1018 1163 BOOL fAudio; 1019 if ( (!(arc = doshHasAudioCD(ulLogicalDrive, 1020 hf, 1164 if ( (!(arc = doshHasAudioCD(hf, 1021 1165 ((fl & DRVFL_MIXEDMODECD) != 0), 1022 1166 &fAudio))) … … 1179 1323 * file systems so we will always have a 1180 1324 * value for the DFL_SUPPORTS_EAS flags. 1181 * Otherwise that flag might or might not1182 * be set correctly.1183 *1184 1325 * The EA support returned by DosFSCtl 1185 1326 * might not be correct for remote file … … 1187 1328 * that query. 1188 1329 * 1189 * -- DRVFL_CHECKLONGNAMES: drive should always be 1190 * checked for longname support. If this is 1330 * If not set, we set DFL_SUPPORTS_EAS only 1331 * for file systems such as HPFS and JFS 1332 * that are known to support EAs. 1333 * 1334 * -- DRVFL_CHECKLONGNAMES: drive should be 1335 * tested for longname support. If this is 1191 1336 * set, we will try a DosOpen("\\long.name.file") 1192 1337 * on the drive to see if it supports long … … 1376 1521 pdi->bType = bTemp; 1377 1522 1378 if (bTemp == DRVTYPE_P ARTITIONABLEREMOVEABLE)1523 if (bTemp == DRVTYPE_PRT) 1379 1524 pdi->flDevice |= DFL_FIXED 1380 1525 | DFL_PARTITIONABLEREMOVEABLE;
Note:
See TracChangeset
for help on using the changeset viewer.