From: Victor Cheng-Yen Yang via ltp <ltp@lists.linux.it>
To: <ltp@lists.linux.it>
Subject: [LTP] [PATCH] mmap21: Check for free space before mapping the file
Date: Tue, 8 Sep 2026 10:31:21 +0800 [thread overview]
Message-ID: <20260908023121.1895897-1-cyyang772@andestech.com> (raw)
From: Victor Cheng-Yen Yang <cyyang772@andestech.com>
The test creates a sparse file with lseek() and a one byte write, so
mmap() allocates no blocks. The child then touches every byte and ext4
fills the holes inside ext4_page_mkwrite(). A store instruction has no
error return, so an ENOSPC there becomes VM_FAULT_SIGBUS and the test
reports only
tst_test.c:536: TBROK: Child (13042) killed by signal SIGBUS
which says nothing about the full filesystem. The information is
available before the mapping and gone after it, so check it in setup
and report TCONF earlier as convention.
Signed-off-by: Victor Cheng-Yen Yang <cyyang772@andestech.com>
---
testcases/kernel/syscalls/mmap/mmap21.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/testcases/kernel/syscalls/mmap/mmap21.c b/testcases/kernel/syscalls/mmap/mmap21.c
index ea3ae835a..3d6e8bd46 100644
--- a/testcases/kernel/syscalls/mmap/mmap21.c
+++ b/testcases/kernel/syscalls/mmap/mmap21.c
@@ -10,6 +10,7 @@
* access, and read back the data from the file.
*/
+#include <sys/vfs.h>
#include "tst_test.h"
#define FILE_NAME "testfile"
@@ -71,11 +72,24 @@ exit:
static void setup(void)
{
+ struct statfs sf;
+ unsigned long long needed, avail;
+
if (tst_parse_filesize(str_pages, &pages, 1, LLONG_MAX))
tst_brk(TBROK, "Invalid number of pages: %s", str_pages);
memory_size = pages * getpagesize();
+ /* the byte written past the mapping costs a whole block */
+ SAFE_STATFS(".", &sf);
+ needed = memory_size + sf.f_bsize;
+ avail = (unsigned long long)sf.f_bavail * sf.f_bsize;
+
+ if (!tst_fs_has_free(".", needed, TST_BYTES)) {
+ tst_brk(TCONF, "Not enough free space, test needs %llu bytes, %llu available",
+ needed, avail);
+ }
+
buff = SAFE_MALLOC(memory_size);
}
--
2.55.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2026-09-08 2:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 2:31 Victor Cheng-Yen Yang via ltp [this message]
2026-09-08 5:41 ` [LTP] mmap21: Check for free space before mapping the file linuxtestproject.agent
2026-09-08 10:47 ` [LTP] [PATCH] " Cyril Hrubis
2026-09-14 2:13 ` Victor Cheng-Yen Yang via ltp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260908023121.1895897-1-cyyang772@andestech.com \
--to=ltp@lists.linux.it \
--cc=cyyang772@andestech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.