All pastes #1579508 Raw Edit

phys_arch.c

public text v1 · immutable
#1579508 ·published 2009-09-25 20:03 UTC
rendered paste body
#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)
#ifdef __arm__
		if (strncmp(utsname.machine, arches[i].machine, 3) == 0)
#endif
			return arches[i].arch;

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