summaryrefslogtreecommitdiff
path: root/kexec/phys_arch.c
blob: ff8c28bd2c9d418b8907e422f00884d71dcf2de3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "kexec.h"
#include <errno.h>
#include <string.h>
#include <sys/utsname.h>

long physical_arch(void)
{
	struct utsname utsname;
	int i, result = uname(&utsname);
	if (result < 0) {
		fprintf(stderr, "uname failed: %s\n",
			strerror(errno));
		return -1;
	}

	for (i = 0; arches[i].machine; ++i)
		if (strcmp(utsname.machine, arches[i].machine) == 0)
			return arches[i].arch;

	fprintf(stderr, "Unsupported machine type: %s\n",
		utsname.machine);
	return -1;
}