xref: /haiku/src/system/libroot/posix/sys/uname.c (revision 93aeb8c3bc3f13cb1f282e3e749258a23790d947)
1 /*
2  * Copyright 2004, 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 <OS.h>
8 
9 #include <sys/utsname.h>
10 #include <errno.h>
11 #include <stdio.h>
12 #include <string.h>
13 
14 
15 int
16 uname(struct utsname *info)
17 {
18 	system_info systemInfo;
19 	const char *platform;
20 
21 	if (!info) {
22 		errno = B_BAD_VALUE;
23 		return -1;
24 	}
25 
26 	get_system_info(&systemInfo);
27 
28 	strlcpy(info->sysname, "Haiku", sizeof(info->sysname));
29 	strlcpy(info->version, systemInfo.kernel_build_date, sizeof(info->version));
30 	strlcat(info->version, systemInfo.kernel_build_time, sizeof(info->version));
31 	snprintf(info->release, sizeof(info->release), "%lld", systemInfo.kernel_version);
32 
33 	// TODO: make this better
34 	switch (systemInfo.platform_type) {
35 		case B_BEBOX_PLATFORM:
36 			platform = "BeBox";
37 			break;
38 		case B_MAC_PLATFORM:
39 			platform = "BeMac";
40 			break;
41 		case B_AT_CLONE_PLATFORM:
42 			platform = "BePC";
43 			break;
44 		default:
45 			platform = "unknown";
46 			break;
47 	}
48 	strlcpy(info->machine, platform, sizeof(info->machine));
49 
50 	// TODO fill nodename field when we have hostname info
51 	strlcpy(info->nodename, "unknown", sizeof(info->nodename));
52 
53 	return 0;
54 }
55 
56