Skip to contentSkip to conversation

fstests: btrfs: test if btrfs control file rejects unknown ioctls

PATCH In review Qu Wenruo 3 participants 3 messages Oct 11 – Oct 12 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 fstests: btrfs: test if btrfs control file rejects unknown ioctls

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.

---
 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
tests/btrfs/359 new file +26 -0
new file mode 100755
index 00000000..46457f57
@@ -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
tests/btrfs/359.out new file +2 -0
new file mode 100644
index 00000000..89090e22
@@ -0,0 +1,2 @@
+QA output created by 359
+ioctl failed: Inappropriate ioctl for device
Signature · 1 line
2.56.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Qu Wenruo

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.

Quoted 4 lines

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

Thanks.

Quoted 51 lines
---
 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
tests/btrfs/359 new file +26 -0
new file mode 100755
index 00000000..46457f57
@@ -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
tests/btrfs/359.out new file +2 -1
new file mode 100644
index 00000000..89090e22
@@ -0,0 +1,2 @@
+QA output created by 359
+ioctl failed: Inappropriate ioctl for device
--

2.56.0

Tested-by Reviewed-by on v1 1/1
#2 lore raw
In reply to Qu Wenruo
Quoted 10 lines · Qu Wenruo

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.

Quoted 6 lines

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

---
 tests/btrfs/359     | 26 ++++++++++++++++++++++++++

fails before the fix, passes after it on a local x86_64 Btrfs VM.

Regards,
Dhruva Gole