Programming with VixMntapi
At the top of your program, include vixMntapi.h along with any other header files you need. Structures and type definitions are declared in the include file, so you do not need to create them or allocate memory for them.
Call VixMntapi_Init() to initialize the library in your application. This function takes major and minor version number to account for future extensions. You can provide your own logging, warning, or panic functions to substitute for the default VixMntapi handlers, and custom library and temporary directories.
Call VixMntapi_OpenDiskSet() to open a set of virtual disks for mounting. Pass a set of disk handles obtained from the VixDiskLib_Open() call. The VixMntapi_OpenDiskSet() function also expects number of disks to open, an optional open mode, and a parameter to pass back the resulting disk-set handle.
File System Support
Windows file systems (FAT, FAT32, and NTFS) are supported. The vixMntapi library depends on the operating system for file system attributes such as compression, encryption, hidden, ACL, and alternate streams. If a vixMntapi-linked application runs on a virtual machine that supports these attributes, it supports them. The following volume types are supported: Simple, Spanned, Striped (RAID 0), and Mirrored (RAID 1). RAID 5 (parity striped) is not supported.
You must open a disk set read/write to obtain the OS information for dynamic volume types including LDM and LVM. If you cannot open a base disk read/write, create a child disk in front, and open it read/write. In a multi-boot setup, only the first entry #0 is opened.
The order of mounting is important. For instance, mount top-level directories before subdirectories, and drives with dependencies after drives that they depend on. Mount points are not enumerated, nor are they restored. When you mount one volume, the other volumes are not implicitly mounted also.
Read-Only Mount on Linux
The VixMntapi library can emulate mounting disks read-only, as in the Linux procedure below. A similar procedure, with different temporary filename, could be used on Windows.
To mount disks read-only
1
Open the base disk with VixDiskLib_Open(), passing the flag VIXDISKLIB_FLAG_OPEN_READ_ONLY.
2
Call VixDiskLib_CreateChild() to create a child of the base disk. VMware recommends creating a file such as /tmp/<uniqueName> using mkstemp() to formulate a unique name for the redo log.
3
Call VixDiskLib_Close() to close the base disk, which is no longer needed.
4
Now use VixMntapi_OpenDisks() as you normally would with diskSet[0] = /tmp/<uniqueName> and openFlags = 0 (meaning read/write).
This allows writing to the redo log (for journal reply and so forth) without affecting the base disk.
Software developers should inform customers that the mounted disk set seems writable, although the effect of changing files and altering directories is only temporary. The base disk is read-only.
To unmount read-only disks
1
Call VixMntapi_CloseDiskSet() to close the disk set.
2
Call VixDiskLib_Unlink() to remove the redo log, /tmp/<uniqueName>.
VMware Product Platforms
Applications written using this release of VixMntapi can manipulate virtual disks created with ESX and ESXi, VMware Server, VMware Fusion, VMware Player, VMware Workstation, and GSX Server.