Skip to content

Commit

Permalink
Merge tag 'linux-kselftest-4.0-rc4' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/shuah/linux-kselftest

Pull Kselftest fix from Shuah Khan:
 "selftests/exec: Check if the syscall exists and bail if not"

* tag 'linux-kselftest-4.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
  selftests/exec: Check if the syscall exists and bail if not
  • Loading branch information
Linus Torvalds committed Mar 14, 2015
2 parents 5fb0f7f + 9a0b574 commit e6c2d9c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tools/testing/selftests/exec/execveat.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static int execveat_(int fd, const char *path, char **argv, char **envp,
#ifdef __NR_execveat
return syscall(__NR_execveat, fd, path, argv, envp, flags);
#else
errno = -ENOSYS;
errno = ENOSYS;
return -1;
#endif
}
Expand Down Expand Up @@ -234,6 +234,14 @@ static int run_tests(void)
int fd_cloexec = open_or_die("execveat", O_RDONLY|O_CLOEXEC);
int fd_script_cloexec = open_or_die("script", O_RDONLY|O_CLOEXEC);

/* Check if we have execveat at all, and bail early if not */
errno = 0;
execveat_(-1, NULL, NULL, NULL, 0);
if (errno == ENOSYS) {
printf("[FAIL] ENOSYS calling execveat - no kernel support?\n");
return 1;
}

/* Change file position to confirm it doesn't affect anything */
lseek(fd, 10, SEEK_SET);

Expand Down

0 comments on commit e6c2d9c

Please sign in to comment.