about summary refs log tree commit diff stats
path: root/src/wrapped
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-03-06 14:11:28 +0100
committerptitSeb <sebastien.chev@gmail.com>2023-03-06 14:11:28 +0100
commit2b5c25ef17718bb0e324ea2febd5b76b829c309b (patch)
tree808c3c4aed7dbc061b32b4e89639e2557743be8c /src/wrapped
parentda34156267c483c3621e447ba78842aa37694751 (diff)
downloadbox64-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-xsrc/wrapped/wrappedlibc.c40
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)