summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2026-07-29 15:03:09 +0200
committerCarlos Maiolino <cem@kernel.org>2026-09-07 07:51:51 +0200
commit9696940fd2e336979364e0ddf365a89455ca041c (patch)
tree8de1c29d56fc2fb4875a5fabc6073ed2cd57b651
parentaea4db0cf7732cc99e3bb958af809a889a45c96e (diff)
downloadlinux-next-9696940fd2e336979364e0ddf365a89455ca041c.tar.gz
linux-next-9696940fd2e336979364e0ddf365a89455ca041c.zip
xfs: split out the handler for XFS_IOC_ERROR_INJECTION
Split out a helper for XFS_IOC_ERROR_INJECTION to keep the stack variables out of xfs_file_ioctl and to clean up the main ioctl handler flow. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
-rw-r--r--fs/xfs/xfs_ioctl.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 1580f8d1299c..a226b33a74b5 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1355,6 +1355,20 @@ xfs_ioc_goingdown(
return xfs_fs_goingdown(mp, in);
}
+static int
+xfs_ioc_error_injection(
+ struct xfs_mount *mp,
+ struct xfs_error_injection __user *arg)
+{
+ struct xfs_error_injection in;
+
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+ if (copy_from_user(&in, arg, sizeof(in)))
+ return -EFAULT;
+ return xfs_errortag_add(mp, in.errtag);
+}
+
/*
* These long-unused ioctls were removed from the official ioctl API in 5.17,
* but retain these definitions so that we can log warnings about them.
@@ -1473,22 +1487,11 @@ xfs_file_ioctl(
case XFS_IOC_GOINGDOWN:
return xfs_ioc_goingdown(mp, arg);
- case XFS_IOC_ERROR_INJECTION: {
- xfs_error_injection_t in;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- if (copy_from_user(&in, arg, sizeof(in)))
- return -EFAULT;
-
- return xfs_errortag_add(mp, in.errtag);
- }
-
+ case XFS_IOC_ERROR_INJECTION:
+ return xfs_ioc_error_injection(mp, arg);
case XFS_IOC_ERROR_CLEARALL:
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
-
return xfs_errortag_clearall(mp);
case XFS_IOC_FREE_EOFBLOCKS: {