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,100 @@
|
|
1
|
+
require 'fs/xfs/inode'
|
2
|
+
|
3
|
+
module XFS
|
4
|
+
# ////////////////////////////////////////////////////////////////////////////
|
5
|
+
# // Class.
|
6
|
+
|
7
|
+
class InodeMap
|
8
|
+
attr_reader :inode_blkno, :inode_length, :inode_boffset
|
9
|
+
|
10
|
+
def valid_inode_size?(sb)
|
11
|
+
if (@inode_blkno + @inode_length) > sb.fsb_to_bb(sb.block_count)
|
12
|
+
$log.error "XFS::InodeMap - Inode #{@inode_blkno} too large for filesystem" if $log
|
13
|
+
raise "XFS::InodeMap - Inode #{@inode_blkno} too large for filesystem"
|
14
|
+
end
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
def valid_inode_number?(inode, sb)
|
19
|
+
if (@agno >= sb.sb['ag_count']) ||
|
20
|
+
(@agbno >= sb.sb['ag_blocks']) ||
|
21
|
+
sb.agino_to_ino(@agno, @agino) != inode
|
22
|
+
$log.error "XFS::InodeMap - Bad Inode number #{inode} for agno #{@agno} agcount #{sb.sb['ag_count']}, agbno #{@agbno}, agblocks #{sb.sb['ag_blocks']}, agino #{@agino}, agino_to_ino #{sb.agino_to_ino(@agno, @agino)}" if $log
|
23
|
+
raise "XFS::InodeMap - Bad Inode number #{inode}"
|
24
|
+
end
|
25
|
+
true
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(inode, sb)
|
29
|
+
#
|
30
|
+
# Split up the inode number into its parts
|
31
|
+
#
|
32
|
+
@inode_number = inode
|
33
|
+
@agno = sb.ino_to_agno(inode)
|
34
|
+
@agino = sb.ino_to_agino(inode)
|
35
|
+
@agbno = sb.agino_to_agbno(@agino)
|
36
|
+
|
37
|
+
valid_inode_number?(inode, sb) || return
|
38
|
+
#
|
39
|
+
# If the inode cluster size is the same as the blocksize or
|
40
|
+
# smaller we get to the block by simple arithmetic
|
41
|
+
#
|
42
|
+
blocks_per_cluster = sb.icluster_size_fsb
|
43
|
+
@inode_length = sb.fsb_to_bb(blocks_per_cluster)
|
44
|
+
if blocks_per_cluster == 1
|
45
|
+
offset = sb.ino_to_offset(inode)
|
46
|
+
@inode_blkno = sb.agbno_to_real_block(@agno, @agbno)
|
47
|
+
@inode_boffset = offset << sb['inode_size_log']
|
48
|
+
return
|
49
|
+
elsif sb.inode_align_mask
|
50
|
+
#
|
51
|
+
# If the inode chunks are aligned then use simple math to
|
52
|
+
# find the location. Otherwise we have to do a btree
|
53
|
+
# lookup to find the location.
|
54
|
+
#
|
55
|
+
offset_agbno = @agbno & (sb.inode_align_mask - 1)
|
56
|
+
chunk_agbno = @agbno - offset_agbno
|
57
|
+
else
|
58
|
+
start_ino = imap_lookup(@agno, @agino)
|
59
|
+
chunk_agbno = sb.agino_to_agbno(start_ino)
|
60
|
+
offset_agbno = @agbno - chunk_agbno
|
61
|
+
end
|
62
|
+
|
63
|
+
@cluster_agbno = chunk_agbno + (offset_agbno / blocks_per_cluster) * blocks_per_cluster
|
64
|
+
offset = (@agbno - @cluster_agbno) * sb.sb['inodes_per_blk'] + sb.ino_to_offset(inode)
|
65
|
+
@inode_blkno = sb.agbno_to_real_block(@agno, @cluster_agbno)
|
66
|
+
@inode_boffset = offset << sb.sb['inode_size_log']
|
67
|
+
valid_inode_size?(sb) || return
|
68
|
+
end # initialize
|
69
|
+
|
70
|
+
def imap_lookup(agno, agino)
|
71
|
+
ag = get_ag(agno)
|
72
|
+
cursor = InodeBtreeCursor.new(@sb, ag.agi, agno, XFS_BTNUM_INO)
|
73
|
+
cursor.block_ptr = ag.agblock
|
74
|
+
error = inobt_lookup(cursor, agino, XFS_LOOKUP_LE)
|
75
|
+
raise "XFS::Superblock.imap_lookup: #{error}" if error
|
76
|
+
inode_rec = inode_btree_record(cursor)
|
77
|
+
if inode_rec.nil?
|
78
|
+
raise "XFS::Superblock.imap_lookup: Error #{cursor.error} getting InodeBtreeRecord for inode #{agino}"
|
79
|
+
end
|
80
|
+
if inode_rec.start_ino > agino ||
|
81
|
+
inode_rec.start_ino + @ialloc_inos <= agino
|
82
|
+
raise "XFS::Superblock.imap_lookup: InodeBtreeRecord does not contain required inode #{agino}"
|
83
|
+
end
|
84
|
+
inode_rec.start_ino
|
85
|
+
end # imap_lookup
|
86
|
+
|
87
|
+
def dump
|
88
|
+
out = "\#<#{self.class}:0x#{format('%08x', object_id)}>\n"
|
89
|
+
out += "Inode Number : #{@inode_number}\n"
|
90
|
+
out += "Alloc Grp Num: #{@agno}\n"
|
91
|
+
out += "AG Ino : #{@agino}\n"
|
92
|
+
out += "AG Block Num : #{@agbno}\n"
|
93
|
+
out += "Inode Length : #{@inode_length}\n"
|
94
|
+
out += "Inode Blkno : #{@inode_blkno}\n"
|
95
|
+
out += "InoBlk Offset: #{@inode_boffset}\n"
|
96
|
+
out += "Cluster AGBNO: #{@cluster_agbno}\n"
|
97
|
+
out
|
98
|
+
end
|
99
|
+
end # Class InodeMap
|
100
|
+
end # Module XFS
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'binary_struct'
|
2
|
+
require 'fs/xfs/inode'
|
3
|
+
|
4
|
+
module XFS
|
5
|
+
# ////////////////////////////////////////////////////////////////////////////
|
6
|
+
# // Data definitions.
|
7
|
+
#
|
8
|
+
# Short Form Directory Entry in a Short Form Inode.
|
9
|
+
#
|
10
|
+
SHORT_FORM_DIRECTORY_ENTRY = BinaryStruct.new([
|
11
|
+
'C', 'name_length', # name length
|
12
|
+
'C', 'offset_byte0',
|
13
|
+
'C', 'offset_byte1',
|
14
|
+
])
|
15
|
+
SIZEOF_SHORT_FORM_DIRECTORY_ENTRY = SHORT_FORM_DIRECTORY_ENTRY.size
|
16
|
+
|
17
|
+
SHORT_FORM_SHORT_INO = BinaryStruct.new([
|
18
|
+
'I>', 'inode_num', # 4 byte inode number
|
19
|
+
])
|
20
|
+
SIZEOF_SHORT_FORM_SHORT_INO = SHORT_FORM_SHORT_INO.size
|
21
|
+
|
22
|
+
SHORT_FORM_LONG_INO = BinaryStruct.new([
|
23
|
+
'Q>', 'inode_num', # 8 byte inode number
|
24
|
+
])
|
25
|
+
SIZEOF_SHORT_FORM_LONG_INO = SHORT_FORM_LONG_INO.size
|
26
|
+
|
27
|
+
class ShortFormDirectoryEntry
|
28
|
+
attr_reader :length, :name, :name_length, :short_inode
|
29
|
+
attr_accessor :file_type, :inode
|
30
|
+
|
31
|
+
def symlink?
|
32
|
+
@file_type == Inode::FT_SYM_LNK
|
33
|
+
end
|
34
|
+
|
35
|
+
def directory?
|
36
|
+
@file_type == Inode::FT_DIRECTORY
|
37
|
+
end
|
38
|
+
|
39
|
+
def file?
|
40
|
+
@file_type == Inode::FT_FILE
|
41
|
+
end
|
42
|
+
|
43
|
+
def device?
|
44
|
+
@file_type == Inode::FT_CHAR || @file_type == Inode::FT_BLOCK ||
|
45
|
+
@file_type == Inode::FT_FIFO || @file_type == Inode::FT_SOCKET
|
46
|
+
end
|
47
|
+
|
48
|
+
def dot_entry(dots, inode_number)
|
49
|
+
@length = 0
|
50
|
+
@name_length = dots
|
51
|
+
@name = "."
|
52
|
+
@name = ".." if dots == 2
|
53
|
+
@inode = inode_number
|
54
|
+
# Inode Numbers will be filled in by the caller
|
55
|
+
end
|
56
|
+
|
57
|
+
def initialize(data, short_inode, sb, dots = nil, inode_number = nil)
|
58
|
+
#
|
59
|
+
# If dots is 1 or 2 we need to construct the
|
60
|
+
# "." and ".." directory entries.
|
61
|
+
#
|
62
|
+
return dot_entry(dots, inode_number) if dots
|
63
|
+
raise "XFS::ShortFormDirectoryEntry.initialize: Nil directory entry data" if data.nil?
|
64
|
+
siz = SIZEOF_SHORT_FORM_DIRECTORY_ENTRY
|
65
|
+
@directory_entry = SHORT_FORM_DIRECTORY_ENTRY.decode(data[0..siz])
|
66
|
+
@name_length = @directory_entry['name_length']
|
67
|
+
unless @name_length == 0
|
68
|
+
@name = data[siz, @name_length]
|
69
|
+
@name_length += 1 if sb.version_has_crc?
|
70
|
+
start = siz + @name_length
|
71
|
+
if short_inode
|
72
|
+
ino_size = SIZEOF_SHORT_FORM_SHORT_INO
|
73
|
+
inode = SHORT_FORM_SHORT_INO.decode(data[start..(start + ino_size)])
|
74
|
+
else
|
75
|
+
ino_size = SIZEOF_SHORT_FORM_LONG_INO
|
76
|
+
inode = SHORT_FORM_LONG_INO.decode(data[start..(start + ino_size)])
|
77
|
+
end
|
78
|
+
@length = start + ino_size
|
79
|
+
@inode = inode['inode_num']
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def dump
|
84
|
+
out = "\#<#{self.class}:0x#{format('%08x', object_id)}>\n"
|
85
|
+
out += "Inode : #{inode}\n"
|
86
|
+
out += "Len : #{length}\n"
|
87
|
+
out += "Name : #{name}\n"
|
88
|
+
out
|
89
|
+
end
|
90
|
+
end # class
|
91
|
+
end # module
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module XFS
|
2
|
+
#
|
3
|
+
# Directory Entry when stored internal to an inode.
|
4
|
+
# Small directories are packed as tightly as possible so as to fit into the
|
5
|
+
# literal area of the inode. These "shortform" directories consist of a
|
6
|
+
# single header followed by zero or more dir entries. Due to the different
|
7
|
+
# inode number storage size and the variable length name field in the dir
|
8
|
+
# entry all these structures are variable length, and the accessors in
|
9
|
+
# this file should be used to iterate over them.
|
10
|
+
#
|
11
|
+
DIRECTORY_SHORTERFORM_HEADER = BinaryStruct.new([
|
12
|
+
'C', 'entry_count', # count of entries
|
13
|
+
'C', 'i8byte_count', # count of 8-byte inode #s
|
14
|
+
'I>', 'parent_ino_4byte', # parent dir inode # stored as 4 8-bit values
|
15
|
+
])
|
16
|
+
SIZEOF_DIRECTORY_SHORTERFORM_HEADER = DIRECTORY_SHORTERFORM_HEADER.size
|
17
|
+
|
18
|
+
DIRECTORY_SHORTFORM_HEADER = BinaryStruct.new([
|
19
|
+
'C', 'entry_count', # count of entries
|
20
|
+
'C', 'i8byte_count', # count of 8-byte inode #s
|
21
|
+
'Q>', 'parent_ino_8byte', # parent dir inode # stored as 8 8-bit values
|
22
|
+
])
|
23
|
+
SIZEOF_DIRECTORY_SHORTFORM_HEADER = DIRECTORY_SHORTFORM_HEADER.size
|
24
|
+
|
25
|
+
class ShortFormHeader
|
26
|
+
attr_reader :short_form_header, :entry_count, :parent_inode, :size, :small_inode
|
27
|
+
|
28
|
+
def initialize(data)
|
29
|
+
@short_form_header = DIRECTORY_SHORTERFORM_HEADER.decode(data)
|
30
|
+
@entry_count = @short_form_header['entry_count']
|
31
|
+
i8byte_count = @short_form_header['i8byte_count']
|
32
|
+
@parent_inode = @short_form_header['parent_ino_4byte']
|
33
|
+
@size = SIZEOF_DIRECTORY_SHORTERFORM_HEADER
|
34
|
+
@small_inode = true
|
35
|
+
if @entry_count == 0
|
36
|
+
@entry_count = i8byte_count
|
37
|
+
@short_form_header = DIRECTORY_SHORTFORM_HEADER.decode(data)
|
38
|
+
@parent_inode = @short_form_header['parent_ino_8byte']
|
39
|
+
@size = SIZEOF_DIRECTORY_SHORTFORM_HEADER
|
40
|
+
@small_inode = nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end # class ShortFormHeader
|
44
|
+
end # module XFS
|