Ignore:
Timestamp:
Oct 13, 2001, 7:57:58 PM (24 years ago)
Author:
umoeller
Message:

Lots of updates from the last week for conditional compiles and other stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/dosh2.c

    r91 r108  
    21862186
    21872187/*
     2188 *@@ CopyToBuffer:
     2189 *      little helper for copying a string to
     2190 *      a target buffer with length checking.
     2191 *
     2192 *      Returns:
     2193 *
     2194 *      --  NO_ERROR
     2195 *
     2196 *      --  ERROR_BUFFER_OVERFLOW if pszTarget does
     2197 *          not have enough room to hold pcszSource
     2198 *          (including the null terminator).
     2199 *
     2200 *@@added V0.9.16 (2001-10-08) [umoeller]
     2201 */
     2202
     2203APIRET CopyToBuffer(PSZ pszTarget,      // out: target buffer
     2204                    PCSZ pcszSource,    // in: source string
     2205                    ULONG cbTarget)     // in: size of target buffer
     2206{
     2207    ULONG ulLength = strlen(pcszSource);
     2208    if (ulLength < cbTarget)
     2209    {
     2210        memcpy(pszTarget,
     2211               pcszSource,
     2212               ulLength + 1);
     2213        return (NO_ERROR);
     2214    }
     2215
     2216    return(ERROR_BUFFER_OVERFLOW);
     2217}
     2218
     2219/*
     2220 *@@ doshSearchPath:
     2221 *      replacement for DosSearchPath.
     2222 *
     2223 *      This looks along all directories which are
     2224 *      specified in the value of the given environment
     2225 *      variable if pcszFile is found.
     2226 *
     2227 *      As opposed to the stupid DosSearchPath, this
     2228 *      ignores subdirectories in the path particles.
     2229 *      For example, DosSearchPath would usually not
     2230 *      find an INSTALL file because \OS2 contains
     2231 *      an INSTALL directory, or NETSCAPE because
     2232 *      \OS2\INSTALL contains a NETSCAPE directory.
     2233 *
     2234 *      Returns:
     2235 *
     2236 *      --  NO_ERROR: pszExecutable has received the
     2237 *          full path of pcszFile.
     2238 *
     2239 *      --  ERROR_FILE_NOT_FOUND: pcszFile was not found
     2240 *          in the specified path (or is a directory).
     2241 *
     2242 *      --  ERROR_BUFFER_OVERFLOW: pcszFile was found, but
     2243 *          the pszExecutable buffer is too small to hold
     2244 *          the full path.
     2245 *
     2246 *@@added V0.9.16 (2001-10-08) [umoeller]
     2247 */
     2248
     2249APIRET doshSearchPath(const char *pcszPath,     // in: path variable name (e.g. "PATH")
     2250                      const char *pcszFile,     // in: file to look for (e.g. "LVM.EXE")
     2251                      PSZ pszExecutable,        // out: full path (e.g. "F:\os2\lvm.exe")
     2252                      ULONG cbExecutable)       // in: sizeof (*pszExecutable)
     2253{
     2254    APIRET arc = NO_ERROR;
     2255
     2256    // get the PATH value
     2257    PSZ pszPath;
     2258    if (!(arc = DosScanEnv((PSZ)pcszPath,
     2259                           &pszPath)))
     2260    {
     2261        // run thru the path components
     2262        PSZ pszPathCopy;
     2263        if (pszPathCopy = strdup(pszPath))
     2264        {
     2265            PSZ pszToken = strtok(pszPathCopy, ";");
     2266            while (pszToken)        // V0.9.12 (2001-05-03) [umoeller]
     2267            {
     2268                CHAR szFileMask[2*CCHMAXPATH];
     2269                FILESTATUS3 fs3;
     2270
     2271                sprintf(szFileMask,
     2272                        "%s\\%s",
     2273                        pszToken,           // path particle
     2274                        pcszFile);          // e.g. "netscape"
     2275
     2276                if (    (!(arc = DosQueryPathInfo(szFileMask,
     2277                                                  FIL_STANDARD,
     2278                                                  &fs3,
     2279                                                  sizeof(fs3))))
     2280                     // make sure it's not a directory
     2281                     // and that it's not hidden
     2282                     && (!(fs3.attrFile & (FILE_DIRECTORY | FILE_HIDDEN)))
     2283                   )
     2284                {
     2285                    // copy
     2286                    arc = CopyToBuffer(pszExecutable,
     2287                                       szFileMask,
     2288                                       cbExecutable);
     2289                    // and stop
     2290                    break;
     2291                }
     2292                else
     2293                    arc = ERROR_FILE_NOT_FOUND;
     2294                    // and search on
     2295
     2296                pszToken = strtok(NULL, ";");
     2297            };
     2298
     2299            free(pszPathCopy);
     2300        }
     2301        else
     2302            arc = ERROR_NOT_ENOUGH_MEMORY;
     2303    }
     2304
     2305    return (arc);
     2306}
     2307
     2308/*
    21882309 * FindFile:
    21892310 *      helper for doshFindExecutable.
    21902311 *
    21912312 *added V0.9.11 (2001-04-25) [umoeller]
     2313 *@@changed V0.9.16 (2001-10-08) [umoeller]: rewrote second half for DosSearchPath replacement, which returns directories too
    21922314 */
    21932315
     
    22102332        if (!arc)
    22112333            if (!(fs3.attrFile & FILE_DIRECTORY))
    2212                 strhncpy0(pszExecutable,
    2213                           pcszCommand,
    2214                           cbExecutable);
     2334                arc = CopyToBuffer(pszExecutable,
     2335                                   pcszCommand,
     2336                                   cbExecutable);
    22152337            else
    22162338                // directory:
     
    22182340    }
    22192341    else
     2342    {
    22202343        // non-qualified:
    2221         arc = DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY,
     2344        /* arc = DosSearchPath(SEARCH_IGNORENETERRS
     2345                                | SEARCH_ENVIRONMENT
     2346                                | SEARCH_CUR_DIRECTORY,
    22222347                            "PATH",
    22232348                            (PSZ)pcszCommand,
    22242349                            pszExecutable,
    2225                             cbExecutable);
     2350                            cbExecutable); */
     2351            // The above is not useable. It returns directories
     2352            // on the path... for example, it returns \OS2\INSTALL\NETSCAPE
     2353            // if netscape is looked for. So we search manually... sigh.
     2354            // V0.9.16 (2001-10-08) [umoeller]
     2355        arc = doshSearchPath("PATH",
     2356                             pcszCommand,
     2357                             pszExecutable,
     2358                             cbExecutable);
     2359    }
    22262360
    22272361    return (arc);
     
    22352369 *      1)  If pcszCommand appears to be qualified (i.e. contains
    22362370 *          a backslash), this checks for whether the file exists.
    2237  *
    2238  *      2)  If pcszCommand contains no backslash, this calls
    2239  *          DosSearchPath in order to find the full path of the
    2240  *          executable.
     2371 *          If it is a directory, ERROR_INVALID_EXE_SIGNATURE is
     2372 *          returned.
     2373 *
     2374 *      2)  If pcszCommand contains no backslash, this searches
     2375 *          all directories on the PATH in order to find the full
     2376 *          path of the executable. Starting with V0.9.16, we
     2377 *          use doshSearchPath for that.
    22412378 *
    22422379 *      papcszExtensions determines if additional searches are to be
    2243  *      performed if the file doesn't exist (case 1) or DosSearchPath
     2380 *      performed if the file doesn't exist (case 1) or doshSearchPath
    22442381 *      returned ERROR_FILE_NOT_FOUND (case 2).
    22452382 *      This must point to an array of strings specifying the extra
     
    22492386 *      extra searches are performed.
    22502387 *
    2251  *      If this returns NO_ERROR, pszExecutable receives
    2252  *      the full path of the executable found by DosSearchPath.
    2253  *      Otherwise ERROR_FILE_NOT_FOUND is returned.
     2388 *      Returns:
     2389 *
     2390 *      --  NO_ERROR: pszExecutable has received the full path of
     2391 *          the executable found by DosSearchPath.
     2392 *
     2393 *      --  ERROR_FILE_NOT_FOUND
     2394 *
     2395 *      --  ERROR_BUFFER_OVERFLOW: pcszCommand was found, but
     2396 *          the pszExecutable buffer is too small to hold
     2397 *          the full path.
    22542398 *
    22552399 *      Example:
     
    22942438            {
    22952439                const char *pcszExtThis = papcszExtensions[ul];
    2296                 sprintf(psz2, "%s.%s", pcszCommand, pcszExtThis);
     2440                sprintf(psz2,
     2441                        "%s.%s",
     2442                        pcszCommand,
     2443                        pcszExtThis);
    22972444                arc = FindFile(psz2,
    22982445                               pszExecutable,
     
    23282475 *      on the system.
    23292476 *
    2330  *      Based on code (C) Dmitry A. Steklenev.
    2331  *
    23322477 *@@added V0.9.0 [umoeller]
    23332478 */
     
    23352480UINT doshQueryDiskCount(VOID)
    23362481{
    2337     USHORT count = 0;
    2338 
    2339     DosPhysicalDisk(INFO_COUNT_PARTITIONABLE_DISKS, &count, 2, 0, 0);
    2340     return (count);
    2341 }
    2342 
    2343 /*
    2344  *@@ doshReadSector:
    2345  *      reads a physical disk sector.
    2346  *
    2347  *      If NO_ERROR is returned, the sector contents
    2348  *      have been stored in *buff.
    2349  *
    2350  *      Based on code (C) Dmitry A. Steklenev.
    2351  *
    2352  *@@added V0.9.0 [umoeller]
    2353  *@@changed V0.9.9 (2001-04-04) [umoeller]: added more error checking
    2354  */
    2355 
    2356 APIRET doshReadSector(USHORT disk,      // in: physical disk no. (1, 2, 3, ...)
    2357                       void *buff,
    2358                       USHORT head,
    2359                       USHORT cylinder,
    2360                       USHORT sector)
    2361 {
    2362     APIRET  arc;
    2363     HFILE   dh = 0;
    2364     char    dn[256];
    2365 
    2366     sprintf(dn, "%u:", disk);
    2367     if (!(arc = DosPhysicalDisk(INFO_GETIOCTLHANDLE, &dh, 2, dn, 3)))
    2368     {
    2369         TRACKLAYOUT DiskIOParm;
    2370         ULONG IOCtlDataLength = sizeof(DiskIOParm);
    2371         ULONG IOCtlParmLength = 512;
    2372 
    2373         DiskIOParm.bCommand = 0;
    2374         DiskIOParm.usHead = head;
    2375         DiskIOParm.usCylinder = cylinder;
    2376         DiskIOParm.usFirstSector = 0;
    2377         DiskIOParm.cSectors = 1;
    2378         DiskIOParm.TrackTable[0].usSectorNumber = sector;
    2379         DiskIOParm.TrackTable[0].usSectorSize = 512;
    2380 
    2381         arc = DosDevIOCtl(dh,
    2382                           IOCTL_PHYSICALDISK, PDSK_READPHYSTRACK,
    2383                           &DiskIOParm, IOCtlParmLength, &IOCtlParmLength,
    2384                           buff       , IOCtlDataLength, &IOCtlDataLength);
    2385 
    2386         DosPhysicalDisk(INFO_FREEIOCTLHANDLE, 0, 0, &dh, 2);
    2387     }
    2388 
    2389     return (arc);
     2482    USHORT usCount = 0;
     2483    DosPhysicalDisk(INFO_COUNT_PARTITIONABLE_DISKS, &usCount, 2, 0, 0);
     2484    return (usCount);
    23902485}
    23912486
     
    23932488 *@@ doshType2FSName:
    23942489 *      this returns a static, zero-terminated string
    2395  *      for the given FS type. This is always 7 bytes
    2396  *      in length.
    2397  *
    2398  *      Values for operating system indicator:
    2399  *      --  00h  empty
    2400  *      --  01h  DOS 12-bit FAT
    2401  *      --  02h  XENIX root file system
    2402  *      --  03h  XENIX /usr file system (obsolete)
    2403  *      --  04h  DOS 16-bit FAT (up to 32M)
    2404  *      --  05h  DOS 3.3+ extended partition
    2405  *      --  06h  DOS 3.31+ Large File System (16-bit FAT, over 32M)
    2406  *      --  07h  QNX
    2407  *      --  07h  OS/2 HPFS
    2408  *      --  07h  Windows NT NTFS
    2409  *      --  07h  Advanced Unix
    2410  *      --  08h  OS/2 (v1.0-1.3 only)
    2411  *      --  08h  AIX bootable partition, SplitDrive
    2412  *      --  08h  Commodore DOS
    2413  *      --  08h  DELL partition spanning multiple drives
    2414  *      --  09h  AIX data partition
    2415  *      --  09h  Coherent filesystem
    2416  *      --  0Ah  OS/2 Boot Manager
    2417  *      --  0Ah  OPUS
    2418  *      --  0Ah  Coherent swap partition
    2419  *      --  0Bh  Windows95 with 32-bit FAT
    2420  *      --  0Ch  Windows95 with 32-bit FAT (using LBA-mode INT 13 extensions)
    2421  *      --  0Eh  logical-block-addressable VFAT (same as 06h but using LBA-mode INT 13)
    2422  *      --  0Fh  logical-block-addressable VFAT (same as 05h but using LBA-mode INT 13)
    2423  *      --  10h  OPUS
    2424  *      --  11h  OS/2 Boot Manager hidden 12-bit FAT partition
    2425  *      --  12h  Compaq Diagnostics partition
    2426  *      --  14h  (resulted from using Novell DOS 7.0 FDISK to delete Linux Native part)
    2427  *      --  14h  OS/2 Boot Manager hidden sub-32M 16-bit FAT partition
    2428  *      --  16h  OS/2 Boot Manager hidden over-32M 16-bit FAT partition
    2429  *      --  17h  OS/2 Boot Manager hidden HPFS partition
    2430  *      --  18h  AST special Windows swap file ("Zero-Volt Suspend" partition)
    2431  *      --  21h  officially listed as reserved
    2432  *      --  23h  officially listed as reserved
    2433  *      --  24h  NEC MS-DOS 3.x
    2434  *      --  26h  officially listed as reserved
    2435  *      --  31h  officially listed as reserved
    2436  *      --  33h  officially listed as reserved
    2437  *      --  34h  officially listed as reserved
    2438  *      --  36h  officially listed as reserved
    2439  *      --  38h  Theos
    2440  *      --  3Ch  PowerQuest PartitionMagic recovery partition
    2441  *      --  40h  VENIX 80286
    2442  *      --  41h  Personal RISC Boot
    2443  *      --  42h  SFS (Secure File System) by Peter Gutmann
    2444  *      --  50h  OnTrack Disk Manager, read-only partition
    2445  *      --  51h  OnTrack Disk Manager, read/write partition
    2446  *      --  51h  NOVEL
    2447  *      --  52h  CP/M
    2448  *      --  52h  Microport System V/386
    2449  *      --  53h  OnTrack Disk Manager, write-only partition???
    2450  *      --  54h  OnTrack Disk Manager (DDO)
    2451  *      --  56h  GoldenBow VFeature
    2452  *      --  61h  SpeedStor
    2453  *      --  63h  Unix SysV/386, 386/ix
    2454  *      --  63h  Mach, MtXinu BSD 4.3 on Mach
    2455  *      --  63h  GNU HURD
    2456  *      --  64h  Novell NetWare 286
    2457  *      --  65h  Novell NetWare (3.11)
    2458  *      --  67h  Novell
    2459  *      --  68h  Novell
    2460  *      --  69h  Novell
    2461  *      --  70h  DiskSecure Multi-Boot
    2462  *      --  71h  officially listed as reserved
    2463  *      --  73h  officially listed as reserved
    2464  *      --  74h  officially listed as reserved
    2465  *      --  75h  PC/IX
    2466  *      --  76h  officially listed as reserved
    2467  *      --  80h  Minix v1.1 - 1.4a
    2468  *      --  81h  Minix v1.4b+
    2469  *      --  81h  Linux
    2470  *      --  81h  Mitac Advanced Disk Manager
    2471  *      --  82h  Linux Swap partition
    2472  *      --  82h  Prime
    2473  *      --  83h  Linux native file system (ext2fs/xiafs)
    2474  *      --  84h  OS/2-renumbered type 04h partition (related to hiding DOS C: drive)
    2475  *      --  86h  FAT16 volume/stripe set (Windows NT)
    2476  *      --  87h  HPFS Fault-Tolerant mirrored partition
    2477  *      --  87h  NTFS volume/stripe set
    2478  *      --  93h  Amoeba file system
    2479  *      --  94h  Amoeba bad block table
    2480  *      --  A0h  Phoenix NoteBIOS Power Management "Save-to-Disk" partition
    2481  *      --  A1h  officially listed as reserved
    2482  *      --  A3h  officially listed as reserved
    2483  *      --  A4h  officially listed as reserved
    2484  *      --  A5h  FreeBSD, BSD/386
    2485  *      --  A6h  officially listed as reserved
    2486  *      --  B1h  officially listed as reserved
    2487  *      --  B3h  officially listed as reserved
    2488  *      --  B4h  officially listed as reserved
    2489  *      --  B6h  officially listed as reserved
    2490  *      --  B7h  BSDI file system (secondarily swap)
    2491  *      --  B8h  BSDI swap partition (secondarily file system)
    2492  *      --  C1h  DR DOS 6.0 LOGIN.EXE-secured 12-bit FAT partition
    2493  *      --  C4h  DR DOS 6.0 LOGIN.EXE-secured 16-bit FAT partition
    2494  *      --  C6h  DR DOS 6.0 LOGIN.EXE-secured Huge partition
    2495  *      --  C6h  corrupted FAT16 volume/stripe set (Windows NT)
    2496  *      --  C7h  Syrinx Boot
    2497  *      --  C7h  corrupted NTFS volume/stripe set
    2498  *      --  D8h  CP/M-86
    2499  *      --  DBh  CP/M, Concurrent CP/M, Concurrent DOS
    2500  *      --  DBh  CTOS (Convergent Technologies OS)
    2501  *      --  E1h  SpeedStor 12-bit FAT extended partition
    2502  *      --  E3h  DOS read-only
    2503  *      --  E3h  Storage Dimensions
    2504  *      --  E4h  SpeedStor 16-bit FAT extended partition
    2505  *      --  E5h  officially listed as reserved
    2506  *      --  E6h  officially listed as reserved
    2507  *      --  F1h  Storage Dimensions
    2508  *      --  F2h  DOS 3.3+ secondary partition
    2509  *      --  F3h  officially listed as reserved
    2510  *      --  F4h  SpeedStor
    2511  *      --  F4h  Storage Dimensions
    2512  *      --  F6h  officially listed as reserved
    2513  *      --  FEh  LANstep
    2514  *      --  FEh  IBM PS/2 IML
    2515  *      --  FFh  Xenix bad block table
    2516  *
    2517  *      Note: for partition type 07h, one should inspect the partition boot record
    2518  *            for the actual file system type
    2519  *
    2520  *      Based on code (C) Dmitry A. Steklenev.
     2490 *      for the given FS type, or NULL if the type
     2491 *      is unknown.
    25212492 *
    25222493 *@@added V0.9.0 [umoeller]
     2494 *@@changed V0.9.16 (2001-10-08) [umoeller]: rewritten
    25232495 */
    25242496
    25252497const char* doshType2FSName(unsigned char bFSType)  // in: FS type
    25262498{
    2527     PSZ zFSName = NULL;
    2528 
    25292499    switch (bFSType)
    25302500    {
    2531         case PAR_UNUSED:
    2532             zFSName = "UNUSED ";
    2533             break;
    2534         case PAR_FAT12SMALL:
    2535             zFSName = "FAT-12 ";
    2536             break;
    2537         case PAR_XENIXROOT:
    2538             zFSName = "XENIX  ";
    2539             break;
    2540         case PAR_XENIXUSER:
    2541             zFSName = "XENIX  ";
    2542             break;
    2543         case PAR_FAT16SMALL:
    2544             zFSName = "FAT-16 ";
    2545             break;
    2546         case PAR_EXTENDED:
    2547             zFSName = "EXTEND ";
    2548             break;
    2549         case PAR_FAT16BIG:
    2550             zFSName = "BIGDOS ";
    2551             break;
    2552         case PAR_HPFS:
    2553             zFSName = "HPFS   ";
    2554             break;
    2555         case PAR_AIXBOOT:
    2556             zFSName = "AIX    ";
    2557             break;
    2558         case PAR_AIXDATA:
    2559             zFSName = "AIX    ";
    2560             break;
    2561         case PAR_BOOTMANAGER:
    2562             zFSName = "BOOTMNG";
    2563             break;
    2564         case PAR_WINDOWS95:
    2565             zFSName = "WIN95  ";
    2566             break;
    2567         case PAR_WINDOWS95LB:
    2568             zFSName = "WIN95  ";
    2569             break;
    2570         case PAR_VFAT16BIG:
    2571             zFSName = "VFAT   ";
    2572             break;
    2573         case PAR_VFAT16EXT:
    2574             zFSName = "VFAT   ";
    2575             break;
    2576         case PAR_OPUS:
    2577             zFSName = "OPUS   ";
    2578             break;
    2579         case PAR_HID12SMALL:
    2580             zFSName = "FAT-12*";
    2581             break;
    2582         case PAR_COMPAQDIAG:
    2583             zFSName = "COMPAQ ";
    2584             break;
    2585         case PAR_HID16SMALL:
    2586             zFSName = "FAT-16*";
    2587             break;
    2588         case PAR_HID16BIG:
    2589             zFSName = "BIGDOS*";
    2590             break;
    2591         case PAR_HIDHPFS:
    2592             zFSName = "HPFS*  ";
    2593             break;
    2594         case PAR_WINDOWSSWP:
    2595             zFSName = "WINSWAP";
    2596             break;
    2597         case PAR_NECDOS:
    2598             zFSName = "NECDOS ";
    2599             break;
    2600         case PAR_THEOS:
    2601             zFSName = "THEOS  ";
    2602             break;
    2603         case PAR_VENIX:
    2604             zFSName = "VENIX  ";
    2605             break;
    2606         case PAR_RISCBOOT:
    2607             zFSName = "RISC   ";
    2608             break;
    2609         case PAR_SFS:
    2610             zFSName = "SFS    ";
    2611             break;
    2612         case PAR_ONTRACK:
    2613             zFSName = "ONTRACK";
    2614             break;
    2615         case PAR_ONTRACKEXT:
    2616             zFSName = "ONTRACK";
    2617             break;
    2618         case PAR_CPM:
    2619             zFSName = "CP/M   ";
    2620             break;
    2621         case PAR_UNIXSYSV:
    2622             zFSName = "UNIX   ";
    2623             break;
    2624         case PAR_NOVELL_64:
    2625             zFSName = "NOVELL ";
    2626             break;
    2627         case PAR_NOVELL_65:
    2628             zFSName = "NOVELL ";
    2629             break;
    2630         case PAR_NOVELL_67:
    2631             zFSName = "NOVELL ";
    2632             break;
    2633         case PAR_NOVELL_68:
    2634             zFSName = "NOVELL ";
    2635             break;
    2636         case PAR_NOVELL_69:
    2637             zFSName = "NOVELL ";
    2638             break;
    2639         case PAR_PCIX:
    2640             zFSName = "PCIX   ";
    2641             break;
    2642         case PAR_MINIX:
    2643             zFSName = "MINIX  ";
    2644             break;
    2645         case PAR_LINUX:
    2646             zFSName = "LINUX  ";
    2647             break;
    2648         case PAR_LINUXSWAP:
    2649             zFSName = "LNXSWP ";
    2650             break;
    2651         case PAR_LINUXFILE:
    2652             zFSName = "LINUX  ";
    2653             break;
    2654         case PAR_FREEBSD:
    2655             zFSName = "FREEBSD";
    2656             break;
    2657         case PAR_BBT:
    2658             zFSName = "BBT    ";
    2659             break;
    2660 
    2661         default:
    2662             zFSName = "       ";
    2663             break;
     2501        case 0x00: return "empty";
     2502        case 0x01: return "DOS 12-bit FAT < 10 Mb";
     2503        case 0x02: return "XENIX root file system";
     2504        case 0x03: return "XENIX /usr file system (obsolete)";
     2505        case 0x04: return "DOS 16-bit FAT < 32 Mb";
     2506        case 0x05: return "DOS 3.3+ extended partition";
     2507        case 0x06: return "DOS 3.31+ 16-bit FAT > 32 Mb";
     2508        case 0x07: return "HPFS/NTFS/QNX/Advanced Unix";
     2509        case 0x08: return "OS/2 1.0-1.3/AIX/Commodore/DELL";
     2510        case 0x09: return "AIX data/Coherent";
     2511        case 0x0A: return "OS/2 Boot Manager/OPUS/Coherent Swap";
     2512        case 0x0B: return "Windows95 with 32-bit FAT";
     2513        case 0x0C: return "Windows95 with 32-bit FAT (LBA)";
     2514        case 0x0E: return "Windows 95 VFAT (06h plus LBA)";
     2515        case 0x0F: return "Windows 95 VFAT (05h plus LBA)";
     2516        case 0x10: return "OPUS";
     2517        case 0x11: return "OS/2 Boot Manager hidden 12-bit FAT";
     2518        case 0x12: return "Compaq Diagnostics";
     2519        case 0x14: return "OS/2 Boot Manager hidden sub-32M 16-bit FAT";
     2520        case 0x16: return "OS/2 Boot Manager hidden over-32M 16-bit FAT";
     2521        case 0x17: return "OS/2 Boot Manager hidden HPFS";
     2522        case 0x18: return "AST special Windows swap file (\"Zero-Volt Suspend\")";
     2523        // case 0x21: reserved
     2524        // case 0x23: reserved
     2525        case 0x24: return "NEC MS-DOS 3.x";
     2526        // case 0x26: reserved
     2527        // case 0x31: reserved
     2528        // case 0x33: reserved
     2529        // case 0x34: reserved
     2530        // case 0x36: reserved
     2531        case 0x38: return "Theos";
     2532        case 0x3C: return "PowerQuest PartitionMagic recovery partition";
     2533        case 0x40: return "VENIX 80286";
     2534        case 0x41: return "Personal RISC Boot";
     2535        case 0x42: return "SFS (Secure File System) by Peter Gutmann";
     2536        case 0x50: return "OnTrack Disk Manager, read-only";
     2537        case 0x51: return "OnTrack Disk Manager, read/write";
     2538        case 0x52: return "CP/M or Microport System V/386";
     2539        case 0x53: return "OnTrack Disk Manager, write-only???";
     2540        case 0x54: return "OnTrack Disk Manager (DDO)";
     2541        case 0x56: return "GoldenBow VFeature";
     2542        case 0x61: return "SpeedStor";
     2543        case 0x63: return "Unix SysV/386, 386/ix or Mach, MtXinu BSD 4.3 on Mach or GNU HURD";
     2544        case 0x64: return "Novell NetWare 286";
     2545        case 0x65: return "Novell NetWare (3.11)";
     2546        case 0x67:
     2547        case 0x68:
     2548        case 0x69: return "Novell";
     2549        case 0x70: return "DiskSecure Multi-Boot";
     2550        // case 0x71: reserved
     2551        // case 0x73: reserved
     2552        // case 0x74: reserved
     2553        case 0x75: return "PC/IX";
     2554        // case 0x76: reserved
     2555        case 0x80: return "Minix v1.1 - 1.4a";
     2556        case 0x81: return "Minix v1.4b+ or Linux or Mitac Advanced Disk Manager";
     2557        case 0x82: return "Linux Swap or Prime";
     2558        case 0x83: return "Linux native file system (ext2fs/xiafs)";
     2559        case 0x84: return "OS/2-renumbered type 04h (hidden DOS C: drive)";
     2560        case 0x86: return "FAT16 volume/stripe set (Windows NT)";
     2561        case 0x87: return "HPFS Fault-Tolerant mirrored partition or NTFS volume/stripe set";
     2562        case 0x93: return "Amoeba file system";
     2563        case 0x94: return "Amoeba bad block table";
     2564        case 0xA0: return "Phoenix NoteBIOS Power Management \"Save-to-Disk\" partition";
     2565        // case 0xA1: reserved
     2566        // case 0xA3: reserved
     2567        // case 0xA4: reserved
     2568        case 0xA5: return "FreeBSD, BSD/386";
     2569        // case 0xA6: reserved
     2570        // case 0xB1: reserved
     2571        // case 0xB3: reserved
     2572        // case 0xB4: reserved
     2573        // case 0xB6: reserved
     2574        case 0xB7: return "BSDI file system (secondarily swap)";
     2575        case 0xB8: return "BSDI swap (secondarily file system)";
     2576        case 0xC1: return "DR DOS 6.0 LOGIN.EXE-secured 12-bit FAT";
     2577        case 0xC4: return "DR DOS 6.0 LOGIN.EXE-secured 16-bit FAT";
     2578        case 0xC6: return "DR DOS 6.0 LOGIN.EXE-secured Huge partition or NT corrupted FAT16 volume/stripe set";
     2579        case 0xC7: return "Syrinx Boot or corrupted NTFS volume/stripe set";
     2580        case 0xD8: return "CP/M-86";
     2581        case 0xDB: return "CP/M, Concurrent CP/M, Concurrent DOS, Convergent Technologies OS";
     2582        case 0xE1: return "SpeedStor 12-bit FAT extended partition";
     2583        case 0xE3: return "DOS read-only or Storage Dimensions";
     2584        case 0xE4: return "SpeedStor 16-bit FAT extended partition";
     2585        // case 0xE5: reserved
     2586        // case 0xE6: reserved
     2587        case 0xF1: return "Storage Dimensions";
     2588        case 0xF2: return "DOS 3.3+ secondary partition";
     2589        // case 0xF3: reserved
     2590        case 0xF4: return "SpeedStor or Storage Dimensions";
     2591        // case 0xF6: reserved
     2592        case 0xFE: return "LANstep or IBM PS/2 IML";
     2593        case 0xFF: return "Xenix bad block table";
    26642594    }
    2665     return zFSName;
     2595
     2596    return NULL;
    26662597}
    26672598
     
    26782609 *      to point to the newly created PARTITIONINFO, so before
    26792610 *      calling this function for the first time,
    2680  *
    2681  *      Based on code (C) Dmitry A. Steklenev.
    26822611 *
    26832612 *@@added V0.9.0 [umoeller]
     
    27122641        ppiNew->cLetter = cLetter;
    27132642        ppiNew->bFSType = bFsType;
    2714         strcpy(ppiNew->szFSType,
    2715                doshType2FSName(bFsType));
     2643        ppiNew->pcszFSType = doshType2FSName(bFsType);
    27162644        ppiNew->fPrimary = fPrimary;
    27172645        ppiNew->fBootable = fBootable;
     
    27412669}
    27422670
     2671#ifndef __XWPLITE__
     2672
     2673/*
     2674 *@@ doshReadSector:
     2675 *      reads a physical disk sector.
     2676 *
     2677 *      If NO_ERROR is returned, the sector contents
     2678 *      have been stored in *buff.
     2679 *
     2680 *      Originally contributed by Dmitry A. Steklenev.
     2681 *
     2682 *@@added V0.9.0 [umoeller]
     2683 *@@changed V0.9.9 (2001-04-04) [umoeller]: added more error checking
     2684 */
     2685
     2686APIRET doshReadSector(USHORT disk,      // in: physical disk no. (1, 2, 3, ...)
     2687                      void *buff,
     2688                      USHORT head,
     2689                      USHORT cylinder,
     2690                      USHORT sector)
     2691{
     2692    APIRET  arc;
     2693    HFILE   dh = 0;
     2694    char    dn[256];
     2695
     2696    sprintf(dn, "%u:", disk);
     2697    if (!(arc = DosPhysicalDisk(INFO_GETIOCTLHANDLE, &dh, 2, dn, 3)))
     2698    {
     2699        TRACKLAYOUT DiskIOParm;
     2700        ULONG IOCtlDataLength = sizeof(DiskIOParm);
     2701        ULONG IOCtlParmLength = 512;
     2702
     2703        DiskIOParm.bCommand = 0;
     2704        DiskIOParm.usHead = head;
     2705        DiskIOParm.usCylinder = cylinder;
     2706        DiskIOParm.usFirstSector = 0;
     2707        DiskIOParm.cSectors = 1;
     2708        DiskIOParm.TrackTable[0].usSectorNumber = sector;
     2709        DiskIOParm.TrackTable[0].usSectorSize = 512;
     2710
     2711        arc = DosDevIOCtl(dh,
     2712                          IOCTL_PHYSICALDISK, PDSK_READPHYSTRACK,
     2713                          &DiskIOParm, IOCtlParmLength, &IOCtlParmLength,
     2714                          buff       , IOCtlDataLength, &IOCtlDataLength);
     2715
     2716        DosPhysicalDisk(INFO_FREEIOCTLHANDLE, 0, 0, &dh, 2);
     2717    }
     2718
     2719    return (arc);
     2720}
     2721
    27432722// Sector and Cylinder values are actually 6 bits and 10 bits:
    27442723//
     
    27562735 *      get cylinder number.
    27572736 *
    2758  *      Based on code (C) Dmitry A. Steklenev.
     2737 *      Originally contributed by Dmitry A. Steklenev.
    27592738 *
    27602739 *@@added V0.9.0 [umoeller]
     
    27712750 *      get sector number.
    27722751 *
    2773  *      Based on code (C) Dmitry A. Steklenev.
     2752 *      Originally contributed by Dmitry A. Steklenev.
    27742753 *
    27752754 *@@added V0.9.0 [umoeller]
     
    27962775 *      -- ERROR_NOT_SUPPORTED (50): boot manager not installed.
    27972776 *
    2798  *      Based on code (C) Dmitry A. Steklenev.
     2777 *      Originally contributed by Dmitry A. Steklenev.
    27992778 *
    28002779 *@@added V0.9.0 [umoeller]
     
    28582837 *      -- ERROR_INVALID_PARAMETER: BMInfo is NULL.
    28592838 *
    2860  *      Based on code (C) Dmitry A. Steklenev.
     2839 *      Originally contributed by Dmitry A. Steklenev.
    28612840 *
    28622841 *@@added V0.9.0 [umoeller]
     
    29072886                    // skip unused partition, BootManager or Extended partition
    29082887                    if (    (MBoot.sPrtnInfo[i].bFileSysCode)  // skip unused
    2909                         &&  (MBoot.sPrtnInfo[i].bFileSysCode != PAR_BOOTMANAGER) // skip boot manager
    2910                         &&  (MBoot.sPrtnInfo[i].bFileSysCode != PAR_EXTENDED) // skip extended
     2888                        &&  (MBoot.sPrtnInfo[i].bFileSysCode != 0x0A) // skip boot manager
     2889                        &&  (MBoot.sPrtnInfo[i].bFileSysCode != 0x05) // skip extended partition
    29112890                       )
    29122891                    {
     
    29452924 *      This gets called from GetExtendedPartition.
    29462925 *
    2947  *      Based on code (C) Dmitry A. Steklenev.
     2926 *      Originally contributed by Dmitry A. Steklenev.
    29482927 *
    29492928 *@@added V0.9.0 [umoeller]
     
    29732952        // skip unused partition or BootManager partition
    29742953        if (    (MBoot.sPrtnInfo[i].bFileSysCode)
    2975              && (MBoot.sPrtnInfo[i].bFileSysCode != PAR_BOOTMANAGER)
     2954             && (MBoot.sPrtnInfo[i].bFileSysCode != 0x0A)
    29762955           )
    29772956        {
     
    29802959
    29812960            // special work around extended partition
    2982             if (MBoot.sPrtnInfo[i].bFileSysCode == PAR_EXTENDED)
     2961            if (MBoot.sPrtnInfo[i].bFileSysCode == 0x05)
    29832962            {
    29842963                if ((arc = GetLogicalDrives(pppiFirst,
     
    29952974
    29962975            // raise driver letter if OS/2 would recognize this drive
    2997             if (    (MBoot.sPrtnInfo[i].bFileSysCode < PAR_PCIX)
     2976            if (    (MBoot.sPrtnInfo[i].bFileSysCode < 0x75)
    29982977               )
    29992978                fAssignLetter = TRUE;
     
    30343013 *      This gets called from doshGetPartitionsList.
    30353014 *
    3036  *      Based on code (C) Dmitry A. Steklenev.
     3015 *      Originally contributed by Dmitry A. Steklenev.
    30373016 *
    30383017 *@@added V0.9.0 [umoeller]
     
    30583037         i++)
    30593038    {
    3060         if (MBoot.sPrtnInfo[i].bFileSysCode == PAR_EXTENDED)
     3039        if (MBoot.sPrtnInfo[i].bFileSysCode == 0x05)
    30613040        {
    30623041            if ((arc = GetLogicalDrives(pppiFirst,
     
    30753054
    30763055/*
     3056 *@@ ReadFDiskPartitions:
     3057 *      helper for doshGetPartitionsList for non-LVM
     3058 *      systems.
     3059 *
     3060 *      Originally contributed by Dmitry A. Steklenev.
     3061 *
     3062 *@@added V0.9.16 (2001-10-08) [umoeller]
     3063 */
     3064
     3065APIRET ReadFDiskPartitions(PARTITIONINFO **ppPartitionInfos,
     3066                           USHORT *pcPartitions,
     3067                           PUSHORT pusContext)              // out: error context
     3068{
     3069    APIRET          arc = NO_ERROR;
     3070
     3071    PAR_INFO        BmInfo;     // BootManager partition
     3072    USHORT          usBmDisk;     // BootManager disk
     3073    USHORT          cDisks = doshQueryDiskCount();    // physical disks count
     3074    USHORT          i;
     3075
     3076    CHAR            cLetter = 'C';  // first drive letter
     3077
     3078    PARTITIONINFO   *ppiTemp = NULL;
     3079
     3080    if (cDisks > 8)              // Not above 8 disks
     3081        cDisks = 8;
     3082
     3083    // get boot manager disk and info
     3084    if ((arc = doshGetBootManager(&usBmDisk,
     3085                                  NULL,
     3086                                  &BmInfo)) != NO_ERROR)
     3087    {
     3088        *pusContext = 1;
     3089    }
     3090    else
     3091    {
     3092        // on each disk, read primary partitions
     3093        for (i = 1; i <= cDisks; i++)
     3094        {
     3095            if ((arc = GetPrimaryPartitions(ppPartitionInfos,
     3096                                            &ppiTemp,
     3097                                            pcPartitions,
     3098                                            &cLetter,
     3099                                            usBmDisk,
     3100                                            usBmDisk ? &BmInfo : 0,
     3101                                            i)))
     3102            {
     3103                *pusContext = 2;
     3104            }
     3105        }
     3106
     3107        if (!arc && usBmDisk)
     3108        {
     3109            // boot manager found:
     3110            // on each disk, read extended partition
     3111            // with logical drives
     3112            for (i = 1; i <= cDisks; i++)
     3113            {
     3114                if ((arc = GetExtendedPartition(ppPartitionInfos,
     3115                                                &ppiTemp,
     3116                                                pcPartitions,
     3117                                                &cLetter,
     3118                                                &BmInfo,
     3119                                                i)))
     3120                {
     3121                    *pusContext = 3;
     3122                }
     3123            }
     3124        }
     3125    } // end else if ((arc = doshGetBootManager(&usBmDisk,
     3126
     3127    return (arc);
     3128}
     3129
     3130#endif
     3131
     3132/*
    30773133 *@@ CleanPartitionInfos:
    30783134 *
     
    31373193 *      --  0: something else.
    31383194 *
    3139  *      Based on code (C) Dmitry A. Steklenev.
     3195 *      Originally contributed by Dmitry A. Steklenev.
    31403196 *
    31413197 *@@added V0.9.0 [umoeller]
     
    31513207    PLVMINFO        pLVMInfo = NULL;
    31523208
    3153     PARTITIONINFO   *pPartitionInfos = NULL, // linked list of all partitions
    3154                     *ppiTemp = NULL;
     3209    PARTITIONINFO   *pPartitionInfos = NULL; // linked list of all partitions
    31553210    USHORT          cPartitions = 0;        // bootable partition count
    31563211
     
    31763231    }
    31773232
     3233#ifndef __XWPLITE__
    31783234    if (arc)
    3179     {
    31803235        // LVM not installed, or failed:
    31813236        // parse partitions manually
    3182         PAR_INFO        BmInfo;     // BootManager partition
    3183         USHORT          usBmDisk;     // BootManager disk
    3184         USHORT          cDisks = doshQueryDiskCount();    // physical disks count
    3185         USHORT          i;
    3186 
    3187         CHAR            cLetter = 'C';  // first drive letter
    3188 
    3189         // start over
    3190         arc = NO_ERROR;
    3191 
    3192         if (cDisks > 8)              // Not above 8 disks
    3193             cDisks = 8;
    3194 
    3195         // get boot manager disk and info
    3196         if ((arc = doshGetBootManager(&usBmDisk,
    3197                                       NULL,
    3198                                       &BmInfo)) != NO_ERROR)
    3199         {
    3200             *pusContext = 1;
    3201         }
    3202         else
    3203         {
    3204             // on each disk, read primary partitions
    3205             for (i = 1; i <= cDisks; i++)
    3206             {
    3207                 if ((arc = GetPrimaryPartitions(&pPartitionInfos,
    3208                                                 &ppiTemp,
    3209                                                 &cPartitions,
    3210                                                 &cLetter,
    3211                                                 usBmDisk,
    3212                                                 usBmDisk ? &BmInfo : 0,
    3213                                                 i)))
    3214                 {
    3215                     *pusContext = 2;
    3216                 }
    3217             }
    3218 
    3219             if (!arc && usBmDisk)
    3220             {
    3221                 // boot manager found:
    3222                 // on each disk, read extended partition
    3223                 // with logical drives
    3224                 for (i = 1; i <= cDisks; i++)
    3225                 {
    3226                     if ((arc = GetExtendedPartition(&pPartitionInfos,
    3227                                                     &ppiTemp,
    3228                                                     &cPartitions,
    3229                                                     &cLetter,
    3230                                                     &BmInfo,
    3231                                                     i)))
    3232                     {
    3233                         *pusContext = 3;
    3234                     }
    3235                 }
    3236             }
    3237         } // end else if ((arc = doshGetBootManager(&usBmDisk,
    3238     } // end else if (!doshQueryLVMInfo(&pLVMInfo))
     3237        arc = ReadFDiskPartitions(&pPartitionInfos,
     3238                                  &cPartitions,
     3239                                  pusContext);
     3240#endif
    32393241
    32403242    if (!arc)
Note: See TracChangeset for help on using the changeset viewer.