[LTP] [PATCH v1 1/2] tools/apicmds: Remove tst_fs_has_free

Cyril Hrubis chrubis@suse.cz
Mon Nov 23 17:23:56 CET 2026


The tst_fs_has_free shell command has no users left in the tree, remove
it from the apicmds binary along with its documentation and entry point.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 doc/old/Shell-Test-API.asciidoc | 22 ---------------
 tools/apicmds/.gitignore        |  1 -
 tools/apicmds/Makefile          |  3 +-
 tools/apicmds/ltpapicmd.c       | 50 +--------------------------------
 4 files changed, 2 insertions(+), 74 deletions(-)

diff --git a/doc/old/Shell-Test-API.asciidoc b/doc/old/Shell-Test-API.asciidoc
index c38fb0698..2b1ad4c19 100644
--- a/doc/old/Shell-Test-API.asciidoc
+++ b/doc/old/Shell-Test-API.asciidoc
@@ -686,28 +686,6 @@ https://github.com/linux-test-project/ltp/wiki/C-Test-API#16-runtime-kernel-vers
 NOTE: See also LTP
       https://github.com/linux-test-project/ltp/wiki/Supported-kernel,-libc,-toolchain-versions#13-minimal-supported-kernel-version[minimal supported kernel version].
 
-tst_fs_has_free
-+++++++++++++++
-
-[source,sh]
--------------------------------------------------------------------------------
-#!/bin/sh
-
-...
-
-# whether current directory has 100MB free space at least.
-if ! tst_fs_has_free . 100MB; then
-	tst_brkm TCONF "Not enough free space"
-fi
-
-...
--------------------------------------------------------------------------------
-
-The 'tst_fs_has_free' shell interface returns 0 if the specified free space is
-satisfied, 1 if not, and 2 on error.
-
-The second argument supports suffixes kB, MB and GB, the default unit is Byte.
-
 tst_retry
 +++++++++
 
diff --git a/tools/apicmds/.gitignore b/tools/apicmds/.gitignore
index 54a1d664d..375e7e9b8 100644
--- a/tools/apicmds/.gitignore
+++ b/tools/apicmds/.gitignore
@@ -6,4 +6,3 @@ tst_ncpus_conf
 tst_ncpus_max
 tst_res
 tst_resm
-tst_fs_has_free
diff --git a/tools/apicmds/Makefile b/tools/apicmds/Makefile
index 4b2a60495..b240a8958 100644
--- a/tools/apicmds/Makefile
+++ b/tools/apicmds/Makefile
@@ -27,8 +27,7 @@ include $(top_srcdir)/include/mk/testcases.mk
 CPPFLAGS		+= -D_GNU_SOURCE
 
 MAKE_TARGETS		:= $(addprefix tst_,brk brkm exit \
-			     res resm ncpus ncpus_conf ncpus_max \
-			     fs_has_free)
+			     res resm ncpus ncpus_conf ncpus_max)
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
 
diff --git a/tools/apicmds/ltpapicmd.c b/tools/apicmds/ltpapicmd.c
index 40018b3ed..9725d2e41 100644
--- a/tools/apicmds/ltpapicmd.c
+++ b/tools/apicmds/ltpapicmd.c
@@ -193,42 +193,6 @@ struct param_pair {
 	int value;
 };
 
-int apicmd_fs_has_free(int argc, char *argv[])
-{
-	if (argc != 3) {
-		fprintf(stderr, "Usage: tst_fs_has_free path required_bytes\n"
-			"path: the pathname of the mounted filesystem\n"
-			"required_bytes: the required free space"
-			" (supports kB, MB and GB suffixes)\n");
-		exit(2);
-	}
-
-	char *endptr;
-	unsigned int required_kib = strtoull(argv[1], &endptr, 0);
-	unsigned int mul = TST_BYTES;
-
-	if (*argv[1] == '\0')
-		goto fs_has_free_err;
-
-	if (*endptr != '\0') {
-		if (!strcasecmp(endptr, "kB")) {
-			mul = TST_KB;
-		} else if (!strcasecmp(endptr, "MB")) {
-			mul = TST_MB;
-		} else if (!strcasecmp(endptr, "GB")) {
-			mul = TST_GB;
-		} else {
-			goto fs_has_free_err;
-		}
-	}
-
-	exit(!tst_fs_has_free(NULL, argv[0], required_kib, mul));
-
-fs_has_free_err:
-	fprintf(stderr, "%s is not a valid size\n", argv[1]);
-	exit(2);
-}
-
 /*
  * Function:    main - entry point of this program
  *
@@ -261,17 +225,7 @@ int main(int argc, char *argv[])
 	TCID = getenv("TCID");
 	tst_total = getenv("TST_TOTAL");
 	tst_cntstr = getenv("TST_COUNT");
-	if (TCID == NULL || tst_total == NULL || tst_cntstr == NULL) {
-		 if(!strcmp(cmd_name, "tst_fs_has_free")) {
-			fprintf(stderr,
-				"\nSet variables TCID, TST_TOTAL, and TST_COUNT before each test:\n"
-				"export TCID=<test name>\n"
-				"export TST_TOTAL=<Total Number of Tests >\n"
-				"export TST_COUNT=<Test case number>\n\n");
-			/* Make sure the user knows there's an error. */
-			abort();
-		}
-	} else {
+	if (TCID && tst_total && tst_cntstr) {
 		TST_TOTAL = atoi(tst_total);
 		tst_count = atoi(tst_cntstr);
 		if (tst_count > 0)
@@ -306,8 +260,6 @@ int main(int argc, char *argv[])
 		printf("%li\n", tst_ncpus_conf());
 	} else if (strcmp(cmd_name, "tst_ncpus_max") == 0) {
 		printf("%li\n", tst_ncpus_max());
-	} else if (strcmp(cmd_name, "tst_fs_has_free") == 0) {
-		apicmd_fs_has_free(argc, argv);
 	}
 
 	exit(0);
-- 
2.55.0



More information about the ltp mailing list