/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
Large files are truncated click here to view the full file
- {
- Copyright (c) International Business Machines Corp., 2000
- Copyright (c) 2003 Yuri Prokushev
- This module defines the interface to LVM.DLL, which is the
- engine that performs all of the disk partitioning/volume
- creation work.
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
- the GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- }
- Unit LVM;
- {$PACKRECORDS C}
- Interface
- {$ifdef os2}
- {$define lvm1}
- {$endif}
- {$ifdef linux}
- {$define lvm2}
- {$endif}
- // The number of bytes in a sector on the disk.
- const
- BYTES_PER_SECTOR=512;
- //The maximum number of cylinders, heads, and sectors that a partition table entry can accomodate.
- //Cylinders are numbered 0 - 1023, for a maximum of 1024 cylinders.
- //eads are numbered 0 - 255, for a maximum of 256 heads.
- //Sectors are numbered 1 - 63, for a maximum of 63 sectors per track.
- const
- MAX_CYLINDERS= 1024;
- MAX_HEADS = 256;
- MAX_SECTORS = 63;
- // The following define the values used to indicate that a partition table entry is for an EBR, not a partition.
- const
- EBR_BOOT_INDICATOR = 0;
- EBR_FORMAT_INDICATOR = 5;
- // The following define is used as the default Format_Indicator for new non-primary partitions.
- const
- NEW_LOGICAL_DRIVE_FORMAT_INDICATOR = $6;
- // The following define is used as the default Format_Indicator for a new non-active primary partitions.
- const
- NEW_PRIMARY_PARTITION_FORMAT_INDICATOR = $16;
- // The following define is used as the default Format_Indicator for a new active primary partition.
- const
- NEW_ACTIVE_PRIMARY_PARTITION_FORMAT_INDICATOR = $06;
- // The following define is used to hold the value of the Boot_Indicator for active partitions.
- const
- ACTIVE_PARTITION = $80;
- // Define the size of a Partition Name. Partition Names are user defined names given to a partition.
- const
- PARTITION_NAME_SIZE = 20;
- // Define the size of a volume name. Volume Names are user defined names given to a volume.
- const
- VOLUME_NAME_SIZE = 20;
- // Define the size of a disk name. Disk Names are user defined names given to physical disk drives in the system.
- const
- DISK_NAME_SIZE = 20;
- // The name of the filesystem in use on a partition. This name may be up to 12 ( + NULL terminator) characters long.
- const
- FILESYSTEM_NAME_SIZE = 20;
- // The comment field is reserved but is not currently used. This is for future expansion and use.
- const
- COMMENT_SIZE = 81;
- // Define the minimum number of sectors to reserve on the disk for Boot Manager.
- const
- BOOT_MANAGER_SIZE = 2048;
- // An INTEGER number is a whole number, either + or -.
- //The number appended to the INTEGER key word indicates the number of bits
- //used to represent an INTEGER of that type.
- type
- INTEGER16=SmallInt;
- INTEGER32=LongInt;
- INTEGER=LongInt;
- // A CARDINAL number is a positive integer >= 0.
- //The number appended to the CARDINAL key word indicates the number of bits
- //used to represent a CARDINAL of that type.
- type
- CARDINAL16=Word;
- CARDINAL32 = Cardinal;
- (*
- /* A REAL number is a floating point number. */
- typedef float REAL32;
- typedef double REAL64;
- *)
- REAL32 = double;
- REAL64 = double;
- // An ADDRESS variable is one which holds an address. The address can contain
- //anything, or even be invalid. It is just an address which is presumed to
- //hold some kind of data.
- Type
- ADDRESS=Pointer;
- Type
- pSTRING=PChar;
- // 4 bytes
- Type
- DoubleWord=Cardinal;
- //* The following types are used in the declaration of disk structures. Disk structures
- //have a defined size and internal structure which must be matched exactly. */
- //* 8 bytes. */
- type
- QuadWord=QWord;
- // The following types are used internally by LVM. */
- // Define a Partition Sector Number. A Partition Sector Number is relative to the start of a partition.
- //The first sector in a partition is PSN 0.
- type
- PSN=Cardinal;
- // Define a Logical Sector Number. A Logical Sector Number is relative to the start of a volume.
- //The first sector in a volume is LSN 0.
- type
- LSN=Cardinal;
- // Define a Logical Block Address. A Logical Block Address is relative to the start of a
- //physical device - a disk drive. The first sector on a disk drive is LBA 0.
- type
- LBA=Cardinal;
- // The following define sets the maximum number of LVM classes for which structures and storage will be reserved.
- const
- MAXIMUM_LVM_CLASSES = 3;
- // The following enum defines the various LVM classes to which a "feature" may belong.
- // An LVM Plugin is used to implement a "feature", so "plugin" and "feature" are really synonyms.
- type
- _LVM_Classes = (
- Partition_Class, // For "features" which must operate on a partition level - i.e. Bad Block Relocation.
- Aggregate_Class, // For "features" which combine partitions into a single logical entity - i.e. Drive Linking.
- Volume_Class // For "features" which operate best on a volume level - i.e. encryption, mirroring etc.
- );
- LVM_Classes = _LVM_Classes;
- // An LVM plugin may belong to one or more classes. For each class to which it belongs, certain attributes must be defined.
- //This structure tracks those attributes for a class.
- type
- _LVM_Class_Attributes=record
- ClassMember: BOOLEAN; // TRUE if a member of this class, FALSE otherwise.
- GlobalExclusive: BOOLEAN; // TRUE if this plugin can not work with any other plugin - i.e. it
- //must be the only "feature" on the volume, besides the built in feature of BBR.
- TopExclusive: BOOLEAN; // TRUE if this plugin must be the topmost plugin in this class.
- BottomExclusive: BOOLEAN; // TRUE if this plugin must be the bottommost plugin in this class.
- ClassExclusive: BOOLEAN; // TRUE if this plugin will not work with any other plugin in this class.
- Weight_Factor: CARDINAL32; // A value between 1 and 100 which is used to guide the LVM interfaces when attempting to
- //establish a default ordering for plugins within this class. A value of 1
- //indicates that this plugin wants to be as close to the bottom of the plugins
- //in this class as possible. A value of 100 means that this plugin wants to
- //be as close to being the topmost plugin in this class as possible. This value
- //is only used if none of the "exclusive" flags are set.
- end;
- LVM_Class_Attributes=_LVM_Class_Attributes;
- // The following enum specifies the interface types that LVM supports, and hence any plugin must support.
- _LVM_Interface_Types= (
- PM_Interface,
- 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.
- Java_Interface // The LVM GUI is written in Java.
- );
- LVM_Interface_Types=_LVM_Interface_Types;
- const
- MAXIMUM_LVM_INTERFACE_TYPES = 3;
- //* The following structures define what functions must be supported for each interface type.
- type
- PADDRESS=^ADDRESS;
- PCARDINAL32=^CARDINAL32;
- _LVM_OS2_Native_Support=record
- //void (* _System Create_and_Configure) ( CARDINAL32 ID, ADDRESS InputBuffer, CARDINAL32 InputBufferSize, ADDRESS * OutputBuffer, CARDINAL32 * OutputBufferSize, CARDINAL32 * Error_Code);
- Create_and_Configure: procedure(ID: CARDINAL32; InputBuffer: ADDRESS; InputBufferSize: CARDINAL32; OutputBuffer: PADDRESS; OutputBufferSize: PCARDINAL32; Error_Code: PCARDINAL32);
- //void (* _System Display_Status) ( ADDRESS Volume_Handle, CARDINAL32 * Error_Code );
- Display_Status: procedure(Volume_Handle: ADDRESS; Error_Code: PCARDINAL32 );
- //void (* _System Control_Panel) (ADDRESS Volume_Handle, CARDINAL32 * Error_Code );
- Control_Panel: procedure(Volume_Handle: ADDRESS; Error_Code: PCARDINAL32 );
- //void (* _System Help_Panel) (CARDINAL32 Help_Index, CARDINAL32 * Error_Code);
- Help_Panel: procedure(Help_Index: CARDINAL32; Error_Code: PCARDINAL32);
- end;
- LVM_OS2_Native_Support=_LVM_OS2_Native_Support;
- type
- _LVM_Interface_Support=record
- Interface_Supported: BOOLEAN;
- case longint of
- 0 : ( Java_Interface_Class : ^char );
- 1 : ( VIO_PM_Calls : LVM_OS2_Native_Support );
- end;
- LVM_Interface_Support=_LVM_Interface_Support;
- //* The following define the default help indicies which must be supported by the Help_Panel function. NOTE: Index
- //values from 0 to 100 are reserved by LVM. The Plugin may, for its own use, use any values above 100.
- const
- HELP_PLUGIN_DESCRIPTION = 0;
- // The following define the maximum length of the names which can be used to represent a feature in LVM. The
- //maximum name length for a feature is 30 characters plus the trailing NULL character. For command line parsing,
- //though, a shorter name is preferable! Thus, the "short" name for a feature will be limited to 10 characters
- //plus the trailing NULL character. The "short" name will be used for command line purposes, while the regular
- //name will be used by all other interfaces.
- const
- MAX_FEATURE_NAME_LENGTH = 31;
- MAX_FEATURE_SHORT_NAME_LENGTH = 11;
- MAX_OEM_INFO_LENGTH =255;
- // The following definitions are used to control and access the various "features" available through the LVM Engine, such as Drive Linking and BBR.
- type
- _Feature_ID_Data=record
- Name: Array[0..MAX_FEATURE_NAME_LENGTH-1] of char; // Feature Name, for use in menus and command line parsing.
- Short_Name: Array[0..MAX_FEATURE_SHORT_NAME_LENGTH-1] of char; // The name/code used to represent this feature during command line parsing.
- OEM_Info: Array[0..MAX_OEM_INFO_LENGTH-1] of char; // Name and copyright info. of the manufacturer, i.e. IBM, Vinca, etc.
- ID: CARDINAL32; // Numeric Feature ID.
- Major_Version_Number: CARDINAL32; // The version number of this feature.
- Minor_Version_Number: CARDINAL32; // The version number of this feature.
- LVM_Major_Version_Number: CARDINAL32; // The version of LVM that this feature was designed to work with.
- LVM_Minor_Version_Number: CARDINAL32; // The version of LVM that this feature was designed to work with.
- Preferred_Class: LVM_Classes; // The class from which this "feature" prefers to be chosen. Encryption can be performed
- //at the partition level or the volume level, and may therefore belong to both the
- //Partition_Class and the Volume_Class. However, it is preferrable for it to be used
- //on the volume level instead of at the partition level. Thus, its perferred class would
- //be the Volume_Class, but it would still be a member of both the Volume_Class and the
- //Partition_Class.
- ClassData: Array[0..MAXIMUM_LVM_CLASSES-1] of LVM_Class_Attributes; // The attributes for each of the LVM classes that this "feature" is in.
- 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.
- end;
- Feature_ID_Data=_Feature_ID_Data;
- // The following defines the TAG value used to identify an item of type Feature_ID_Data in a DLIST.
- const
- FEATURE_ID_DATA_TAG = 354385972;
- // The following are invariant for a disk drive.
- Type
- Drive_Control_Record = record
- Drive_Number: CARDINAL32; // OS/2 Drive Number for this drive.
- Drive_Size: CARDINAL32; // The total number of sectors on the drive.
- Drive_Serial_Number: DoubleWord; // The serial number assigned to this drive. For info. purposes only.
- Drive_Handle: ADDRESS; // Handle used for operations on the disk that this record corresponds to.
- Cylinder_Count: CARDINAL32; // The number of cylinders on the drive.
- Heads_Per_Cylinder: CARDINAL32; // The number of heads per cylinder for this drive.
- Sectors_Per_Track: CARDINAL32; // The number of sectors per track for this drive.
- Drive_Is_PRM: BOOLEAN; // Set to TRUE if this drive is a PRM.
- Reserved: Array[0..3-1] of BYTE; // Alignment.
- end;
- // The following structure is returned by the Get_Drive_Control_Data function.
- Drive_Control_Array=record
- Drive_Control_Data: ^Drive_Control_Record; // An array of drive control records.
- Count: CARDINAL32; // The number of entries in the array of drive control records.
- end;
- // The following structure defines the information that can be changed for a specific disk drive.
- Drive_Information_Record=record
- Total_Available_Sectors: CARDINAL32; // The number of sectors on the disk which are not currently assigned to a partition.
- Largest_Free_Block_Of_Sectors: CARDINAL32; // The number of sectors in the largest contiguous block of available sectors.
- Corrupt_Partition_Table: BOOLEAN; // If TRUE, then the partitioning information found on the drive is incorrect!
- Unusable: BOOLEAN; // If TRUE, the drive's MBR is not accessible and the drive can not be partitioned.
- IO_Error: BOOLEAN; // If TRUE, then the last I/O operation on this drive failed!
- 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).
- Drive_Name: Array[0..DISK_NAME_SIZE-1] of Char; // User assigned name for this disk drive.
- end;
- Partition_Information_Record=record
- Partition_Handle: ADDRESS; // The handle used to perform operations on this partition.
- Volume_Handle: ADDRESS; // If this partition is part of a volume, this will be the handle of
- //the volume. If this partition is NOT part of a volume, then this
- //handle will be 0.
- Drive_Handle: ADDRESS; // The handle for the drive this partition resides on.
- Partition_Serial_Number: DoubleWord; // The serial number assigned to this partition.
- Partition_Start: CARDINAL32; // The LBA of the first sector of the partition.
- True_Partition_Size: CARDINAL32; // The total number of sectors comprising the partition.
- Usable_Partition_Size: CARDINAL32; // The size of the partition as reported to the IFSM. This is the
- //size of the partition less any LVM overhead.
- Boot_Limit: CARDINAL32; // The maximum number of sectors from this block of free space that can be used to
- //create a bootable partition if you allocate from the beginning of the block of
- //free space.
- Spanned_Volume: BOOLEAN; // TRUE if this partition is part of a multi-partition volume.
- Primary_Partition: BOOLEAN; // True or False. Any non-zero value here indicates that
- //this partition is a primary partition. Zero here indicates
- //that this partition is a "logical drive" - i.e. it resides
- //inside of an extended partition.
- Active_Flag: BYTE; // 80 = Partition is marked as being active.
- // 0 = Partition is not active.
- OS_Flag: BYTE; // This field is from the partition table. It is known as the
- //OS flag, the Partition Type Field, Filesystem Type, and
- //various other names.
- //Values of interest
- //If this field is: (values are in hex)
- //07 = The partition is a compatibility partition formatted for use
- //with an installable filesystem, such as HPFS or JFS.
- //00 = Unformatted partition
- //01 = FAT12 filesystem is in use on this partition.
- //04 = FAT16 filesystem is in use on this partition.
- //0A = OS/2 Boot Manager Partition
- //35 = LVM partition
- //84 = OS/2 FAT16 partition which has been relabeled by Boot Manager to "Hide" it.
- Partition_Type: BYTE; // 0 = Free Space
- //1 = LVM Partition (Part of an LVM Volume.)
- //2 = Compatibility Partition
- //All other values are reserved for future use.
- Partition_Status: BYTE; // 0 = Free Space
- //1 = In Use - i.e. already assigned to a volume.
- //2 = Available - i.e. not currently assigned to a volume.
- On_Boot_Manager_Menu: BOOLEAN; // Set to TRUE if this partition is not part of a Volume yet is on the Boot Manager Menu.
- Reserved: BYTE; // Alignment.
- Volume_Drive_Letter: char; // The drive letter assigned to the volume that this partition is a part of.
- Drive_Name: Array[0..DISK_NAME_SIZE-1] of char; // User assigned name for this disk drive.
- 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.
- Partition_Name: Array[0..PARTITION_NAME_SIZE-1] of char; // The user assigned name for this partition.
- Volume_Name: Array[0..VOLUME_NAME_SIZE-1] of char; // If this partition is part of a volume, then this will be the
- //name of the volume that this partition is a part of. If this
- //record represents free space, then the Volume_Name will be
- //"FREE SPACE xx", where xx is a unique numeric ID generated by
- //LVM.DLL. Otherwise it will be an empty string.
- end;
- // The following defines are for use with the Partition_Type field in the Partition_Information_Record.
- const
- pt_FREE_SPACE_PARTITION = 0;
- pt_LVM_PARTITION = 1;
- pt_COMPATIBILITY_PARTITION = 2;
- // The following defines are for use with the Partition_Status field in the Partition_Information_Record.
- const
- PARTITION_IS_IN_USE = 1;
- PARTITION_IS_AVAILABLE = 2;
- PARTITION_IS_FREE_SPACE = 0;
- // The following structure is returned by various functions in the LVM Engine.
- type
- Partition_Information_Array=record
- Partition_Array: ^Partition_Information_Record; // An array of Partition_Information_Records.
- Count: CARDINAL32; // The number of entries in the Partition_Array.
- end;
- // The following items are invariant for a volume.
- type
- Volume_Control_Record=record
- Volume_Serial_Number: DoubleWord; // The serial number assigned to this volume.
- Volume_Handle: ADDRESS; // The handle used to perform operations on this volume.
- Compatibility_Volume: BOOLEAN; // TRUE indicates that this volume is compatible with older versions of OS/2.
- //FALSE indicates that this is an LVM specific volume and can not be used without OS2LVM.DMD.
- Device_Type: BYTE; // Indicates what type of device the Volume resides on:
- //0 = Hard Drive under LVM Control
- //1 = PRM under LVM Control
- //2 = CD-ROM
- //3 = Network drive
- //4 = Unknown device NOT under LVM Control
- Reserved: Array[0..2-1] of BYTE; // Alignment.
- end;
- // The following define the device types used in the Device_Type field of the Volume_Control_Record.
- const
- LVM_HARD_DRIVE = 0;
- LVM_PRM = 1;
- NON_LVM_CDROM = 2;
- NETWORK_DRIVE = 3;
- NON_LVM_DEVICE = 4;
- // The following structure is returned by the Get_Volume_Control_Data function.
- type
- Volume_Control_Array=record
- Volume_Control_Data: ^Volume_Control_Record; // An array of volume control records.
- Count: CARDINAL32; // The number of entries in the array of volume control records.
- end;
- // The following information about a volume can (and often does) vary.
- type
- Volume_Information_Record=record
- Volume_Size: CARDINAL32; // The number of sectors comprising the volume.
- Partition_Count: CARDINAL32; // The number of partitions which comprise this volume.
- Drive_Letter_Conflict: CARDINAL32; // 0 indicates that the drive letter preference for this volume is unique.
- //1 indicates that the drive letter preference for this volume
- //is not unique, but this volume got its preferred drive letter anyway.
- //2 indicates that the drive letter preference for this volume
- //is not unique, and this volume did NOT get its preferred drive letter.
- //4 indicates that this volume is currently "hidden" - i.e. it has
- //no drive letter preference at the current time.
- Compatibility_Volume: BOOLEAN; // TRUE if this is for a compatibility volume, FALSE otherwise.
- Bootable: BOOLEAN; // Set to TRUE if this volume appears on the Boot Manager menu, or if it is
- //a compatibility volume and its corresponding partition is the first active
- //primary partition on the first drive.
- Drive_Letter_Preference: char; // The drive letter that this volume desires to be.
- Current_Drive_Letter: char; // The drive letter currently used to access this volume. May be different than
- //Drive_Letter_Preference if there was a conflict ( i.e. Drive_Letter_Preference
- //is already in use by another volume ).
- Initial_Drive_Letter: char; // The drive letter assigned to this volume by the operating system when LVM was started.
- //This may be different from the Drive_Letter_Preference if there were conflicts, and
- //may be different from the Current_Drive_Letter. This will be 0x0 if the Volume did
- //not exist when the LVM Engine was opened (i.e. it was created during this LVM session).
- New_Volume: BOOLEAN; // Set to FALSE if this volume existed before the LVM Engine was opened. Set to
- //TRUE if this volume was created after the LVM Engine was opened.
- Status: BYTE; // 0 = None.
- //1 = Bootable
- //2 = Startable
- //3 = Installable.
- Reserved_1: BYTE;
- Volume_Name: Array[0..VOLUME_NAME_SIZE-1] of char; // The user assigned name for this volume.
- 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.
- end;
- // The following structure is used to return the feature information for the installed features, or the features on a volume.
- type
- Feature_Information_Array=record
- Count: CARDINAL32;
- Feature_Data: ^Feature_ID_Data;
- end;
- // The following structure defines an item on the Boot Manager Menu.
- type
- Boot_Manager_Menu_Item=record
- Handle: ADDRESS; // A Volume or Partition handle.
- Volume: BOOLEAN; // If TRUE, then Handle is the handle of a Volume. Otherwise, Handle is the handle of a partition.
- end;
- // The following structure is used to get a list of the items on the partition manager menu.
- type
- Boot_Manager_Menu=record
- Menu_Items: ^Boot_Manager_Menu_Item;
- Count: CARDINAL32;
- end;
- // The following structure is used to specify an LVM Feature when creating a volume. Since LVM Features may be part of
- //more than one LVM Class, the specific class to be used with the feature must also be specified.
- type
- LVM_Feature_Specification_Record=record
- Feature_ID: CARDINAL32; // The feature ID of the feature to use.
- Actual_Class: LVM_Classes; // The LVM Class (supported by the specified feature) to use.
- Init_Data: ADDRESS; // The address of a buffer containing initialization data for this feature.
- //NULL if there is no initialization data being provided for this feature.
- end;
- // The following structure is used with the Get_Child_Handles function.
- Type
- LVM_Handle_Array_Record=record
- Count: CARDINAL32;
- Handles: ^ADDRESS;
- end;
- // The following preprocessor directives define the operations that can be performed on a partition, volume, or a block of free space.
- // These definitions represent bits in a 32 bit value returned by the Get_Valid_Options function.
- const
- CREATE_PRIMARY_PARTITION = 1;
- CREATE_LOGICAL_DRIVE = 2;
- DELETEPARTITION = 4;
- SET_ACTIVE_PRIMARY = 8;
- SET_PARTITION_ACTIVE = $10;
- SET_PARTITION_INACTIVE = $20;
- SETSTARTABLE = $40;
- INSTALLBOOTMANAGER = $80;
- REMOVEBOOTMANAGER = $100;
- SET_BOOT_MANAGER_DEFAULTS = $200;
- ADD_TO_BOOT_MANAGER_MENU = $400;
- REMOVE_FROM_BOOT_MANAGER_MENU = $800;
- DELETEVOLUME = $1000;
- HIDEVOLUME = $2000;
- EXPANDVOLUME = $4000;
- SET_VOLUME_INSTALLABLE = $8000;
- ASSIGNDRIVELETTER = $10000;
- CAN_BOOT_PRIMARY = $20000; // If a primary is created from this block of free space, then it can be made bootable.
- 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.
- CAN_SET_NAME = $80000;
- SET_BOOT_MANAGER_STARTABLE = $100000;
- // The following enumeration defines the allocation strategies used by the Create_Partition function.
- type
- _Allocation_Algorithm =(
- Automatic, // Let LVM decide which block of free space to use to create the partition.
- Best_Fit, // Use the block of free space which is closest in size to the partition being created.
- First_Fit, // Use the first block of free space on the disk which is large enough to hold a partition of the specified size.
- Last_Fit, // Use the last block of free space on the disk which is large enough to hold a partition of the specified size.
- From_Largest, // Find the largest block of free space and allocate the partition from that block of free space.
- From_Smallest, // Find the smallest block of free space that can accommodate a partition of the size specified.
- All // Turn the specified drive or block of free space into a single partition.
- );
- Allocation_Algorithm=_Allocation_Algorithm;
- // Error codes returned by the LVM Engine.
- const
- LVM_ENGINE_NO_ERROR = 0;
- LVM_ENGINE_OUT_OF_MEMORY = 1;
- LVM_ENGINE_IO_ERROR = 2;
- LVM_ENGINE_BAD_HANDLE = 3;
- LVM_ENGINE_INTERNAL_ERROR = 4;
- LVM_ENGINE_ALREADY_OPEN = 5;
- LVM_ENGINE_NOT_OPEN = 6;
- LVM_ENGINE_NAME_TOO_BIG = 7;
- LVM_ENGINE_OPERATION_NOT_ALLOWED = 8;
- LVM_ENGINE_DRIVE_OPEN_FAILURE = 9;
- LVM_ENGINE_BAD_PARTITION = 10;
- LVM_ENGINE_CAN_NOT_MAKE_PRIMARY_PARTITION = 11;
- LVM_ENGINE_TOO_MANY_PRIMARY_PARTITIONS = 12;
- LVM_ENGINE_CAN_NOT_MAKE_LOGICAL_DRIVE = 13;
- LVM_ENGINE_REQUESTED_SIZE_TOO_BIG = 14;
- LVM_ENGINE_1024_CYLINDER_LIMIT = 15;
- LVM_ENGINE_PARTITION_ALIGNMENT_ERROR = 16;
- LVM_ENGINE_REQUESTED_SIZE_TOO_SMALL = 17;
- LVM_ENGINE_NOT_ENOUGH_FREE_SPACE = 18;
- LVM_ENGINE_BAD_ALLOCATION_ALGORITHM = 19;
- LVM_ENGINE_DUPLICATE_NAME = 20;
- LVM_ENGINE_BAD_NAME = 21;
- LVM_ENGINE_BAD_DRIVE_LETTER_PREFERENCE = 22;
- LVM_ENGINE_NO_DRIVES_FOUND = 23;
- LVM_ENGINE_WRONG_VOLUME_TYPE = 24;
- LVM_ENGINE_VOLUME_TOO_SMALL = 25;
- LVM_ENGINE_BOOT_MANAGER_ALREADY_INSTALLED = 26;
- LVM_ENGINE_BOOT_MANAGER_NOT_FOUND = 27;
- LVM_ENGINE_INVALID_PARAMETER = 28;
- LVM_ENGINE_BAD_FEATURE_SET = 29;
- LVM_ENGINE_TOO_MANY_PARTITIONS_SPECIFIED = 30;
- LVM_ENGINE_LVM_PARTITIONS_NOT_BOOTABLE = 31;
- LVM_ENGINE_PARTITION_ALREADY_IN_USE = 32;
- LVM_ENGINE_SELECTED_PARTITION_NOT_BOOTABLE = 33;
- LVM_ENGINE_VOLUME_NOT_FOUND = 34;
- LVM_ENGINE_DRIVE_NOT_FOUND = 35;
- LVM_ENGINE_PARTITION_NOT_FOUND = 36;
- LVM_ENGINE_TOO_MANY_FEATURES_ACTIVE = 37;
- LVM_ENGINE_PARTITION_TOO_SMALL = 38;
- LVM_ENGINE_MAX_PARTITIONS_ALREADY_IN_USE = 39;
- LVM_ENGINE_IO_REQUEST_OUT_OF_RANGE = 40;
- LVM_ENGINE_SPECIFIED_PARTITION_NOT_STARTABLE = 41;
- LVM_ENGINE_SELECTED_VOLUME_NOT_STARTABLE = 42;
- LVM_ENGINE_EXTENDFS_FAILED = 43;
- LVM_ENGINE_REBOOT_REQUIRED = 44;
- LVM_ENGINE_CAN_NOT_OPEN_LOG_FILE = 45;
- LVM_ENGINE_CAN_NOT_WRITE_TO_LOG_FILE = 46;
- LVM_ENGINE_REDISCOVER_FAILED = 47;
- LVM_ENGINE_INTERNAL_VERSION_FAILURE = 48;
- LVM_ENGINE_PLUGIN_OPERATION_INCOMPLETE = 49;
- LVM_ENGINE_BAD_FEATURE_ID = 50;
- LVM_ENGINE_NO_INIT_DATA = 51;
- LVM_ENGINE_NO_CONTEXT_DATA = 52;
- LVM_ENGINE_WRONG_CLASS_FOR_FEATURE = 53;
- LVM_ENGINE_INCOMPATIBLE_FEATURES_SELECTED = 54;
- LVM_ENGINE_NO_CHILDREN = 55;
- LVM_ENGINE_FEATURE_NOT_SUPPORTED_BY_INTERFACE= 56;
- LVM_ENGINE_NO_PARENT = 57;
- LVM_ENGINE_VOLUME_HAS_NOT_BEEN_COMMITTED_YET = 58;
- LVM_ENGINE_UNABLE_TO_REFERENCE_VOLUME = 59;
- LVM_ENGINE_PARSING_ERROR = 60;
- LVM_ENGINE_INTERNAL_FEATURE_ERROR = 61;
- LVM_ENGINE_VOLUME_NOT_CONVERTED = 62;
- // The following definitions are used for command line processing. As the command line is processed,
- //the command line is first broken up into tokens. Each token has a "characterization", which indicates
- //what the token is thought to be.
- type
- Token_Characterizations=(
- LVM_AcceptableCharsStr,
- LVM_All,
- LVM_BestFit,
- LVM_BootDOS,
- LVM_BootOS2,
- LVM_Bootable,
- LVM_CR,
- LVM_CRI,
- LVM_Compatibility,
- LVM_Drive,
- LVM_Existing,
- LVM_Expand,
- LVM_FS,
- LVM_FirstFit,
- LVM_Freespace,
- LVM_FromEnd,
- LVM_FromLargest,
- LVM_FromSmallest,
- LVM_FromStart,
- LVM_LVM,
- LVM_LastFit,
- LVM_Logical,
- LVM_New,
- LVM_NoBoot,
- LVM_NonBootable,
- LVM_NotBootable,
- LVM_Partition,
- LVM_Primary,
- LVM_RB,
- LVM_Size,
- LVM_Unusable,
- LVM_Unused,
- LVM_Volume,
- LVM_Volumes,
- LVM_Comma,
- LVM_Number,
- LVM_Colon,
- LVM_Space,
- LVM_Tab,
- LVM_MultiSpace,
- LVM_MultiTab,
- LVM_String,
- LVM_FileNameStr,
- LVM_SemiColon,
- LVM_Eof,
- LVM_Separator,
- LVM_Open_Paren, //* ( */
- LVM_Close_Paren, //* ) */
- LVM_Open_Bracket, //* [ */
- LVM_Close_Bracket, //* ] */
- LVM_Open_Brace, //* { */
- LVM_Close_Brace, //* } */
- LVM_EQ_Sign, //* = */
- LVM_Bootmgr,
- LVM_Create,
- LVM_Delete,
- LVM_DriveLetter,
- LVM_File,
- LVM_Hide,
- LVM_Install,
- LVM_NewMBR,
- LVM_Query,
- LVM_RediscoverPRM,
- LVM_SetName,
- LVM_SetStartable,
- LVM_SI,
- LVM_SlashSize,
- LVM_StartLog
- );
- type
- _LVM_Token=record
- TokenText: PChar; // The actual text of the token.
- TokenType: Token_Characterizations; // What the token is thought to be.
- Position: CARDINAL32; // The position of the first character of the token on the command line.
- end;
- LVM_Token=_LVM_Token;
- const
- LVM_TOKEN_TAG = 28387473;
- // Function Prototypes
- //***************************************************************************
- //
- // Functions relating to the LVM Engine itself
- //
- //***************************************************************************
- //****************************************************************************************************/
- //* */
- //* Function Name: Open_LVM_Engine */
- //* */
- //* Descriptive Name: Opens the LVM Engine and readies it for use. */
- //* */
- //* Input: BOOLEAN Ignore_CHS : If TRUE, then the LVM engine will not check the CHS values in the */
- //* MBR/EBR partition tables for validity. This is useful if there */
- //* are drive geometry problems, such as the drive was partitioned and */
- //* formatted with one geometry and then moved to a different machine */
- //* which uses a different geometry for the drive. This would cause */
- //* the starting and ending CHS values in the partition tables to */
- //* be inconsistent with the size and partition offset entries in the */
- //* partition tables. Setting Ignore_CHS to TRUE will disable the */
- //* LVM Engine's CHS consistency checks, thereby allowing the drive */
- //* to be partitioned. */
- //* CARDINAL32 * Error_Code - The address of a CARDINAL32 in which to store an error code */
- //* should an error occur. */
- //* */
- //* Output: *Error_Code will be 0 if this function completes successfully. If an error occurs, */
- //* *Error_Code will contain a non-zero error code. */
- //* */
- //* Error Handling: If this function aborts with an error, all memory allocated during the course */
- //* of this function will be released. Disk read errors will be reported to the */
- //* user via pop-up error messages. Disk read errors will only cause this */
- //* function to abort if none of the disk drives in the system could be */
- //* successfully read. */
- //* */
- //* Side Effects: The LVM Engine will be initialized. The partition tables for all OS2DASD */
- //* controlled disk drives will be read into memory. Memory will be allocated for */
- //* the data structures used by the LVM Engine. */
- //* */
- //* Notes: This is provided for programs that used LVM Version 1. This function assumes an */
- //* LVM_Interface_Type of VIO_Interface. */
- //* */
- //****************************************************************************************************/
- procedure Open_LVM_Engine(Ignore_CHS: BOOLEAN; Error_Code: PCARDINAL32); external 'lvm' name 'Open_LVM_Engine';
- //****************************************************************************************************/
- //* */
- //* Function Name: Open_LVM_Engine2 */
- //* */
- //* Descriptive Name: Opens the LVM Engine and readies it for use. */
- //* */
- //* Input: BOOLEAN Ignore_CHS : If TRUE, then the LVM engine will not check the CHS values in the */
- //* MBR/EBR partition tables for validity. This is useful if there */
- //* are drive geometry problems, such as the drive was partitioned and */
- //* formatted with one geometry and then moved to a different machine */
- //* which uses a different geometry for the drive. This would cause */
- //* the starting and ending CHS values in the partition tables to */
- //* be inconsistent with the size and partition offset entries in the */
- //* partition tables. Setting Ignore_CHS to TRUE will disable the */
- //* LVM Engine's CHS consistency checks, thereby allowing the drive */
- //* to be partitioned. */
- //* LVM_Interface_Types Interface_Type - Indicate the type of user interface being used: */
- //* PM_Interface, VIO_Interface, or Java_Interface. This lets the */
- //* LVM Engine know which interface support routines to call in any */
- //* plugin modules which may be loaded. */
- //* CARDINAL32 * Error_Code - The address of a CARDINAL32 in which to store an error code */
- //* should an error occur. */
- //* */
- //* Output: *Error_Code will be 0 if this function completes successfully. If an error occurs, */
- //* *Error_Code will contain a non-zero error code. */
- //* */
- //* Error Handling: If this function aborts with an error, all memory allocated during the course */
- //* of this function will be released. Disk read errors will be reported to the */
- //* user via pop-up error messages. Disk read errors will only cause this */
- //* function to abort if none of the disk drives in the system could be */
- //* successfully read. */
- //* */
- //* Side Effects: The LVM Engine will be initialized. The partition tables for all OS2DASD */
- //* controlled disk drives will be read into memory. Memory will be allocated for */
- //* the data structures used by the LVM Engine. */
- //* */
- //* Notes: New in LVM Version 2 */
- //* */
- //****************************************************************************************************/
- {$ifdef lvm2}
- procedure Open_LVM_Engine2(Ignore_CHS: BOOLEAN; Interface_Type: LVM_Interface_Types; Error_Code: PCARDINAL32); external 'lvm' name 'Open_LVM_Engine2';
- {$endif}
- //*********************************************************************/
- //* */
- //* Function Name: Commit_Changes */
- //* */
- //* Descriptive Name: Saves any changes made to the partitioning */
- //* information of the OS2DASD controlled disk */
- //* drives in the system. */
- //* */
- //* Input: CARDINAL32 * Error_Code - The address of a CARDINAL32 in */
- //* in which to store an error code */
- //* should an error occur. */
- //* */
- //* Output: The function return value will be TRUE if all of the */
- //* partitioning/volume changes made were successfully */
- //* written to disk. Also, *Error_Code will be 0 if no */
- //* errors occur. */
- //* */
- //* If an error occurs, then the furnction return value */
- //* will be FALSE and *Error_Code will contain a non-zero */
- //* error code. */
- //* */
- //* Error Handling: If an error occurs, the function return value */
- //* will be false and *Error_Code will be > 0. */
- //* */
- //* Disk read and write errors will be indicated by*/
- //* setting the IO_Error field of the */
- //* Drive_Information_Record to TRUE. Thus, if */
- //* the function return value is FALSE, and */
- //* *Error_Code indicates an I/O error, the caller */
- //* of this function should call the */
- //* Get_Drive_Status function on each drive to */
- //* determine which drives had I/O errors. */
- //* */
- //* If a read or write error occurs, then the */
- //* engine may not have been able to create a */
- //* partition or volume. Thus, the caller */
- //* may want to refresh all partition and volume */
- //* data to see what the engine was and was not */
- //* able to create. */
- //* */
- //* Side Effects: The partitioning information of the disk drives */
- //* in the system may be altered. */
- //* */
- //* Notes: None. */
- //* */
- //*********************************************************************/
- function Commit_Changes(Error_Code: PCARDINAL32): BOOLEAN; external 'lvm' name 'Commit_Changes';
- //*********************************************************************/
- //* */
- //* Function Name: Set_Java_Call_Back */
- //* */
- //* Descriptive Name: This function allows the calling Java program */
- //* to set the call back address. The call back */
- //* address is used when the LVM Engine or one of */
- //* its plug-ins, needs to run a Java class to */
- //* gather information from the user. */
- //* */
- //* Input: void ( * Execute_Java_Class) ... - The address of a */
- //* function that the LVM */
- //* engine may call when */
- //* it needs a Java class */
- //* to be executed. This */
- //* is only required if the*/
- //* user interface being */
- //* used is written in Java*/
- //* CARDINAL32 * Error_Code - The address of a CARDINAL32 in */
- //* in which to store an error code */
- //* should an error occur. */
- //* */
- //* Output: If the function completes successfully, then *Error_Code*/
- //* will be set to LVM_ENGINE_NO_ERROR. Otherwise, */
- //* *Error_Code will be set to a non-zero error code. */
- //* */
- //* Error Handling: If an error occurs, the function will abort and*/
- //* *Error_Code will be set to a non-zero error */
- //* code. */
- //* */
- //* Side Effects: The Java call back address is set to point to the*/
- //* specified function. Once the Java call back */
- //* address is set, LVM plug-ins which require the */
- //* Java call back will be enabled and can be used */
- //* during the creation of LVM Volumes. */
- //* */
- //* Notes: If a Java interface is in use (as specified on the */
- //* Open_LVM_Engine call), then this function must be called*/
- //* in order to enable those LVM plug-ins which require */
- //* initialization information during the creation of an */
- //* LVM Volume. If these plug-ins are not enabled, then */
- //* they will not be reported by the Get_Available_Features */
- //* API, nor can they be used or accessed by any other LVM */
- //* Engine APIs. Thus, this function should be called */
- //* immediately after the Open_LVM_Engine API is called. */
- //* */
- //*********************************************************************/
- {$ifdef lvm2}
- type
- TJavaExecProc=procedure(
- Class_Name: PChar;
- InputBuffer: ADDRESS;
- InputBufferSize: CARDINAL32;
- OutputBuffer: PADDRESS;
- OutputBufferSize,
- Error_Code: PCARDINAL32);
- procedure Set_Java_Call_Back(
- Execute_Java_Class: TJAvaExecProc;
- Error_Code: PCARDINAL32); external 'lvm' name 'Set_Java_Call_Back';
- {$endif}
- //*********************************************************************/
- //* */
- //* Function Name: Close_LVM_Engine */
- //* */
- //* Descriptive Name: Closes the LVM Engine and frees any memory */
- //* held by the LVM Engine. */
- //* */
- //* Input: None. */
- //* */
- //* Output: None. */
- //* */
- //* Error Handling: N/A */
- //* */
- //* Side Effects: Any memory held by the LVM Engine is released. */
- //* */
- //* Notes: None. */
- //* */
- //*********************************************************************/
- procedure Close_LVM_Engine; external 'lvm' name 'Close_LVM_Engine';
- //*********************************************************************/
- //*…