From: Eugene Syromyatnikov Date: Sun, 23 Oct 2016 20:23:05 +0000 (+0300) Subject: tests: require only presence of __NR_* macros for file_handle test X-Git-Tag: v4.15~180 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad7f4354d5cfd8008b2cfffaf0dcb7cb64bbcbea;p=strace tests: require only presence of __NR_* macros for file_handle test * tests/file_handle.c: replace fcntl.h include with asm/unistd.h. [MAX_HANDLE_SZ]: change to defined __NR_name_to_handle_at && defined __NR_open_by_handle_at, add fcntl.h include [!MAX_HANDLE_SZ]: Add definition of MAX_HANDLE_SZ and struct file_handle. (main): Change name_to_handle_at and open_by_handle_at calls to syscall. --- diff --git a/tests/file_handle.c b/tests/file_handle.c index ac2b358d..42b89d8e 100644 --- a/tests/file_handle.c +++ b/tests/file_handle.c @@ -26,14 +26,29 @@ */ #include "tests.h" -#include +#include -#ifdef MAX_HANDLE_SZ +#if defined __NR_name_to_handle_at && defined __NR_open_by_handle_at # include # include # include +# include # include +# include + + +# ifndef MAX_HANDLE_SZ + +# define MAX_HANDLE_SZ 128 + +struct file_handle { + unsigned int handle_bytes; + int handle_type; + unsigned char f_handle[0]; +}; +# endif /* !MAX_HANDLE_SZ */ + int main(void) @@ -47,20 +62,23 @@ main(void) handle->handle_bytes = 0; - assert(name_to_handle_at(dirfd, ".", handle, &mount_id, flags | 1) == -1); + assert(syscall(__NR_name_to_handle_at, dirfd, ".", handle, &mount_id, + flags | 1) == -1); if (EINVAL != errno) perror_msg_and_skip("name_to_handle_at"); printf("name_to_handle_at(AT_FDCWD, \".\", {handle_bytes=0}, %p" ", AT_SYMLINK_FOLLOW|0x1) = -1 EINVAL (%m)\n", &mount_id); - assert(name_to_handle_at(dirfd, ".", handle, &mount_id, flags) == -1); + assert(syscall(__NR_name_to_handle_at, dirfd, ".", handle, &mount_id, + flags) == -1); if (EOVERFLOW != errno) perror_msg_and_skip("name_to_handle_at"); printf("name_to_handle_at(AT_FDCWD, \".\", {handle_bytes=0 => %u}" ", %p, AT_SYMLINK_FOLLOW) = -1 EOVERFLOW (%m)\n", handle->handle_bytes, &mount_id); - assert(name_to_handle_at(dirfd, ".", handle, &mount_id, flags) == 0); + assert(syscall(__NR_name_to_handle_at, dirfd, ".", handle, &mount_id, + flags) == 0); printf("name_to_handle_at(AT_FDCWD, \".\", {handle_bytes=%u" ", handle_type=%d, f_handle=0x", handle->handle_bytes, handle->handle_type); @@ -72,7 +90,8 @@ main(void) ", f_handle=0x", handle->handle_bytes, handle->handle_type); for (i = 0; i < handle->handle_bytes; ++i) printf("%02x", handle->f_handle[i]); - int rc = open_by_handle_at(-1, handle, O_RDONLY | O_DIRECTORY); + int rc = syscall(__NR_open_by_handle_at, -1, handle, + O_RDONLY | O_DIRECTORY); printf("}, O_RDONLY|O_DIRECTORY) = %d %s (%m)\n", rc, errno2name()); puts("+++ exited with 0 +++"); @@ -81,6 +100,6 @@ main(void) #else -SKIP_MAIN_UNDEFINED("MAX_HANDLE_SZ") +SKIP_MAIN_UNDEFINED("__NR_name_to_handle_at && __NR_open_by_handle_at") #endif