]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - sys-utils/setarch.c
setarch: use kernel address size if possible
[thirdparty/util-linux.git] / sys-utils / setarch.c
index b86be1e29da1d3d8c4d1302fd68f53690acd01e5..d6789d05e86f555853d4b4d5fc842ac58377d6a7 100644 (file)
@@ -35,6 +35,7 @@
 #include "nls.h"
 #include "c.h"
 #include "closestream.h"
+#include "sysfs.h"
 
 #ifndef HAVE_PERSONALITY
 # include <syscall.h>
@@ -232,7 +233,9 @@ static struct arch_domain *init_arch_domains(void)
                if (!strcmp(un.machine, transitions[i].target_arch))
                        break;
        if (transitions[i].perval < 0) {
-               unsigned long wrdsz = CHAR_BIT * sizeof(void *);
+               int wrdsz = sysfs_get_address_bits(NULL);
+               if (wrdsz < 0)
+                       wrdsz = CHAR_BIT * sizeof(void *);
                if (wrdsz == 32 || wrdsz == 64) {
                        /* fill up the place holder */
                        transitions[i].perval = wrdsz == 32 ? PER_LINUX32 : PER_LINUX;