Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH] fstests: btrfs: test if btrfs control file rejects unknown ioctls
Date: Mon, 12 Oct 2026 09:37:16 +1030	[thread overview]
Message-ID: <20261011230716.16860-1-wqu@suse.com> (raw)

This is a regression test for a recent bug fix, where unsupported ioctls
are not properly rejected for btrfs control file (normally at
"/dev/btrfs-control").

The test case itself is super simple, which doesn't even require test or
scratch device, it just run the "btrfs_ioctl" program using
"get_subvol_info" ioctl on "/dev/btrfs-control", which should fail as
that ioctl only makes sense on a mounted btrfs, not the btrfs control
file.

The error will be outputted to the golden output so that we can catch
any unexpected success.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 tests/btrfs/359     | 26 ++++++++++++++++++++++++++
 tests/btrfs/359.out |  2 ++
 2 files changed, 28 insertions(+)
 create mode 100755 tests/btrfs/359
 create mode 100644 tests/btrfs/359.out

diff --git a/tests/btrfs/359 b/tests/btrfs/359
new file mode 100755
index 00000000..46457f57
--- /dev/null
+++ b/tests/btrfs/359
@@ -0,0 +1,26 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 SUSE S.A.  All Rights Reserved.
+#
+# FS QA Test 359
+#
+# Make sure the btrfs control file (/dev/btrfs-control) properly rejects
+# an unsupported ioctl.
+#
+. ./common/preamble
+_begin_fstest auto quick ioctl
+
+_fixed_by_kernel_commit xxxxxxxxxxxx \
+	"btrfs: return -ENOTTY for unknown ioctls on the control device"
+
+_require_test_program btrfs_ioctl
+
+path="/dev/btrfs-control"
+if [ ! -c "$path" ]; then
+	_notrun "No btrfs control file at \"$path\""
+fi
+
+# This should fail with -ENOTTY error.
+$here/src/btrfs_ioctl get_subvol_info "$path" >> $seqres.full
+
+_exit 0
diff --git a/tests/btrfs/359.out b/tests/btrfs/359.out
new file mode 100644
index 00000000..89090e22
--- /dev/null
+++ b/tests/btrfs/359.out
@@ -0,0 +1,2 @@
+QA output created by 359
+ioctl failed: Inappropriate ioctl for device
-- 
2.56.0


             reply	other threads:[~2026-10-11 23:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-11 23:07 Qu Wenruo [this message]
2026-10-12 11:27 ` [PATCH] fstests: btrfs: test if btrfs control file rejects unknown ioctls Filipe Manana
2026-10-12 16:46 ` Dhruva G

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=20261011230716.16860-1-wqu@suse.com \
    --to=wqu@suse.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox