int uname(struct utsname *info) { system_info systemInfo; const char *platform; const char *haikuRevision; if (!info) { errno = B_BAD_VALUE; return -1; } get_system_info(&systemInfo); strlcpy(info->sysname, "Haiku", sizeof(info->sysname)); haikuRevision = __get_haiku_revision(); if (haikuRevision[0] != '\0') snprintf(info->version, sizeof(info->version), "%s ", haikuRevision); else info->version[0] = '\0'; strlcat(info->version, systemInfo.kernel_build_date, sizeof(info->version)); strlcat(info->version, " ", sizeof(info->version)); strlcat(info->version, systemInfo.kernel_build_time, sizeof(info->version)); snprintf(info->release, sizeof(info->release), "%lld", systemInfo.kernel_version); // TODO: make this better switch (systemInfo.platform_type) { case B_BEBOX_PLATFORM: platform = "BeBox"; break; case B_MAC_PLATFORM: platform = "BeMac"; break; case B_AT_CLONE_PLATFORM: platform = "BePC"; break; default: platform = "unknown"; break; } strlcpy(info->machine, platform, sizeof(info->machine)); if (gethostname(info->nodename, sizeof(info->nodename)) != 0) strlcpy(info->nodename, "unknown", sizeof(info->nodename)); return 0; }
int uname(struct utsname *info) { cpu_topology_node_info root; system_info systemInfo; const char *platform; const char *haikuRevision; uint32 count = 1; status_t error; if (!info) { __set_errno(B_BAD_VALUE); return -1; } get_system_info(&systemInfo); strlcpy(info->sysname, "Haiku", sizeof(info->sysname)); haikuRevision = __get_haiku_revision(); if (haikuRevision[0] != '\0') snprintf(info->version, sizeof(info->version), "%s ", haikuRevision); else info->version[0] = '\0'; strlcat(info->version, systemInfo.kernel_build_date, sizeof(info->version)); strlcat(info->version, " ", sizeof(info->version)); strlcat(info->version, systemInfo.kernel_build_time, sizeof(info->version)); snprintf(info->release, sizeof(info->release), "%" B_PRId64, systemInfo.kernel_version); error = get_cpu_topology_info(&root, &count); if (error != B_OK || count < 1) platform = "unknown"; else { switch (root.data.root.platform) { case B_CPU_x86: platform = "BePC"; break; case B_CPU_x86_64: platform = "x86_64"; break; case B_CPU_PPC: platform = "ppc"; break; case B_CPU_PPC_64: platform = "ppc64"; break; case B_CPU_M68K: platform = "m68k"; break; case B_CPU_ARM: /* The minimal ARM version emulated by QEMU * XXX: use armv6 (raspberry Pi)? * XXX: should we really use B_HOST_IS_LENDIAN here? * XXX: use real cpu version as on Linux? * cf. http://git.qemu.org/?p=qemu.git;a=blob;f=linux-user/uname.c */ #if B_HOST_IS_LENDIAN platform = "armv5tel"; #else platform = "armv5teb"; #endif break; case B_CPU_ARM_64: platform = "aarch64"; break; case B_CPU_ALPHA: platform = "alpha"; break; case B_CPU_MIPS: platform = "mips"; break; case B_CPU_SH: platform = "sh4"; break; case B_CPU_UNKNOWN: default: platform = "unknown"; break; } } strlcpy(info->machine, platform, sizeof(info->machine)); if (gethostname(info->nodename, sizeof(info->nodename)) != 0) strlcpy(info->nodename, "unknown", sizeof(info->nodename)); return 0; }
AboutView::AboutView() : BView("aboutview", B_WILL_DRAW | B_PULSE_NEEDED), fLastActionTime(system_time()), fScrollRunner(NULL) { // Begin Construction of System Information controls system_info systemInfo; get_system_info(&systemInfo); // Create all the various labels for system infomation // OS Version char string[1024]; strlcpy(string, B_TRANSLATE("Unknown"), sizeof(string)); // the version is stored in the BEOS:APP_VERSION attribute of libbe.so BPath path; if (find_directory(B_BEOS_LIB_DIRECTORY, &path) == B_OK) { path.Append("libbe.so"); BAppFileInfo appFileInfo; version_info versionInfo; BFile file; if (file.SetTo(path.Path(), B_READ_ONLY) == B_OK && appFileInfo.SetTo(&file) == B_OK && appFileInfo.GetVersionInfo(&versionInfo, B_APP_VERSION_KIND) == B_OK && versionInfo.short_info[0] != '\0') strlcpy(string, versionInfo.short_info, sizeof(string)); } // Add system revision const char* haikuRevision = __get_haiku_revision(); if (haikuRevision != NULL) { strlcat(string, " (", sizeof(string)); strlcat(string, B_TRANSLATE("Revision"), sizeof(string)); strlcat(string, " ", sizeof(string)); strlcat(string, haikuRevision, sizeof(string)); strlcat(string, ")", sizeof(string)); } BStringView* versionView = new BStringView("ostext", string); versionView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); // GCC version BEntry gccFourHybrid("/boot/system/lib/gcc2/libstdc++.r4.so"); BEntry gccTwoHybrid("/boot/system/lib/gcc4/libsupc++.so"); bool isHybrid = gccFourHybrid.Exists() || gccTwoHybrid.Exists(); if (isHybrid) { snprintf(string, sizeof(string), B_TRANSLATE("GCC %d Hybrid"), __GNUC__); } else snprintf(string, sizeof(string), "GCC %d", __GNUC__); BStringView* gccView = new BStringView("gcctext", string); gccView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); #if __GNUC__ == 2 if (isHybrid) { // do now show the GCC version if it's the default gccView->Hide(); } #endif // CPU count, type and clock speed char processorLabel[256]; if (systemInfo.cpu_count > 1) { snprintf(processorLabel, sizeof(processorLabel), B_TRANSLATE("%ld Processors:"), systemInfo.cpu_count); } else strlcpy(processorLabel, B_TRANSLATE("Processor:"), sizeof(processorLabel)); BString cpuType; cpuType << get_cpu_vendor_string(systemInfo.cpu_type) << " " << get_cpu_model_string(&systemInfo); BStringView* cpuView = new BStringView("cputext", cpuType.String()); cpuView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); int32 clockSpeed = get_rounded_cpu_speed(); if (clockSpeed < 1000) snprintf(string, sizeof(string), B_TRANSLATE("%ld MHz"), clockSpeed); else snprintf(string, sizeof(string), B_TRANSLATE("%.2f GHz"), clockSpeed / 1000.0f); BStringView* frequencyView = new BStringView("frequencytext", string); frequencyView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); // RAM BStringView *memSizeView = new BStringView("ramsizetext", MemSizeToString(string, sizeof(string), &systemInfo)); memSizeView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); fMemView = new BStringView("ramtext", MemUsageToString(string, sizeof(string), &systemInfo)); fMemView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); // Kernel build time/date snprintf(string, sizeof(string), "%s %s", systemInfo.kernel_build_date, systemInfo.kernel_build_time); BStringView* kernelView = new BStringView("kerneltext", string); kernelView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); // Uptime fUptimeView = new BTextView("uptimetext"); fUptimeView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fUptimeView->MakeEditable(false); fUptimeView->MakeSelectable(false); fUptimeView->SetWordWrap(true); fUptimeView->SetText(UptimeToString(string, sizeof(string))); const float offset = 5; SetLayout(new BGroupLayout(B_HORIZONTAL, 0)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BLayoutBuilder::Group<>((BGroupLayout*)GetLayout()) .AddGroup(B_VERTICAL, 0) .Add(new LogoView()) .AddGroup(B_VERTICAL, 0) .Add(_CreateLabel("oslabel", B_TRANSLATE("Version:"))) .Add(versionView) .Add(gccView) .AddStrut(offset) .Add(_CreateLabel("cpulabel", processorLabel)) .Add(cpuView) .Add(frequencyView) .AddStrut(offset) .Add(_CreateLabel("memlabel", B_TRANSLATE("Memory:"))) .Add(memSizeView) .Add(fMemView) .AddStrut(offset) .Add(_CreateLabel("kernellabel", B_TRANSLATE("Kernel:"))) .Add(kernelView) .AddStrut(offset) .Add(_CreateLabel("uptimelabel", B_TRANSLATE("Time running:"))) .Add(fUptimeView) .SetInsets(5, 5, 5, 5) .End() // TODO: investigate: adding this causes the time to be cut //.AddGlue() .End() .Add(_CreateCreditsView()); float min = fMemView->MinSize().width * 1.1f; fCreditsView->SetExplicitMinSize(BSize(min, min)); }