-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support compression in VMware sparse disk #115
base: master
Are you sure you want to change the base?
Support compression in VMware sparse disk #115
Conversation
1cd4b2d
to
c30a383
Compare
5548095
to
82cc7f9
Compare
# 'K' D' 'M' 'V' 0x02 0x00 0x00 0x00 | ||
|
||
# flags contains the following bits of information. | ||
'L', 'flags', # bit 0: valid new line detection test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a way to do bit level here, so you can actually give each of these flags an individual name here, and then you don't need the method that maps to a hash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried doing this, but all the ways to do it are kind of clunky, so probably ok to go with what's here...
So I thought you could do
'b', :flag1,
'b', :flag2,
'b', :flag3,
...
Unfortunately the way the b
identifier works is that it consumes 1 bit, then moves the iterator forward the rest of the byte. So, the only way to read consecutive bits is to do something like...
'b8', :flags
which then gives something like {:flags => "01100100"}
.
I think BinaryStruct could be enhanced with some sort of bit decoding, but I'm not sure what a nice interface would look like offhand. I'm guessing the caller would just want to deal with bits individually, but under the covers as we build the format string we'd have to understand consecutive b
definitions and pack them into a single b<N>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That being said, it might be easier to use the bit decoding and do something like this...
# Instead of
'L', 'flags'
# use this
'b16' 'flags'
# and then immediately after decoding do:
sparseHeader["flags"] = sparseHeader["flags"].chars.map {|c| c == "1"}
# Then perhps something like...
sparseHeader["valid_new_line_detection_test"] = sparseHeader["flags"][0]
sparseHeader["redundant_grain_table_used"] = sparseHeader["flags"][1]
sparseHeader["zero_grain_gte_used"] = sparseHeader["flags"][2]
sparseHeader["grains_compressed"] = sparseHeader["flags"][16]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be b32
since we need to access bit 0 as well as bit 16 and bit 17?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes...I typoed it.
Additionally, add support for USE_REDUNDANT_GRAIN_TABLE flag Additionally, enhance the comments and logic around SPARSE_EXTENT_HEADER parsing.
3d37db2
to
f6e9f29
Compare
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation. |
This pull request has been automatically closed because it has not been updated for at least 3 months. Feel free to reopen this pull request if these changes are still valid. Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation. |
Checked commits chessbyte/manageiq-smartstate@8521141~...f6e9f29 with ruby 2.6.10, rubocop 1.28.2, haml-lint 0.35.0, and yamllint lib/disk/modules/VMWareSparseDisk.rb
|
Much of the comments and understanding in this PR derives from the VMware Virtual Disk Format 5.0 Documentation and this repo