-
Notifications
You must be signed in to change notification settings - Fork 117
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
partition: add repair capabilities to GPT #187
Conversation
@thebsdbox is great, isn't he? Did he do work elsewhere that you are moving in here? |
c938571
to
77a4994
Compare
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.
Just 2 style comments.
partition/gpt/table.go
Outdated
// potential protective MBR is at LBA0 | ||
hasProtectiveMBR := readProtectiveMBR(b[:logicalBlockSize], uint32(header.secondaryHeader)) | ||
|
||
table := Table{ |
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.
Rather than copying the fields, since readGptHeader()
returns *Table
, wouldn't it be easier to just add the data to it and return it? Something like:
table, err := readGptHeader(gpt)
// .. lots of other stuff
table.LogicalSectorSize = logicalBlockSize
table.PhysicalSectorSize = physicalBlockSize
table.ProtectiveMBR = hasProtectiveMBR
table.initialized = true
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.
Thanks for your suggestion, I updated code.
partition/gpt/table.go
Outdated
// GPT starts at LBA1 | ||
gpt := b[logicalBlockSize:] | ||
// readGptHeader reads the GPT header from the given byte slice | ||
func readGptHeader(b []byte) (*Table, error) { |
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 suspect lint will complain that this should be readGPTHeader()
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.
Fixed.
1. add Repair and Verify interfaces in type table 2. add test to test opening the GPT image Signed-off-by: thebsdbox <[email protected]> Signed-off-by: Qinqi Qu <[email protected]>
77a4994
to
610b365
Compare
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.
And CI is happy too.
Thank for this @adamqqqplay !
@deitch Thanks for your review! I just discovered a new improvement point. Maybe we could merge this two function in the future: tableFromBytes and tableHeaderFromBytes. |
If it is easier, sure. These are private functions, so no worry about impact other than where they exist, and ability to read clearly. |
Apologies, I was always meant to circle back and finish this off :-( |
Based on #112, and addressing review comments. Thanks to the original author! @thebsdbox