Skip to content

Fix for skipping OEM partitions #17

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions src/ldm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,7 @@ _read_privhead(const int fd, const gchar * const path, const guint secsize,
{
// Whether the disk is MBR or GPT, we expect to find an MBR at the beginning
mbr_t mbr;
int i;
int r = mbr_read(fd, &mbr);
if (r < 0) {
switch (-r) {
Expand All @@ -1440,18 +1441,23 @@ _read_privhead(const int fd, const gchar * const path, const guint secsize,
}
}

switch (mbr.part[0].type) {
case MBR_PART_WINDOWS_LDM:
return _read_privhead_mbr(fd, path, secsize, privhead, err);
// Check all primary partitions on MBR - OEM and other partition types can co-exist with LDM
for (i=0; i < 4; i++) {
switch (mbr.part[i].type) {
case MBR_PART_WINDOWS_LDM:
return _read_privhead_mbr(fd, path, secsize, privhead, err);

case MBR_PART_EFI_PROTECTIVE:
return _read_privhead_gpt(fd, path, secsize, privhead, err);
case MBR_PART_EFI_PROTECTIVE:
return _read_privhead_gpt(fd, path, secsize, privhead, err);

default:
g_set_error(err, LDM_ERROR, LDM_ERROR_NOT_LDM,
"%s does not contain LDM metadata", path);
return FALSE;
default:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're mixing tabs and spaces in these 3 lines.

g_set_error(err, LDM_ERROR, LDM_ERROR_NOT_LDM,
"partition %d type=%x does not contain LDM metadata, skipping", i+1, mbr.part[i].type);
}
}
g_set_error(err, LDM_ERROR, LDM_ERROR_NOT_LDM,
"%s does not contain LDM metadata", path);
return FALSE;
}

#define PARSE_VAR_INT(func_name, out_type) \
Expand Down