[PATCH v1 17/17] selftests/nolibc: vfprintf: support tmpfs and hugetlbfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When CONFIG_TMPFS not enabled, kernel will use the ramfs based tmpfs
instead, but memfd_create doesn't work with such tmpfs, for this type of
tmpfs, let's use it instead of memfd_create.

At the same time, let's support hugetlbfs too if there is one.

Signed-off-by: Zhangjin Wu <falcon@xxxxxxxxxxx>
---
 tools/testing/selftests/nolibc/nolibc-test.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 85fa64746cde..bff72365a158 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -796,6 +796,14 @@ static int expect_vfprintf(int llen, size_t c, const char *expected, const char
 	if (fd == -1)
 		fd = memfd_create("vfprintf", 0);
 
+	/* memfd_create not work with ramfs based tmpfs, try tmpfs and hugetlbfs in order instead */
+	if (fd == -1) {
+		if (tmpfs)
+			fd = open("/tmp/vfprintf", O_CREAT | O_TRUNC | O_RDWR);
+		else if (hugetlbfs)
+			fd = open("/hugetlb/vfprintf", O_CREAT | O_TRUNC | O_RDWR);
+	}
+
 	if (fd == -1) {
 		pad_spc(llen, 64, "[FAIL]\n");
 		return 1;
-- 
2.25.1




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux