long rc = syscall(__NR_access, sample, F_OK);
printf("access(\"%s\", F_OK) = %ld %s (%m)\n",
- sample, rc, errno == ENOSYS ? "ENOSYS" : "ENOENT");
+ sample, rc, errno2name());
rc = syscall(__NR_access, sample, R_OK|W_OK|X_OK);
printf("access(\"%s\", R_OK|W_OK|X_OK) = %ld %s (%m)\n",
- sample, rc, errno == ENOSYS ? "ENOSYS" : "ENOENT");
+ sample, rc, errno2name());
return 0;
}
len, flags) == -1);
printf("copy_file_range(%d, [%lld], %d, [%lld], %zu, %u) = -1 %s (%m)\n",
(int) fd_in, *off_in, (int) fd_out, *off_out, len, flags,
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
}
int rc = syscall(__NR_creat, TMP_FILE, S_IRUSR);
printf("creat(\"%s\", %#o) = %d %s (%m)\n",
TMP_FILE, S_IRUSR, rc,
- errno == ENOSYS ? "ENOSYS" : "ETXTBSY");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
int rc = dup(fd);
printf("dup(%d) = %d %s (%m)\n",
fd, rc,
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
int rc = syscall(__NR_dup2, fd_old, fd_new);
printf("dup2(%d, %d) = %d %s (%m)\n",
(int) fd_old, (int) fd_new, rc,
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
int rc = syscall(__NR_dup3, fd_old, fd_new, O_CLOEXEC);
printf("dup3(%d, %d, O_CLOEXEC) = %d %s (%m)\n",
(int) fd_old, (int) fd_new, rc,
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
{
int rc = syscall(__NR_epoll_create, -1);
printf("epoll_create(-1) = %d %s (%m)\n",
- rc, errno == ENOSYS ? "ENOSYS" : "EINVAL");
+ rc, errno2name());
puts("+++ exited with 0 +++");
return 0;
printf("epoll_ctl(-1, EPOLL_CTL_ADD, -2, {EPOLLIN,"
" {u32=%u, u64=%" PRIu64 "}}) = %d %s (%m)\n",
ev->data.u32, ev->data.u64, rc,
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
rc = syscall(__NR_epoll_ctl, -3, EPOLL_CTL_DEL, -4, ev);
printf("epoll_ctl(-3, EPOLL_CTL_DEL, -4, %p) = %d %s (%m)\n",
- ev, rc, errno == ENOSYS ? "ENOSYS" : "EBADF");
+ ev, rc, errno2name());
rc = syscall(__NR_epoll_ctl, -1L, EPOLL_CTL_MOD, -16L, 0);
printf("epoll_ctl(-1, EPOLL_CTL_MOD, -16, NULL) = %d %s (%m)\n",
- rc, errno == ENOSYS ? "ENOSYS" : "EFAULT");
+ rc, errno2name());
puts("+++ exited with 0 +++");
return 0;
int rc = syscall(__NR_epoll_wait, -1, ev, 1, -2);
printf("epoll_wait(-1, %p, 1, -2) = %d %s (%m)\n",
- ev, rc, errno == ENOSYS ? "ENOSYS" : "EBADF");
+ ev, rc, errno2name());
puts("+++ exited with 0 +++");
return 0;
#ifdef VERBOSE_EXECVEAT
q_envp[0], q_envp[1], envp[2], envp[3], envp[4],
#endif
- errno == ENOSYS ? "ENOSYS" : "ENOENT");
+ errno2name());
tail_argv[ARRAY_SIZE(q_argv)] = NULL;
tail_envp[ARRAY_SIZE(q_envp)] = NULL;
#ifdef VERBOSE_EXECVEAT
q_envp[0], q_envp[1],
#endif
- errno == ENOSYS ? "ENOSYS" : "ENOENT");
+ errno2name());
syscall(__NR_execveat, -100, FILENAME, tail_argv + 2, tail_envp + 1, 0x1100);
printf("execveat(AT_FDCWD, \"%s\", [\"%s\"]"
#ifdef VERBOSE_EXECVEAT
q_envp[1],
#endif
- errno == ENOSYS ? "ENOSYS" : "ENOENT");
+ errno2name());
char **const empty = tail_alloc(sizeof(*empty));
char **const efault = empty + 1;
", [/* 0 vars */]"
#endif
", AT_SYMLINK_NOFOLLOW|AT_EMPTY_PATH) = -1 %s (%m)\n",
- Q_FILENAME, errno == ENOSYS ? "ENOSYS" : "ENOENT");
+ Q_FILENAME, errno2name());
char str_a[] = "012345678901234567890123456789012";
char str_b[] = "_abcdefghijklmnopqrstuvwxyz()[]{}";
printf("], [/* %u vars */", DEFAULT_STRLEN + 1);
#endif
printf("], AT_SYMLINK_NOFOLLOW|AT_EMPTY_PATH) = -1 %s (%m)\n",
- errno == ENOSYS ? "ENOSYS" : "ENOENT");
+ errno2name());
syscall(__NR_execveat, -100, FILENAME, a + 1, b + 1, 0x1100);
printf("execveat(AT_FDCWD, \"%s\", [\"%s\"", Q_FILENAME, a[1]);
printf("], [/* %d vars */", DEFAULT_STRLEN);
#endif
printf("], AT_SYMLINK_NOFOLLOW|AT_EMPTY_PATH) = -1 %s (%m)\n",
- errno == ENOSYS ? "ENOSYS" : "ENOENT");
+ errno2name());
syscall(__NR_execveat, -100, FILENAME, NULL, efault, 0x1100);
printf("execveat(AT_FDCWD, \"%s\", NULL, %p"
", AT_SYMLINK_NOFOLLOW|AT_EMPTY_PATH) = -1 %s (%m)\n",
- Q_FILENAME, efault, errno == ENOSYS ? "ENOSYS" : "ENOENT");
+ Q_FILENAME, efault, errno2name());
syscall(__NR_execveat, -100, FILENAME, efault, NULL, 0x1100);
printf("execveat(AT_FDCWD, \"%s\", %p, NULL"
", AT_SYMLINK_NOFOLLOW|AT_EMPTY_PATH) = -1 %s (%m)\n",
- Q_FILENAME, efault, errno == ENOSYS ? "ENOSYS" : "ENOENT");
+ Q_FILENAME, efault, errno2name());
puts("+++ exited with 0 +++");
return 0;
int rc = syscall(__NR_faccessat, fd, sample, F_OK);
printf("faccessat(%d, \"%s\", F_OK) = %d %s (%m)\n",
(int) fd, sample, rc,
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
long rc = syscall(__NR_fchdir, fd);
printf("fchdir(%d) = %ld %s (%m)\n",
- (int) fd, rc, errno == ENOSYS ? "ENOSYS" : "EBADF");
+ (int) fd, rc, errno2name());
puts("+++ exited with 0 +++");
return 0;
int rc = syscall(__NR_fdatasync, fd);
printf("fdatasync(%d) = %d %s (%m)\n",
(int) fd, rc,
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
int rc = syscall(__NR_flock, fd, LOCK_SH);
printf("flock(%d, LOCK_SH) = %d %s (%m)\n",
(int) fd, rc,
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
int rc = syscall(__NR_fsync, fd);
printf("fsync(%d) = %d %s (%m)\n",
(int) fd, rc,
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
int rc = syscall(__NR_linkat, fd_old, sample_1, fd_new, sample_2, 0);
printf("linkat(%d, \"%s\", %d, \"%s\", 0) = %d %s (%m)\n",
(int) fd_old, sample_1, (int) fd_new, sample_2, rc,
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
rc = syscall(__NR_linkat, -100, sample_1, -100, sample_2, -1L);
printf("linkat(%s, \"%s\", %s, \"%s\", %s) = %d %s (%m)\n",
"AT_FDCWD", sample_1, "AT_FDCWD", sample_2,
"AT_SYMLINK_NOFOLLOW|AT_REMOVEDIR|AT_SYMLINK_FOLLOW"
"|AT_NO_AUTOMOUNT|AT_EMPTY_PATH|0xffffe0ff",
- rc, errno == ENOSYS ? "ENOSYS" : "EINVAL");
+ rc, errno2name());
puts("+++ exited with 0 +++");
return 0;
{
assert(syscall(__NR_membarrier, 3, 255) == -1);
printf("membarrier(0x3 /* MEMBARRIER_CMD_??? */, 255) = -1 %s (%m)\n",
- errno == ENOSYS ? "ENOSYS" : "EINVAL");
+ errno2name());
if (errno != ENOSYS) {
/* the test needs to be updated? */
assert(syscall(__NR_membarrier, 0, 0) == 1);
long rc = syscall(__NR_mkdir, sample, 0600);
printf("mkdir(\"%s\", 0600) = %ld %s (%m)\n",
- sample, rc, errno == ENOSYS ? "ENOSYS" : "EEXIST");
+ sample, rc, errno2name());
puts("+++ exited with 0 +++");
return 0;
int rc = syscall(__NR_mkdirat, fd, sample, 0600);
printf("mkdirat(%d, \"%s\", 0600) = %d %s (%m)\n",
(int) fd, sample, rc,
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
int rc = syscall(__NR_mknod, TMP_FILE, S_IFREG|0600, 0);
printf("mknod(\"%s\", S_IFREG|0600) = %d %s (%m)\n",
TMP_FILE, rc,
- errno == ENOSYS ? "ENOSYS" : "EEXIST");
+ errno2name());
const unsigned long dev =
(unsigned long) 0xdeadbeef00000000 | makedev(1, 7);
rc = syscall(__NR_mknod, TMP_FILE, S_IFCHR | 0400, dev);
printf("mknod(\"%s\", S_IFCHR|0400, makedev(1, 7)) = %d %s (%m)\n",
TMP_FILE, rc,
- errno == ENOSYS ? "ENOSYS" : "EEXIST");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
{
assert(syscall(__NR_mlock2, 0xdeadbeef, 0xdefaced, 0xffff) == -1);
printf("mlock2(0xdeadbeef, 233811181, MLOCK_ONFAULT|0xfffe)"
- " = -1 %s (%m)\n", errno == ENOSYS ? "ENOSYS" : "EINVAL");
+ " = -1 %s (%m)\n", errno2name());
puts("+++ exited with 0 +++");
return 0;
}
puts("mlockall(MCL_CURRENT) = 0");
} else {
printf("mlockall(MCL_CURRENT) = -1 %s (%m)\n",
- errno == ENOMEM ? "ENOMEM" : "EPERM");
+ errno2name());
}
puts("+++ exited with 0 +++");
if (rc != -1)
perror_msg_and_fail("pwritev: expected -1, returned %ld", rc);
tprintf("pwritev(1, %p, 42, 0) = -1 %s (%m)\n",
- efault, errno == EINVAL ? "EINVAL" : "EFAULT");
+ efault, errno2name());
rc = preadv(0, efault, 42, 0);
if (rc != -1)
perror_msg_and_fail("preadv: expected -1, returned %ld", rc);
tprintf("preadv(0, %p, 42, 0) = -1 %s (%m)\n",
- efault, errno == EINVAL ? "EINVAL" : "EFAULT");
+ efault, errno2name());
static const char r0_c[] = "01234567";
const char *r0_d = hexdump_strdup(r0_c);
rc);
tprintf("pwritev(1, [{\"%s\", %u}, %p], 2, 0) = -1 %s (%m)\n",
w2_c, LENGTH_OF(w2_c), w_iov + ARRAY_SIZE(w_iov_),
- errno == EINVAL ? "EINVAL" : "EFAULT");
+ errno2name());
const unsigned int w_len =
LENGTH_OF(w0_c) + LENGTH_OF(w1_c) + LENGTH_OF(w2_c);
print_iovec(iov + i, n, LEN - i);
printf(", %u, %lld) = -1 %s (%m)\n",
n, (long long) offset + LEN + i,
- errno == EINVAL ? "EINVAL" : "EFAULT");
+ errno2name());
}
iov->iov_base = iov + LEN * 2;
assert(writev(1, efault, 42) == -1);
tprintf("writev(1, %p, 42) = -1 %s (%m)\n",
- efault, errno == EINVAL ? "EINVAL" : "EFAULT");
+ efault, errno2name());
assert(readv(0, efault, 42) == -1);
tprintf("readv(0, %p, 42) = -1 %s (%m)\n",
- efault, errno == EINVAL ? "EINVAL" : "EFAULT");
+ efault, errno2name());
static const char r0_c[] = "01234567";
const char *r0_d = hexdump_strdup(r0_c);
assert(writev(1, w_iov + ARRAY_SIZE(w_iov_) - 1, 2) == -1);
tprintf("writev(1, [{\"%s\", %u}, %p], 2) = -1 %s (%m)\n",
w2_c, LENGTH_OF(w2_c), w_iov + ARRAY_SIZE(w_iov_),
- errno == EINVAL ? "EINVAL" : "EFAULT");
+ errno2name());
const unsigned int w_len =
LENGTH_OF(w0_c) + LENGTH_OF(w1_c) + LENGTH_OF(w2_c);
int rc = syscall(__NR_rename, OLD_FILE, NEW_FILE);
printf("rename(\"%s\", \"%s\") = %d %s (%m)\n",
OLD_FILE, NEW_FILE, rc,
- errno == ENOSYS ? "ENOSYS" : "ENOENT");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
int rc = syscall(__NR_renameat, fd_old, OLD_FILE, fd_new, NEW_FILE);
printf("renameat(%d, \"%s\", %d, \"%s\") = %d %s (%m)\n",
(int) fd_old, OLD_FILE, (int) fd_new, NEW_FILE, rc,
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
rc = syscall(__NR_sched_setparam, 0, param);
printf("sched_setparam(0, [%d]) = %d %s (%m)\n",
param->sched_priority, rc,
- errno == EPERM ? "EPERM" : "EINVAL");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
rc = syscall(__NR_sched_setscheduler, 0, SCHED_FIFO, param);
printf("sched_setscheduler(0, SCHED_FIFO, [%d]) = %d %s (%m)\n",
param->sched_priority, rc,
- errno == EPERM ? "EPERM" : "EINVAL");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
errno = saved_errno;
if (expected)
printf(") = -1 %s (%m)\n",
- errno == EPERM ? "EPERM" : "EINVAL");
+ errno2name());
else
printf(") = 0\n");
}
shmat(id, NULL, SHM_REMAP);
printf("%s(%d, NULL, SHM_REMAP) = -1 %s (%m)\n",
- SHMAT, id, errno == ENOSYS ? "ENOSYS" : "EINVAL");
+ SHMAT, id, errno2name());
void *shmaddr = shmat(id, NULL, SHM_RDONLY);
if (shmaddr == (void *)(-1))
printf("splice(%d, [%lld], %d, [%lld], %zu, %s) = -1 %s (%m)\n",
(int) fd_in, *off_in, (int) fd_out, *off_out, len,
"SPLICE_F_MOVE|SPLICE_F_NONBLOCK|SPLICE_F_MORE|SPLICE_F_GIFT",
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
}
long rc = syscall(__NR_symlinkat, oldpath, fd, newpath);
printf("symlinkat(\"%s\", %d, \"%s\") = %ld %s (%m)\n",
oldpath, (int) fd, newpath, rc,
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
"sync_file_range", fd,
(long long) offset,
(long long) nbytes,
- errno == ENOSYS ? "ENOSYS" : "EINVAL");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
"sync_file_range2", fd,
(long long) offset,
(long long) nbytes,
- errno == ENOSYS ? "ENOSYS" : "EINVAL");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
printf("tee(%d, %d, %zu, %s) = -1 %s (%m)\n",
(int) fd_in, (int) fd_out, len,
"SPLICE_F_MOVE|SPLICE_F_NONBLOCK|SPLICE_F_MORE|SPLICE_F_GIFT",
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
}
int rc = syscall(__NR_unlinkat, fd, sample, 0);
printf("unlinkat(%d, \"%s\", 0) = %d %s (%m)\n",
(int) fd, sample, rc,
- errno == ENOSYS ? "ENOSYS" : "EBADF");
+ errno2name());
rc = syscall(__NR_unlinkat, -100, sample, -1L);
printf("unlinkat(%s, \"%s\", %s) = %d %s (%m)\n",
"AT_FDCWD", sample,
"AT_SYMLINK_NOFOLLOW|AT_REMOVEDIR|AT_SYMLINK_FOLLOW"
"|AT_NO_AUTOMOUNT|AT_EMPTY_PATH|0xffffe0ff",
- rc, errno == ENOSYS ? "ENOSYS" : "EINVAL");
+ rc, errno2name());
puts("+++ exited with 0 +++");
return 0;
{
assert(syscall(__NR_userfaultfd, 1 | O_NONBLOCK | O_CLOEXEC) == -1);
printf("userfaultfd(O_NONBLOCK|O_CLOEXEC|0x1) = -1 %s (%m)\n",
- errno == ENOSYS ? "ENOSYS" : "EINVAL");
+ errno2name());
puts("+++ exited with 0 +++");
return 0;
}
printf("setpriority(PRIO_PROCESS, %d, 0) = 0\n", pid);
} else {
printf("setpriority(PRIO_PROCESS, %d, 0) = -1 %s (%m)\n",
- pid, errno == EPERM ? "EPERM" : "EACCES");
+ pid, errno2name());
}
puts("+++ exited with 0 +++");