@@ -592,6 +592,7 @@ ioctl_ns07 ioctl_ns07
ioctl_sg01 ioctl_sg01
ioctl_ficlone01 ioctl_ficlone01
+ioctl_ficlone02 ioctl_ficlone02
inotify_init1_01 inotify_init1_01
inotify_init1_02 inotify_init1_02
@@ -23,3 +23,4 @@
/ioctl_ns07
/ioctl_sg01
/ioctl_ficlone01
+/ioctl_ficlone02
new file mode 100644
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 Andrea Cervesato andrea.cervesato@suse.com
+ */
+
+/*\
+ * [Description]
+ *
+ * This test verifies that ioctl() FICLONE feature correctly raises EOPNOTSUPP
+ * when an unsupported filesystem is used. In particular, filesystems which
+ * don't support copy-on-write.
+ */
+
+#include "tst_test.h"
+#include "lapi/fs.h"
+
+#define MNTPOINT "mnt"
+#define SRCPATH MNTPOINT "/file0"
+#define DSTPATH MNTPOINT "/file1"
+
+static void run(void)
+{
+ int src_fd;
+ int dst_fd;
+
+ src_fd = SAFE_OPEN(SRCPATH, O_CREAT | O_RDWR, 0640);
+ dst_fd = SAFE_OPEN(DSTPATH, O_CREAT | O_RDWR, 0640);
+
+ TST_EXP_FAIL(ioctl(dst_fd, FICLONE, src_fd), EOPNOTSUPP);
+
+ SAFE_CLOSE(src_fd);
+ SAFE_CLOSE(dst_fd);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .min_kver = "4.5",
+ .needs_root = 1,
+ .mount_device = 1,
+ .mntpoint = MNTPOINT,
+ .all_filesystems = 1,
+ .skip_filesystems = (const char *[]) {
+ "btrfs",
+ "overlayfs",
+ "nfs",
+ "xfs",
+ NULL,
+ },
+};