]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
setarch: use personality() system call when it is available
authorSami Kerola <kerolasa@iki.fi>
Sat, 6 Sep 2014 23:16:18 +0000 (00:16 +0100)
committerSami Kerola <kerolasa@iki.fi>
Fri, 19 Sep 2014 18:31:02 +0000 (19:31 +0100)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/setarch.c

index 468e492602383ff55fa0939076e22b3c0eeff87b..ed2a6a64cb361e3846a721983f580e3242dc34f3 100644 (file)
@@ -24,8 +24,7 @@
  * sparc32 util by Jakub Jelinek (1998, 1999)
  */
 
-#include <syscall.h>
-#include <linux/personality.h>
+#include <sys/personality.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <string.h>
 #include "c.h"
 #include "closestream.h"
 
-#define set_pers(pers) ((long)syscall(SYS_personality, pers))
+#ifndef HAVE_PERSONALITY
+# include <syscall.h>
+# define personality(pers) ((long)syscall(SYS_personality, pers))
+#endif
 
 /* Options without equivalent short options */
 enum {
@@ -229,7 +231,7 @@ static int set_arch(const char *pers, unsigned long options, int list)
        if (transitions[i].perval < 0)
                errx(EXIT_FAILURE, _("%s: Unrecognized architecture"), pers);
        pers_value = transitions[i].perval | options;
-       if (set_pers(pers_value) == -EINVAL)
+       if (personality(pers_value) == -EINVAL)
                return 1;
        uname(&un);
        if (transitions[i].result_arch && strcmp(un.machine, transitions[i].result_arch)) {