Skip to content

Commit 6ca06c8

Browse files
committed
libbootimg_architecture: Use uname instead of /proc/cpuinfo
* 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 properly Change-Id: Ib7f1aa6303390b4cc64e402e7ee242a272ddf722 Signed-off-by: Adrian DC <radian.dc@gmail.com>
1 parent 056a34a commit 6ca06c8

1 file changed

Lines changed: 3 additions & 18 deletions

File tree

src/libbootimg.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,25 +1258,10 @@ int libbootimg_write_img_and_destroy(struct bootimg *b, const char *dest)
12581258

12591259
uint8_t libbootimg_architecture(void)
12601260
{
1261-
FILE* cpuinfo;
1262-
char buffer[100];
1261+
struct utsname sysinfo;
1262+
uname(&sysinfo);
12631263

1264-
memset(buffer, 0, sizeof(buffer));
1265-
cpuinfo = fopen("/proc/cpuinfo", "rb");
1266-
1267-
if (cpuinfo == NULL)
1268-
{
1269-
return ARCH_32_BITS;
1270-
}
1271-
1272-
if (fread(buffer, 1, sizeof(buffer), cpuinfo) == 0)
1273-
{
1274-
fclose(cpuinfo);
1275-
return ARCH_32_BITS;
1276-
}
1277-
fclose(cpuinfo);
1278-
1279-
if (strstr(buffer, "aarch64")) {
1264+
if (strstr(sysinfo.machine, "aarch64")) {
12801265
return ARCH_64_BITS;
12811266
}
12821267

0 commit comments

Comments
 (0)