Build fix undefined struct file_handle
cover Build fix undefined struct file_handle
Hi all,
this would be great to get merged before release.
Kind regards,
Petr
Petr Vorel (3):
lapi: Move struct file_handle into lapi/fcntl.h
fanotify: Fix build on undefined struct file_handle
syscalls: Remove unused include <fcntl.h>
include/lapi/fcntl.h | 10 ++++++++++ include/lapi/name_to_handle_at.h | 9 +-------- testcases/kernel/syscalls/fanotify/fanotify.h | 2 +- testcases/kernel/syscalls/fanotify/fanotify09.c | 1 - testcases/kernel/syscalls/fanotify/fanotify13.c | 1 - testcases/kernel/syscalls/fanotify/fanotify15.c | 1 - testcases/kernel/syscalls/fanotify/fanotify16.c | 1 - .../syscalls/name_to_handle_at/name_to_handle_at01.c | 1 - .../syscalls/name_to_handle_at/name_to_handle_at02.c | 1 - .../syscalls/open_by_handle_at/open_by_handle_at01.c | 1 - .../syscalls/open_by_handle_at/open_by_handle_at02.c | 1 - 11 files changed, 12 insertions(+), 17 deletions(-)
Signature · 1 line
2.29.2
PATCH 1/3 lapi: Move struct file_handle into lapi/fcntl.h
that way it can be used in fanotify tests
(some of use the struct, but not name_to_handle_at() syscall) and the struct is defined in <fcntl.h> anyway.
--- include/lapi/fcntl.h | 10 ++++++++++ include/lapi/name_to_handle_at.h | 9 +-------- 2 files changed, 11 insertions(+), 8 deletions(-)
include/lapi/fcntl.h +10 -0
@@ -6,6 +6,7 @@#ifndef __LAPI_FCNTL_H__#define __LAPI_FCNTL_H__ +#include "config.h" #include <fcntl.h> #include <sys/socket.h>
@@ -140,4 +141,13 @@# define MAX_HANDLE_SZ 128#endif +#ifndef HAVE_NAME_TO_HANDLE_AT +struct file_handle { +unsigned int handle_bytes; +int handle_type; +/* File identifier. */ +unsigned char f_handle[0 ]; +}; +#endif /* HAVE_NAME_TO_HANDLE_AT */ +#endif /* __LAPI_FCNTL_H__ */
include/lapi/name_to_handle_at.h +1 -8
@@ -15,13 +15,6 @@#include "tst_test.h" #ifndef HAVE_NAME_TO_HANDLE_AT -struct file_handle { -unsigned int handle_bytes; -int handle_type; -/* File identifier. */ -unsigned char f_handle[0 ]; -}; -static inline int name_to_handle_at (int dfd,const char *pathname,struct file_handle *handle,int *mount_id,int flags)
@@ -35,7 +28,7 @@ static inline int open_by_handle_at(int mount_fd, struct file_handle *handle, {return tst_syscall (__NR_open_by_handle_at, mount_fd, handle, flags); } -#endif +#endif /* HAVE_NAME_TO_HANDLE_AT */ /* Returns a valid pointer on success, NULL on errors */ static inline struct file_handle *
Signature · 1 line
2.29.2
PATCH 2/3 fanotify: Fix build on undefined struct file_handle
In reply to Petr VorelThis fixes error:
fanotify09.c:201:32: error: dereferencing pointer to incomplete type ?struct file_handle?
201 | filename = (char *)file_handle->f_handle + file_handle->handle_bytes;
--- testcases/kernel/syscalls/fanotify/fanotify.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/fanotify/fanotify.h +1 -1
@@ -12,8 +12,8 @@#include <sys/types.h> #include <sys/stat.h> #include <errno.h> -#include <fcntl.h> #include <sys/fanotify.h> +#include "lapi/fcntl.h" int safe_fanotify_init (const char *file,const int lineno,unsigned int flags,unsigned int event_f_flags)
Signature · 1 line
2.29.2
PATCH 3/3 syscalls: Remove unused include <fcntl.h>
In reply to Petr VorelTests should always use lapi/fcntl.h instead of <fcntl.h> to fix possible missing definitions.
But in this case removing include, because fanotify tests include <fcntl.h> in lapi/fcntl.h (via fanotify.h) and {name_to,open_by}_handle_at tests include lapi/fcntl.h in lapi/name_to_handle_at.h.
--- testcases/kernel/syscalls/fanotify/fanotify09.c | 1 - testcases/kernel/syscalls/fanotify/fanotify13.c | 1 - testcases/kernel/syscalls/fanotify/fanotify15.c | 1 - testcases/kernel/syscalls/fanotify/fanotify16.c | 1 - .../kernel/syscalls/name_to_handle_at/name_to_handle_at01.c | 1 - .../kernel/syscalls/name_to_handle_at/name_to_handle_at02.c | 1 - .../kernel/syscalls/open_by_handle_at/open_by_handle_at01.c | 1 - .../kernel/syscalls/open_by_handle_at/open_by_handle_at02.c | 1 - 8 files changed, 8 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify09.c +0 -1
@@ -30,7 +30,6 @@#include <stdio.h> #include <sys/stat.h> #include <sys/types.h> -#include <fcntl.h> #include <errno.h> #include <string.h> #include <sys/mount.h>
testcases/kernel/syscalls/fanotify/fanotify13.c +0 -1
@@ -21,7 +21,6 @@#include <sys/statfs.h> #include <sys/types.h> #include <sys/stat.h> -#include <fcntl.h> #include <errno.h> #include <unistd.h> #include "tst_test.h"
testcases/kernel/syscalls/fanotify/fanotify15.c +0 -1
@@ -19,7 +19,6 @@#include <string.h> #include <errno.h> -#include <fcntl.h> #include <sys/statfs.h> #include <sys/types.h> #include "tst_test.h"
testcases/kernel/syscalls/fanotify/fanotify16.c +0 -1
@@ -18,7 +18,6 @@#include <stdio.h> #include <sys/stat.h> #include <sys/types.h> -#include <fcntl.h> #include <errno.h> #include <string.h> #include <sys/mount.h>
testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at01.c +0 -1
@@ -15,7 +15,6 @@\*/ #define _GNU_SOURCE -#include <fcntl.h> #include <sys/stat.h> #include "lapi/name_to_handle_at.h"
testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at02.c +0 -1
@@ -10,7 +10,6 @@\*/ #define _GNU_SOURCE -#include <fcntl.h> #include "lapi/name_to_handle_at.h" #define TEST_FILE "test_file"
testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at01.c +0 -1
@@ -15,7 +15,6 @@\*/ #define _GNU_SOURCE -#include <fcntl.h> #include <sys/stat.h> #include "lapi/name_to_handle_at.h"
testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at02.c +0 -1
@@ -10,7 +10,6 @@\*/ #define _GNU_SOURCE#include <linux/capability.h> -#include <fcntl.h> #include "tst_capability.h" #include "lapi/name_to_handle_at.h"
Signature · 1 line
2.29.2
cover Build fix undefined struct file_handle
In reply to Petr VorelHi Petr
I think detecting file_handle struct(it is in fcntl.h) in configure.ac is correct instead of using HAVE_NAME_TO_HANDLE_AT macro directly.
Best Regards
Yang Xu
Quoted 25 lines
Hi all,
this would be great to get merged before release.
Kind regards,
PetrPetr Vorel (3):
lapi: Move structfile_handleintolapi/fcntl.h
fanotify: Fix build on undefined structfile_handle
syscalls: Remove unused include<fcntl.h>include/lapi/fcntl.h | 10 ++++++++++ include/lapi/name_to_handle_at.h | 9 +-------- testcases/kernel/syscalls/fanotify/fanotify.h | 2 +- testcases/kernel/syscalls/fanotify/fanotify09.c | 1 - testcases/kernel/syscalls/fanotify/fanotify13.c | 1 - testcases/kernel/syscalls/fanotify/fanotify15.c | 1 - testcases/kernel/syscalls/fanotify/fanotify16.c | 1 - .../syscalls/name_to_handle_at/name_to_handle_at01.c | 1 - .../syscalls/name_to_handle_at/name_to_handle_at02.c | 1 - .../syscalls/open_by_handle_at/open_by_handle_at01.c | 1 - .../syscalls/open_by_handle_at/open_by_handle_at02.c | 1 - 11 files changed, 12 insertions(+), 17 deletions(-)
cover Build fix undefined struct file_handle
Hi Xu,
Quoted 3 lines
Hi Petr
I think detectingfile_handlestruct(it is infcntl.h) in configure.ac is correct instead of usingHAVE_NAME_TO_HANDLE_ATmacro directly.
You're right, using AC_CHECK_TYPES([struct, ],,,[#include <fcntl.h>]) is probably safer. I'll send v2.
Kind regards,
Petr Vorel
Quoted 2 lines
Best Regards
Yang Xu