]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
setarch: add generic support for setarch $(uname -m) ...
authorRuediger Meier <ruediger.meier@ga-group.nl>
Thu, 29 May 2014 00:53:18 +0000 (02:53 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 29 May 2014 07:52:26 +0000 (09:52 +0200)
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/setarch.c

index 8e2b6e531a5e9f5bb7224809000f022d0e18e253..4cce877be52e621067ffee8e7ccede1f6eac939c 100644 (file)
@@ -202,9 +202,25 @@ set_arch(const char *pers, unsigned long options, int list)
     {PER_LINUX, "alphaev6", "alpha"},
     {PER_LINUX, "alphaev67", "alpha"},
 #endif
+    {-1, NULL, NULL}, /* place holder, eventually filled up at runtime */
     {-1, NULL, NULL}
   };
 
+  /* Add the trivial transition {PER_LINUX, machine, machine} if no such
+     target_arch is hardcoded yet. */
+  uname(&un);
+  for (i = 0; transitions[i].perval >= 0; i++)
+       if(!strcmp(un.machine, transitions[i].target_arch))
+               break;
+  if (transitions[i].perval < 0) {
+       unsigned long wrdsz = CHAR_BIT * sizeof(void*);
+       if (wrdsz == 32 || wrdsz == 64) {
+               transitions[i].perval = wrdsz == 32 ? PER_LINUX32 : PER_LINUX;
+               transitions[i].target_arch = un.machine;
+               transitions[i].result_arch = un.machine;
+       }
+  }
+
   if (list) {
     for(i = 0; transitions[i].target_arch != NULL; i++)
       printf("%s\n", transitions[i].target_arch);