PageRenderTime 37ms CodeModel.GetById 12ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 1ms

/packages/os2units/src/lvm.pas

https://github.com/slibre/freepascal
Pascal | 5232 lines | 723 code | 189 blank | 4320 comment | 0 complexity | 28c7140800a34d5da5d8fd98da9400c0 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1{
  2   Copyright (c) International Business Machines  Corp., 2000
  3   Copyright (c) 2003 Yuri Prokushev
  4
  5   This module defines the interface to LVM.DLL, which is the
  6   engine that performs all of the disk partitioning/volume
  7   creation work.
  8
  9   This program is free software;  you can redistribute it and/or modify
 10   it under the terms of the GNU General Public License as published by
 11   the Free Software Foundation; either version 2 of the License, or
 12   (at your option) any later version.
 13
 14   This program is distributed in the hope that it will be useful,
 15   but WITHOUT ANY WARRANTY;  without even the implied warranty of
 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
 17   the GNU General Public License for more details.
 18
 19   You should have received a copy of the GNU General Public License
 20   along with this program;  if not, write to the Free Software
 21   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 22
 23}
 24Unit LVM;
 25
 26{$PACKRECORDS C}
 27
 28Interface
 29
 30{$ifdef os2}
 31  {$define lvm1}
 32{$endif}
 33
 34{$ifdef linux}
 35  {$define lvm2}
 36{$endif}
 37
 38// The number of bytes in a sector on the disk.
 39const
 40  BYTES_PER_SECTOR=512;
 41
 42//The maximum number of cylinders, heads, and sectors that a partition table entry can accomodate.
 43//Cylinders are numbered 0 - 1023, for a maximum of 1024 cylinders.
 44//eads are numbered 0 - 255, for a maximum of 256 heads.
 45//Sectors are numbered 1 - 63, for a maximum of 63 sectors per track.
 46const
 47  MAX_CYLINDERS= 1024;
 48  MAX_HEADS    = 256;
 49  MAX_SECTORS  = 63;
 50
 51// The following define the values used to indicate that a partition table entry is for an EBR, not a partition.
 52const
 53  EBR_BOOT_INDICATOR = 0;
 54  EBR_FORMAT_INDICATOR = 5;
 55
 56// The following define is used as the default Format_Indicator for new non-primary partitions.
 57const
 58  NEW_LOGICAL_DRIVE_FORMAT_INDICATOR = $6;
 59
 60// The following define is used as the default Format_Indicator for a new non-active primary partitions.
 61const
 62  NEW_PRIMARY_PARTITION_FORMAT_INDICATOR = $16;
 63
 64// The following define is used as the default Format_Indicator for a new active primary partition.
 65const
 66  NEW_ACTIVE_PRIMARY_PARTITION_FORMAT_INDICATOR = $06;
 67
 68// The following define is used to hold the value of the Boot_Indicator for active partitions.
 69const
 70  ACTIVE_PARTITION = $80;
 71
 72// Define the size of a Partition Name.  Partition Names are user defined names given to a partition.
 73const
 74  PARTITION_NAME_SIZE = 20;
 75
 76// Define the size of a volume name.  Volume Names are user defined names given to a volume.
 77const
 78  VOLUME_NAME_SIZE = 20;
 79
 80// Define the size of a disk name.  Disk Names are user defined names given to physical disk drives in the system.
 81const
 82  DISK_NAME_SIZE = 20;
 83
 84// The name of the filesystem in use on a partition.  This name may be up to 12 ( + NULL terminator) characters long.
 85const
 86  FILESYSTEM_NAME_SIZE = 20;
 87
 88// The comment field is reserved but is not currently used.  This is for future expansion and use.
 89const
 90  COMMENT_SIZE = 81;
 91
 92// Define the minimum number of sectors to reserve on the disk for Boot Manager.
 93const
 94  BOOT_MANAGER_SIZE = 2048;
 95
 96// An INTEGER number is a whole number, either + or -.
 97//The number appended to the INTEGER key word indicates the number of bits
 98//used to represent an INTEGER of that type.
 99type
100  INTEGER16=SmallInt;
101  INTEGER32=LongInt;
102  INTEGER=LongInt;
103
104// A CARDINAL number is a positive integer >= 0.
105//The number appended to the CARDINAL key word indicates the number of bits
106//used to represent a CARDINAL of that type.
107type
108  CARDINAL16=Word;
109  CARDINAL32 = Cardinal;
110
111(*
112/* A REAL number is a floating point number. */
113typedef float   REAL32;
114typedef double  REAL64;
115*)
116  REAL32 = double;
117  REAL64 = double;
118
119
120// An ADDRESS variable is one which holds an address.  The address can contain
121//anything, or even be invalid.  It is just an address which is presumed to
122//hold some kind of data.
123Type
124  ADDRESS=Pointer;
125
126Type
127  pSTRING=PChar;
128
129// 4 bytes
130Type
131  DoubleWord=Cardinal;
132
133//* The following types are used in the declaration of disk structures.  Disk structures
134//have a defined size and internal structure which must be matched exactly.              */
135
136//* 8 bytes. */
137type
138  QuadWord=QWord;
139
140// The following types are used internally by LVM.  */
141
142// Define a Partition Sector Number.  A Partition Sector Number is relative to the start of a partition.
143//The first sector in a partition is PSN 0.
144type
145  PSN=Cardinal;
146
147// Define a Logical Sector Number.  A Logical Sector Number is relative to the start of a volume.
148//The first sector in a volume is LSN 0.
149type
150  LSN=Cardinal;
151
152// Define a Logical Block Address.  A Logical Block Address is relative to the start of a
153//physical device - a disk drive.  The first sector on a disk drive is LBA 0.
154type
155  LBA=Cardinal;
156
157// The following define sets the maximum number of LVM classes for which structures and storage will be reserved.
158const
159  MAXIMUM_LVM_CLASSES = 3;
160
161// The following enum defines the various LVM classes to which a "feature" may belong.
162// An LVM Plugin is used to implement a "feature", so "plugin" and "feature" are really synonyms.
163
164type
165  _LVM_Classes = (
166    Partition_Class, // For "features" which must operate on a partition level - i.e. Bad Block Relocation.
167    Aggregate_Class, // For "features" which combine partitions into a single logical entity - i.e. Drive Linking.
168    Volume_Class     // For "features" which operate best on a volume level - i.e. encryption, mirroring etc.
169       );
170  LVM_Classes = _LVM_Classes;
171
172
173// An LVM plugin may belong to one or more classes.  For each class to which it belongs, certain attributes must be defined.
174//This structure tracks those attributes for a class.
175type
176  _LVM_Class_Attributes=record
177    ClassMember: BOOLEAN;      // TRUE if a member of this class, FALSE otherwise.
178    GlobalExclusive: BOOLEAN;  // TRUE if this plugin can not work with any other plugin - i.e. it
179//must be the only "feature" on the volume, besides the built in feature of BBR.
180    TopExclusive: BOOLEAN;     // TRUE if this plugin must be the topmost plugin in this class.
181    BottomExclusive: BOOLEAN;  // TRUE if this plugin must be the bottommost plugin in this class.
182    ClassExclusive: BOOLEAN;   // TRUE if this plugin will not work with any other plugin in this class.
183    Weight_Factor: CARDINAL32;    // A value between 1 and 100 which is used to guide the LVM interfaces when attempting to
184//establish a default ordering for plugins within this class.  A value of 1
185//indicates that this plugin wants to be as close to the bottom of the plugins
186//in this class as possible.  A value of 100 means that this plugin wants to
187//be as close to being the topmost plugin in this class as possible.  This value
188//is only used if none of the "exclusive" flags are set.
189  end;
190  LVM_Class_Attributes=_LVM_Class_Attributes;
191
192// The following enum specifies the interface types that LVM supports, and hence any plugin must support.
193  _LVM_Interface_Types= (
194    PM_Interface,
195    VIO_Interface,           // LVM.EXE is a VIO app. since it is used during install, and during recovery scenarios where PM/Java may not be available.
196    Java_Interface          // The LVM GUI is written in Java.
197  );
198  LVM_Interface_Types=_LVM_Interface_Types;
199
200const
201  MAXIMUM_LVM_INTERFACE_TYPES = 3;
202
203
204//* The following structures define what functions must be supported for each interface type.
205type
206  PADDRESS=^ADDRESS;
207  PCARDINAL32=^CARDINAL32;
208
209  _LVM_OS2_Native_Support=record
210//void (* _System Create_and_Configure) ( CARDINAL32 ID, ADDRESS InputBuffer, CARDINAL32 InputBufferSize, ADDRESS * OutputBuffer, CARDINAL32 * OutputBufferSize, CARDINAL32 * Error_Code);
211    Create_and_Configure: procedure(ID: CARDINAL32; InputBuffer: ADDRESS; InputBufferSize: CARDINAL32; OutputBuffer: PADDRESS; OutputBufferSize: PCARDINAL32; Error_Code: PCARDINAL32);
212//void (* _System Display_Status) ( ADDRESS Volume_Handle, CARDINAL32 * Error_Code );
213    Display_Status: procedure(Volume_Handle: ADDRESS; Error_Code: PCARDINAL32 );
214//void (* _System Control_Panel) (ADDRESS Volume_Handle, CARDINAL32 * Error_Code );
215    Control_Panel: procedure(Volume_Handle: ADDRESS; Error_Code: PCARDINAL32 );
216//void (* _System Help_Panel) (CARDINAL32 Help_Index, CARDINAL32 * Error_Code);
217    Help_Panel: procedure(Help_Index: CARDINAL32; Error_Code: PCARDINAL32);
218  end;
219  LVM_OS2_Native_Support=_LVM_OS2_Native_Support;
220
221
222type
223  _LVM_Interface_Support=record
224    Interface_Supported: BOOLEAN;
225  case longint of
226      0 : ( Java_Interface_Class : ^char );
227      1 : ( VIO_PM_Calls : LVM_OS2_Native_Support );
228  end;
229  LVM_Interface_Support=_LVM_Interface_Support;
230
231//* The following define the default help indicies which must be supported by the Help_Panel function.  NOTE:  Index
232//values from 0 to 100 are reserved by LVM.  The Plugin may, for its own use, use any values above 100.
233const
234  HELP_PLUGIN_DESCRIPTION   = 0;
235
236// The following define the maximum length of the names which can be used to represent a feature in LVM.  The
237//maximum name length for a feature is 30 characters plus the trailing NULL character.  For command line parsing,
238//though, a shorter name is preferable!  Thus, the "short" name for a feature will be limited to 10 characters
239//plus the trailing NULL character.  The "short" name will be used for command line purposes, while the regular
240//name will be used by all other interfaces.
241const
242  MAX_FEATURE_NAME_LENGTH       = 31;
243  MAX_FEATURE_SHORT_NAME_LENGTH = 11;
244  MAX_OEM_INFO_LENGTH           =255;
245
246// The following definitions are used to control and access the various "features" available through the LVM Engine, such as Drive Linking and BBR.
247type
248  _Feature_ID_Data=record
249    Name: Array[0..MAX_FEATURE_NAME_LENGTH-1] of char;             // Feature Name, for use in menus and command line parsing.
250    Short_Name: Array[0..MAX_FEATURE_SHORT_NAME_LENGTH-1] of char; // The name/code used to represent this feature during command line parsing.
251    OEM_Info: Array[0..MAX_OEM_INFO_LENGTH-1] of char;             // Name and copyright info. of the manufacturer, i.e. IBM, Vinca, etc.
252    ID: CARDINAL32;                                        // Numeric Feature ID.
253    Major_Version_Number: CARDINAL32;                      // The version number of this feature.
254    Minor_Version_Number: CARDINAL32;                      // The version number of this feature.
255    LVM_Major_Version_Number: CARDINAL32;                  // The version of LVM that this feature was designed to work with.
256    LVM_Minor_Version_Number: CARDINAL32;                  // The version of LVM that this feature was designed to work with.
257    Preferred_Class: LVM_Classes;                           // The class from which this "feature" prefers to be chosen.  Encryption can be performed
258//at the partition level or the volume level, and may therefore belong to both the
259//Partition_Class and the Volume_Class.  However, it is preferrable for it to be used
260//on the volume level instead of at the partition level.  Thus, its perferred class would
261//be the Volume_Class, but it would still be a member of both the Volume_Class and the
262//Partition_Class.
263    ClassData: Array[0..MAXIMUM_LVM_CLASSES-1] of LVM_Class_Attributes;  // The attributes for each of the LVM classes that this "feature" is in.
264    Interface_Support: Array[0..MAXIMUM_LVM_INTERFACE_TYPES-1] of LVM_Interface_Support;  // The functions and classes for each of the video modes that LVM can run it.
265  end;
266  Feature_ID_Data=_Feature_ID_Data;
267
268// The following defines the TAG value used to identify an item of type Feature_ID_Data in a DLIST.
269const
270  FEATURE_ID_DATA_TAG = 354385972;
271
272// The following are invariant for a disk drive.
273Type
274  Drive_Control_Record = record
275    Drive_Number: CARDINAL32;                   // OS/2 Drive Number for this drive.
276    Drive_Size: CARDINAL32;                     // The total number of sectors on the drive.
277    Drive_Serial_Number: DoubleWord;            // The serial number assigned to this drive.  For info. purposes only.
278    Drive_Handle: ADDRESS;                      // Handle used for operations on the disk that this record corresponds to.
279    Cylinder_Count: CARDINAL32;                 // The number of cylinders on the drive.
280    Heads_Per_Cylinder: CARDINAL32;             // The number of heads per cylinder for this drive.
281    Sectors_Per_Track: CARDINAL32;              // The number of sectors per track for this drive.
282    Drive_Is_PRM: BOOLEAN;                      // Set to TRUE if this drive is a PRM.
283    Reserved: Array[0..3-1] of BYTE;              // Alignment.
284  end;
285
286// The following structure is returned by the Get_Drive_Control_Data function.
287  Drive_Control_Array=record
288    Drive_Control_Data: ^Drive_Control_Record;       // An array of drive control records.
289    Count: CARDINAL32;                               // The number of entries in the array of drive control records.
290  end;
291
292// The following structure defines the information that can be changed for a specific disk drive.
293  Drive_Information_Record=record
294    Total_Available_Sectors: CARDINAL32;        // The number of sectors on the disk which are not currently assigned to a partition.
295    Largest_Free_Block_Of_Sectors: CARDINAL32;  // The number of sectors in the largest contiguous block of available sectors.
296    Corrupt_Partition_Table: BOOLEAN;           // If TRUE, then the partitioning information found on the drive is incorrect!
297    Unusable: BOOLEAN;                          // If TRUE, the drive's MBR is not accessible and the drive can not be partitioned.
298    IO_Error: BOOLEAN;                          // If TRUE, then the last I/O operation on this drive failed!
299    Is_Big_Floppy: BOOLEAN;                     // If TRUE, then the drive is a PRM formatted as a big floppy (i.e. the old style removable media support).
300    Drive_Name: Array[0..DISK_NAME_SIZE-1] of Char; // User assigned name for this disk drive.
301  end;
302
303  Partition_Information_Record=record
304    Partition_Handle: ADDRESS;                      // The handle used to perform operations on this partition.
305    Volume_Handle: ADDRESS;                         // If this partition is part of a volume, this will be the handle of
306                                                    //the volume.  If this partition is NOT part of a volume, then this
307                                                    //handle will be 0.
308    Drive_Handle: ADDRESS;                          // The handle for the drive this partition resides on.
309    Partition_Serial_Number: DoubleWord;            // The serial number assigned to this partition.
310    Partition_Start: CARDINAL32;                    // The LBA of the first sector of the partition.
311    True_Partition_Size: CARDINAL32;                // The total number of sectors comprising the partition.
312    Usable_Partition_Size: CARDINAL32;              // The size of the partition as reported to the IFSM.  This is the
313                                                    //size of the partition less any LVM overhead.
314    Boot_Limit: CARDINAL32;                         // The maximum number of sectors from this block of free space that can be used to
315                                                    //create a bootable partition if you allocate from the beginning of the block of
316                                                    //free space.
317    Spanned_Volume: BOOLEAN;                        // TRUE if this partition is part of a multi-partition volume.
318    Primary_Partition: BOOLEAN;                     // True or False.  Any non-zero value here indicates that
319                                                    //this partition is a primary partition.  Zero here indicates
320                                                    //that this partition is a "logical drive" - i.e. it resides
321                                                    //inside of an extended partition.
322    Active_Flag: BYTE;                              // 80 = Partition is marked as being active.
323                                                    // 0 = Partition is not active.
324    OS_Flag: BYTE;                                  // This field is from the partition table.  It is known as the
325                                                    //OS flag, the Partition Type Field, Filesystem Type, and
326                                                    //various other names.
327
328                                                    //Values of interest
329
330                                                    //If this field is: (values are in hex)
331
332                                                    //07 = The partition is a compatibility partition formatted for use
333                                                    //with an installable filesystem, such as HPFS or JFS.
334                                                    //00 = Unformatted partition
335                                                    //01 = FAT12 filesystem is in use on this partition.
336                                                    //04 = FAT16 filesystem is in use on this partition.
337                                                    //0A = OS/2 Boot Manager Partition
338                                                    //35 = LVM partition
339                                                    //84 = OS/2 FAT16 partition which has been relabeled by Boot Manager to "Hide" it.
340    Partition_Type: BYTE;                           // 0 = Free Space
341                                                    //1 = LVM Partition (Part of an LVM Volume.)
342                                                    //2 = Compatibility Partition
343                                                    //All other values are reserved for future use.
344    Partition_Status: BYTE;                         // 0 = Free Space
345                                                    //1 = In Use - i.e. already assigned to a volume.
346                                                    //2 = Available - i.e. not currently assigned to a volume.
347    On_Boot_Manager_Menu: BOOLEAN;                  // Set to TRUE if this partition is not part of a Volume yet is on the Boot Manager Menu.
348    Reserved: BYTE;                                 // Alignment.
349    Volume_Drive_Letter: char;                      // The drive letter assigned to the volume that this partition is a part of.
350    Drive_Name: Array[0..DISK_NAME_SIZE-1] of char;   // User assigned name for this disk drive.
351    File_System_Name: Array[0..FILESYSTEM_NAME_SIZE-1] of char;// The name of the filesystem in use on this partition, if it is known.
352    Partition_Name: Array[0..PARTITION_NAME_SIZE-1] of char;   // The user assigned name for this partition.
353    Volume_Name: Array[0..VOLUME_NAME_SIZE-1] of char;         // If this partition is part of a volume, then this will be the
354                                                             //name of the volume that this partition is a part of.  If this
355                                                             //record represents free space, then the Volume_Name will be
356                                                             //"FREE SPACE xx", where xx is a unique numeric ID generated by
357                                                             //LVM.DLL.  Otherwise it will be an empty string.
358  end;
359
360// The following defines are for use with the Partition_Type field in the Partition_Information_Record.
361const
362  pt_FREE_SPACE_PARTITION = 0;
363  pt_LVM_PARTITION        = 1;
364  pt_COMPATIBILITY_PARTITION = 2;
365
366// The following defines are for use with the Partition_Status field in the Partition_Information_Record.
367const
368  PARTITION_IS_IN_USE    = 1;
369  PARTITION_IS_AVAILABLE = 2;
370  PARTITION_IS_FREE_SPACE = 0;
371
372// The following structure is returned by various functions in the LVM Engine.
373type
374  Partition_Information_Array=record
375    Partition_Array: ^Partition_Information_Record; // An array of Partition_Information_Records.
376    Count: CARDINAL32;           // The number of entries in the Partition_Array.
377  end;
378
379// The following items are invariant for a volume.
380type
381  Volume_Control_Record=record
382    Volume_Serial_Number: DoubleWord;            // The serial number assigned to this volume.
383    Volume_Handle: ADDRESS;                   // The handle used to perform operations on this volume.
384    Compatibility_Volume: BOOLEAN;            // TRUE indicates that this volume is compatible with older versions of OS/2.
385//FALSE indicates that this is an LVM specific volume and can not be used without OS2LVM.DMD.
386    Device_Type: BYTE;                     // Indicates what type of device the Volume resides on:
387//0 = Hard Drive under LVM Control
388//1 = PRM under LVM Control
389//2 = CD-ROM
390//3 = Network drive
391//4 = Unknown device NOT under LVM Control
392    Reserved: Array[0..2-1] of BYTE;                     // Alignment.
393  end;
394
395// The following define the device types used in the Device_Type field of the Volume_Control_Record.
396const
397  LVM_HARD_DRIVE = 0;
398  LVM_PRM        = 1;
399  NON_LVM_CDROM  = 2;
400  NETWORK_DRIVE  = 3;
401  NON_LVM_DEVICE = 4;
402
403// The following structure is returned by the Get_Volume_Control_Data function.
404type
405  Volume_Control_Array=record
406    Volume_Control_Data: ^Volume_Control_Record;      // An array of volume control records.
407    Count: CARDINAL32;                    // The number of entries in the array of volume control records.
408  end;
409
410// The following information about a volume can (and often does) vary.
411type
412  Volume_Information_Record=record
413    Volume_Size: CARDINAL32;                           // The number of sectors comprising the volume.
414    Partition_Count: CARDINAL32;                       // The number of partitions which comprise this volume.
415    Drive_Letter_Conflict: CARDINAL32;                 // 0 indicates that the drive letter preference for this volume is unique.
416//1 indicates that the drive letter preference for this volume
417//is not unique, but this volume got its preferred drive letter anyway.
418//2 indicates that the drive letter preference for this volume
419//is not unique, and this volume did NOT get its preferred drive letter.
420//4 indicates that this volume is currently "hidden" - i.e. it has
421//no drive letter preference at the current time.
422    Compatibility_Volume: BOOLEAN;                  // TRUE if this is for a compatibility volume, FALSE otherwise.
423    Bootable: BOOLEAN;                              // Set to TRUE if this volume appears on the Boot Manager menu, or if it is
424//a compatibility volume and its corresponding partition is the first active
425//primary partition on the first drive.
426    Drive_Letter_Preference: char;               // The drive letter that this volume desires to be.
427    Current_Drive_Letter: char;                  // The drive letter currently used to access this volume.  May be different than
428//Drive_Letter_Preference if there was a conflict ( i.e. Drive_Letter_Preference
429//is already in use by another volume ).
430    Initial_Drive_Letter: char;                  // The drive letter assigned to this volume by the operating system when LVM was started.
431//This may be different from the Drive_Letter_Preference if there were conflicts, and
432//may be different from the Current_Drive_Letter.  This will be 0x0 if the Volume did
433//not exist when the LVM Engine was opened (i.e. it was created during this LVM session).
434    New_Volume: BOOLEAN;                            // Set to FALSE if this volume existed before the LVM Engine was opened.  Set to
435//TRUE if this volume was created after the LVM Engine was opened.
436    Status: BYTE;                                // 0 = None.
437//1 = Bootable
438//2 = Startable
439//3 = Installable.
440    Reserved_1: BYTE;
441    Volume_Name: Array[0..VOLUME_NAME_SIZE-1] of char;         // The user assigned name for this volume.
442    File_System_Name: Array[0..FILESYSTEM_NAME_SIZE-1] of char;// The name of the filesystem in use on this partition, if it is known.
443  end;
444
445// The following structure is used to return the feature information for the installed features, or the features on a volume.
446type
447  Feature_Information_Array=record
448    Count: CARDINAL32;
449    Feature_Data: ^Feature_ID_Data;
450  end;
451
452// The following structure defines an item on the Boot Manager Menu.
453type
454  Boot_Manager_Menu_Item=record
455    Handle: ADDRESS;            // A Volume or Partition handle.
456    Volume: BOOLEAN;            // If TRUE, then Handle is the handle of a Volume.  Otherwise, Handle is the handle of a partition.
457  end;
458
459// The following structure is used to get a list of the items on the partition manager menu.
460type
461  Boot_Manager_Menu=record
462    Menu_Items: ^Boot_Manager_Menu_Item;
463    Count: CARDINAL32;
464  end;
465
466// The following structure is used to specify an LVM Feature when creating a volume.  Since LVM Features may be part of
467//more than one LVM Class, the specific class to be used with the feature must also be specified.
468type
469  LVM_Feature_Specification_Record=record
470    Feature_ID: CARDINAL32;      // The feature ID of the feature to use.
471    Actual_Class: LVM_Classes;   // The LVM Class (supported by the specified feature) to use.
472    Init_Data: ADDRESS;          // The address of a buffer containing initialization data for this feature.
473                                 //NULL if there is no initialization data being provided for this feature.
474  end;
475
476// The following structure is used with the Get_Child_Handles function.
477Type
478  LVM_Handle_Array_Record=record
479    Count: CARDINAL32;
480    Handles: ^ADDRESS;
481  end;
482
483// The following preprocessor directives define the operations that can be performed on a partition, volume, or a block of free space.
484// These definitions represent bits in a 32 bit value returned by the Get_Valid_Options function.
485const
486  CREATE_PRIMARY_PARTITION          = 1;
487  CREATE_LOGICAL_DRIVE              = 2;
488  DELETEPARTITION                   = 4;
489  SET_ACTIVE_PRIMARY                = 8;
490  SET_PARTITION_ACTIVE             = $10;
491  SET_PARTITION_INACTIVE           = $20;
492  SETSTARTABLE                    = $40;
493  INSTALLBOOTMANAGER             = $80;
494  REMOVEBOOTMANAGER              = $100;
495  SET_BOOT_MANAGER_DEFAULTS        = $200;
496  ADD_TO_BOOT_MANAGER_MENU         = $400;
497  REMOVE_FROM_BOOT_MANAGER_MENU    = $800;
498  DELETEVOLUME                    = $1000;
499  HIDEVOLUME                      = $2000;
500  EXPANDVOLUME                    = $4000;
501  SET_VOLUME_INSTALLABLE           = $8000;
502  ASSIGNDRIVELETTER              = $10000;
503  CAN_BOOT_PRIMARY                 = $20000;      // If a primary is created from this block of free space, then it can be made bootable.
504  CAN_BOOT_LOGICAL                 = $40000;      // If a logical drive is created from this block of free space, then OS/2 can boot from it by adding it to the boot manager menu.
505  CAN_SET_NAME                     = $80000;
506  SET_BOOT_MANAGER_STARTABLE       = $100000;
507
508// The following enumeration defines the allocation strategies used by the Create_Partition function.
509type
510  _Allocation_Algorithm =(
511Automatic,               // Let LVM decide which block of free space to use to create the partition.
512Best_Fit,                // Use the block of free space which is closest in size to the partition being created.
513First_Fit,               // Use the first block of free space on the disk which is large enough to hold a partition of the specified size.
514Last_Fit,                // Use the last block of free space on the disk which is large enough to hold a partition of the specified size.
515From_Largest,            // Find the largest block of free space and allocate the partition from that block of free space.
516From_Smallest,           // Find the smallest block of free space that can accommodate a partition of the size specified.
517All                      // Turn the specified drive or block of free space into a single partition.
518);
519  Allocation_Algorithm=_Allocation_Algorithm;
520
521// Error codes returned by the LVM Engine.
522const
523  LVM_ENGINE_NO_ERROR                          =  0;
524  LVM_ENGINE_OUT_OF_MEMORY                     =  1;
525  LVM_ENGINE_IO_ERROR                          =  2;
526  LVM_ENGINE_BAD_HANDLE                        =  3;
527  LVM_ENGINE_INTERNAL_ERROR                    =  4;
528  LVM_ENGINE_ALREADY_OPEN                      =  5;
529  LVM_ENGINE_NOT_OPEN                          =  6;
530  LVM_ENGINE_NAME_TOO_BIG                      =  7;
531  LVM_ENGINE_OPERATION_NOT_ALLOWED             =  8;
532  LVM_ENGINE_DRIVE_OPEN_FAILURE                =  9;
533  LVM_ENGINE_BAD_PARTITION                     = 10;
534  LVM_ENGINE_CAN_NOT_MAKE_PRIMARY_PARTITION    = 11;
535  LVM_ENGINE_TOO_MANY_PRIMARY_PARTITIONS       = 12;
536  LVM_ENGINE_CAN_NOT_MAKE_LOGICAL_DRIVE        = 13;
537  LVM_ENGINE_REQUESTED_SIZE_TOO_BIG            = 14;
538  LVM_ENGINE_1024_CYLINDER_LIMIT               = 15;
539  LVM_ENGINE_PARTITION_ALIGNMENT_ERROR         = 16;
540  LVM_ENGINE_REQUESTED_SIZE_TOO_SMALL          = 17;
541  LVM_ENGINE_NOT_ENOUGH_FREE_SPACE             = 18;
542  LVM_ENGINE_BAD_ALLOCATION_ALGORITHM          = 19;
543  LVM_ENGINE_DUPLICATE_NAME                    = 20;
544  LVM_ENGINE_BAD_NAME                          = 21;
545  LVM_ENGINE_BAD_DRIVE_LETTER_PREFERENCE       = 22;
546  LVM_ENGINE_NO_DRIVES_FOUND                   = 23;
547  LVM_ENGINE_WRONG_VOLUME_TYPE                 = 24;
548  LVM_ENGINE_VOLUME_TOO_SMALL                  = 25;
549  LVM_ENGINE_BOOT_MANAGER_ALREADY_INSTALLED    = 26;
550  LVM_ENGINE_BOOT_MANAGER_NOT_FOUND            = 27;
551  LVM_ENGINE_INVALID_PARAMETER                 = 28;
552  LVM_ENGINE_BAD_FEATURE_SET                   = 29;
553  LVM_ENGINE_TOO_MANY_PARTITIONS_SPECIFIED     = 30;
554  LVM_ENGINE_LVM_PARTITIONS_NOT_BOOTABLE       = 31;
555  LVM_ENGINE_PARTITION_ALREADY_IN_USE          = 32;
556  LVM_ENGINE_SELECTED_PARTITION_NOT_BOOTABLE   = 33;
557  LVM_ENGINE_VOLUME_NOT_FOUND                  = 34;
558  LVM_ENGINE_DRIVE_NOT_FOUND                   = 35;
559  LVM_ENGINE_PARTITION_NOT_FOUND               = 36;
560  LVM_ENGINE_TOO_MANY_FEATURES_ACTIVE          = 37;
561  LVM_ENGINE_PARTITION_TOO_SMALL               = 38;
562  LVM_ENGINE_MAX_PARTITIONS_ALREADY_IN_USE     = 39;
563  LVM_ENGINE_IO_REQUEST_OUT_OF_RANGE           = 40;
564  LVM_ENGINE_SPECIFIED_PARTITION_NOT_STARTABLE = 41;
565  LVM_ENGINE_SELECTED_VOLUME_NOT_STARTABLE     = 42;
566  LVM_ENGINE_EXTENDFS_FAILED                   = 43;
567  LVM_ENGINE_REBOOT_REQUIRED                   = 44;
568  LVM_ENGINE_CAN_NOT_OPEN_LOG_FILE             = 45;
569  LVM_ENGINE_CAN_NOT_WRITE_TO_LOG_FILE         = 46;
570  LVM_ENGINE_REDISCOVER_FAILED                 = 47;
571  LVM_ENGINE_INTERNAL_VERSION_FAILURE          = 48;
572  LVM_ENGINE_PLUGIN_OPERATION_INCOMPLETE       = 49;
573  LVM_ENGINE_BAD_FEATURE_ID                    = 50;
574  LVM_ENGINE_NO_INIT_DATA                      = 51;
575  LVM_ENGINE_NO_CONTEXT_DATA                   = 52;
576  LVM_ENGINE_WRONG_CLASS_FOR_FEATURE           = 53;
577  LVM_ENGINE_INCOMPATIBLE_FEATURES_SELECTED    = 54;
578  LVM_ENGINE_NO_CHILDREN                       = 55;
579  LVM_ENGINE_FEATURE_NOT_SUPPORTED_BY_INTERFACE= 56;
580  LVM_ENGINE_NO_PARENT                         = 57;
581  LVM_ENGINE_VOLUME_HAS_NOT_BEEN_COMMITTED_YET = 58;
582  LVM_ENGINE_UNABLE_TO_REFERENCE_VOLUME        = 59;
583  LVM_ENGINE_PARSING_ERROR                     = 60;
584  LVM_ENGINE_INTERNAL_FEATURE_ERROR            = 61;
585  LVM_ENGINE_VOLUME_NOT_CONVERTED              = 62;
586
587
588// The following definitions are used for command line processing.  As the command line is processed,
589//the command line is first broken up into tokens.  Each token has a "characterization", which indicates
590//what the token is thought to be.
591
592type
593  Token_Characterizations=(
594LVM_AcceptableCharsStr,
595LVM_All,
596LVM_BestFit,
597LVM_BootDOS,
598LVM_BootOS2,
599LVM_Bootable,
600LVM_CR,
601LVM_CRI,
602LVM_Compatibility,
603LVM_Drive,
604LVM_Existing,
605LVM_Expand,
606LVM_FS,
607LVM_FirstFit,
608LVM_Freespace,
609LVM_FromEnd,
610LVM_FromLargest,
611LVM_FromSmallest,
612LVM_FromStart,
613LVM_LVM,
614LVM_LastFit,
615LVM_Logical,
616LVM_New,
617LVM_NoBoot,
618LVM_NonBootable,
619LVM_NotBootable,
620LVM_Partition,
621LVM_Primary,
622LVM_RB,
623LVM_Size,
624LVM_Unusable,
625LVM_Unused,
626LVM_Volume,
627LVM_Volumes,
628LVM_Comma,
629LVM_Number,
630LVM_Colon,
631LVM_Space,
632LVM_Tab,
633LVM_MultiSpace,
634LVM_MultiTab,
635LVM_String,
636LVM_FileNameStr,
637LVM_SemiColon,
638LVM_Eof,
639LVM_Separator,
640LVM_Open_Paren,                    //* ( */
641LVM_Close_Paren,                   //* ) */
642LVM_Open_Bracket,                  //* [ */
643LVM_Close_Bracket,                 //* ] */
644LVM_Open_Brace,                    //* { */
645LVM_Close_Brace,                   //* } */
646LVM_EQ_Sign,                       //* = */
647LVM_Bootmgr,
648LVM_Create,
649LVM_Delete,
650LVM_DriveLetter,
651LVM_File,
652LVM_Hide,
653LVM_Install,
654LVM_NewMBR,
655LVM_Query,
656LVM_RediscoverPRM,
657LVM_SetName,
658LVM_SetStartable,
659LVM_SI,
660LVM_SlashSize,
661LVM_StartLog
662);
663
664type
665  _LVM_Token=record
666    TokenText: PChar;  // The actual text of the token.
667    TokenType: Token_Characterizations;  // What the token is thought to be.
668    Position: CARDINAL32;   // The position of the first character of the token on the command line.
669  end;
670  LVM_Token=_LVM_Token;
671
672const
673  LVM_TOKEN_TAG = 28387473;
674
675// Function Prototypes
676
677//***************************************************************************
678//
679// Functions relating to the LVM Engine itself
680//
681//***************************************************************************
682
683//****************************************************************************************************/
684//*                                                                                                  */
685//*   Function Name: Open_LVM_Engine                                                                 */
686//*                                                                                                  */
687//*   Descriptive Name: Opens the LVM Engine and readies it for use.                                 */
688//*                                                                                                  */
689//*   Input: BOOLEAN Ignore_CHS : If TRUE, then the LVM engine will not check the CHS values in the  */
690//*                               MBR/EBR partition tables for validity.  This is useful if there    */
691//*                               are drive geometry problems, such as the drive was partitioned and */
692//*                               formatted with one geometry and then moved to a different machine  */
693//*                               which uses a different geometry for the drive.  This would cause   */
694//*                               the starting and ending CHS values in the partition tables to      */
695//*                               be inconsistent with the size and partition offset entries in the  */
696//*                               partition tables.  Setting Ignore_CHS to TRUE will disable the     */
697//*                               LVM Engine's CHS consistency checks, thereby allowing the drive    */
698//*                               to be partitioned.                                                 */
699//*          CARDINAL32 * Error_Code - The address of a CARDINAL32 in which to store an error code   */
700//*                                    should an error occur.                                        */
701//*                                                                                                  */
702//*   Output:  *Error_Code will be 0 if this function completes successfully.  If an error occurs,   */
703//*            *Error_Code will contain a non-zero error code.                                       */
704//*                                                                                                  */
705//*   Error Handling: If this function aborts with an error, all memory allocated during the course  */
706//*                   of this function will be released.  Disk read errors will be reported to the   */
707//*                   user via pop-up error messages.  Disk read errors will only cause this         */
708//*                   function to abort if none of the disk drives in the system could be            */
709//*                   successfully read.                                                             */
710//*                                                                                                  */
711//*   Side Effects:  The LVM Engine will be initialized.  The partition tables for all OS2DASD       */
712//*                  controlled disk drives will be read into memory.  Memory will be allocated for  */
713//*                  the data structures used by the LVM Engine.                                     */
714//*                                                                                                  */
715//*   Notes:  This is provided for programs that used LVM Version 1.  This function assumes an       */
716//*           LVM_Interface_Type of VIO_Interface.                                                   */
717//*                                                                                                  */
718//****************************************************************************************************/
719procedure Open_LVM_Engine(Ignore_CHS: BOOLEAN; Error_Code: PCARDINAL32); external 'lvm' name 'Open_LVM_Engine';
720
721//****************************************************************************************************/
722//*                                                                                                  */
723//*   Function Name: Open_LVM_Engine2                                                                */
724//*                                                                                                  */
725//*   Descriptive Name: Opens the LVM Engine and readies it for use.                                 */
726//*                                                                                                  */
727//*   Input: BOOLEAN Ignore_CHS : If TRUE, then the LVM engine will not check the CHS values in the  */
728//*                               MBR/EBR partition tables for validity.  This is useful if there    */
729//*                               are drive geometry problems, such as the drive was partitioned and */
730//*                               formatted with one geometry and then moved to a different machine  */
731//*                               which uses a different geometry for the drive.  This would cause   */
732//*                               the starting and ending CHS values in the partition tables to      */
733//*                               be inconsistent with the size and partition offset entries in the  */
734//*                               partition tables.  Setting Ignore_CHS to TRUE will disable the     */
735//*                               LVM Engine's CHS consistency checks, thereby allowing the drive    */
736//*                               to be partitioned.                                                 */
737//*          LVM_Interface_Types Interface_Type - Indicate the type of user interface being used:    */
738//*                               PM_Interface, VIO_Interface, or Java_Interface.  This lets the     */
739//*                               LVM Engine know which interface support routines to call in any    */
740//*                               plugin modules which may be loaded.                                */
741//*          CARDINAL32 * Error_Code - The address of a CARDINAL32 in which to store an error code   */
742//*                                    should an error occur.                                        */
743//*                                                                                                  */
744//*   Output:  *Error_Code will be 0 if this function completes successfully.  If an error occurs,   */
745//*            *Error_Code will contain a non-zero error code.                                       */
746//*                                                                                                  */
747//*   Error Handling: If this function aborts with an error, all memory allocated during the course  */
748//*                   of this function will be released.  Disk read errors will be reported to the   */
749//*                   user via pop-up error messages.  Disk read errors will only cause this         */
750//*                   function to abort if none of the disk drives in the system could be            */
751//*                   successfully read.                                                             */
752//*                                                                                                  */
753//*   Side Effects:  The LVM Engine will be initialized.  The partition tables for all OS2DASD       */
754//*                  controlled disk drives will be read into memory.  Memory will be allocated for  */
755//*                  the data structures used by the LVM Engine.                                     */
756//*                                                                                                  */
757//*   Notes:  New in LVM Version 2                                                                   */
758//*                                                                                                  */
759//****************************************************************************************************/
760{$ifdef lvm2}
761procedure Open_LVM_Engine2(Ignore_CHS: BOOLEAN; Interface_Type: LVM_Interface_Types; Error_Code: PCARDINAL32); external 'lvm' name 'Open_LVM_Engine2';
762{$endif}
763//*********************************************************************/
764//*                                                                   */
765//*   Function Name: Commit_Changes                                   */
766//*                                                                   */
767//*   Descriptive Name: Saves any changes made to the partitioning    */
768//*                     information of the OS2DASD controlled disk    */
769//*                     drives in the system.                         */
770//*                                                                   */
771//*   Input: CARDINAL32 * Error_Code - The address of a CARDINAL32 in */
772//*                                   in which to store an error code */
773//*                                   should an error occur.          */
774//*                                                                   */
775//*   Output:  The function return value will be TRUE if all of the   */
776//*            partitioning/volume changes made were successfully     */
777//*            written to disk.  Also, *Error_Code will be 0 if no    */
778//*            errors occur.                                          */
779//*                                                                   */
780//*            If an error occurs, then the furnction return value    */
781//*            will be FALSE and *Error_Code will contain a non-zero  */
782//*            error code.                                            */
783//*                                                                   */
784//*   Error Handling:  If an error occurs, the function return value  */
785//*                    will be false and *Error_Code will be > 0.     */
786//*                                                                   */
787//*                    Disk read and write errors will be indicated by*/
788//*                    setting the IO_Error field of the              */
789//*                    Drive_Information_Record to TRUE.  Thus, if    */
790//*                    the function return value is FALSE, and        */
791//*                    *Error_Code indicates an I/O error, the caller */
792//*                    of this function should call the               */
793//*                    Get_Drive_Status function on each drive to     */
794//*                    determine which drives had I/O errors.         */
795//*                                                                   */
796//*                    If a read or write error occurs, then the      */
797//*                    engine may not have been able to create a      */
798//*                    partition or volume.  Thus, the caller         */
799//*                    may want to refresh all partition and volume   */
800//*                    data to see what the engine was and was not    */
801//*                    able to create.                                */
802//*                                                                   */
803//*   Side Effects:  The partitioning information of the disk drives  */
804//*                  in the system may be altered.                    */
805//*                                                                   */
806//*   Notes:  None.                                                   */
807//*                                                                   */
808//*********************************************************************/
809function Commit_Changes(Error_Code: PCARDINAL32): BOOLEAN; external 'lvm' name 'Commit_Changes';
810
811//*********************************************************************/
812//*                                                                   */
813//*   Function Name: Set_Java_Call_Back                               */
814//*                                                                   */
815//*   Descriptive Name: This function allows the calling Java program */
816//*                     to set the call back address.  The call back  */
817//*                     address is used when the LVM Engine or one of */
818//*                     its plug-ins, needs to run a Java class to    */
819//*                     gather information from the user.             */
820//*                                                                   */
821//*   Input: void ( * Execute_Java_Class) ... - The address of a       */
822//*                                            function that the LVM  */
823//*                                            engine may call when   */
824//*                                            it needs a Java class  */
825//*                                            to be executed.  This  */
826//*                                            is only required if the*/
827//*                                            user interface being   */
828//*                                            used is written in Java*/
829//*          CARDINAL32 * Error_Code - The address of a CARDINAL32 in */
830//*                                   in which to store an error code */
831//*                                   should an error occur.          */
832//*                                                                   */
833//*   Output: If the function completes successfully, then *Error_Code*/
834//*           will be set to LVM_ENGINE_NO_ERROR.  Otherwise,         */
835//*           *Error_Code will be set to a non-zero error code.       */
836//*                                                                   */
837//*   Error Handling:  If an error occurs, the function will abort and*/
838//*                    *Error_Code will be set to a non-zero error    */
839//*                    code.                                          */
840//*                                                                   */
841//*   Side Effects:  The Java call back address is set to point to the*/
842//*                  specified function.  Once the Java call back     */
843//*                  address is set, LVM plug-ins which require the   */
844//*                  Java call back will be enabled and can be used   */
845//*                  during the creation of LVM Volumes.              */
846//*                                                                   */
847//*   Notes:  If a Java interface is in use (as specified on the      */
848//*           Open_LVM_Engine call), then this function must be called*/
849//*           in order to enable those LVM plug-ins which require     */
850//*           initialization information during the creation of an    */
851//*           LVM Volume.  If these plug-ins are not enabled, then    */
852//*           they will not be reported by the Get_Available_Features */
853//*           API, nor can they be used or accessed by any other LVM  */
854//*           Engine APIs.  Thus, this function should be called      */
855//*           immediately after the Open_LVM_Engine API is called.    */
856//*                                                                   */
857//*********************************************************************/
858{$ifdef lvm2}
859type
860  TJavaExecProc=procedure(
861    Class_Name: PChar;
862    InputBuffer: ADDRESS;
863    InputBufferSize: CARDINAL32;
864    OutputBuffer: PADDRESS;
865    OutputBufferSize,
866    Error_Code: PCARDINAL32);
867
868procedure Set_Java_Call_Back(
869  Execute_Java_Class: TJAvaExecProc;
870  Error_Code: PCARDINAL32); external 'lvm' name 'Set_Java_Call_Back';
871
872{$endif}
873//*********************************************************************/
874//*                                                                   */
875//*   Function Name: Close_LVM_Engine                                 */
876//*                                                                   */
877//*   Descriptive Name: Closes the LVM Engine and frees any memory    */
878//*                     held by the LVM Engine.                       */
879//*                                                                   */
880//*   Input: None.                                                    */
881//*                                                                   */
882//*   Output:  None.                                                  */
883//*                                                                   */
884//*   Error Handling: N/A                                             */
885//*                                                                   */
886//*   Side Effects:  Any memory held by the LVM Engine is released.   */
887//*                                                                   */
888//*   Notes:  None.                                                   */
889//*                                                                   */
890//*********************************************************************/
891procedure Close_LVM_Engine; external 'lvm' name 'Close_LVM_Engine';
892
893//*********************************************************************/
894//*          …

Large files files are truncated, but you can click here to view the full file