[LTP] [PATCH v4] lib: LTP_SINGLE_FS_TYPE and LTP_FORCE_SINGLE_FS_TYPE
Petr Vorel
pvorel@suse.cz
Tue May 27 13:32:44 CEST 2025
Hi Cyril, all,
> Hi!
> > > That's right, just confirmed with Cyril, so far we need to do nothing
> > > unless tst_get_supported_fs_types() is abused somewhere.
> > Abusing the function should be prevented if Cyril adds before merge 'static'
> > keyword to the function (as I suggested earlier).
> That's a different function and that is going to be static in the final
> patch.
Ah, thanks for info.
> This is the function that is called from tst_test.c and I guess that we
> can remove it from the tst_fs.h in order to make sure nobody tries to
> misuse it. That would look like:
> diff --git a/include/tst_fs.h b/include/tst_fs.h
> index 19c240e07..ceae78e7e 100644
> --- a/include/tst_fs.h
> +++ b/include/tst_fs.h
> @@ -203,13 +203,6 @@ enum tst_fs_impl {
> */
> enum tst_fs_impl tst_fs_is_supported(const char *fs_type);
> -/*
> - * Returns NULL-terminated array of kernel-supported filesystems.
> - *
> - * @skiplist A NULL terminated array of filesystems to skip.
> - */
> -const char **tst_get_supported_fs_types(const char *const *skiplist);
> -
> /*
> * Returns 1 if filesystem is in skiplist 0 otherwise.
> *
> diff --git a/lib/tst_internal.h b/lib/tst_internal.h
> new file mode 100644
> index 000000000..a0ae733f6
> --- /dev/null
> +++ b/lib/tst_internal.h
> @@ -0,0 +1,17 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (c) 2015-2025 Cyril Hrubis <chrubis@suse.cz>
> + * Copyright (c) Linux Test Project, 2017-2025
> + */
> +
> +#ifndef TST_INTERNAL_H__
> +#define TST_INTERNAL_H__
> +
> +/*
> + * Returns NULL-terminated array of kernel-supported filesystems.
> + *
> + * @skiplist A NULL terminated array of filesystems to skip.
> + */
> +const char **tst_get_supported_fs_types(const char *const *skiplist);
> +
> +#endif /* TST_INTERNAL_H__ */
> diff --git a/lib/tst_supported_fs_types.c b/lib/tst_supported_fs_types.c
> index 46165ebc6..cc5522a08 100644
> --- a/lib/tst_supported_fs_types.c
> +++ b/lib/tst_supported_fs_types.c
> @@ -14,6 +14,7 @@
> #define TST_NO_DEFAULT_MAIN
> #include "tst_test.h"
> #include "tst_fs.h"
> +#include "tst_internal.h"
> /*
> * NOTE: new filesystem should be also added to
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 45fc28498..f62cc195a 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -38,6 +38,7 @@
> #include "old_device.h"
> #include "old_tmpdir.h"
> #include "ltp-version.h"
> +#include "tst_internal.h"
> /*
> * Hack to get TCID defined in newlib tests
FYI also testcases/lib/tst_supported_fs.c uses it:
tst_supported_fs.c: In function ‘main’:
tst_supported_fs.c:152:23: error: implicit declaration of function ‘tst_get_supported_fs_types’ [-Wimplicit-function-declaration]
152 | filesystems = tst_get_supported_fs_types((const char * const*)skiplist);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
tst_supported_fs.c:152:21: error: assignment to ‘const char * const*’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
152 | filesystems = tst_get_supported_fs_types((const char * const*)skiplist);
| ^
make: *** [../../include/mk/rules.mk:48: tst_supported_fs] Error 1
Therefore we need either relative path (below) or tweak CFLAGS to add -I.
Otherwise LGTM, ideally send a patch.
Kind regards,
Petr
+++ testcases/lib/tst_supported_fs.c
@@ -14,6 +14,7 @@
#define TST_NO_DEFAULT_MAIN
#include "tst_test.h"
#include "tst_fs.h"
+#include "../../lib/tst_internal.h"
#define err_exit(...) ({ \
fprintf(stderr, __VA_ARGS__); \
More information about the ltp
mailing list