2 * Copyright 2004-2007, Jérôme Duval jerome.duval@free.fr. All rights reserved.
3 * Distributed under the terms of the MIT License.
7 #include <sys/utsname.h>
15 #include <ByteOrder.h>
17 #include <errno_private.h>
18 #include <system_revision.h>
22 uname(struct utsname
*info
)
24 cpu_topology_node_info root
;
25 system_info systemInfo
;
27 const char *haikuRevision
;
32 __set_errno(B_BAD_VALUE
);
36 get_system_info(&systemInfo
);
38 strlcpy(info
->sysname
, "Haiku", sizeof(info
->sysname
));
40 haikuRevision
= __get_haiku_revision();
41 if (haikuRevision
[0] != '\0')
42 snprintf(info
->version
, sizeof(info
->version
), "%s ", haikuRevision
);
44 info
->version
[0] = '\0';
45 strlcat(info
->version
, systemInfo
.kernel_build_date
, sizeof(info
->version
));
46 strlcat(info
->version
, " ", sizeof(info
->version
));
47 strlcat(info
->version
, systemInfo
.kernel_build_time
, sizeof(info
->version
));
48 snprintf(info
->release
, sizeof(info
->release
), "%" B_PRId64
,
49 systemInfo
.kernel_version
);
51 error
= get_cpu_topology_info(&root
, &count
);
52 if (error
!= B_OK
|| count
< 1)
55 switch (root
.data
.root
.platform
) {
72 /* The minimal ARM version emulated by QEMU
73 * XXX: use armv6 (raspberry Pi)?
74 * XXX: should we really use B_HOST_IS_LENDIAN here?
75 * XXX: use real cpu version as on Linux?
76 * cf. http://git.qemu.org/?p=qemu.git;a=blob;f=linux-user/uname.c
79 platform
= "armv5tel";
81 platform
= "armv5teb";
103 strlcpy(info
->machine
, platform
, sizeof(info
->machine
));
105 if (gethostname(info
->nodename
, sizeof(info
->nodename
)) != 0)
106 strlcpy(info
->nodename
, "unknown", sizeof(info
->nodename
));