manageiq-smartstate 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +4 -0
- data/.rspec_ci +4 -0
- data/.travis.yml +15 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +202 -0
- data/README.md +45 -0
- data/Rakefile +23 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/MiqContainerGroup/MiqContainerGroup.rb +31 -0
- data/lib/MiqVm/MiqLocalVm.rb +50 -0
- data/lib/MiqVm/MiqRhevmVm.rb +179 -0
- data/lib/MiqVm/MiqVm.rb +355 -0
- data/lib/MiqVm/miq_azure_vm.rb +96 -0
- data/lib/MiqVm/miq_scvmm_vm.rb +38 -0
- data/lib/MiqVm/test/camcorder_fleece_test.rb +60 -0
- data/lib/MiqVm/test/localVm.rb +45 -0
- data/lib/MiqVm/test/partitionAlignmentCheck.rb +76 -0
- data/lib/MiqVm/test/remoteVm.rb +65 -0
- data/lib/MiqVm/test/rhevmNfsTest.rb +62 -0
- data/lib/MiqVm/test/rhevmNfsTest2.rb +66 -0
- data/lib/MiqVm/test/rhevmTest.rb +70 -0
- data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackCommon.rb +107 -0
- data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackImage.rb +67 -0
- data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackInstance.rb +182 -0
- data/lib/Scvmm/miq_hyperv_disk.rb +273 -0
- data/lib/Scvmm/miq_scvmm_parse_powershell.rb +75 -0
- data/lib/Scvmm/miq_scvmm_vm_ssa_info.rb +135 -0
- data/lib/Scvmm/test/miq_hyperv_disk_test.rb +33 -0
- data/lib/Scvmm/test/miq_scvmm_vm_ssa_info_test.rb +41 -0
- data/lib/VmLocalDiskAccess/test/localCfg.rb +97 -0
- data/lib/VolumeManager/LVM/logical_volume.rb +75 -0
- data/lib/VolumeManager/LVM/lv_segment.rb +43 -0
- data/lib/VolumeManager/LVM/lvm2disk.rb +158 -0
- data/lib/VolumeManager/LVM/parser.rb +138 -0
- data/lib/VolumeManager/LVM/physical_volume.rb +19 -0
- data/lib/VolumeManager/LVM/scanner.rb +156 -0
- data/lib/VolumeManager/LVM/thin/btree.rb +83 -0
- data/lib/VolumeManager/LVM/thin/constants.rb +86 -0
- data/lib/VolumeManager/LVM/thin/data_map.rb +44 -0
- data/lib/VolumeManager/LVM/thin/mapping_tree.rb +19 -0
- data/lib/VolumeManager/LVM/thin/space_maps.rb +58 -0
- data/lib/VolumeManager/LVM/thin/superblock.rb +136 -0
- data/lib/VolumeManager/LVM/thin.rb +6 -0
- data/lib/VolumeManager/LVM/volume_group.rb +97 -0
- data/lib/VolumeManager/LVM.rb +8 -0
- data/lib/VolumeManager/MiqLdm.rb +546 -0
- data/lib/VolumeManager/MiqLvm.rb +17 -0
- data/lib/VolumeManager/MiqNativeVolumeManager.rb +150 -0
- data/lib/VolumeManager/MiqVolumeManager.rb +277 -0
- data/lib/VolumeManager/VolMgrPlatformSupport.rb +18 -0
- data/lib/VolumeManager/VolMgrPlatformSupportLinux.rb +77 -0
- data/lib/VolumeManager/VolMgrPlatformSupportWin.rb +17 -0
- data/lib/VolumeManager/test/blockDevTest.rb +40 -0
- data/lib/VolumeManager/test/ldm.rb +97 -0
- data/lib/blackbox/VmBlackBox.rb +103 -0
- data/lib/blackbox/xmlStorage.rb +180 -0
- data/lib/db/MiqBdb/MiqBdb.rb +309 -0
- data/lib/db/MiqBdb/MiqBdbBtree.rb +219 -0
- data/lib/db/MiqBdb/MiqBdbHash.rb +199 -0
- data/lib/db/MiqBdb/MiqBdbPage.rb +159 -0
- data/lib/db/MiqBdb/MiqBdbUtil.rb +18 -0
- data/lib/db/MiqSqlite/MiqSqlite3.rb +330 -0
- data/lib/db/MiqSqlite/MiqSqlite3Cell.rb +167 -0
- data/lib/db/MiqSqlite/MiqSqlite3Page.rb +151 -0
- data/lib/db/MiqSqlite/MiqSqlite3Table.rb +124 -0
- data/lib/db/MiqSqlite/MiqSqlite3Util.rb +32 -0
- data/lib/disk/DiskProbe.rb +68 -0
- data/lib/disk/MiqDisk.rb +317 -0
- data/lib/disk/camcorder_test.rb +90 -0
- data/lib/disk/dos_mbr.img +0 -0
- data/lib/disk/modules/AzureBlobDisk.rb +101 -0
- data/lib/disk/modules/LocalDevMod.rb +47 -0
- data/lib/disk/modules/LocalDevProbe.rb +6 -0
- data/lib/disk/modules/MSCommon.rb +352 -0
- data/lib/disk/modules/MSVSDiffDisk.rb +91 -0
- data/lib/disk/modules/MSVSDiskProbe.rb +61 -0
- data/lib/disk/modules/MSVSDynamicDisk.rb +42 -0
- data/lib/disk/modules/MSVSFixedDisk.rb +45 -0
- data/lib/disk/modules/MiqLargeFile.rb +63 -0
- data/lib/disk/modules/MiqLargeFileWin32.rb +107 -0
- data/lib/disk/modules/QcowDisk.rb +692 -0
- data/lib/disk/modules/QcowDiskProbe.rb +34 -0
- data/lib/disk/modules/RawBlockIO.rb +116 -0
- data/lib/disk/modules/RawDisk.rb +45 -0
- data/lib/disk/modules/RawDiskProbe.rb +7 -0
- data/lib/disk/modules/RhevmDescriptor.rb +167 -0
- data/lib/disk/modules/RhevmDiskProbe.rb +52 -0
- data/lib/disk/modules/VMWareCowdDisk.rb +207 -0
- data/lib/disk/modules/VMWareDescriptor.rb +214 -0
- data/lib/disk/modules/VMWareDiskProbe.rb +74 -0
- data/lib/disk/modules/VMWareSparseDisk.rb +189 -0
- data/lib/disk/modules/VhdxDisk.rb +625 -0
- data/lib/disk/modules/VhdxDiskProbe.rb +46 -0
- data/lib/disk/modules/VixDiskMod.rb +54 -0
- data/lib/disk/modules/VixDiskProbe.rb +6 -0
- data/lib/disk/modules/miq_disk_cache.rb +135 -0
- data/lib/disk/modules/miq_dummy_disk.rb +41 -0
- data/lib/disk/modules/vhdx_bat_entry.rb +10 -0
- data/lib/disk/test.rb +66 -0
- data/lib/fs/MetakitFS/MetakitFS.rb +530 -0
- data/lib/fs/MetakitFS/test/Makefile +14 -0
- data/lib/fs/MetakitFS/test/MkCollectFiles.rb +165 -0
- data/lib/fs/MetakitFS/test/MkSelectFiles.rb +30 -0
- data/lib/fs/MetakitFS/test/collect_files.yaml +70 -0
- data/lib/fs/MetakitFS/test/init.rb +3 -0
- data/lib/fs/MetakitFS/test/mk2vmdk.rb +64 -0
- data/lib/fs/MetakitFS/test/mk4test.c +92 -0
- data/lib/fs/MetakitFS/test/mkFsTest.rb +113 -0
- data/lib/fs/MetakitFS/test/proto.rb +97 -0
- data/lib/fs/MiqFS/FsProbe.rb +39 -0
- data/lib/fs/MiqFS/MiqFS.rb +515 -0
- data/lib/fs/MiqFS/modules/AUFSProbe.rb +26 -0
- data/lib/fs/MiqFS/modules/Ext3.rb +305 -0
- data/lib/fs/MiqFS/modules/Ext3Probe.rb +25 -0
- data/lib/fs/MiqFS/modules/Ext4.rb +304 -0
- data/lib/fs/MiqFS/modules/Ext4Probe.rb +25 -0
- data/lib/fs/MiqFS/modules/Fat32.rb +318 -0
- data/lib/fs/MiqFS/modules/Fat32Probe.rb +30 -0
- data/lib/fs/MiqFS/modules/HFSProbe.rb +18 -0
- data/lib/fs/MiqFS/modules/Iso9660.rb +293 -0
- data/lib/fs/MiqFS/modules/Iso9660Probe.rb +18 -0
- data/lib/fs/MiqFS/modules/LocalFS.rb +105 -0
- data/lib/fs/MiqFS/modules/NTFS.rb +287 -0
- data/lib/fs/MiqFS/modules/NTFSProbe.rb +21 -0
- data/lib/fs/MiqFS/modules/NativeFS.rb +155 -0
- data/lib/fs/MiqFS/modules/ReFSProbe.rb +17 -0
- data/lib/fs/MiqFS/modules/RealFS.rb +79 -0
- data/lib/fs/MiqFS/modules/RealFSProbe.rb +6 -0
- data/lib/fs/MiqFS/modules/Reiser4Probe.rb +18 -0
- data/lib/fs/MiqFS/modules/ReiserFS.rb +315 -0
- data/lib/fs/MiqFS/modules/ReiserFSProbe.rb +42 -0
- data/lib/fs/MiqFS/modules/UnionFSProbe.rb +18 -0
- data/lib/fs/MiqFS/modules/WebDAV.rb +127 -0
- data/lib/fs/MiqFS/modules/WebDAVFile.rb +68 -0
- data/lib/fs/MiqFS/modules/XFS.rb +300 -0
- data/lib/fs/MiqFS/modules/XFSProbe.rb +26 -0
- data/lib/fs/MiqFS/modules/ZFSProbe.rb +18 -0
- data/lib/fs/MiqFS/test.rb +59 -0
- data/lib/fs/MiqFsUtil.rb +383 -0
- data/lib/fs/MiqMountManager.rb +209 -0
- data/lib/fs/MiqNativeMountManager.rb +101 -0
- data/lib/fs/MountManagerProbe.rb +29 -0
- data/lib/fs/ReiserFS/block.rb +209 -0
- data/lib/fs/ReiserFS/directory.rb +136 -0
- data/lib/fs/ReiserFS/directory_entry.rb +140 -0
- data/lib/fs/ReiserFS/file_data.rb +111 -0
- data/lib/fs/ReiserFS/superblock.rb +140 -0
- data/lib/fs/ReiserFS/utils.rb +95 -0
- data/lib/fs/VimDatastoreFS/VimDatastoreFS.rb +192 -0
- data/lib/fs/ext3/alloc_bitmap.rb +38 -0
- data/lib/fs/ext3/block_pointers_path.rb +130 -0
- data/lib/fs/ext3/directory.rb +51 -0
- data/lib/fs/ext3/directory_entry.rb +67 -0
- data/lib/fs/ext3/ex_attrib_header.rb +14 -0
- data/lib/fs/ext3/ex_attrib_name.rb +23 -0
- data/lib/fs/ext3/file_data.rb +130 -0
- data/lib/fs/ext3/group_descriptor_entry.rb +65 -0
- data/lib/fs/ext3/group_descriptor_table.rb +54 -0
- data/lib/fs/ext3/hash_tree_entry.rb +18 -0
- data/lib/fs/ext3/hash_tree_header.rb +15 -0
- data/lib/fs/ext3/inode.rb +228 -0
- data/lib/fs/ext3/posix_acl_entry.rb +29 -0
- data/lib/fs/ext3/posix_acl_header.rb +11 -0
- data/lib/fs/ext3/superblock.rb +406 -0
- data/lib/fs/ext3/test/tc_Ext3BlockPointersPath.rb +74 -0
- data/lib/fs/ext4/alloc_bitmap.rb +38 -0
- data/lib/fs/ext4/directory.rb +87 -0
- data/lib/fs/ext4/directory_entry.rb +77 -0
- data/lib/fs/ext4/ex_attrib_header.rb +14 -0
- data/lib/fs/ext4/ex_attrib_name.rb +23 -0
- data/lib/fs/ext4/extent.rb +35 -0
- data/lib/fs/ext4/extent_header.rb +40 -0
- data/lib/fs/ext4/extent_index.rb +33 -0
- data/lib/fs/ext4/group_descriptor_entry.rb +69 -0
- data/lib/fs/ext4/group_descriptor_table.rb +54 -0
- data/lib/fs/ext4/hash_tree_entry.rb +58 -0
- data/lib/fs/ext4/hash_tree_header.rb +35 -0
- data/lib/fs/ext4/inode.rb +465 -0
- data/lib/fs/ext4/posix_acl_entry.rb +29 -0
- data/lib/fs/ext4/posix_acl_header.rb +11 -0
- data/lib/fs/ext4/superblock.rb +412 -0
- data/lib/fs/fat32/boot_sect.rb +379 -0
- data/lib/fs/fat32/directory.rb +222 -0
- data/lib/fs/fat32/directory_entry.rb +540 -0
- data/lib/fs/fat32/file_data.rb +128 -0
- data/lib/fs/iso9660/boot_sector.rb +170 -0
- data/lib/fs/iso9660/directory.rb +90 -0
- data/lib/fs/iso9660/directory_entry.rb +147 -0
- data/lib/fs/iso9660/file_data.rb +78 -0
- data/lib/fs/iso9660/rock_ridge.rb +329 -0
- data/lib/fs/iso9660/util.rb +57 -0
- data/lib/fs/modules/LinuxMount.rb +300 -0
- data/lib/fs/modules/LinuxMountProbe.rb +29 -0
- data/lib/fs/modules/WinMount.rb +97 -0
- data/lib/fs/modules/WinMountProbe.rb +24 -0
- data/lib/fs/ntfs/attrib_attribute_list.rb +131 -0
- data/lib/fs/ntfs/attrib_bitmap.rb +26 -0
- data/lib/fs/ntfs/attrib_data.rb +74 -0
- data/lib/fs/ntfs/attrib_file_name.rb +110 -0
- data/lib/fs/ntfs/attrib_header.rb +194 -0
- data/lib/fs/ntfs/attrib_index_allocation.rb +19 -0
- data/lib/fs/ntfs/attrib_index_root.rb +247 -0
- data/lib/fs/ntfs/attrib_object_id.rb +40 -0
- data/lib/fs/ntfs/attrib_standard_information.rb +107 -0
- data/lib/fs/ntfs/attrib_type.rb +49 -0
- data/lib/fs/ntfs/attrib_volume_information.rb +53 -0
- data/lib/fs/ntfs/attrib_volume_name.rb +31 -0
- data/lib/fs/ntfs/boot_sect.rb +253 -0
- data/lib/fs/ntfs/data_run.rb +358 -0
- data/lib/fs/ntfs/directory_index_node.rb +114 -0
- data/lib/fs/ntfs/index_node_header.rb +69 -0
- data/lib/fs/ntfs/index_record_header.rb +85 -0
- data/lib/fs/ntfs/mft_entry.rb +288 -0
- data/lib/fs/ntfs/utils.rb +43 -0
- data/lib/fs/test/camcorder_fs_test.rb +108 -0
- data/lib/fs/test/collect_files_direct.yaml +22 -0
- data/lib/fs/test/collect_files_in.yaml +24 -0
- data/lib/fs/test/collect_files_in_nc.yaml +22 -0
- data/lib/fs/test/collect_files_out.yaml +6 -0
- data/lib/fs/test/collect_files_rm.yaml +6 -0
- data/lib/fs/test/copyTest.rb +126 -0
- data/lib/fs/test/fsTest.rb +87 -0
- data/lib/fs/test/updateTest.rb +184 -0
- data/lib/fs/xfs/allocation_group.rb +160 -0
- data/lib/fs/xfs/bmap_btree_block.rb +125 -0
- data/lib/fs/xfs/bmap_btree_record.rb +80 -0
- data/lib/fs/xfs/bmap_btree_root_node.rb +72 -0
- data/lib/fs/xfs/directory.rb +133 -0
- data/lib/fs/xfs/directory2_data_header.rb +27 -0
- data/lib/fs/xfs/directory3_data_header.rb +34 -0
- data/lib/fs/xfs/directory_block_tail.rb +22 -0
- data/lib/fs/xfs/directory_data_header.rb +46 -0
- data/lib/fs/xfs/directory_entry.rb +106 -0
- data/lib/fs/xfs/inode.rb +532 -0
- data/lib/fs/xfs/inode_map.rb +100 -0
- data/lib/fs/xfs/short_form_directory_entry.rb +91 -0
- data/lib/fs/xfs/short_form_header.rb +44 -0
- data/lib/fs/xfs/superblock.rb +556 -0
- data/lib/lib/tasks/azure.rake +52 -0
- data/lib/manageiq/smartstate/version.rb +5 -0
- data/lib/manageiq/smartstate.rb +7 -0
- data/lib/manageiq-smartstate.rb +1 -0
- data/lib/metadata/MIQExtract/MIQExtract.rb +297 -0
- data/lib/metadata/MIQExtract/test/extractTest.rb +41 -0
- data/lib/metadata/MIQExtract/test/full_extract_test.rb +68 -0
- data/lib/metadata/ScanProfile/HostScanItem.rb +4 -0
- data/lib/metadata/ScanProfile/HostScanProfile.rb +4 -0
- data/lib/metadata/ScanProfile/HostScanProfiles.rb +41 -0
- data/lib/metadata/ScanProfile/ScanItemBase.rb +63 -0
- data/lib/metadata/ScanProfile/ScanProfileBase.rb +51 -0
- data/lib/metadata/ScanProfile/ScanProfilesBase.rb +60 -0
- data/lib/metadata/ScanProfile/VmScanItem.rb +4 -0
- data/lib/metadata/ScanProfile/VmScanProfile.rb +4 -0
- data/lib/metadata/ScanProfile/VmScanProfiles.rb +38 -0
- data/lib/metadata/ScanProfile/modules/HostScanItemFile.rb +51 -0
- data/lib/metadata/ScanProfile/modules/HostScanItemNteventlog.rb +84 -0
- data/lib/metadata/ScanProfile/modules/VmScanItemFile.rb +39 -0
- data/lib/metadata/ScanProfile/modules/VmScanItemNteventlog.rb +34 -0
- data/lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb +64 -0
- data/lib/metadata/VMMount/VMMount.rb +81 -0
- data/lib/metadata/VMMount/VMPlatformMount.rb +18 -0
- data/lib/metadata/VMMount/VMPlatformMountLinux.rb +75 -0
- data/lib/metadata/VMMount/VMPlatformMountWin.rb +13 -0
- data/lib/metadata/VmConfig/GetNativeCfg.rb +45 -0
- data/lib/metadata/VmConfig/VmConfig.rb +947 -0
- data/lib/metadata/VmConfig/cfgConfig.rb +45 -0
- data/lib/metadata/VmConfig/ovfConfig.rb +99 -0
- data/lib/metadata/VmConfig/test/GetVMwareCfgTest.rb +40 -0
- data/lib/metadata/VmConfig/vmcConfig.rb +116 -0
- data/lib/metadata/VmConfig/vmtxConfig.rb +4 -0
- data/lib/metadata/VmConfig/vmxConfig.rb +162 -0
- data/lib/metadata/VmConfig/xmlConfig.rb +79 -0
- data/lib/metadata/VmConfig/xmlMsHyperVConfig.rb +41 -0
- data/lib/metadata/linux/InitProcHash.rb +632 -0
- data/lib/metadata/linux/LinuxInitProcs.rb +142 -0
- data/lib/metadata/linux/LinuxOSInfo.rb +237 -0
- data/lib/metadata/linux/LinuxPackages.rb +209 -0
- data/lib/metadata/linux/LinuxSystemd.rb +130 -0
- data/lib/metadata/linux/LinuxUsers.rb +289 -0
- data/lib/metadata/linux/LinuxUtils.rb +197 -0
- data/lib/metadata/linux/MiqConaryPackages.rb +41 -0
- data/lib/metadata/linux/MiqRpmPackages.rb +160 -0
- data/lib/metadata/linux/test/Name +0 -0
- data/lib/metadata/linux/test/Packages +0 -0
- data/lib/metadata/linux/test/rpoTest.rb +5 -0
- data/lib/metadata/linux/test/tc_LinuxUtils.rb +4157 -0
- data/lib/metadata/util/event_log_filter.rb +61 -0
- data/lib/metadata/util/md5deep.rb +280 -0
- data/lib/metadata/util/win32/Win32Accounts.rb +764 -0
- data/lib/metadata/util/win32/Win32EventLog.rb +743 -0
- data/lib/metadata/util/win32/Win32Services.rb +86 -0
- data/lib/metadata/util/win32/Win32Software.rb +326 -0
- data/lib/metadata/util/win32/Win32System.rb +333 -0
- data/lib/metadata/util/win32/boot_info_win.rb +59 -0
- data/lib/metadata/util/win32/fleece_hives.rb +220 -0
- data/lib/metadata/util/win32/ms-registry.rb +650 -0
- data/lib/metadata/util/win32/peheader.rb +868 -0
- data/lib/metadata/util/win32/remote-registry.rb +142 -0
- data/lib/metadata/util/win32/system_path_win.rb +103 -0
- data/lib/metadata/util/win32/versioninfo.rb +17 -0
- data/manageiq-smartstate.gemspec +35 -0
- metadata +486 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'disk/modules/MSCommon'
|
2
|
+
|
3
|
+
module MSVSDynamicDisk
|
4
|
+
def d_init
|
5
|
+
self.diskType = "MSVS Dynamic"
|
6
|
+
self.blockSize = MSCommon::SECTOR_LENGTH
|
7
|
+
if dInfo.mountMode.nil? || dInfo.mountMode == "r"
|
8
|
+
dInfo.mountMode = "r"
|
9
|
+
fileMode = "r"
|
10
|
+
elsif dInfo.mountMode == "rw"
|
11
|
+
fileMode = "r+"
|
12
|
+
else
|
13
|
+
raise "Unrecognized mountMode: #{dInfo.mountMode}"
|
14
|
+
end
|
15
|
+
@ms_disk_file = if dInfo.hyperv_connection
|
16
|
+
MSCommon.connect_to_hyperv(dInfo)
|
17
|
+
else
|
18
|
+
MiqLargeFile.open(dInfo.fileName, fileMode)
|
19
|
+
end
|
20
|
+
MSCommon.d_init_common(dInfo, @ms_disk_file)
|
21
|
+
end
|
22
|
+
|
23
|
+
def getBase
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
def d_read(pos, len)
|
28
|
+
MSCommon.d_read_common(pos, len)
|
29
|
+
end
|
30
|
+
|
31
|
+
def d_write(pos, buf, len)
|
32
|
+
MSCommon.d_write_common(pos, buf, len)
|
33
|
+
end
|
34
|
+
|
35
|
+
def d_close
|
36
|
+
@ms_disk_file.close
|
37
|
+
end
|
38
|
+
|
39
|
+
def d_size
|
40
|
+
MSCommon.d_size_common
|
41
|
+
end
|
42
|
+
end # module
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'disk/modules/MiqLargeFile'
|
2
|
+
|
3
|
+
module MSVSFixedDisk
|
4
|
+
def d_init
|
5
|
+
@diskType = "MSVSFixed"
|
6
|
+
@blockSize = 512
|
7
|
+
|
8
|
+
if dInfo.mountMode.nil? || dInfo.mountMode == "r"
|
9
|
+
dInfo.mountMode = "r"
|
10
|
+
fileMode = "r"
|
11
|
+
elsif dInfo.mountMode == "rw"
|
12
|
+
fileMode = "r+"
|
13
|
+
else
|
14
|
+
raise "Unrecognized mountMode: #{dInfo.mountMode}"
|
15
|
+
end
|
16
|
+
|
17
|
+
if dInfo.hyperv_connection
|
18
|
+
@ms_flat_disk_file = MSCommon.connect_to_hyperv(dInfo)
|
19
|
+
else
|
20
|
+
@ms_flat_disk_file = MiqLargeFile.open(dInfo.fileName, fileMode)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def d_read(pos, len)
|
25
|
+
@ms_flat_disk_file.seek(pos, IO::SEEK_SET)
|
26
|
+
@ms_flat_disk_file.read(len)
|
27
|
+
end
|
28
|
+
|
29
|
+
def getBase
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def d_write(pos, buf, len)
|
34
|
+
@ms_flat_disk_file.seek(pos, IO::SEEK_SET)
|
35
|
+
@ms_flat_disk_file.write(buf, len)
|
36
|
+
end
|
37
|
+
|
38
|
+
def d_close
|
39
|
+
@ms_flat_disk_file.close
|
40
|
+
end
|
41
|
+
|
42
|
+
def d_size
|
43
|
+
File.size(dInfo.fileName)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'sys-uname'
|
2
|
+
require 'util/miq-system'
|
3
|
+
|
4
|
+
if Sys::Platform::IMPL == :linux
|
5
|
+
if MiqSystem.arch == :x86_64
|
6
|
+
require 'linux_block_device'
|
7
|
+
require 'disk/modules/RawBlockIO'
|
8
|
+
end
|
9
|
+
elsif Sys::Platform::OS == :windows
|
10
|
+
require 'disk/modules/MiqLargeFileWin32'
|
11
|
+
end
|
12
|
+
|
13
|
+
module MiqLargeFile
|
14
|
+
def self.open(file_name, flags)
|
15
|
+
case Sys::Platform::OS
|
16
|
+
when :windows
|
17
|
+
return(MiqLargeFileWin32.new(file_name, flags))
|
18
|
+
when :unix
|
19
|
+
if Sys::Platform::IMPL == :linux
|
20
|
+
return(RawBlockIO.new(file_name, flags)) if MiqLargeFileStat.new(file_name).blockdev?
|
21
|
+
end
|
22
|
+
return(MiqLargeFileOther.new(file_name, flags))
|
23
|
+
else
|
24
|
+
return(MiqLargeFileOther.new(file_name, flags))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.size(file_name)
|
29
|
+
case Sys::Platform::OS
|
30
|
+
when :windows
|
31
|
+
# The win32/file require is needed to support +2GB file sizes
|
32
|
+
require 'win32/file'
|
33
|
+
File.size(file_name)
|
34
|
+
else
|
35
|
+
f = open(file_name, "r")
|
36
|
+
s = f.size
|
37
|
+
f.close
|
38
|
+
return s
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# For camcorder interposition.
|
43
|
+
class MiqLargeFileStat
|
44
|
+
def initialize(file_name)
|
45
|
+
@file_name = file_name
|
46
|
+
end
|
47
|
+
|
48
|
+
def blockdev?
|
49
|
+
File.stat(@file_name).blockdev?
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class MiqLargeFileOther < File
|
54
|
+
def write(buf, _len)
|
55
|
+
super(buf)
|
56
|
+
end
|
57
|
+
|
58
|
+
def size
|
59
|
+
return stat.size unless stat.blockdev?
|
60
|
+
LinuxBlockDevice.size(fileno)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'memory_buffer'
|
2
|
+
require 'Win32API'
|
3
|
+
|
4
|
+
class MiqLargeFileWin32
|
5
|
+
# Access specifiers.
|
6
|
+
GENERIC_READ = 0x80000000
|
7
|
+
GENERIC_WRITE = 0x40000000
|
8
|
+
|
9
|
+
# Share specifiers.
|
10
|
+
FILE_SHARE_READ = 0x00000001
|
11
|
+
FILE_SHARE_WRITE = 0x00000002
|
12
|
+
|
13
|
+
# Creation disposition specifiers.
|
14
|
+
OPEN_EXISTING = 3
|
15
|
+
|
16
|
+
# Seek origin.
|
17
|
+
FILE_BEGIN = 0
|
18
|
+
FILE_CURRENT = 1
|
19
|
+
FILE_END = 2
|
20
|
+
|
21
|
+
# Misc.
|
22
|
+
INVALID_HANDLE_VALUE = -1
|
23
|
+
|
24
|
+
# API.
|
25
|
+
@@createFile = Win32API.new('kernel32', 'CreateFileA', 'PLLLLLL', 'L')
|
26
|
+
@@setFilePointerEx = Win32API.new('kernel32', 'SetFilePointerEx', 'LLLPL', 'L')
|
27
|
+
@@readFile = Win32API.new('kernel32', 'ReadFile', 'LPLPL', 'L')
|
28
|
+
@@writeFile = Win32API.new('kernel32', 'WriteFile', 'LPLPL', 'L')
|
29
|
+
@@closeHandle = Win32API.new('kernel32', 'CloseHandle', 'L', 'L')
|
30
|
+
@@getFileSize = Win32API.new('kernel32', 'GetFileSizeEx', 'LP', 'L')
|
31
|
+
@@getLastError = Win32API.new('kernel32', 'GetLastError', nil, 'L')
|
32
|
+
|
33
|
+
# Default constructor.
|
34
|
+
def initialize(file, access = "r")
|
35
|
+
accessOptions = 0
|
36
|
+
accessOptions |= GENERIC_READ if access.include?("r")
|
37
|
+
accessOptions |= GENERIC_WRITE if access.include?("+")
|
38
|
+
@hFile = @@createFile.call(file, accessOptions, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0)
|
39
|
+
raise "Couldn't open file #{file}" if @hFile == INVALID_HANDLE_VALUE
|
40
|
+
$log.debug("MiqLargeFile<#{object_id}> Opening #{file}, handle 0x#{'%08x' % @hFile}") if $log
|
41
|
+
end
|
42
|
+
|
43
|
+
# Alternative initialization.
|
44
|
+
def self.open(file, access = "r")
|
45
|
+
initialize(file, access)
|
46
|
+
end
|
47
|
+
|
48
|
+
def size
|
49
|
+
siz = MemoryBuffer.create_quad
|
50
|
+
err = @@getFileSize.call(@hFile, siz)
|
51
|
+
siz.unpack('Q')[0]
|
52
|
+
end
|
53
|
+
|
54
|
+
def seek(offset, whence)
|
55
|
+
method = case whence
|
56
|
+
when IO::SEEK_SET then FILE_BEGIN
|
57
|
+
when IO::SEEK_CUR then FILE_CURRENT
|
58
|
+
when IO::SEEK_END then FILE_END
|
59
|
+
else raise "Invalid seek method: #{whence}"
|
60
|
+
end
|
61
|
+
offHi, offLo = offset.divmod(4294967296) # 2 ** 32
|
62
|
+
new_pos = MemoryBuffer.create_quad
|
63
|
+
res = @@setFilePointerEx.call(@hFile, offLo, offHi, new_pos, method)
|
64
|
+
if res == 0
|
65
|
+
last_error = @@getLastError.call
|
66
|
+
raise "SetFilePointerEx failed - Offset:[#{offset}] method:[#{whence}] Handle:[0x#{'%08x' % @hFile}] GetLastErrorNum:[#{last_error}]"
|
67
|
+
end
|
68
|
+
new_pos = new_pos.unpack('Q')[0]
|
69
|
+
new_pos
|
70
|
+
end
|
71
|
+
|
72
|
+
def read(bytes)
|
73
|
+
# puts "#{getFilePos}, #{bytes}" if $track_pos
|
74
|
+
buf = MemoryBuffer.create(bytes)
|
75
|
+
bytesRead = MemoryBuffer.create_long
|
76
|
+
res = @@readFile.call(@hFile, buf, bytes, bytesRead, 0)
|
77
|
+
bytesRead = bytesRead.unpack('L')[0]
|
78
|
+
if bytesRead == 0 && bytes != 0 || res == 0
|
79
|
+
last_error = @@getLastError.call
|
80
|
+
raise "Read from disk file failed - result:[#{res}] bytesRead:[#{bytesRead}] expected:[#{bytes}] file pointer:[#{getFilePos}] file size:[#{size}] Handle:[0x#{'%08x' % @hFile}] GetLastErrorNum:[#{last_error}]."
|
81
|
+
end
|
82
|
+
buf = buf[0...bytesRead] if bytesRead != bytes
|
83
|
+
buf
|
84
|
+
end
|
85
|
+
|
86
|
+
def write(buf, len)
|
87
|
+
# NOTE: len must be a double word.
|
88
|
+
bytesWritten = MemoryBuffer.create_long
|
89
|
+
res = @@writeFile.call(@hFile, buf, len, bytesWritten, 0)
|
90
|
+
raise "WriteFile failed" if res == 0
|
91
|
+
bytesWritten = bytesWritten.unpack('L')[0]
|
92
|
+
raise "Not all data written" if bytesWritten != len
|
93
|
+
bytesWritten
|
94
|
+
end
|
95
|
+
|
96
|
+
def close
|
97
|
+
$log.debug("MiqLargeFile<#{object_id}> Closing handle 0x#{'%08x' % @hFile}") if $log
|
98
|
+
h = @hFile
|
99
|
+
res = @@closeHandle.call(@hFile)
|
100
|
+
@hFile = INVALID_HANDLE_VALUE if res != 0
|
101
|
+
return res, h
|
102
|
+
end
|
103
|
+
|
104
|
+
def getFilePos
|
105
|
+
seek(0, IO::SEEK_CUR)
|
106
|
+
end
|
107
|
+
end
|