1 /* 2 * Copyright 2004-2007, Jérôme Duval jerome.duval@free.fr. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <sys/utsname.h> 8 9 #include <errno.h> 10 #include <stdio.h> 11 #include <string.h> 12 #include <unistd.h> 13 14 #include <OS.h> 15 16 #include <system_revision.h> 17 18 19 int 20 uname(struct utsname *info) 21 { 22 system_info systemInfo; 23 const char *platform; 24 const char *haikuRevision; 25 26 if (!info) { 27 errno = B_BAD_VALUE; 28 return -1; 29 } 30 31 get_system_info(&systemInfo); 32 33 strlcpy(info->sysname, "Haiku", sizeof(info->sysname)); 34 35 haikuRevision = __get_haiku_revision(); 36 if (haikuRevision[0] != '\0') 37 snprintf(info->version, sizeof(info->version), "%s ", haikuRevision); 38 else 39 info->version[0] = '\0'; 40 strlcat(info->version, systemInfo.kernel_build_date, sizeof(info->version)); 41 strlcat(info->version, " ", sizeof(info->version)); 42 strlcat(info->version, systemInfo.kernel_build_time, sizeof(info->version)); 43 snprintf(info->release, sizeof(info->release), "%lld", 44 systemInfo.kernel_version); 45 46 // TODO: make this better 47 switch (systemInfo.platform_type) { 48 case B_BEBOX_PLATFORM: 49 platform = "BeBox"; 50 break; 51 case B_MAC_PLATFORM: 52 platform = "BeMac"; 53 break; 54 case B_AT_CLONE_PLATFORM: 55 platform = "BePC"; 56 break; 57 default: 58 platform = "unknown"; 59 break; 60 } 61 strlcpy(info->machine, platform, sizeof(info->machine)); 62 63 if (gethostname(info->nodename, sizeof(info->nodename)) != 0) 64 strlcpy(info->nodename, "unknown", sizeof(info->nodename)); 65 66 return 0; 67 } 68 69