forked from smuos/uname
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uname.c
34 lines (27 loc) · 771 Bytes
/
uname.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/utsname.h>
#include <errno.h>
int main(int argc, char *argv[]) {
int ret_val;
struct utsname ubuffer;
// Check for proper usage
if (argc != 1) {
fprintf(stderr, "%s: Aborting, not enough arguments.\n", argv[0]);
return (-1);
}
ret_val = uname(&ubuffer);
if (ret_val == -1)
{
fprintf(stderr, "%s: failed \n", strerror(errno));
exit(1);
}
printf("System name: %s\n", ubuffer.sysname);
printf("Host name: %s\n", ubuffer.nodename);
printf("OS Release: %s\n", ubuffer.release);
printf("OS Version: %s\n", ubuffer.version);
printf("CPU Type: %s\n", ubuffer.machine);
return 0;
}