[LTP] [PATCH v2 2/3] tst_fill_fs: Ensure data is not easily compressed
Richard Palethorpe
rpalethorpe@suse.com
Mon Dec 12 14:55:23 CET 2022
If the stack is auto initialized to zero, then we will write all
zeros. Some FS may treat this as a special case and just record the
number of zero bytes or sectors.
This could alter the test behaviour in unpredictable ways. For example
a large number of (slow) syscalls may be required to fill up the
drive, extending the required test time. Or we could overflow the file
size/offset causing EFBIG.
So this uses tst_rand_data.
Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
Cc: Cyril Hrubis <chrubis@suse.cz>
---
lib/tst_fill_fs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/tst_fill_fs.c b/lib/tst_fill_fs.c
index 121dd2f20..1d6d76abd 100644
--- a/lib/tst_fill_fs.c
+++ b/lib/tst_fill_fs.c
@@ -11,16 +11,17 @@
#define TST_NO_DEFAULT_MAIN
#include "tst_test.h"
#include "tst_fs.h"
+#include "tst_rand_data.h"
void tst_fill_fs(const char *path, int verbose)
{
int i = 0;
char file[PATH_MAX];
- char buf[4096];
size_t len;
ssize_t ret;
int fd;
struct statvfs fi;
+
statvfs(path, &fi);
for (;;) {
@@ -41,7 +42,7 @@ void tst_fill_fs(const char *path, int verbose)
}
while (len) {
- ret = write(fd, buf, MIN(len, sizeof(buf)));
+ ret = write(fd, tst_rand_data, MIN(len, tst_rand_data_len));
if (ret < 0) {
/* retry on ENOSPC to make sure filesystem is really full */
--
2.38.1
More information about the ltp
mailing list