diff mbox series

[V2,02/10] lapi/fsmount.h: Add fsopen_supported_by_kernel()

Message ID 8d552688d85a7acc62d654832ab7ce270a70cf77.1582104018.git.viresh.kumar@linaro.org
State Changes Requested
Headers show
Series Add new LTP tests related to fsmount family of syscalls | expand

Commit Message

Viresh Kumar Feb. 19, 2020, 9:27 a.m. UTC
Add a helper to check if the fsmount() related syscalls are supported by
the kernel or not.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 include/lapi/fsmount.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Petr Vorel Feb. 20, 2020, 8:01 a.m. UTC | #1
Hi Viresh,

...
> +++ b/include/lapi/fsmount.h
...
> +void fsopen_supported_by_kernel(void)
> +{
> +	if ((tst_kvercmp(5, 2, 0)) < 0) {
> +		/* Check if the syscall is backported on an older kernel */
> +		TEST(syscall(__NR_fsopen, NULL, 0));
> +		if (TST_RET == -1 && TST_ERR == ENOSYS)
> +			tst_brk(TCONF, "Test not supporter on kernel version < v5.2");
typo supporter => supported.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr
diff mbox series

Patch

diff --git a/include/lapi/fsmount.h b/include/lapi/fsmount.h
index 87f2f229c371..e23b52e3733b 100644
--- a/include/lapi/fsmount.h
+++ b/include/lapi/fsmount.h
@@ -130,5 +130,14 @@  enum fsconfig_command {
 
 #endif /* OPEN_TREE_CLONE */
 
+void fsopen_supported_by_kernel(void)
+{
+	if ((tst_kvercmp(5, 2, 0)) < 0) {
+		/* Check if the syscall is backported on an older kernel */
+		TEST(syscall(__NR_fsopen, NULL, 0));
+		if (TST_RET == -1 && TST_ERR == ENOSYS)
+			tst_brk(TCONF, "Test not supporter on kernel version < v5.2");
+	}
+}
 
 #endif /* FSMOUNT_H__ */