diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:56:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:56:35 +0000 |
commit | eba0cfa6b0bef4f2e73c8630a7efa3944df8b0f8 (patch) | |
tree | 74c37eede1f0634cc5de1c63c934edaa1630c6bc /kexec/phys_arch.c | |
parent | Initial commit. (diff) | |
download | kexec-tools-upstream.tar.xz kexec-tools-upstream.zip |
Adding upstream version 1:2.0.27.upstream/1%2.0.27upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | kexec/phys_arch.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/kexec/phys_arch.c b/kexec/phys_arch.c new file mode 100644 index 0000000..1571a0f --- /dev/null +++ b/kexec/phys_arch.c @@ -0,0 +1,28 @@ +#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; + if ((strcmp(arches[i].machine, "arm") == 0) && + (strncmp(utsname.machine, arches[i].machine, + strlen(arches[i].machine)) == 0)) + return arches[i].arch; + } + + fprintf(stderr, "Unsupported machine type: %s\n", + utsname.machine); + return -1; +} |