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,315 @@
|
|
1
|
+
# ReiserFS stuff.
|
2
|
+
require 'fs/ReiserFS/superblock'
|
3
|
+
require 'fs/ReiserFS/directory'
|
4
|
+
require 'fs/ReiserFS/directory_entry'
|
5
|
+
require 'fs/ReiserFS/file_data'
|
6
|
+
|
7
|
+
require 'rufus/lru'
|
8
|
+
|
9
|
+
# Reiser file system interface to MiqFS.
|
10
|
+
module ReiserFS
|
11
|
+
# Default directory cache size.
|
12
|
+
DEF_CACHE_SIZE = 50
|
13
|
+
|
14
|
+
# Members (these become members of an MiqFS instance).
|
15
|
+
attr_accessor :superblock, :rootDir, :entry_cache, :dir_cache, :cache_hits
|
16
|
+
|
17
|
+
# Top level file object.
|
18
|
+
class FileObject
|
19
|
+
include ReiserFS
|
20
|
+
attr_reader :path, :de, :data, :miqfs
|
21
|
+
# NOTE: miqfs will always be an MiqFS instance.
|
22
|
+
|
23
|
+
# fs_fileOpen passes 'self' into .. er, 'this'.
|
24
|
+
def initialize(path, miqfs)
|
25
|
+
@path = path
|
26
|
+
@miqfs = miqfs
|
27
|
+
end
|
28
|
+
|
29
|
+
def open(mode = "r")
|
30
|
+
# ReiserFS module methods use miqfs instance accessors to touch @boot_sector.
|
31
|
+
@mode = mode.downcase
|
32
|
+
@de = ifs_getFile(@path, @miqfs)
|
33
|
+
raise "File is directory: '#{@path}'" if @de && @de.isDir?
|
34
|
+
|
35
|
+
if mode.include?("r")
|
36
|
+
raise "File not found: '#{@path}'" if @de.nil?
|
37
|
+
@data = FileData.new(@de, @miqfs.superblock)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def aTime
|
42
|
+
@de.aTime
|
43
|
+
end
|
44
|
+
|
45
|
+
def cTime
|
46
|
+
@de.cTime
|
47
|
+
end
|
48
|
+
|
49
|
+
def mTime
|
50
|
+
@de.mTime
|
51
|
+
end
|
52
|
+
|
53
|
+
def length
|
54
|
+
@de.length
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# File system interface.
|
59
|
+
def fs_init
|
60
|
+
self.fsType = "ReiserFS"
|
61
|
+
|
62
|
+
# Initialize bs & read root dir.
|
63
|
+
@dobj.seek(0, IO::SEEK_SET)
|
64
|
+
self.superblock = Superblock.new(@dobj)
|
65
|
+
self.rootDir = Directory.new(superblock)
|
66
|
+
self.entry_cache = LruHash.new(DEF_CACHE_SIZE)
|
67
|
+
self.dir_cache = LruHash.new(DEF_CACHE_SIZE)
|
68
|
+
self.cache_hits = 0
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns free space on file system in bytes.
|
72
|
+
def fs_freeBytes
|
73
|
+
@superblock.freeBytes
|
74
|
+
end
|
75
|
+
|
76
|
+
#
|
77
|
+
# Directory instance methods.
|
78
|
+
#
|
79
|
+
|
80
|
+
# Returns String array of all names, sans path.
|
81
|
+
def fs_dirEntries(p)
|
82
|
+
# Get path directory.
|
83
|
+
dir = ifs_getDir(p)
|
84
|
+
return nil if dir.nil?
|
85
|
+
dir.globNames
|
86
|
+
end
|
87
|
+
|
88
|
+
# Make a directory. Parent must exist.
|
89
|
+
def fs_dirMkdir(_p)
|
90
|
+
raise "Write functionality is not yet supported on ReiserFS."
|
91
|
+
end
|
92
|
+
|
93
|
+
# Remove a directory.
|
94
|
+
def fs_dirRmdir(_p)
|
95
|
+
raise "Write functionality is not yet supported on ReiserFS."
|
96
|
+
end
|
97
|
+
|
98
|
+
#
|
99
|
+
# File instance methods.
|
100
|
+
#
|
101
|
+
|
102
|
+
# Returns true if name exists, false if not.
|
103
|
+
def fs_fileExists?(p)
|
104
|
+
de = ifs_getFile(p)
|
105
|
+
return false if de.nil?
|
106
|
+
true
|
107
|
+
end
|
108
|
+
|
109
|
+
# Returns true if name is a regular file.
|
110
|
+
def fs_fileFile?(p)
|
111
|
+
de = ifs_getFile(p)
|
112
|
+
return false if de.nil?
|
113
|
+
de.isFile?
|
114
|
+
end
|
115
|
+
|
116
|
+
# Returns true if name is a directory.
|
117
|
+
def fs_fileDirectory?(p)
|
118
|
+
de = ifs_getFile(p)
|
119
|
+
return false if de.nil?
|
120
|
+
de.isDir?
|
121
|
+
end
|
122
|
+
|
123
|
+
# Returns size in bytes.
|
124
|
+
def fs_fileSize(p)
|
125
|
+
de = ifs_getFile(p)
|
126
|
+
return nil if de.nil?
|
127
|
+
de.length
|
128
|
+
end
|
129
|
+
|
130
|
+
# Delete file.
|
131
|
+
def fs_fileDelete(_p)
|
132
|
+
raise "Write functionality is not yet supported on ReiserFS."
|
133
|
+
end
|
134
|
+
|
135
|
+
# Returns Ruby Time object.
|
136
|
+
def fs_fileAtime(p)
|
137
|
+
de = ifs_getFile(p)
|
138
|
+
return nil if de.nil?
|
139
|
+
de.aTime
|
140
|
+
end
|
141
|
+
|
142
|
+
# Returns Ruby Time object.
|
143
|
+
def fs_fileCtime(p)
|
144
|
+
de = ifs_getFile(p)
|
145
|
+
return nil if de.nil?
|
146
|
+
de.cTime
|
147
|
+
end
|
148
|
+
|
149
|
+
# Returns Ruby Time object.
|
150
|
+
def fs_fileMtime(p)
|
151
|
+
de = ifs_getFile(p)
|
152
|
+
return nil if de.nil?
|
153
|
+
de.mTime
|
154
|
+
end
|
155
|
+
|
156
|
+
# Return true if p is a path to a symbolic link.
|
157
|
+
def fs_isSymLink?(p)
|
158
|
+
de = ifs_getFile(p)
|
159
|
+
return false if de.nil?
|
160
|
+
de.isSymLink?
|
161
|
+
end
|
162
|
+
# In these, fobj is a FileObject.
|
163
|
+
|
164
|
+
def fs_fileSize_obj(fobj)
|
165
|
+
fobj.length
|
166
|
+
end
|
167
|
+
|
168
|
+
# Returns a Ruby Time object.
|
169
|
+
def fs_fileAtime_obj(fobj)
|
170
|
+
fobj.aTime
|
171
|
+
end
|
172
|
+
|
173
|
+
# Returns a Ruby Time object.
|
174
|
+
def fs_fileCtime_obj(fobj)
|
175
|
+
fobj.cTime
|
176
|
+
end
|
177
|
+
|
178
|
+
# Returns a Ruby Time obect.
|
179
|
+
def fs_fileMtime_obj(fobj)
|
180
|
+
fobj.mTime
|
181
|
+
end
|
182
|
+
|
183
|
+
# New FileObject instance.
|
184
|
+
# NOTE: FileObject must have access to Ext3 members.
|
185
|
+
# This is kind of like a 'skip this' thing. Ext3 methods
|
186
|
+
# use stuff owned by MiqFS, so this is necessary.
|
187
|
+
def fs_fileOpen(p, mode = "r")
|
188
|
+
fobj = FileObject.new(p, self)
|
189
|
+
fobj.open(mode)
|
190
|
+
fobj
|
191
|
+
end
|
192
|
+
|
193
|
+
# Returns current file position.
|
194
|
+
def fs_fileSeek(fobj, offset, whence)
|
195
|
+
fobj.data.seek(offset, whence)
|
196
|
+
end
|
197
|
+
|
198
|
+
# Returns a Ruby String object.
|
199
|
+
def fs_fileRead(fobj, len)
|
200
|
+
fobj.data.read(len)
|
201
|
+
end
|
202
|
+
|
203
|
+
def fs_fileWrite(_fobj, _buf, _len)
|
204
|
+
raise "Write functionality is not yet supported on ReiserFS."
|
205
|
+
# fobj.data.write(buf, len)
|
206
|
+
end
|
207
|
+
|
208
|
+
# Write changes & destroy.
|
209
|
+
def fs_fileClose(_fobj)
|
210
|
+
# TODO: unrem when write is supported.
|
211
|
+
# fobj.data.close
|
212
|
+
fobj = nil
|
213
|
+
end
|
214
|
+
|
215
|
+
# IFS members: internal file system.
|
216
|
+
|
217
|
+
# Return a DirectoryEntry for a given file or nil if not exist.
|
218
|
+
def ifs_getFile(p, miqfs = nil)
|
219
|
+
# If this is being called from a FileObject instance, then MiqFS owns contained instance members.
|
220
|
+
# If this is being called from an Ext3 module method, then self owns contained instance members.
|
221
|
+
miqfs = self if miqfs.nil?
|
222
|
+
|
223
|
+
# Preprocess path.
|
224
|
+
p = unnormalizePath(p)
|
225
|
+
dir, fname = File.split(p)
|
226
|
+
# Fix for FB#835: if fname == root then fname needs to be "."
|
227
|
+
fname = "." if fname == "/" || fname == "\\"
|
228
|
+
|
229
|
+
# Check for this file in the cache.
|
230
|
+
cache_name = "#{dir == '/' ? '' : dir}/#{fname}"
|
231
|
+
if miqfs.entry_cache.key?(cache_name)
|
232
|
+
miqfs.cache_hits += 1
|
233
|
+
return miqfs.entry_cache[cache_name]
|
234
|
+
end
|
235
|
+
|
236
|
+
# Look for file in dir, but don't error if it doesn't exist.
|
237
|
+
# NOTE: if p is a directory that's ok, find it.
|
238
|
+
begin
|
239
|
+
dirObj = ifs_getDir(dir, miqfs)
|
240
|
+
dirEnt = dirObj.nil? ? nil : dirObj.findEntry(fname)
|
241
|
+
rescue RuntimeError
|
242
|
+
dirEnt = nil
|
243
|
+
end
|
244
|
+
|
245
|
+
miqfs.entry_cache[cache_name] = dirEnt
|
246
|
+
end
|
247
|
+
|
248
|
+
# Create a directory entry.
|
249
|
+
def ifs_putFile(p, miqfs = nil)
|
250
|
+
raise "Write functionality is not yet supported on ReiserFS."
|
251
|
+
|
252
|
+
# Commented out for now to avoid unreachable code
|
253
|
+
#
|
254
|
+
# # If this is being called from a FileObject instance, then MiqFS owns contained instance members.
|
255
|
+
# # If this is being called from an ReiserFS module method, then self owns contained instance members.
|
256
|
+
# miqfs = self if miqfs.nil?
|
257
|
+
|
258
|
+
# # Preprocess path.
|
259
|
+
# p = unnormalizePath(p)
|
260
|
+
# dir, fil = File.split(p)
|
261
|
+
|
262
|
+
# # Parent directory must exist.
|
263
|
+
# dirObj = ifs_getDir(dir, miqfs)
|
264
|
+
# return nil if dir.nil?
|
265
|
+
# dirObj.createFile(fil)
|
266
|
+
end
|
267
|
+
|
268
|
+
# Return a Directory object for a path.
|
269
|
+
# Raise error if path doesn't exist.
|
270
|
+
def ifs_getDir(p, miqfs = nil)
|
271
|
+
# If this is being called from a FileObject instance, then MiqFS owns contained instance members.
|
272
|
+
# If this is being called from an ReiserFS module method, then self owns contained instance members.
|
273
|
+
miqfs = self if miqfs.nil?
|
274
|
+
|
275
|
+
# Wack leading drive.
|
276
|
+
p = unnormalizePath(p)
|
277
|
+
|
278
|
+
# Get an array of directory names, kill off the first (it's always empty).
|
279
|
+
names = p.split(/[\\\/]/)
|
280
|
+
names.shift
|
281
|
+
|
282
|
+
dir = ifs_getDirR(names, miqfs)
|
283
|
+
raise "Directory '#{p}' not found" if dir.nil?
|
284
|
+
dir
|
285
|
+
end
|
286
|
+
|
287
|
+
# Return Directory recursively for given directory or nil if not exist.
|
288
|
+
def ifs_getDirR(names, miqfs)
|
289
|
+
return miqfs.rootDir if names.empty?
|
290
|
+
|
291
|
+
# Check for this path in the cache.
|
292
|
+
fname = names.join('/')
|
293
|
+
if miqfs.dir_cache.key?(fname)
|
294
|
+
miqfs.cache_hits += 1
|
295
|
+
return miqfs.dir_cache[fname]
|
296
|
+
end
|
297
|
+
|
298
|
+
name = names.pop
|
299
|
+
pdir = ifs_getDirR(names, miqfs)
|
300
|
+
return nil if pdir.nil?
|
301
|
+
|
302
|
+
key = pdir.findKey(name)
|
303
|
+
return nil if key.nil?
|
304
|
+
|
305
|
+
dir = Directory.new(miqfs.superblock, key)
|
306
|
+
return nil if dir.nil?
|
307
|
+
|
308
|
+
miqfs.dir_cache[fname] = dir
|
309
|
+
end
|
310
|
+
|
311
|
+
# Wack leading drive leter & colon.
|
312
|
+
def unnormalizePath(p)
|
313
|
+
p[1] == 58 ? p[2, p.size] : p
|
314
|
+
end
|
315
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module ReiserFSProbe
|
2
|
+
REISERFS_DISK_OFFSET_NEW = 64 * 1024
|
3
|
+
REISERFS_DISK_OFFSET_OLD = 8 * 1024
|
4
|
+
|
5
|
+
REISERFS_SUPER_SIZE = 204
|
6
|
+
|
7
|
+
REISERFS_MAGIC_OFFSET = 52
|
8
|
+
REISERFS_MAGIC_SIZE = 10
|
9
|
+
|
10
|
+
REISERFS_MAGIC1 = "ReIsErFs"
|
11
|
+
REISERFS_MAGIC2 = "ReIsEr2Fs"
|
12
|
+
REISERFS_MAGIC3 = "ReIsEr3Fs"
|
13
|
+
|
14
|
+
def self.probe(dobj)
|
15
|
+
return false unless dobj.kind_of?(MiqDisk)
|
16
|
+
|
17
|
+
return true if ReiserFSProbe.isMagic?(ReiserFSProbe.getMagic(dobj, REISERFS_DISK_OFFSET_NEW))
|
18
|
+
return true if ReiserFSProbe.isMagic?(ReiserFSProbe.getMagic(dobj, REISERFS_DISK_OFFSET_OLD))
|
19
|
+
|
20
|
+
# No ReiserFS.
|
21
|
+
false
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.getMagic(dobj, offset)
|
25
|
+
# Assume ReiserFS - read superblock at desired offset.
|
26
|
+
dobj.seek(offset) # new disk start offset.
|
27
|
+
sb = dobj.read(REISERFS_SUPER_SIZE)
|
28
|
+
|
29
|
+
return nil if sb.nil?
|
30
|
+
return nil if sb.size < (REISERFS_MAGIC_OFFSET + REISERFS_MAGIC_SIZE - 1)
|
31
|
+
|
32
|
+
# Check magic at offset 52 for accepted ReiserFS identifiers.
|
33
|
+
magic = sb[REISERFS_MAGIC_OFFSET, REISERFS_MAGIC_SIZE].strip
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.isMagic?(magic)
|
37
|
+
return true if magic == REISERFS_MAGIC1
|
38
|
+
return true if magic == REISERFS_MAGIC2
|
39
|
+
return true if magic == REISERFS_MAGIC3
|
40
|
+
false
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module UnionFSProbe
|
2
|
+
UNIONFS_SUPER_OFFSET = 1024
|
3
|
+
UNIONFS_MAGIC_OFFSET = 52
|
4
|
+
UNIONFS_MAGIC_SIZE = 4
|
5
|
+
UNIONFS_MAGIC = 0xf15f083d
|
6
|
+
|
7
|
+
def self.probe(dobj)
|
8
|
+
return false unless dobj.kind_of?(MiqDisk)
|
9
|
+
|
10
|
+
# Assume UnionFS - read magic at offset.
|
11
|
+
dobj.seek(UNIONFS_SUPER_OFFSET + UNIONFS_MAGIC_OFFSET)
|
12
|
+
magic = dobj.read(UNIONFS_MAGIC_SIZE).unpack('L')
|
13
|
+
raise "UnionFS is Not Supported" if magic == UNIONFS_MAGIC
|
14
|
+
|
15
|
+
# No UnionFS.
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
|
4
|
+
require 'fs/MiqFS/modules/WebDAVFile'
|
5
|
+
|
6
|
+
module WebDAV
|
7
|
+
attr_reader :guestOS
|
8
|
+
|
9
|
+
def fs_init
|
10
|
+
@fsType = "WebDAV"
|
11
|
+
@guestOS = @dobj.guest_os
|
12
|
+
|
13
|
+
@uri = URI(@dobj.uri.to_s)
|
14
|
+
@headers = @dobj.headers || {}
|
15
|
+
|
16
|
+
@connection = Net::HTTP.start(
|
17
|
+
@uri.host,
|
18
|
+
@uri.port,
|
19
|
+
@dobj.http_options
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def fs_unmount
|
24
|
+
@connection.finish
|
25
|
+
end
|
26
|
+
|
27
|
+
def freeBytes
|
28
|
+
0
|
29
|
+
end
|
30
|
+
|
31
|
+
def fs_dirEntries(_path)
|
32
|
+
raise NotImplementedError
|
33
|
+
end
|
34
|
+
|
35
|
+
def fs_fileExists?(path)
|
36
|
+
response = WebDAVFile.head_response(@connection, remote_uri(path), @headers)
|
37
|
+
case response
|
38
|
+
when Net::HTTPOK
|
39
|
+
return true
|
40
|
+
when Net::HTTPNotFound
|
41
|
+
return false
|
42
|
+
else
|
43
|
+
raise Errno::EINVAL
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def fs_fileDirectory?(path)
|
48
|
+
# TODO: implement proper check for being a directory
|
49
|
+
path += '/' unless path.end_with?('/')
|
50
|
+
fs_fileExists?(path)
|
51
|
+
end
|
52
|
+
|
53
|
+
def fs_fileFile?(_path)
|
54
|
+
raise NotImplementedError
|
55
|
+
end
|
56
|
+
|
57
|
+
def fs_fileSize(path)
|
58
|
+
WebDAVFile.file_size(remote_uri(path))
|
59
|
+
end
|
60
|
+
|
61
|
+
def fs_fileSize_obj(fobj)
|
62
|
+
fobj.size
|
63
|
+
end
|
64
|
+
|
65
|
+
def fs_fileAtime(_path)
|
66
|
+
raise NotImplementedError
|
67
|
+
end
|
68
|
+
|
69
|
+
def fs_fileCtime(_path)
|
70
|
+
raise NotImplementedError
|
71
|
+
end
|
72
|
+
|
73
|
+
def fs_fileMtime(_path)
|
74
|
+
raise NotImplementedError
|
75
|
+
end
|
76
|
+
|
77
|
+
def fs_fileAtime_obj(_fobj)
|
78
|
+
raise NotImplementedError
|
79
|
+
end
|
80
|
+
|
81
|
+
def fs_fileCtime_obj(_fobj)
|
82
|
+
raise NotImplementedError
|
83
|
+
end
|
84
|
+
|
85
|
+
def fs_fileMtime_obj(_fobj)
|
86
|
+
raise NotImplementedError
|
87
|
+
end
|
88
|
+
|
89
|
+
def fs_fileOpen(path, mode = "r")
|
90
|
+
raise Errno::EACCES unless mode == 'r'
|
91
|
+
WebDAVFile.new(remote_uri(path), @dobj.http_options, @headers)
|
92
|
+
end
|
93
|
+
|
94
|
+
def fs_fileSeek(fobj, offset, whence)
|
95
|
+
fobj.seek(offset, whence)
|
96
|
+
end
|
97
|
+
|
98
|
+
def fs_fileRead(fobj, len)
|
99
|
+
fobj.read(len)
|
100
|
+
end
|
101
|
+
|
102
|
+
def fs_fileClose(fobj)
|
103
|
+
fobj.close
|
104
|
+
end
|
105
|
+
|
106
|
+
def fs_fileWrite(_fobj, _buf, _len)
|
107
|
+
raise Errno::EACCES
|
108
|
+
end
|
109
|
+
|
110
|
+
def fs_dirMkdir(_path)
|
111
|
+
raise Errno::EACCES
|
112
|
+
end
|
113
|
+
|
114
|
+
def dirRmdir(_path)
|
115
|
+
raise Errno::EACCES
|
116
|
+
end
|
117
|
+
|
118
|
+
def fs_fileDelete(_path)
|
119
|
+
raise Errno::EACCES
|
120
|
+
end
|
121
|
+
|
122
|
+
private
|
123
|
+
|
124
|
+
def remote_uri(path)
|
125
|
+
@uri.merge(@uri.path + path)
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
class WebDAVFile
|
4
|
+
def initialize(uri, http_options, headers)
|
5
|
+
@uri = uri
|
6
|
+
@headers = headers
|
7
|
+
@offset = 0
|
8
|
+
@connection = Net::HTTP.start(
|
9
|
+
@uri.host,
|
10
|
+
@uri.port,
|
11
|
+
http_options
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def seek(offset, whence)
|
16
|
+
case whence
|
17
|
+
when IO::SEEK_SET
|
18
|
+
@offset = offset
|
19
|
+
when IO::SEEK_CUR
|
20
|
+
@offset += offset
|
21
|
+
else
|
22
|
+
raise NotImplementedError
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def read(length)
|
27
|
+
@next_offset = @offset + length
|
28
|
+
|
29
|
+
request = Net::HTTP::Get.new(@uri, @headers)
|
30
|
+
request.set_range(@offset, @next_offset)
|
31
|
+
|
32
|
+
response = @connection.request(request)
|
33
|
+
|
34
|
+
case response
|
35
|
+
when Net::HTTPOK
|
36
|
+
# In this case (server not supporting ranges) the communication
|
37
|
+
# is highly inefficient.
|
38
|
+
data = response.body[@offset..@next_offset]
|
39
|
+
when Net::HTTPPartialContent
|
40
|
+
data = response.body
|
41
|
+
else
|
42
|
+
raise Errno::ENOENT
|
43
|
+
end
|
44
|
+
|
45
|
+
@offset = @next_offset
|
46
|
+
data
|
47
|
+
end
|
48
|
+
|
49
|
+
def size
|
50
|
+
self.class.file_size(@connection, @uri, @headers)
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.head_response(connection, uri, headers)
|
54
|
+
request = Net::HTTP::Head.new(uri, headers)
|
55
|
+
connection.request(request)
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.file_size(connection, uri, headers)
|
59
|
+
response = head_response(connection, uri, headers)
|
60
|
+
raise Errno::ENOENT unless response.kind_of?(Net::HTTPOK)
|
61
|
+
raise Errno::EINVAL if response["content-length"].nil?
|
62
|
+
response["content-length"].to_i
|
63
|
+
end
|
64
|
+
|
65
|
+
def close
|
66
|
+
@connection.finish
|
67
|
+
end
|
68
|
+
end
|