diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2023-03-06 14:11:28 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2023-03-06 14:11:28 +0100 |
| commit | 2b5c25ef17718bb0e324ea2febd5b76b829c309b (patch) | |
| tree | 808c3c4aed7dbc061b32b4e89639e2557743be8c /src/wrapped | |
| parent | da34156267c483c3621e447ba78842aa37694751 (diff) | |
| download | box64-2b5c25ef17718bb0e324ea2febd5b76b829c309b.tar.gz box64-2b5c25ef17718bb0e324ea2febd5b76b829c309b.zip | |
Change branding of Cpu to refect Box64 and the cpu it's running on
Diffstat (limited to 'src/wrapped')
| -rwxr-xr-x | src/wrapped/wrappedlibc.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 0f9ae4a5..b3f52353 100755 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -1457,6 +1457,46 @@ int getNCpu() return nCPU; } +const char* getCpuName() +{ + static char name[200] = "Unknown"; + static int done = 0; + if(done) + return name; + done = 1; + FILE* f = popen("lscpu | grep \"Model name:\" | sed -r 's/Model name:\\s{1,}//g'", "r"); + if(f) { + char tmp[200] = ""; + ssize_t s = fread(tmp, 1, 200, f); + pclose(f); + if(s>0) { + // worked! + // trim ending + while(strlen(tmp) && tmp[strlen(tmp)-1]=='\n') + tmp[strlen(tmp)-1] = 0; + strncpy(name, tmp, 199); + return name; + } + } + // failled, try to get architecture at least + f = popen("lscpu | grep \"Architecture:\" | sed -r 's/Architecture:\\s{1,}//g'", "r"); + if(f) { + char tmp[200] = ""; + ssize_t s = fread(tmp, 1, 200, f); + pclose(f); + if(s>0) { + // worked! + // trim ending + while(strlen(tmp) && tmp[strlen(tmp)-1]=='\n') + tmp[strlen(tmp)-1] = 0; + snprintf(name, 199, "unknown %s cpu", tmp); + return name; + } + } + // Nope, bye + return name; +} + #ifndef NOALIGN void CreateCPUInfoFile(int fd) |