All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/3] Build fix undefined struct file_handle
@ 2021-01-12 19:30 Petr Vorel
  2021-01-12 19:30 ` [LTP] [PATCH 1/3] lapi: Move struct file_handle into lapi/fcntl.h Petr Vorel
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Petr Vorel @ 2021-01-12 19:30 UTC (permalink / raw)
  To: ltp

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(-)

-- 
2.29.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 1/3] lapi: Move struct file_handle into lapi/fcntl.h
  2021-01-12 19:30 [LTP] [PATCH 0/3] Build fix undefined struct file_handle Petr Vorel
@ 2021-01-12 19:30 ` Petr Vorel
  2021-01-12 19:30 ` [LTP] [PATCH 2/3] fanotify: Fix build on undefined struct file_handle Petr Vorel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2021-01-12 19:30 UTC (permalink / raw)
  To: ltp

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.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 include/lapi/fcntl.h             | 10 ++++++++++
 include/lapi/name_to_handle_at.h |  9 +--------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/include/lapi/fcntl.h b/include/lapi/fcntl.h
index d6665915f..ab460beb3 100644
--- a/include/lapi/fcntl.h
+++ b/include/lapi/fcntl.h
@@ -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__ */
diff --git a/include/lapi/name_to_handle_at.h b/include/lapi/name_to_handle_at.h
index 3484133d1..275db4ae0 100644
--- a/include/lapi/name_to_handle_at.h
+++ b/include/lapi/name_to_handle_at.h
@@ -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 *
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 2/3] fanotify: Fix build on undefined struct file_handle
  2021-01-12 19:30 [LTP] [PATCH 0/3] Build fix undefined struct file_handle Petr Vorel
  2021-01-12 19:30 ` [LTP] [PATCH 1/3] lapi: Move struct file_handle into lapi/fcntl.h Petr Vorel
@ 2021-01-12 19:30 ` Petr Vorel
  2021-01-12 19:30 ` [LTP] [PATCH 3/3] syscalls: Remove unused include <fcntl.h> Petr Vorel
  2021-01-13  2:23 ` [LTP] [PATCH 0/3] Build fix undefined struct file_handle Yang Xu
  3 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2021-01-12 19:30 UTC (permalink / raw)
  To: ltp

This 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;

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/syscalls/fanotify/fanotify.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
index 8907db052..039379961 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify.h
+++ b/testcases/kernel/syscalls/fanotify/fanotify.h
@@ -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)
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 3/3] syscalls: Remove unused include <fcntl.h>
  2021-01-12 19:30 [LTP] [PATCH 0/3] Build fix undefined struct file_handle Petr Vorel
  2021-01-12 19:30 ` [LTP] [PATCH 1/3] lapi: Move struct file_handle into lapi/fcntl.h Petr Vorel
  2021-01-12 19:30 ` [LTP] [PATCH 2/3] fanotify: Fix build on undefined struct file_handle Petr Vorel
@ 2021-01-12 19:30 ` Petr Vorel
  2021-01-13  2:23 ` [LTP] [PATCH 0/3] Build fix undefined struct file_handle Yang Xu
  3 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2021-01-12 19:30 UTC (permalink / raw)
  To: ltp

Tests 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.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 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(-)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify09.c b/testcases/kernel/syscalls/fanotify/fanotify09.c
index 30e212f44..918e40274 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify09.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify09.c
@@ -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>
diff --git a/testcases/kernel/syscalls/fanotify/fanotify13.c b/testcases/kernel/syscalls/fanotify/fanotify13.c
index c9cf10555..6d812cdd1 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify13.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify13.c
@@ -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"
diff --git a/testcases/kernel/syscalls/fanotify/fanotify15.c b/testcases/kernel/syscalls/fanotify/fanotify15.c
index ba8259c7c..fe143823e 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify15.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify15.c
@@ -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"
diff --git a/testcases/kernel/syscalls/fanotify/fanotify16.c b/testcases/kernel/syscalls/fanotify/fanotify16.c
index 5ffaec92f..c4b8a5abc 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify16.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify16.c
@@ -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>
diff --git a/testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at01.c b/testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at01.c
index 84ac32eab..1ac9d8214 100644
--- a/testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at01.c
+++ b/testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at01.c
@@ -15,7 +15,6 @@
 \*/
 
 #define _GNU_SOURCE
-#include <fcntl.h>
 #include <sys/stat.h>
 #include "lapi/name_to_handle_at.h"
 
diff --git a/testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at02.c b/testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at02.c
index 7c0d57485..020b25531 100644
--- a/testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at02.c
+++ b/testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at02.c
@@ -10,7 +10,6 @@
 \*/
 
 #define _GNU_SOURCE
-#include <fcntl.h>
 #include "lapi/name_to_handle_at.h"
 
 #define TEST_FILE "test_file"
diff --git a/testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at01.c b/testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at01.c
index c1b08f1b8..0d09e1ed8 100644
--- a/testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at01.c
+++ b/testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at01.c
@@ -15,7 +15,6 @@
 \*/
 
 #define _GNU_SOURCE
-#include <fcntl.h>
 #include <sys/stat.h>
 #include "lapi/name_to_handle_at.h"
 
diff --git a/testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at02.c b/testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at02.c
index 3c8f06d85..0f60752c4 100644
--- a/testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at02.c
+++ b/testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at02.c
@@ -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"
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 0/3] Build fix undefined struct file_handle
  2021-01-12 19:30 [LTP] [PATCH 0/3] Build fix undefined struct file_handle Petr Vorel
                   ` (2 preceding siblings ...)
  2021-01-12 19:30 ` [LTP] [PATCH 3/3] syscalls: Remove unused include <fcntl.h> Petr Vorel
@ 2021-01-13  2:23 ` Yang Xu
  2021-01-13  6:33   ` Petr Vorel
  3 siblings, 1 reply; 6+ messages in thread
From: Yang Xu @ 2021-01-13  2:23 UTC (permalink / raw)
  To: ltp

Hi 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
> 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(-)
>




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 0/3] Build fix undefined struct file_handle
  2021-01-13  2:23 ` [LTP] [PATCH 0/3] Build fix undefined struct file_handle Yang Xu
@ 2021-01-13  6:33   ` Petr Vorel
  0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2021-01-13  6:33 UTC (permalink / raw)
  To: ltp

Hi Xu,

> Hi 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.

You're right, using AC_CHECK_TYPES([struct, ],,,[#include <fcntl.h>]) is
probably safer. I'll send v2.

Kind regards,
Petr Vorel

> Best Regards
> Yang Xu

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-13  6:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12 19:30 [LTP] [PATCH 0/3] Build fix undefined struct file_handle Petr Vorel
2021-01-12 19:30 ` [LTP] [PATCH 1/3] lapi: Move struct file_handle into lapi/fcntl.h Petr Vorel
2021-01-12 19:30 ` [LTP] [PATCH 2/3] fanotify: Fix build on undefined struct file_handle Petr Vorel
2021-01-12 19:30 ` [LTP] [PATCH 3/3] syscalls: Remove unused include <fcntl.h> Petr Vorel
2021-01-13  2:23 ` [LTP] [PATCH 0/3] Build fix undefined struct file_handle Yang Xu
2021-01-13  6:33   ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.