]> granicus.if.org Git - strace/commitdiff
tests/umount.c: use errno2name
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 21 Apr 2016 21:32:00 +0000 (21:32 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 21 Apr 2016 22:05:56 +0000 (22:05 +0000)
tests/umount.c

index 9ad88284b5638d4ee7e9c2d101572558ef5022a7..d5cde96bbda8a91434d14934717a37038ae7e20a 100644 (file)
 #include "tests.h"
 #include <errno.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <sys/stat.h>
 #include <sys/mount.h>
 #include <sys/syscall.h>
+#include <unistd.h>
 
 #ifdef __NR_oldumount
 # define TEST_SYSCALL_STR "oldumount"
@@ -48,24 +48,16 @@ int
 main(void)
 {
        static const char sample[] = "umount.sample";
-       const char *errno_text;
        if (mkdir(sample, 0700))
                perror_msg_and_fail("mkdir: %s", sample);
-       (void) syscall(__NR_oldumount, sample);
-       switch (errno) {
-               case ENOSYS:
-                       errno_text = "ENOSYS";
-                       break;
-               case EPERM:
-                       errno_text = "EPERM";
-                       break;
-               default:
-                       errno_text = "EINVAL";
-       }
-       printf("%s(\"%s\") = -1 %s (%m)\n",
-              TEST_SYSCALL_STR, sample, errno_text);
+
+       long rc = syscall(__NR_oldumount, sample);
+       printf("%s(\"%s\") = %ld %s (%m)\n",
+              TEST_SYSCALL_STR, sample, rc, errno2name());
+
        if (rmdir(sample))
                perror_msg_and_fail("rmdir: %s", sample);
+
        puts("+++ exited with 0 +++");
        return 0;
 }