update dev300-m57
[ooovba.git] / sal / osl / os2 / helpers / dosh.h
blobd2e936a57447ca462ebee6d5e299e8f5d71be78a
2 /*
3 *@@sourcefile dosh.h:
4 * header file for dosh.c. See remarks there.
6 * Note: Version numbering in this file relates to XWorkplace version
7 * numbering.
9 *@@include #define INCL_DOSPROCESS
10 *@@include #define INCL_DOSDEVIOCTL // for doshQueryDiskParams only
11 *@@include #include <os2.h>
12 *@@include #include "helpers\dosh.h"
15 /* This file Copyright (C) 1997-2001 Ulrich M”ller,
16 * Dmitry A. Steklenev.
17 * This file is part of the "XWorkplace helpers" source package.
18 * This is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published
20 * by the Free Software Foundation, in version 2 as it comes in the
21 * "COPYING" file of the XWorkplace main distribution.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
28 #if __cplusplus
29 extern "C" {
30 #endif
32 #ifndef DOSH_HEADER_INCLUDED
33 #define DOSH_HEADER_INCLUDED
35 /* ******************************************************************
37 * Wrappers
39 ********************************************************************/
41 // if DOSH_STANDARDWRAPPERS is #define'd before including dosh.h,
42 // all the following Dos* API calls are redirected to the dosh*
43 // counterparts
45 #ifdef DOSH_STANDARDWRAPPERS
47 #ifdef INCL_DOSPROCESS
49 APIRET XWPENTRY doshSleep(ULONG msec);
50 #define DosSleep(a) doshSleep((a))
52 #endif
54 #ifdef INCL_DOSSEMAPHORES
56 APIRET XWPENTRY doshCreateMutexSem(PSZ pszName,
57 PHMTX phmtx,
58 ULONG flAttr,
59 BOOL32 fState);
60 #define DosCreateMutexSem(a, b, c, d) doshCreateMutexSem((a), (b), (c), (d))
62 APIRET XWPENTRY doshRequestMutexSem(HMTX hmtx, ULONG ulTimeout);
63 #define DosRequestMutexSem(h, t) doshRequestMutexSem((h), (t))
65 APIRET XWPENTRY doshReleaseMutexSem(HMTX hmtx);
66 #define DosReleaseMutexSem(h) doshReleaseMutexSem((h))
68 #endif
70 #ifdef INCL_DOSEXCEPTIONS
72 APIRET XWPENTRY doshSetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec);
73 #define DosSetExceptionHandler(a) doshSetExceptionHandler((a))
75 APIRET XWPENTRY doshUnsetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec);
76 #define DosUnsetExceptionHandler(a) doshUnsetExceptionHandler((a))
78 #endif
80 #endif
82 /* ******************************************************************
84 * Miscellaneous
86 ********************************************************************/
88 CHAR doshGetChar(VOID);
90 BOOL doshQueryShiftState(VOID);
92 ULONG doshIsWarp4(VOID);
94 PSZ doshQuerySysErrorMsg(APIRET arc);
96 ULONG doshQuerySysUptime(VOID);
98 /* ******************************************************************
100 * Memory helpers
102 ********************************************************************/
104 PVOID doshMalloc(ULONG cb,
105 APIRET *parc);
107 APIRET doshAllocArray(ULONG c,
108 ULONG cbArrayItem,
109 PBYTE *ppv,
110 PULONG pcbAllocated);
112 PVOID doshAllocSharedMem(ULONG ulSize,
113 const char* pcszName);
115 PVOID doshRequestSharedMem(PCSZ pcszName);
117 /* ******************************************************************
119 * Drive helpers
121 ********************************************************************/
123 APIRET doshIsFixedDisk(ULONG ulLogicalDrive,
124 PBOOL pfFixed);
126 #ifdef INCL_DOSDEVIOCTL
128 // #pragma pack(1)
131 * DRIVEPARAMS:
132 * structure used for doshQueryDiskParams.
133 * removed this, we can directly use BIOSPARAMETERBLOCK
134 * V0.9.13 (2001-06-14) [umoeller]
137 /* typedef struct _DRIVEPARAMS
139 BIOSPARAMETERBLOCK bpb;
140 // BIOS parameter block. This is the first sector
141 // (at byte 0) in each partition. This is defined
142 // in the OS2 headers as follows:
144 typedef struct _BIOSPARAMETERBLOCK {
145 0 USHORT usBytesPerSector;
146 // Number of bytes per sector.
147 2 BYTE bSectorsPerCluster;
148 // Number of sectors per cluster.
149 3 USHORT usReservedSectors;
150 // Number of reserved sectors.
151 5 BYTE cFATs;
152 // Number of FATs.
153 6 USHORT cRootEntries;
154 // Number of root directory entries.
155 8 USHORT cSectors;
156 // Number of sectors.
157 10 BYTE bMedia;
158 // Media descriptor.
159 11 USHORT usSectorsPerFAT;
160 // Number of secctors per FAT.
161 13 USHORT usSectorsPerTrack;
162 // Number of sectors per track.
163 15 USHORT cHeads;
164 // Number of heads.
165 17 ULONG cHiddenSectors;
166 // Number of hidden sectors.
167 21 ULONG cLargeSectors;
168 // Number of large sectors.
169 25 BYTE abReserved[6];
170 // Reserved.
171 31 USHORT cCylinders;
172 // Number of cylinders defined for the physical
173 // device.
174 33 BYTE bDeviceType;
175 // Physical layout of the specified device.
176 34 USHORT fsDeviceAttr;
177 // A bit field that returns flag information
178 // about the specified drive.
179 } BIOSPARAMETERBLOCK;
181 // removed the following fields... these are already
182 // in the extended BPB structure, as defined in the
183 // Toolkit's BIOSPARAMETERBLOCK struct. Checked this,
184 // the definition is the same for the Toolkit 3 and 4.5.
186 USHORT usCylinders;
187 // no. of cylinders
188 UCHAR ucDeviceType;
189 // device type; according to the IBM Control
190 // Program Reference (see DSK_GETDEVICEPARAMS),
191 // this value can be:
192 // -- 0: 48 TPI low-density diskette drive
193 // -- 1: 96 TPI high-density diskette drive
194 // -- 2: 3.5-inch 720KB diskette drive
195 // -- 3: 8-Inch single-density diskette drive
196 // -- 4: 8-Inch double-density diskette drive
197 // -- 5: Fixed disk
198 // -- 6: Tape drive
199 // -- 7: Other (includes 1.44MB 3.5-inch diskette drive
200 // and CD-ROMs)
201 // -- 8: R/W optical disk
202 // -- 9: 3.5-inch 4.0MB diskette drive (2.88MB formatted)
203 USHORT usDeviceAttrs;
204 // DEVATTR_* flags
205 } DRIVEPARAMS, *PDRIVEPARAMS;
206 #pragma pack() */
208 APIRET doshQueryDiskParams(ULONG ulLogicalDrive,
209 PBIOSPARAMETERBLOCK pdp);
211 BYTE doshQueryDriveType(ULONG ulLogicalDrive,
212 PBIOSPARAMETERBLOCK pdp,
213 BOOL fFixed);
215 APIRET XWPENTRY doshHasAudioCD(ULONG ulLogicalDrive,
216 HFILE hfDrive,
217 BOOL fMixedModeCD,
218 PBOOL pfAudio);
220 #endif
222 VOID XWPENTRY doshEnumDrives(PSZ pszBuffer,
223 PCSZ pcszFileSystem,
224 BOOL fSkipRemoveables);
225 typedef VOID XWPENTRY DOSHENUMDRIVES(PSZ pszBuffer,
226 PCSZ pcszFileSystem,
227 BOOL fSkipRemoveables);
228 typedef DOSHENUMDRIVES *PDOSHENUMDRIVES;
230 CHAR doshQueryBootDrive(VOID);
232 #define ERROR_AUDIO_CD_ROM 10000
234 #define DRVFL_MIXEDMODECD 0x0001
235 #define DRVFL_TOUCHFLOPPIES 0x0002
236 #define DRVFL_CHECKEAS 0x0004
237 #define DRVFL_CHECKLONGNAMES 0x0008
239 APIRET doshAssertDrive(ULONG ulLogicalDrive,
240 ULONG fl);
242 #ifdef INCL_DOSDEVIOCTL
245 *@@ XDISKINFO:
247 *@@added V0.9.16 (2002-01-13) [umoeller]
250 typedef struct _XDISKINFO
252 CHAR cDriveLetter; // drive letter
253 CHAR cLogicalDrive; // logical drive no.
255 BOOL fPresent; // if FALSE, drive does not exist
257 // the following are only valid if fPresent == TRUE
259 BIOSPARAMETERBLOCK bpb;
260 // 0x00 USHORT usBytesPerSector;
261 // 0x02 BYTE bSectorsPerCluster;
262 // 0x03 USHORT usReservedSectors;
263 // 0x05 BYTE cFATs;
264 // 0x06 USHORT cRootEntries;
265 // 0x08 USHORT cSectors;
266 // 0x0a BYTE bMedia;
267 // 0x0b USHORT usSectorsPerFAT;
268 // 0x0d USHORT usSectorsPerTrack;
269 // 0x0f USHORT cHeads;
270 // 0x11 ULONG cHiddenSectors;
271 // 0x15 ULONG cLargeSectors;
272 // 0x19 BYTE abReserved[6];
273 // 0x1a USHORT cCylinders;
274 // 0x1c BYTE bDeviceType;
275 #ifndef DEVTYPE_48TPI
276 #define DEVTYPE_48TPI 0x0000
277 #define DEVTYPE_96TPI 0x0001
278 #define DEVTYPE_35 0x0002
279 #define DEVTYPE_8SD 0x0003
280 #define DEVTYPE_8DD 0x0004
281 #define DEVTYPE_FIXED 0x0005
282 #define DEVTYPE_TAPE 0x0006
283 #endif
284 #define DEVTYPE_OTHER 0x0007
285 // includes 1.44 3.5" floppy
286 #define DEVTYPE_RWOPTICAL 0x0008
287 #define DEVTYPE_35_288MB 0x0009
288 // 0x1d USHORT fsDeviceAttr;
289 #define DEVATTR_REMOVEABLE 0x0001
290 // drive is removeable
291 #define DEVATTR_CHANGELINE 0x0002
292 // device can determine whether media has
293 // been removed since last I/O operation
294 #define DEVATTR_GREATER16MB 0x0004
295 // physical device driver supports physical
296 // addresses > 16 MB
297 #define DEVATTR_PARTITIONALREMOVEABLE 0x0008
298 // undocumented flag; set for ZIP drives
300 BYTE bType;
301 // do not change these codes, XWorkplace relies
302 // on them too to parse WPDisk data
303 #define DRVTYPE_HARDDISK 0
304 #define DRVTYPE_FLOPPY 1
305 #define DRVTYPE_TAPE 2
306 #define DRVTYPE_VDISK 3
307 #define DRVTYPE_CDROM 4
308 #define DRVTYPE_LAN 5
309 #define DRVTYPE_PARTITIONABLEREMOVEABLE 6
310 #define DRVTYPE_UNKNOWN 255
312 ULONG flDevice;
313 // any combination of the following:
314 #define DFL_REMOTE 0x0001
315 // drive is remote (not local)
316 #define DFL_FIXED 0x0002
317 // drive is fixed; otherwise it is removeable!
318 // always set for harddisks and zip drives
319 #define DFL_PARTITIONABLEREMOVEABLE 0x0004
320 // set for zip drives;
321 // in that case, DFL_FIXED is set also
322 #define DFL_BOOTDRIVE 0x0008
323 // drive was booted from
325 // media flags:
327 #define DFL_MEDIA_PRESENT 0x1000
328 // media is present in drive;
329 // -- always set for harddisks,
330 // unless the file system is not
331 // understood
332 // -- always set for remove drives
333 // -- always set for A: and B:
334 // -- set for CD-ROMS only if data
335 // CD-ROM is inserted
336 #define DFL_AUDIO_CD 0x2000
337 // set for CD-ROMs only, if an audio CD
338 // is currently inserted; in that case,
339 // DFL_MEDIA_PRESENT is _not_ set
340 #define DFL_SUPPORTS_EAS 0x4000
341 // drive supports extended attributes
342 // (assumption based on DosFSCtl,
343 // might not be correct for remote drives;
344 // reports correctly for FAT32 though)
345 #define DFL_SUPPORTS_LONGNAMES 0x8000
346 // drive supports long names; this does not
347 // necessarily mean that we support all IFS
348 // characters also
350 // the following are only valid if DFL_MEDIA_PRESENT is set;
351 // they are always set for drives A: and B:
353 CHAR szFileSystem[30];
354 // e.g. "FAT" or "HPFS" or "JFS" or "CDFS"
356 LONG lFileSystem;
357 // do not change these codes, XWorkplace relies
358 // on them too to parse WPDisk data
359 #define FSYS_UNKNOWN 0
360 // drive not formatted, or unknown file system
361 #define FSYS_FAT 1
362 #define FSYS_HPFS_JFS 2
363 #define FSYS_CDFS 3
364 #define FSYS_CDWFS 6 // not used by WPS!
365 // added V0.9.19 (2002-04-25) [umoeller]
366 #define FSYS_TVFS 7 // not used by WPS!
367 #define FSYS_FAT32_EXT2 8 // not used by WPS!
368 #define FSYS_RAMFS 9 // not used by WPS!
369 #define FSYS_REMOTE 10
370 // NOTE: if this has a negative value, this is
371 // the APIRET code from DosQueryFSAttach
373 // error codes for various operations
374 APIRET arcIsFixedDisk,
375 arcQueryDiskParams,
376 arcQueryMedia,
377 arcOpenLongnames;
379 } XDISKINFO, *PXDISKINFO;
381 APIRET doshGetDriveInfo(ULONG ulLogicalDrive,
382 ULONG fl,
383 PXDISKINFO pdi);
385 #endif
387 APIRET doshSetLogicalMap(ULONG ulLogicalDrive);
389 APIRET XWPENTRY doshQueryDiskSize(ULONG ulLogicalDrive, double *pdSize);
390 typedef APIRET XWPENTRY DOSHQUERYDISKSIZE(ULONG ulLogicalDrive, double *pdSize);
391 typedef DOSHQUERYDISKSIZE *PDOSHQUERYDISKSIZE;
393 APIRET XWPENTRY doshQueryDiskFree(ULONG ulLogicalDrive, double *pdFree);
394 typedef APIRET XWPENTRY DOSHQUERYDISKFREE(ULONG ulLogicalDrive, double *pdFree);
395 typedef DOSHQUERYDISKFREE *PDOSHQUERYDISKFREE;
397 APIRET XWPENTRY doshQueryDiskFSType(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf);
398 typedef APIRET XWPENTRY DOSHQUERYDISKFSTYPE(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf);
399 typedef DOSHQUERYDISKFSTYPE *PDOSHQUERYDISKFSTYPE;
401 APIRET doshQueryDiskLabel(ULONG ulLogicalDrive,
402 PSZ pszVolumeLabel);
404 APIRET doshSetDiskLabel(ULONG ulLogicalDrive,
405 PSZ pszNewLabel);
407 /* ******************************************************************
409 * Module handling helpers
411 ********************************************************************/
413 APIRET doshQueryProcAddr(PCSZ pcszModuleName,
414 ULONG ulOrdinal,
415 PFN *ppfn);
418 *@@ RESOLVEFUNCTION:
419 * one of these structures each define
420 * a single function import to doshResolveImports.
422 *@@added V0.9.3 (2000-04-25) [umoeller]
425 typedef struct _RESOLVEFUNCTION
427 const char *pcszFunctionName;
428 PFN *ppFuncAddress;
429 } RESOLVEFUNCTION, *PRESOLVEFUNCTION;
431 typedef const struct _RESOLVEFUNCTION *PCRESOLVEFUNCTION;
433 APIRET doshResolveImports(PCSZ pcszModuleName,
434 HMODULE *phmod,
435 PCRESOLVEFUNCTION paResolves,
436 ULONG cResolves);
438 /* ******************************************************************
440 * Performance Counters (CPU Load)
442 ********************************************************************/
444 #define CMD_PERF_INFO 0x41
445 #define CMD_KI_ENABLE 0x60
446 #define CMD_KI_DISABLE 0x61
447 #ifndef CMD_KI_RDCNT
448 #define CMD_KI_RDCNT 0x63
449 typedef APIRET APIENTRY FNDOSPERFSYSCALL(ULONG ulCommand,
450 ULONG ulParm1,
451 ULONG ulParm2,
452 ULONG ulParm3);
453 typedef FNDOSPERFSYSCALL *PFNDOSPERFSYSCALL;
454 #endif
456 typedef struct _CPUUTIL
458 ULONG ulTimeLow; // low 32 bits of time stamp
459 ULONG ulTimeHigh; // high 32 bits of time stamp
460 ULONG ulIdleLow; // low 32 bits of idle time
461 ULONG ulIdleHigh; // high 32 bits of idle time
462 ULONG ulBusyLow; // low 32 bits of busy time
463 ULONG ulBusyHigh; // high 32 bits of busy time
464 ULONG ulIntrLow; // low 32 bits of interrupt time
465 ULONG ulIntrHigh; // high 32 bits of interrupt time
466 } CPUUTIL, *PCPUUTIL;
468 // macro to convert 8-byte (low, high) time value to double
469 #define LL2F(high, low) (4294967296.0*(high)+(low))
472 *@@ DOSHPERFSYS:
473 * structure used with doshPerfOpen.
475 *@@added V0.9.7 (2000-12-02) [umoeller]
476 *@@changed V0.9.9 (2001-03-14) [umoeller]: added interrupt load
479 typedef struct _DOSHPERFSYS
481 // output: no. of processors on the system
482 ULONG cProcessors;
483 // output: one CPU load for each CPU
484 PLONG palLoads;
486 // output: one CPU interrupt load for each CPU
487 PLONG palIntrs;
489 // each of the following ptrs points to an array of cProcessors items
490 PCPUUTIL paCPUUtils; // CPUUTIL structures
491 double *padBusyPrev; // previous "busy" calculations
492 double *padTimePrev; // previous "time" calculations
493 double *padIntrPrev; // previous "intr" calculations
495 // private stuff
496 HMODULE hmod;
497 BOOL fInitialized;
498 PFNDOSPERFSYSCALL pDosPerfSysCall;
499 } DOSHPERFSYS, *PDOSHPERFSYS;
501 APIRET doshPerfOpen(PDOSHPERFSYS *ppPerfSys);
503 APIRET doshPerfGet(PDOSHPERFSYS pPerfSys);
505 APIRET doshPerfClose(PDOSHPERFSYS *ppPerfSys);
507 /* ******************************************************************
509 * File name parsing
511 ********************************************************************/
513 APIRET doshGetDriveSpec(PCSZ pcszFullFile,
514 PSZ pszDrive,
515 PULONG pulDriveLen,
516 PBOOL pfIsUNC);
518 PSZ doshGetExtension(PCSZ pcszFilename);
520 /* ******************************************************************
522 * File helpers
524 ********************************************************************/
526 BOOL doshIsFileOnFAT(const char* pcszFileName);
528 APIRET doshIsValidFileName(const char* pcszFile,
529 BOOL fFullyQualified);
531 BOOL doshMakeRealName(PSZ pszTarget, PSZ pszSource, CHAR cReplace, BOOL fIsFAT);
533 APIRET doshQueryFileSize(HFILE hFile,
534 PULONG pulSize);
536 APIRET doshQueryPathSize(PCSZ pcszFile,
537 PULONG pulSize);
539 APIRET doshQueryPathAttr(const char* pcszFile,
540 PULONG pulAttr);
542 APIRET doshSetPathAttr(const char* pcszFile,
543 ULONG ulAttr);
545 /* ******************************************************************
547 * XFILEs
549 ********************************************************************/
552 *@@ XFILE:
554 *@@added V0.9.16 (2001-10-19) [umoeller]
557 typedef struct _XFILE
559 HFILE hf;
561 PSZ pszFilename; // as given to doshOpen
562 ULONG flOpenMode; // as given to doshOpen
564 ULONG cbInitial, // intial file size on open (can be 0 if new)
565 cbCurrent; // current file size (raised with each write)
567 PBYTE pbCache; // if != NULL, cached data from doshReadAt
568 ULONG cbCache, // size of data in cbCache
569 ulReadFrom; // file offset where pbCache was read from
570 } XFILE, *PXFILE;
572 #define XOPEN_READ_EXISTING 0x0001
573 #define XOPEN_READWRITE_EXISTING 0x0002
574 #define XOPEN_READWRITE_APPEND 0x0003
575 #define XOPEN_READWRITE_NEW 0x0004
576 #define XOPEN_ACCESS_MASK 0xffff
578 #define XOPEN_BINARY 0x10000000
580 APIRET doshOpen(PCSZ pcszFilename,
581 ULONG flOpenMode,
582 PULONG pcbFile,
583 PXFILE *ppFile);
585 #define DRFL_NOCACHE 0x0001
586 #define DRFL_FAILIFLESS 0x0002
588 APIRET doshReadAt(PXFILE pFile,
589 ULONG ulOffset,
590 PULONG pcb,
591 PBYTE pbData,
592 ULONG fl);
594 APIRET doshWrite(PXFILE pFile,
595 ULONG cb,
596 PCSZ pbData);
598 APIRET doshWriteAt(PXFILE pFile,
599 ULONG ulOffset,
600 ULONG cb,
601 PCSZ pbData);
603 APIRET doshWriteLogEntry(PXFILE pFile,
604 const char* pcszFormat,
605 ...);
607 APIRET doshClose(PXFILE *ppFile);
609 APIRET doshReadText(PXFILE pFile,
610 PSZ* ppszContent,
611 PULONG pcbRead);
613 APIRET doshLoadTextFile(PCSZ pcszFile,
614 PSZ* ppszContent,
615 PULONG pcbRead);
617 PSZ doshCreateBackupFileName(const char* pszExisting);
619 APIRET doshCreateTempFileName(PSZ pszTempFileName,
620 PCSZ pcszDir,
621 PCSZ pcszPrefix,
622 PCSZ pcszExt);
624 APIRET doshWriteTextFile(const char* pszFile,
625 const char* pszContent,
626 PULONG pulWritten,
627 PSZ pszBackup);
630 /* ******************************************************************
632 * Directory helpers
634 ********************************************************************/
636 BOOL doshQueryDirExist(PCSZ pcszDir);
638 APIRET doshCreatePath(PCSZ pcszPath,
639 BOOL fHidden);
641 APIRET doshQueryCurrentDir(PSZ pszBuf);
643 APIRET doshSetCurrentDir(PCSZ pcszDir);
645 #define DOSHDELDIR_RECURSE 0x0001
646 #define DOSHDELDIR_DELETEFILES 0x0002
648 APIRET doshDeleteDir(PCSZ pcszDir,
649 ULONG flFlags,
650 PULONG pulDirs,
651 PULONG pulFiles);
653 APIRET doshCanonicalize(PCSZ pcszFileIn,
654 PSZ pszFileOut,
655 ULONG cbFileOut);
657 /* ******************************************************************
659 * Process helpers
661 ********************************************************************/
663 ULONG XWPENTRY doshMyPID(VOID);
664 typedef ULONG XWPENTRY DOSHMYPID(VOID);
665 typedef DOSHMYPID *PDOSHMYPID;
667 ULONG XWPENTRY doshMyTID(VOID);
668 typedef ULONG XWPENTRY DOSHMYTID(VOID);
669 typedef DOSHMYTID *PDOSHMYTID;
671 APIRET doshExecVIO(PCSZ pcszExecWithArgs,
672 PLONG plExitCode);
674 APIRET doshQuickStartSession(PCSZ pcszPath,
675 PCSZ pcszParams,
676 BOOL fForeground,
677 USHORT usPgmCtl,
678 BOOL fWait,
679 PULONG pulSID,
680 PPID ppid,
681 PUSHORT pusReturn);
683 APIRET doshSearchPath(PCSZ pcszPath,
684 PCSZ pcszFile,
685 PSZ pszExecutable,
686 ULONG cbExecutable);
688 APIRET doshFindExecutable(PCSZ pcszCommand,
689 PSZ pszExecutable,
690 ULONG cbExecutable,
691 PCSZ *papcszExtensions,
692 ULONG cExtensions);
694 /********************************************************************
696 * Partition functions
698 ********************************************************************/
701 *@@ LVMINFO:
702 * informational structure created by
703 * doshQueryLVMInfo.
705 *@@added V0.9.9 (2001-04-07) [umoeller]
708 typedef struct _LVMINFO
710 HMODULE hmodLVM;
712 } LVMINFO, *PLVMINFO;
714 /* #define DOSH_PARTITIONS_LIMIT 10
716 #define PAR_UNUSED 0x00 // Unused
717 #define PAR_FAT12SMALL 0x01 // DOS FAT 12-bit < 10 Mb
718 #define PAR_XENIXROOT 0x02 // XENIX root
719 #define PAR_XENIXUSER 0x03 // XENIX user
720 #define PAR_FAT16SMALL 0x04 // DOS FAT 16-bit < 32 Mb
721 #define PAR_EXTENDED 0x05 // Extended partition
722 #define PAR_FAT16BIG 0x06 // DOS FAT 16-bit > 32 Mb
723 #define PAR_HPFS 0x07 // OS/2 HPFS
724 #define PAR_AIXBOOT 0x08 // AIX bootable partition
725 #define PAR_AIXDATA 0x09 // AIX bootable partition
726 #define PAR_BOOTMANAGER 0x0A // OS/2 Boot Manager
727 #define PAR_WINDOWS95 0x0B // Windows 95 32-bit FAT
728 #define PAR_WINDOWS95LB 0x0C // Windows 95 32-bit FAT with LBA
729 #define PAR_VFAT16BIG 0x0E // LBA VFAT (same as 06h but using LBA-mode)
730 #define PAR_VFAT16EXT 0x0F // LBA VFAT (same as 05h but using LBA-mode)
731 #define PAR_OPUS 0x10 // OPUS
732 #define PAR_HID12SMALL 0x11 // OS/2 hidden DOS FAT 12-bit
733 #define PAR_COMPAQDIAG 0x12 // Compaq diagnostic
734 #define PAR_HID16SMALL 0x14 // OS/2 hidden DOS FAT 16-bit
735 #define PAR_HID16BIG 0x16 // OS/2 hidden DOS FAT 16-bit
736 #define PAR_HIDHPFS 0x17 // OS/2 hidden HPFS
737 #define PAR_WINDOWSSWP 0x18 // AST Windows Swap File
738 #define PAR_NECDOS 0x24 // NEC MS-DOS 3.x
739 #define PAR_THEOS 0x38 // THEOS
740 #define PAR_VENIX 0x40 // VENIX
741 #define PAR_RISCBOOT 0x41 // Personal RISC boot
742 #define PAR_SFS 0x42 // SFS
743 #define PAR_ONTRACK 0x50 // Ontrack
744 #define PAR_ONTRACKEXT 0x51 // Ontrack extended partition
745 #define PAR_CPM 0x52 // CP/M
746 #define PAR_UNIXSYSV 0x63 // UNIX SysV/386
747 #define PAR_NOVELL_64 0x64 // Novell
748 #define PAR_NOVELL_65 0x65 // Novell
749 #define PAR_NOVELL_67 0x67 // Novell
750 #define PAR_NOVELL_68 0x68 // Novell
751 #define PAR_NOVELL_69 0x69 // Novell
752 #define PAR_PCIX 0x75 // PCIX
753 #define PAR_MINIX 0x80 // MINIX
754 #define PAR_LINUX 0x81 // Linux
755 #define PAR_LINUXSWAP 0x82 // Linux Swap Partition
756 #define PAR_LINUXFILE 0x83 // Linux File System
757 #define PAR_FREEBSD 0xA5 // FreeBSD
758 #define PAR_BBT 0xFF // BBT
761 // one-byte alignment
762 #pragma pack(1)
765 *@@ PAR_INFO:
766 * partition table
769 typedef struct _PAR_INFO
771 BYTE bBootFlag; // 0=not active, 80H = active (boot this partition
772 BYTE bBeginHead; // partition begins at this head...
773 USHORT rBeginSecCyl; // ...and this sector and cylinder (see below)
774 BYTE bFileSysCode; // file system type
775 BYTE bEndHead; // partition ends at this head...
776 USHORT bEndSecCyl; // ...and this sector and cylinder (see below)
777 ULONG lBeginAbsSec; // partition begins at this absolute sector #
778 ULONG lTotalSects; // total sectors in this partition
779 } PAR_INFO, *PPAR_INFO;
782 *@@ MBR_INFO:
783 * master boot record table.
784 * This has the four primary partitions.
787 typedef struct _MBR_INFO // MBR
789 BYTE aBootCode[0x1BE]; // abBootCode master boot executable code
790 PAR_INFO sPrtnInfo[4]; // primary partition entries
791 USHORT wPrtnTblSig; // partition table signature (aa55H)
792 } MBR_INFO, *PMBR_INFO;
795 *@@ SYS_INFO:
799 typedef struct _SYS_INFO
801 BYTE startable;
802 BYTE unknown[3];
803 BYTE bootable;
804 BYTE name[8];
805 BYTE reservd[3];
806 } SYS_INFO, *PSYS_INFO;
809 *@@ SYE_INFO:
813 typedef struct _SYE_INFO
815 BYTE bootable;
816 BYTE name[8];
817 } SYE_INFO, *PSYE_INFO;
820 *@@ EXT_INFO:
824 typedef struct _EXT_INFO
826 BYTE aBootCode[0x18A]; // abBootCode master boot executable code
827 SYE_INFO sBmNames[4]; // System Names
828 BYTE bReserved[16]; // reserved
829 PAR_INFO sPrtnInfo[4]; // partitioms entrys
830 USHORT wPrtnTblSig; // partition table signature (aa55H)
831 } EXT_INFO, *PEXT_INFO;
833 typedef struct _PARTITIONINFO *PPARTITIONINFO;
836 *@@ PARTITIONINFO:
837 * informational structure returned
838 * by doshGetPartitionsList. One of
839 * these items is created for each
840 * bootable partition.
843 typedef struct _PARTITIONINFO
845 BYTE bDisk; // drive number
846 CHAR cLetter; // probable drive letter or ' ' if none
847 BYTE bFSType; // file system type
848 PCSZ pcszFSType; // file system name (as returned by
849 // doshType2FSName, can be NULL!)
850 BOOL fPrimary; // primary partition?
851 BOOL fBootable; // bootable by Boot Manager?
852 CHAR szBootName[21]; // Boot Manager name, if (fBootable)
853 // extended for LVM names V0.9.20 (2002-08-10) [umoeller]
854 ULONG ulSize; // size MBytes
855 PPARTITIONINFO pNext; // next info or NULL if last
856 } PARTITIONINFO;
858 UINT doshQueryDiskCount(VOID);
860 APIRET doshReadSector(USHORT disk,
861 void *buff,
862 USHORT head,
863 USHORT cylinder,
864 USHORT sector);
866 // restore original alignment
867 #pragma pack()
869 const char* doshType2FSName(unsigned char bFSType);
871 APIRET doshGetBootManager(USHORT *pusDisk,
872 USHORT *pusPart,
873 PAR_INFO *BmInfo);
875 typedef struct _PARTITIONSLIST
877 PLVMINFO pLVMInfo; // != NULL if LVM is installed
879 // partitions array
880 PPARTITIONINFO pPartitionInfo;
881 USHORT cPartitions;
882 } PARTITIONSLIST, *PPARTITIONSLIST;
884 APIRET doshGetPartitionsList(PPARTITIONSLIST *ppList,
885 PUSHORT pusContext);
887 APIRET doshFreePartitionsList(PPARTITIONSLIST ppList);
889 APIRET doshQueryLVMInfo(PLVMINFO *ppLVMInfo);
891 APIRET doshReadLVMPartitions(PLVMINFO pInfo,
892 PPARTITIONINFO *ppPartitionInfo,
893 PUSHORT pcPartitions);
895 VOID doshFreeLVMInfo(PLVMINFO pInfo);
897 /* ******************************************************************
899 * Wildcard matching
901 ********************************************************************/
903 BOOL doshMatchCase(PCSZ pcszMask,
904 PCSZ pcszName);
906 BOOL doshMatchCaseNoPath(const char *pcszMask,
907 const char *pcszName);
909 BOOL doshMatch(PCSZ pcszMask,
910 PCSZ pcszName);
912 #endif
914 #if __cplusplus
916 #endif