Skip to contentSkip to conversation

selftests-filesystems-add-a-vfat-rename_exchange-test.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Jun 17, 2022

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: selftests/filesystems: add a vfat RENAME_EXCHANGE test
has been removed from the -mm tree. Its filename was
selftests-filesystems-add-a-vfat-rename_exchange-test.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Javier Martinez Canillas <[email protected]>
Subject: selftests/filesystems: add a vfat RENAME_EXCHANGE test
Date: Fri, 10 Jun 2022 09:57:21 +0200

Add a test for the renameat2 RENAME_EXCHANGE support in vfat, but split it in a tool that just does the rename exchange and a script that is run by the kselftests framework on make TARGETS="filesystems/fat" kselftest.

That way the script can be easily extended to test other file operations.

The script creates a 1 MiB disk image, that is then formated with a vfat filesystem and mounted using a loop device. That way all file operations are done on an ephemeral filesystem.

---

 MAINTAINERS                                               |    1 
 tools/testing/selftests/Makefile                          |    1 
 tools/testing/selftests/filesystems/fat/.gitignore        |    2 
 tools/testing/selftests/filesystems/fat/Makefile          |    7 
 tools/testing/selftests/filesystems/fat/config            |    2 
 tools/testing/selftests/filesystems/fat/rename_exchange.c |   37 ++++
 tools/testing/selftests/filesystems/fat/run_fat_tests.sh  |   82 ++++++++++
 7 files changed, 132 insertions(+)
MAINTAINERS renamed from MAINTAINERS~selftests-filesystems-add-a-vfat-rename_exchange-test +1 -0
@@ -20891,6 +20891,7 @@ M:	OGAWA Hirofumi <[email protected]
 S:	Maintained
 F:	Documentation/filesystems/vfat.rst
 F:	fs/fat/
+F:	tools/testing/selftests/filesystems/fat/
 
 VFIO DRIVER
 M:	Alex Williamson <[email protected]>
tools/testing/selftests/filesystems/fat/config new file +2 -0
@@ -0,0 +1,2 @@
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_VFAT_FS=y
tools/testing/selftests/filesystems/fat/.gitignore new file +2 -0
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+rename_exchange
tools/testing/selftests/filesystems/fat/Makefile new file +7 -0
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0
+
+TEST_PROGS := run_fat_tests.sh
+TEST_GEN_PROGS_EXTENDED := rename_exchange
+CFLAGS += -O2 -g -Wall $(KHDR_INCLUDES)
+
+include ../../lib.mk
tools/testing/selftests/filesystems/fat/rename_exchange.c new file +37 -0
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Program that atomically exchanges two paths using
+ * the renameat2() system call RENAME_EXCHANGE flag.
+ *
+ * Copyright 2022 Red Hat Inc.
+ * Author: Javier Martinez Canillas <[email protected]>
+ */
+
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void print_usage(const char *program)
+{
+	printf("Usage: %s [oldpath] [newpath]\n", program);
+	printf("Atomically exchange oldpath and newpath\n");
+}
+
+int main(int argc, char *argv[])
+{
+	int ret;
+
+	if (argc != 3) {
+		print_usage(argv[0]);
+		exit(EXIT_FAILURE);
+	}
+
+	ret = renameat2(AT_FDCWD, argv[1], AT_FDCWD, argv[2], RENAME_EXCHANGE);
+	if (ret) {
+		perror("rename exchange failed");
+		exit(EXIT_FAILURE);
+	}
+
+	exit(EXIT_SUCCESS);
+}
tools/testing/selftests/filesystems/fat/run_fat_tests.sh new file +82 -0

82 lines not on this page · raw message

tools/testing/selftests/Makefile renamed from tools/testing/selftests/Makefile~selftests-filesystems-add-a-vfat-rename_exchange-test +1 -0
@@ -17,6 +17,7 @@ TARGETS += exec
 TARGETS += filesystems
 TARGETS += filesystems/binderfs
 TARGETS += filesystems/epoll
+TARGETS += filesystems/fat
 TARGETS += firmware
 TARGETS += fpu
 TARGETS += ftrace

_

Patches currently in -mm which might be from [email protected] are