[PATCH v1 2/2] fsx-linux: Fix op_max_size handling in op_file_position()

Jinseok Kim <[email protected]>
Newsgroups gmane.linux.ltp
Message-ID <[email protected]>
op_file_position() ignored op_max_size (-o option), causing operation
sizes to span up to the entire file size. Cap max_len with op_max_size
to honor the user option.

Signed-off-by: Jinseok Kim <[email protected]>
---
 testcases/kernel/fs/fsx-linux/fsx-linux.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/fs/fsx-linux/fsx-linux.c b/testcases/kernel/fs/fsx-linux/fsx-linux.c
index 21390c58c..81aca5dab 100644
--- a/testcases/kernel/fs/fsx-linux/fsx-linux.c
+++ b/testcases/kernel/fs/fsx-linux/fsx-linux.c
@@ -77,9 +77,15 @@ static void op_file_position(
 	struct file_pos_t *pos)
 {
 	long long diff;
+	long long max_len;

 	pos->offset = random() % fsize;
-	pos->size = random() % (fsize - pos->offset);
+
+	max_len = fsize - pos->offset;
+	if (max_len > op_max_size)
+		max_len = op_max_size;
+
+	pos->size = random() % max_len;

 	diff = pos->offset % align;

--
2.43.0

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.