source: trunk/src/kernel32/osliblvm.h@ 22015

Last change on this file since 22015 was 21916, checked in by dmik, 14 years ago

Merge branch gcc-kmk to trunk.

File size: 22.7 KB
Line 
1/* $Id: osliblvm.h,v 1.6 2003-01-20 10:46:27 sandervl Exp $ */
2/*
3 * OS/2 LVM (Logical Volume Management) functions
4 *
5 * Copyright 2002 Sander van Leeuwen
6 *
7 * Project Odin Software License can be found in LICENSE.TXT
8 *
9 */
10#ifndef __OSLIBLVM_H__
11#define __OSLIBLVM_H__
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17#include <win/winioctl.h>
18
19#ifdef OS2_INCLUDED
20
21typedef unsigned short int CARDINAL16;
22typedef unsigned long CARDINAL32;
23typedef unsigned int CARDINAL;
24typedef unsigned char BOOLEAN;
25typedef short int INTEGER16;
26typedef long int INTEGER32;
27typedef int INTEGER;
28typedef unsigned long DoubleWord;
29typedef short unsigned int Word;
30typedef unsigned long LBA;
31
32/* Define a Partition Sector Number. A Partition Sector Number is
33 relative to the start of a partition. The first sector in a partition
34 is PSN 0. */
35typedef unsigned long PSN;
36
37/* Define the size of a Partition Name. Partition Names are user defined names given to a partition. */
38#define PARTITION_NAME_SIZE 20
39
40/* Define the size of a volume name. Volume Names are user defined names given to a volume. */
41#define VOLUME_NAME_SIZE 20
42
43/* Define the size of a disk name. Disk Names are user defined names given to physical disk drives in the system. */
44#define DISK_NAME_SIZE 20
45
46/* The name of the filesystem in use on a partition. This name may be up to 12 ( + NULL terminator) characters long. */
47#define FILESYSTEM_NAME_SIZE 20
48
49/* The number of bytes in a sector on the disk. */
50#define BYTES_PER_SECTOR 512
51
52/* The following are invariant for a disk drive. */
53typedef struct _Drive_Control_Record {
54 CARDINAL32 Drive_Number; /* OS/2 Drive Number for this drive. */
55 CARDINAL32 Drive_Size; /* The total number of sectors on the drive. */
56 DoubleWord Drive_Serial_Number; /* The serial number assigned to this drive.
57 For info. purposes only. */
58 ULONG Drive_Handle; /* Handle used for operations on the disk that
59 this record corresponds to. */
60 CARDINAL32 Cylinder_Count; /* The number of cylinders on the drive. */
61 CARDINAL32 Heads_Per_Cylinder; /* The number of heads per cylinder for this drive. */
62 CARDINAL32 Sectors_Per_Track; /* The number of sectors per track for this drive. */
63 BOOLEAN Drive_Is_PRM; /* Set to TRUE if this drive is a PRM. */
64 BYTE Reserved[3]; /* Alignment. */
65} Drive_Control_Record;
66
67/* The following structure is returned by the Get_Drive_Control_Data function. */
68typedef struct _Drive_Control_Array{
69 Drive_Control_Record * Drive_Control_Data; /* An array of drive control records. */
70 CARDINAL32 Count; /* The number of entries in the array
71 of drive control records. */
72} Drive_Control_Array;
73
74
75/* The following structure defines the information that can be changed for a specific disk drive. */
76typedef struct _Drive_Information_Record {
77 CARDINAL32 Total_Available_Sectors; /* The number of sectors on the disk which are not currently assigned to a partition. */
78 CARDINAL32 Largest_Free_Block_Of_Sectors; /* The number of sectors in the largest contiguous block of available sectors. */
79 BOOLEAN Corrupt_Partition_Table; /* If TRUE, then the partitioning information found on the drive is incorrect! */
80 BOOLEAN Unusable; /* If TRUE, the drive's MBR is not accessible and the drive can not be partitioned. */
81 BOOLEAN IO_Error; /* If TRUE, then the last I/O operation on this drive failed! */
82 BOOLEAN Is_Big_Floppy; /* If TRUE, then the drive is a PRM formatted as a big floppy (i.e. the old style removable media support). */
83 char Drive_Name[DISK_NAME_SIZE]; /* User assigned name for this disk drive. */
84} Drive_Information_Record;
85
86typedef struct _Partition_Information_Record {
87 ULONG Partition_Handle; /* The handle used to perform
88 operations on this partition. */
89 ULONG Volume_Handle; /* If this partition is part
90 of a volume, this will be the
91 handle of the volume. If
92 this partition is NOT
93 part of a volume, then
94 this handle will be 0. */
95 ULONG Drive_Handle; /* The handle for the drive
96 this partition resides on. */
97 DoubleWord Partition_Serial_Number; /* The serial number assigned
98 to this partition. */
99 CARDINAL32 Partition_Start; /* The LBA of the first
100 sector of the partition. */
101 CARDINAL32 True_Partition_Size; /* The total number of
102 sectors comprising the partition. */
103 CARDINAL32 Usable_Partition_Size; /* The size of the partition
104 as reported to the IFSM. This is the
105 size of the partition less
106 any LVM overhead. */
107 CARDINAL32 Boot_Limit; /* The maximum number of
108 sectors from this block
109 of free space that can be
110 used to create a bootable
111 partition if you allocate
112 from the beginning of the block
113 of free space. */
114 BOOLEAN Spanned_Volume; /* TRUE if this partition is
115 part of a multi-partition
116 volume. */
117 BOOLEAN Primary_Partition; /* True or False. Any
118 non-zero value here indicates
119 that this partition is
120 a primary partition. Zero
121 here indicates that this
122 partition is a "logical drive"
123 - i.e. it resides inside of
124 an extended partition. */
125 BYTE Active_Flag; /* 80 = Partition is marked
126 as being active.
127 0 = Partition is not
128 active. */
129 BYTE OS_Flag; /* This field is from the
130 partition table. It is
131 known as the OS flag, the
132 Partition Type Field,
133 Filesystem Type, and
134 various other names.
135 Values of interest
136 If this field is: (values
137 are in hex)
138 07 = The partition is a
139 compatibility
140 partition formatted
141 for use with an
142 installable
143 filesystem, such as
144 HPFS or JFS.
145 00 = Unformatted partition
146 01 = FAT12 filesystem is
147 in use on this
148 partition.
149 04 = FAT16 filesystem is
150 in use on this
151 partition.
152 0A = OS/2 Boot Manager
153 Partition
154 35 = LVM partition
155 06 = OS/2 FAT16 partition */
156 BYTE Partition_Type; /* 0 = Free Space
157 1 = LVM Partition (Part of
158 an LVM Volume.)
159 2 = Compatibility Partition
160 All other values are reserved
161 for future use. */
162 BYTE Partition_Status; /* 0 = Free Space
163 1 = In Use - i.e. already
164 assigned to a volume.
165 2 = Available - i.e. not
166 currently assigned
167 to a volume. */
168 BOOLEAN On_Boot_Manager_Menu; /* Set to TRUE if this
169 partition is not part of
170 a Volume yet is on the
171 Boot Manager Menu. */
172 BYTE Reserved; /* Alignment. */
173 char Volume_Drive_Letter; /* The drive letter assigned
174 to the volume that this
175 partition is a part of. */
176 char Drive_Name[DISK_NAME_SIZE]; /* User assigned name for
177 this disk drive. */
178 char File_System_Name[FILESYSTEM_NAME_SIZE];/* The name of the filesystem
179 in use on this partition,
180 if it is known. */
181 char Partition_Name[PARTITION_NAME_SIZE]; /* The user assigned name for
182 this partition. */
183 char Volume_Name[VOLUME_NAME_SIZE]; /* If this partition is part
184 of a volume, then this
185 will be the name of the
186 volume that this partition
187 is a part of. If this record
188 represents free space,
189 then the Volume_Name will be
190 "FS xx", where xx is a unique
191 numeric ID generated by
192 LVM.DLL. Otherwise it
193 will be an empty string. */
194} Partition_Information_Record;
195
196/* The following defines are for use with the Partition_Type field in the Partition_Information_Record. */
197#define FREE_SPACE_PARTITION 0
198#define LVM_PARTITION 1
199#define COMPATIBILITY_PARTITION 2
200
201/* The following defines are for use with the Partition_Status field in the Partition_Information_Record. */
202#define PARTITION_IS_IN_USE 1
203#define PARTITION_IS_AVAILABLE 2
204#define PARTITION_IS_FREE_SPACE 0
205
206
207/* The following structure is returned by various functions in the LVM Engine. */
208typedef struct _Partition_Information_Array {
209 Partition_Information_Record * Partition_Array; /* An array of Partition_Information_Records. */
210 CARDINAL32 Count; /* The number of entries in the Partition_Array. */
211} Partition_Information_Array;
212
213/* The following items are invariant for a volume. */
214typedef struct _Volume_Control_Record {
215 DoubleWord Volume_Serial_Number; /* The serial number assigned to this volume. */
216 ULONG Volume_Handle; /* The handle used to perform operations on this volume. */
217 BOOLEAN Compatibility_Volume; /* TRUE indicates that this volume is compatible with older versions of OS/2.
218 FALSE indicates that this is an LVM specific volume and can not be used without OS2LVM.DMD. */
219 BYTE Device_Type; /* Indicates what type of device the Volume resides on:
220 0 = Hard Drive under LVM Control
221 1 = PRM under LVM Control
222 2 = CD-ROM
223 3 = Network drive
224 4 = Unknown device NOT under LVM Control
225 */
226 BYTE Reserved[2]; /* Alignment. */
227} Volume_Control_Record;
228
229/* The following define the device types used in the Device_Type field of the Volume_Control_Record. */
230#define LVM_HARD_DRIVE 0
231#define LVM_PRM 1
232#define NON_LVM_CDROM 2
233#define NETWORK_DRIVE 3
234#define NON_LVM_DEVICE 4
235
236/* The following structure is returned by the Get_Volume_Control_Data function. */
237typedef struct _Volume_Control_Array{
238 Volume_Control_Record * Volume_Control_Data; /* An array of volume control records. */
239 CARDINAL32 Count; /* The number of entries in the array of volume control records. */
240} Volume_Control_Array;
241
242
243/* The following information about a volume can (and often does) vary. */
244typedef struct _Volume_Information_Record {
245 CARDINAL32 Volume_Size; /* The number of sectors comprising the volume. */
246 CARDINAL32 Partition_Count; /* The number of partitions which comprise this volume. */
247 CARDINAL32 Drive_Letter_Conflict; /* 0 indicates that the drive letter preference for this volume is unique.
248 1 indicates that the drive letter preference for this volume
249 is not unique, but this volume got its preferred drive letter anyway.
250 2 indicates that the drive letter preference for this volume
251 is not unique, and this volume did NOT get its preferred drive letter.
252 4 indicates that this volume is currently "hidden" - i.e. it has
253 no drive letter preference at the current time. */
254 BOOLEAN Compatibility_Volume; /* TRUE if this is for a compatibility volume, FALSE otherwise. */
255 BOOLEAN Bootable; /* Set to TRUE if this volume appears on the Boot Manager menu, or if it is
256 a compatibility volume and its corresponding partition is the first active
257 primary partition on the first drive. */
258 char Drive_Letter_Preference; /* The drive letter that this volume desires to be. */
259 char Current_Drive_Letter; /* The drive letter currently used to access this volume. May be different than
260 Drive_Letter_Preference if there was a conflict ( i.e. Drive_Letter_Preference
261 is already in use by another volume ). */
262 char Initial_Drive_Letter; /* The drive letter assigned to this volume by the operating system when LVM was started.
263 This may be different from the Drive_Letter_Preference if there were conflicts, and
264 may be different from the Current_Drive_Letter. This will be 0x0 if the Volume did
265 not exist when the LVM Engine was opened (i.e. it was created during this LVM session). */
266 BOOLEAN New_Volume; /* Set to FALSE if this volume existed before the LVM Engine was opened. Set to
267 TRUE if this volume was created after the LVM Engine was opened. */
268 BYTE Status; /* 0 = None.
269 1 = Bootable
270 2 = Startable
271 3 = Installable. */
272 BYTE Reserved_1;
273 char Volume_Name[VOLUME_NAME_SIZE]; /* The user assigned name for this volume. */
274 char File_System_Name[FILESYSTEM_NAME_SIZE];/* The name of the filesystem in use on this partition, if it is known. */
275} Volume_Information_Record;
276
277
278/* Error codes returned by the LVM Engine. */
279#define LVM_ENGINE_NO_ERROR 0
280#define LVM_ENGINE_OUT_OF_MEMORY 1
281#define LVM_ENGINE_IO_ERROR 2
282#define LVM_ENGINE_BAD_HANDLE 3
283#define LVM_ENGINE_INTERNAL_ERROR 4
284#define LVM_ENGINE_ALREADY_OPEN 5
285#define LVM_ENGINE_NOT_OPEN 6
286#define LVM_ENGINE_NAME_TOO_BIG 7
287#define LVM_ENGINE_OPERATION_NOT_ALLOWED 8
288#define LVM_ENGINE_DRIVE_OPEN_FAILURE 9
289#define LVM_ENGINE_BAD_PARTITION 10
290#define LVM_ENGINE_CAN_NOT_MAKE_PRIMARY_PARTITION 11
291#define LVM_ENGINE_TOO_MANY_PRIMARY_PARTITIONS 12
292#define LVM_ENGINE_CAN_NOT_MAKE_LOGICAL_DRIVE 13
293#define LVM_ENGINE_REQUESTED_SIZE_TOO_BIG 14
294#define LVM_ENGINE_1024_CYLINDER_LIMIT 15
295#define LVM_ENGINE_PARTITION_ALIGNMENT_ERROR 16
296#define LVM_ENGINE_REQUESTED_SIZE_TOO_SMALL 17
297#define LVM_ENGINE_NOT_ENOUGH_FREE_SPACE 18
298#define LVM_ENGINE_BAD_ALLOCATION_ALGORITHM 19
299#define LVM_ENGINE_DUPLICATE_NAME 20
300#define LVM_ENGINE_BAD_NAME 21
301#define LVM_ENGINE_BAD_DRIVE_LETTER_PREFERENCE 22
302#define LVM_ENGINE_NO_DRIVES_FOUND 23
303#define LVM_ENGINE_WRONG_VOLUME_TYPE 24
304#define LVM_ENGINE_VOLUME_TOO_SMALL 25
305#define LVM_ENGINE_BOOT_MANAGER_ALREADY_INSTALLED 26
306#define LVM_ENGINE_BOOT_MANAGER_NOT_FOUND 27
307#define LVM_ENGINE_INVALID_PARAMETER 28
308#define LVM_ENGINE_BAD_FEATURE_SET 29
309#define LVM_ENGINE_TOO_MANY_PARTITIONS_SPECIFIED 30
310#define LVM_ENGINE_LVM_PARTITIONS_NOT_BOOTABLE 31
311#define LVM_ENGINE_PARTITION_ALREADY_IN_USE 32
312#define LVM_ENGINE_SELECTED_PARTITION_NOT_BOOTABLE 33
313#define LVM_ENGINE_VOLUME_NOT_FOUND 34
314#define LVM_ENGINE_DRIVE_NOT_FOUND 35
315#define LVM_ENGINE_PARTITION_NOT_FOUND 36
316#define LVM_ENGINE_TOO_MANY_FEATURES_ACTIVE 37
317#define LVM_ENGINE_PARTITION_TOO_SMALL 38
318#define LVM_ENGINE_MAX_PARTITIONS_ALREADY_IN_USE 39
319#define LVM_ENGINE_IO_REQUEST_OUT_OF_RANGE 40
320#define LVM_ENGINE_SPECIFIED_PARTITION_NOT_STARTABLE 41
321#define LVM_ENGINE_SELECTED_VOLUME_NOT_STARTABLE 42
322#define LVM_ENGINE_EXTENDFS_FAILED 43
323#define LVM_ENGINE_REBOOT_REQUIRED 44
324
325#endif
326
327#define VOLUME_NAME_PREFIX "\\\\?\\Volume\\"
328
329void OSLibLVMExit();
330HANDLE OSLibLVMQueryVolumeControlData();
331void OSLibLVMFreeVolumeControlData(HANDLE hVolumeControlData);
332BOOL OSLibLVMQueryVolumeName(HANDLE hVolumeControlData, ULONG *pVolIndex,
333 LPSTR lpszVolumeName, DWORD cchBufferLength);
334
335BOOL OSLibLVMGetPartitionInfo(ULONG driveLetter, LPSTR lpszVolumeName, PPARTITION_INFORMATION pPartition);
336BOOL OSLibLVMGetVolumeExtents(ULONG driveLetter, LPSTR lpszVolumeName, PVOLUME_DISK_EXTENTS pVolExtent, BOOL *pfLVMVolume = NULL);
337
338ULONG OSLibLVMGetDriveType(LPCSTR lpszVolume);
339CHAR OSLibLVMQueryDriveFromVolumeName(LPCSTR lpszVolume);
340BOOL OSLibLVMGetVolumeNameForVolumeMountPoint(LPCSTR lpszVolumeMountPoint, LPSTR lpszVolumeName,
341 DWORD cchBufferLength);
342
343
344DWORD OSLibLVMQueryVolumeFS(LPSTR lpszVolume, LPSTR lpFileSystemNameBuffer, DWORD nFileSystemNameSize);
345DWORD OSLibLVMQueryVolumeSerialAndName(LPSTR lpszVolume, LPDWORD lpVolumeSerialNumber, LPSTR lpVolumeNameBuffer, DWORD nVolumeNameSize);
346
347BOOL OSLibLVMStripVolumeName(LPCSTR lpszWin32VolumeName, LPSTR lpszOS2VolumeName, DWORD cchBufferLength);
348BOOL OSLibLVMGetDiskGeometry(DWORD dwDiskNr, PDISK_GEOMETRY pGeom);
349
350#ifdef __cplusplus
351}
352#endif
353
354#endif //__OSLIBLVM_H__
Note: See TracBrowser for help on using the repository browser.