Skip to content

Commit

Permalink
libbootimg_architecture: Use uname instead of /proc/cpuinfo
Browse files Browse the repository at this point in the history
 * A new situation on the Sony X Performance has shown
    that the "Processor" field from cpuinfo can be missing,
    therefore breaking the 32 / 64bits detection

 * Instead, use the native uname handling to get the name of
    the host machine, allowing to detect aarch64/armv8 properly

Change-Id: Ib7f1aa6303390b4cc64e402e7ee242a272ddf722
Signed-off-by: Adrian DC <[email protected]>
  • Loading branch information
AdrianDC committed Dec 25, 2017
1 parent 056a34a commit 6c14c4a
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/libbootimg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,25 +1258,11 @@ int libbootimg_write_img_and_destroy(struct bootimg *b, const char *dest)

uint8_t libbootimg_architecture(void)
{
FILE* cpuinfo;
char buffer[100];
struct utsname sysinfo;
uname(&sysinfo);

memset(buffer, 0, sizeof(buffer));
cpuinfo = fopen("/proc/cpuinfo", "rb");

if (cpuinfo == NULL)
{
return ARCH_32_BITS;
}

if (fread(buffer, 1, sizeof(buffer), cpuinfo) == 0)
{
fclose(cpuinfo);
return ARCH_32_BITS;
}
fclose(cpuinfo);

if (strstr(buffer, "aarch64")) {
if (strstr(sysinfo.machine, "aarch64")
|| strstr(sysinfo.machine, "armv8")) {
return ARCH_64_BITS;
}

Expand Down

0 comments on commit 6c14c4a

Please sign in to comment.