[LTP] [PATCH] tst_device: use raw syscall in the tst_device.h

Cyril Hrubis chrubis@suse.cz
Thu Jan 9 10:52:39 CET 2020


Hi!
> +#define _GNU_SOURCE
>  #include <unistd.h>
> +#include <sys/syscall.h>

Defining _GNU_SOURCE anywhere but at the top of the test source is
meaningless. It has to be defined before we include any libc headers
otherwise it's ignored.

>  struct tst_device {
>  	const char *dev;
> @@ -75,9 +77,9 @@ int tst_detach_device(const char *dev_path);
>   * simply before the tst_dev_bytes_written invocation. For easy to use,
>   * we create this inline function tst_dev_sync.
>   */
> -static inline void tst_dev_sync(int fd)
> +static inline int tst_dev_sync(int fd)
>  {
> -	syncfs(fd);
> +	return syscall(__NR_syncfs, fd);
>  }
>  
>  /*
> diff --git a/testcases/kernel/syscalls/fadvise/posix_fadvise01.c b/testcases/kernel/syscalls/fadvise/posix_fadvise01.c
> index 2af040840..f5d7ca8ac 100644
> --- a/testcases/kernel/syscalls/fadvise/posix_fadvise01.c
> +++ b/testcases/kernel/syscalls/fadvise/posix_fadvise01.c
> @@ -20,6 +20,7 @@
>   *	None
>   */
>  
> +#define _GNU_SOURCE
>  #define _XOPEN_SOURCE 600
>  #include <fcntl.h>

Why do we need the _GNU_SOURCE here? We switched to a syscall() in the
header, hence we do not need the syncfs() prototype anymore.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list